1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 #include <officecfg/Office/Common.hxx>
10 #include "sdmodeltestbase.hxx"
11 #include <comphelper/propertysequence.hxx>
12 #include <comphelper/sequence.hxx>
13 #include <editeng/eeitem.hxx>
14 #include <editeng/editobj.hxx>
15 #include <editeng/outlobj.hxx>
16 #include <editeng/numitem.hxx>
17 #include <editeng/unoprnms.hxx>
18 
19 #include <svx/svdotext.hxx>
20 #include <svx/svdomedia.hxx>
21 #include <svx/svdotable.hxx>
22 #include <svx/xlineit0.hxx>
23 #include <svx/xlndsit.hxx>
24 #include <rtl/ustring.hxx>
25 
26 #include <com/sun/star/drawing/XDrawPage.hpp>
27 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
28 #include <com/sun/star/animations/TransitionType.hpp>
29 #include <com/sun/star/animations/TransitionSubType.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/awt/Gradient.hpp>
32 #include <com/sun/star/awt/Rectangle.hpp>
33 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
34 #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp>
35 #include <com/sun/star/drawing/FillStyle.hpp>
36 #include <com/sun/star/style/LineSpacing.hpp>
37 #include <com/sun/star/style/LineSpacingMode.hpp>
38 #include <com/sun/star/frame/XLoadable.hpp>
39 #include <com/sun/star/text/XTextColumns.hpp>
40 
41 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
42 
43 #include <sdpage.hxx>
44 #include <cfloat>
45 #include <cstdlib>
46 
47 #include <rtl/character.hxx>
48 
49 using namespace css;
50 using namespace css::animations;
51 
52 namespace {
53 
checkBeginWithNumber(const OUString & rStr)54 bool checkBeginWithNumber(const OUString& rStr)
55 {
56     sal_Unicode aChar = (rStr.getLength() > 1) ? rStr[0] : '\0';
57     return aChar == '.' || aChar == '-' || rtl::isAsciiDigit(aChar);
58 }
59 
60 }
61 
62 #define CPPUNIT_ASSERT_MOTIONPATH(expect, actual) \
63       assertMotionPath(expect, actual, CPPUNIT_SOURCELINE())
64 
assertMotionPath(const OUString & rStr1,const OUString & rStr2,const CppUnit::SourceLine & rSourceLine)65 static void assertMotionPath(const OUString &rStr1, const OUString &rStr2, const CppUnit::SourceLine &rSourceLine)
66 {
67     sal_Int32 nIdx1 = 0;
68     sal_Int32 nIdx2 = 0;
69 
70     OString sMessage = "Motion path values mismatch.\nExpect: " +
71             OUStringToOString(rStr1, RTL_TEXTENCODING_UTF8) +
72             "\nActual: " + OUStringToOString(rStr2, RTL_TEXTENCODING_UTF8);
73 
74     while(nIdx1 != -1 && nIdx2 != -1)
75     {
76         OUString aToken1 = rStr1.getToken(0, ' ', nIdx1);
77         OUString aToken2 = rStr2.getToken(0, ' ', nIdx2);
78 
79         if (checkBeginWithNumber(aToken1) && checkBeginWithNumber(aToken2))
80             assertDoubleEquals(aToken1.toDouble(), aToken2.toDouble(), DBL_EPSILON, rSourceLine, sMessage.getStr());
81         else
82             assertEquals(aToken1, aToken2, rSourceLine, sMessage.getStr());
83     }
84     assertEquals(sal_Int32(-1), nIdx1, rSourceLine, sMessage.getStr());
85     assertEquals(sal_Int32(-1), nIdx2, rSourceLine, sMessage.getStr());
86 }
87 
88 class SdOOXMLExportTest2 : public SdModelTestBaseXML
89 {
90 public:
91     void testTdf131905();
92     void testTdf93883();
93     void testTdf91378();
94     void testBnc822341();
95     void testMathObject();
96     void testMathObjectPPT2010();
97     void testTdf119015();
98     void testTdf123090();
99     void testTdf126324();
100     void testTdf119187();
101     void testTdf132472();
102     void testTdf80224();
103     void testExportTransitionsPPTX();
104     void testPresetShapesExport();
105     void testTdf92527();
106     void testDatetimeFieldNumberFormat();
107     void testDatetimeFieldNumberFormatPPTX();
108     void testSlideNumberField();
109     void testSlideNumberFieldPPTX();
110     void testSlideCountField();
111     void testSlideNameField();
112     void testExtFileField();
113     void testAuthorField();
114     void testTdf99224();
115     void testTdf92076();
116     void testTdf59046();
117     void testTdf133502();
118     void testTdf105739();
119     void testPageBitmapWithTransparency();
120     void testPptmContentType();
121     void testTdf111798();
122     void testPptmVBAStream();
123     void testTdf111863();
124     void testTdf111518();
125     void testTdf100387();
126     void testClosingShapesAndLineCaps();
127     void testRotateFlip();
128     void testTdf106867();
129     void testTdf112280();
130     void testTdf112088();
131     void testTdf112333();
132     void testTdf112552();
133     void testTdf112557();
134     void testTdf128049();
135     void testTdf106026();
136     void testTdf112334();
137     void testTdf112089();
138     void testTdf112086();
139     void testTdf112647();
140     void testGroupRotation();
141     void testTdf104788();
142     void testSmartartRotation2();
143     void testTdf91999_rotateShape();
144     void testTdf114845_rotateShape();
145     void testGroupsPosition();
146     void testGroupsRotatedPosition();
147     void testAccentColor();
148     void testThemeColors();
149     void testTdf118825();
150     void testTextColumns_tdf140852();
151     void testTextColumns_3columns();
152 
153     CPPUNIT_TEST_SUITE(SdOOXMLExportTest2);
154 
155     CPPUNIT_TEST(testTdf131905);
156     CPPUNIT_TEST(testTdf93883);
157     CPPUNIT_TEST(testTdf91378);
158     CPPUNIT_TEST(testBnc822341);
159     CPPUNIT_TEST(testMathObject);
160     CPPUNIT_TEST(testMathObjectPPT2010);
161     CPPUNIT_TEST(testTdf119015);
162     CPPUNIT_TEST(testTdf123090);
163     CPPUNIT_TEST(testTdf126324);
164     CPPUNIT_TEST(testTdf119187);
165     CPPUNIT_TEST(testTdf132472);
166     CPPUNIT_TEST(testTdf80224);
167     CPPUNIT_TEST(testExportTransitionsPPTX);
168     CPPUNIT_TEST(testPresetShapesExport);
169     CPPUNIT_TEST(testTdf92527);
170     CPPUNIT_TEST(testDatetimeFieldNumberFormat);
171     CPPUNIT_TEST(testDatetimeFieldNumberFormatPPTX);
172     CPPUNIT_TEST(testSlideNumberField);
173     CPPUNIT_TEST(testSlideNumberFieldPPTX);
174     CPPUNIT_TEST(testSlideCountField);
175     CPPUNIT_TEST(testSlideNameField);
176     CPPUNIT_TEST(testExtFileField);
177     CPPUNIT_TEST(testAuthorField);
178     CPPUNIT_TEST(testTdf99224);
179     CPPUNIT_TEST(testTdf92076);
180     CPPUNIT_TEST(testTdf59046);
181     CPPUNIT_TEST(testTdf133502);
182     CPPUNIT_TEST(testTdf105739);
183     CPPUNIT_TEST(testPageBitmapWithTransparency);
184     CPPUNIT_TEST(testPptmContentType);
185     CPPUNIT_TEST(testTdf111798);
186     CPPUNIT_TEST(testPptmVBAStream);
187     CPPUNIT_TEST(testTdf111863);
188     CPPUNIT_TEST(testTdf111518);
189     CPPUNIT_TEST(testTdf100387);
190     CPPUNIT_TEST(testClosingShapesAndLineCaps);
191     CPPUNIT_TEST(testRotateFlip);
192     CPPUNIT_TEST(testTdf106867);
193     CPPUNIT_TEST(testTdf112280);
194     CPPUNIT_TEST(testTdf112088);
195     CPPUNIT_TEST(testTdf112333);
196     CPPUNIT_TEST(testTdf112552);
197     CPPUNIT_TEST(testTdf112557);
198     CPPUNIT_TEST(testTdf128049);
199     CPPUNIT_TEST(testTdf106026);
200     CPPUNIT_TEST(testTdf112334);
201     CPPUNIT_TEST(testTdf112089);
202     CPPUNIT_TEST(testTdf112086);
203     CPPUNIT_TEST(testTdf112647);
204     CPPUNIT_TEST(testGroupRotation);
205     CPPUNIT_TEST(testTdf104788);
206     CPPUNIT_TEST(testSmartartRotation2);
207     CPPUNIT_TEST(testTdf91999_rotateShape);
208     CPPUNIT_TEST(testTdf114845_rotateShape);
209     CPPUNIT_TEST(testGroupsPosition);
210     CPPUNIT_TEST(testGroupsRotatedPosition);
211     CPPUNIT_TEST(testAccentColor);
212     CPPUNIT_TEST(testThemeColors);
213     CPPUNIT_TEST(testTdf118825);
214     CPPUNIT_TEST(testTextColumns_tdf140852);
215     CPPUNIT_TEST(testTextColumns_3columns);
216 
217     CPPUNIT_TEST_SUITE_END();
218 
registerNamespaces(xmlXPathContextPtr & pXmlXPathCtx)219     virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
220     {
221         XmlTestTools::registerOOXMLNamespaces(pXmlXPathCtx);
222     }
223 };
224 
testTdf131905()225 void SdOOXMLExportTest2::testTdf131905()
226 {
227     ::sd::DrawDocShellRef xDocShRef
228         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf131905.pptx"), PPTX);
229     utl::TempFile tempFile;
230     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
231 
232     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
233     assertXPath(
234         pXmlDocContent,
235         "/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr[1]/a:tc/a:tcPr",
236         "anchor", "t");
237 
238     assertXPath(
239         pXmlDocContent,
240         "/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr[2]/a:tc/a:tcPr",
241         "anchor", "ctr");
242 
243     assertXPath(
244         pXmlDocContent,
245         "/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/a:tbl/a:tr[3]/a:tc/a:tcPr",
246         "anchor", "b");
247 
248     xDocShRef->DoClose();
249 }
250 
testTdf93883()251 void SdOOXMLExportTest2::testTdf93883()
252 {
253     ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf93883.odp"), ODP);
254     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
255     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
256     uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
257     uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
258     CPPUNIT_ASSERT(!xPropSet->getPropertyValue("NumberingLevel").hasValue());
259 }
260 
testBnc822341()261 void SdOOXMLExportTest2::testBnc822341()
262 {
263     // Check import / export of embedded text document
264     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/bnc822341.odp"), ODP);
265     utl::TempFile tempFile1;
266     xDocShRef = saveAndReload( xDocShRef.get(), PPTX, &tempFile1 );
267 
268     // Export an LO specific ole object (imported from an ODP document)
269     {
270         xmlDocUniquePtr pXmlDocCT = parseExport(tempFile1, "[Content_Types].xml");
271         assertXPath(pXmlDocCT,
272                     "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.wordprocessingml.document']",
273                     "PartName",
274                     "/ppt/embeddings/oleObject1.docx");
275 
276         xmlDocUniquePtr pXmlDocRels = parseExport(tempFile1, "ppt/slides/_rels/slide1.xml.rels");
277         assertXPath(pXmlDocRels,
278             "/rels:Relationships/rels:Relationship[@Target='../embeddings/oleObject1.docx']",
279             "Type",
280             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
281 
282         xmlDocUniquePtr pXmlDocContent = parseExport(tempFile1, "ppt/slides/slide1.xml");
283         assertXPath(pXmlDocContent,
284             "/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/p:oleObj",
285             "progId",
286             "Word.Document.12");
287 
288         const SdrPage *pPage = GetPage( 1, xDocShRef.get() );
289 
290         const SdrObject* pObj = pPage->GetObj(0);
291         CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
292         CPPUNIT_ASSERT_EQUAL( OBJ_OLE2, pObj->GetObjIdentifier() );
293     }
294 
295     utl::TempFile tempFile2;
296     xDocShRef = saveAndReload( xDocShRef.get(), PPTX, &tempFile2 );
297 
298     // Export an MS specific ole object (imported from a PPTX document)
299     {
300         xmlDocUniquePtr pXmlDocCT = parseExport(tempFile2, "[Content_Types].xml");
301         assertXPath(pXmlDocCT,
302                     "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.wordprocessingml.document']",
303                     "PartName",
304                     "/ppt/embeddings/oleObject1.docx");
305 
306         xmlDocUniquePtr pXmlDocRels = parseExport(tempFile2, "ppt/slides/_rels/slide1.xml.rels");
307         assertXPath(pXmlDocRels,
308             "/rels:Relationships/rels:Relationship[@Target='../embeddings/oleObject1.docx']",
309             "Type",
310             "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
311 
312         xmlDocUniquePtr pXmlDocContent = parseExport(tempFile2, "ppt/slides/slide1.xml");
313         assertXPath(pXmlDocContent,
314             "/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/p:oleObj",
315             "progId",
316             "Word.Document.12");
317 
318         SdDrawDocument *pDoc = xDocShRef->GetDoc();
319         CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
320         const SdrPage *pPage = pDoc->GetPage(1);
321         CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
322 
323         const SdrObject* pObj = pPage->GetObj(0);
324         CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
325         CPPUNIT_ASSERT_EQUAL( OBJ_OLE2, pObj->GetObjIdentifier() );
326     }
327 
328     xDocShRef->DoClose();
329 }
330 
testMathObject()331 void SdOOXMLExportTest2::testMathObject()
332 {
333     // Check import / export of math object
334     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/math.odp"), ODP);
335     utl::TempFile tempFile1;
336     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile1);
337 
338     // Export an LO specific ole object (imported from an ODP document)
339     {
340         xmlDocUniquePtr pXmlDocContent = parseExport(tempFile1, "ppt/slides/slide1.xml");
341         assertXPath(pXmlDocContent,
342             "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice",
343             "Requires",
344             "a14");
345         assertXPathContent(pXmlDocContent,
346             "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice/p:sp/p:txBody/a:p/a14:m/m:oMath/m:r[1]/m:t",
347             "a");
348 
349         const SdrPage *pPage = GetPage(1, xDocShRef);
350         const SdrObject* pObj = pPage->GetObj(0);
351         CPPUNIT_ASSERT_MESSAGE("no object", pObj != nullptr);
352         CPPUNIT_ASSERT_EQUAL(OBJ_OLE2, pObj->GetObjIdentifier());
353     }
354 
355     utl::TempFile tempFile2;
356     xDocShRef = saveAndReload( xDocShRef.get(), PPTX, &tempFile2 );
357 
358     // Export an MS specific ole object (imported from a PPTX document)
359     {
360         xmlDocUniquePtr pXmlDocContent = parseExport(tempFile1, "ppt/slides/slide1.xml");
361         assertXPath(pXmlDocContent,
362             "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice",
363             "Requires",
364             "a14");
365         assertXPathContent(pXmlDocContent,
366             "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice/p:sp/p:txBody/a:p/a14:m/m:oMath/m:r[1]/m:t",
367             "a");
368 
369         const SdrPage *pPage = GetPage(1, xDocShRef);
370         const SdrObject* pObj = pPage->GetObj(0);
371         CPPUNIT_ASSERT_MESSAGE("no object", pObj != nullptr);
372         CPPUNIT_ASSERT_EQUAL(OBJ_OLE2, pObj->GetObjIdentifier());
373     }
374 
375     xDocShRef->DoClose();
376 }
377 
testMathObjectPPT2010()378 void SdOOXMLExportTest2::testMathObjectPPT2010()
379 {
380     // Check import / export of math object
381     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/Math.pptx"), PPTX);
382     utl::TempFile tempFile1;
383     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile1);
384 
385     // Export an MS specific ole object (imported from a PPTX document)
386     {
387         xmlDocUniquePtr pXmlDocContent = parseExport(tempFile1, "ppt/slides/slide1.xml");
388         assertXPath(pXmlDocContent,
389             "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice",
390             "Requires",
391             "a14");
392         assertXPathContent(pXmlDocContent,
393             "/p:sld/p:cSld/p:spTree/mc:AlternateContent/mc:Choice/p:sp/p:txBody/a:p/a14:m/m:oMath/m:sSup/m:e/m:r[1]/m:t",
394             u"\U0001D44E"); // non-BMP char
395 
396         const SdrPage *pPage = GetPage(1, xDocShRef);
397         const SdrObject* pObj = pPage->GetObj(0);
398         CPPUNIT_ASSERT_MESSAGE("no object", pObj != nullptr);
399         CPPUNIT_ASSERT_EQUAL(OBJ_OLE2, pObj->GetObjIdentifier());
400     }
401 
402     xDocShRef->DoClose();
403 }
404 
testTdf119015()405 void SdOOXMLExportTest2::testTdf119015()
406 {
407     ::sd::DrawDocShellRef xDocShRef
408         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf119015.pptx"), PPTX);
409     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
410 
411     const SdrPage* pPage = GetPage(1, xDocShRef);
412 
413     sdr::table::SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
414     CPPUNIT_ASSERT(pTableObj);
415     // The position was previously not properly initialized: (0, 0, 100, 100)
416     CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(6991, 6902), Size(14099, 1999)),
417                          pTableObj->GetLogicRect());
418     uno::Reference<table::XTable> xTable(pTableObj->getTable());
419 
420     // Test that we actually have three cells: this threw css.lang.IndexOutOfBoundsException
421     uno::Reference<text::XTextRange> xTextRange(xTable->getCellByPosition(1, 0),
422                                                 uno::UNO_QUERY_THROW);
423     CPPUNIT_ASSERT_EQUAL(OUString("A3"), xTextRange->getString());
424 
425     xDocShRef->DoClose();
426 }
427 
testTdf123090()428 void SdOOXMLExportTest2::testTdf123090()
429 {
430     ::sd::DrawDocShellRef xDocShRef
431         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf123090.pptx"), PPTX);
432     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
433 
434     const SdrPage* pPage = GetPage(1, xDocShRef);
435 
436     sdr::table::SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
437     CPPUNIT_ASSERT(pTableObj);
438 
439     uno::Reference<table::XTable> xTable(pTableObj->getTable());
440 
441     // Test that we actually have two cells: this threw css.lang.IndexOutOfBoundsException
442     uno::Reference<text::XTextRange> xTextRange(xTable->getCellByPosition(1, 0),
443                                                 uno::UNO_QUERY_THROW);
444     CPPUNIT_ASSERT_EQUAL(OUString("aaa"), xTextRange->getString());
445 
446     sal_Int32 nWidth;
447     uno::Reference< css::table::XTableColumns > xColumns( xTable->getColumns(), uno::UNO_SET_THROW);
448     uno::Reference< beans::XPropertySet > xRefColumn( xColumns->getByIndex(1), uno::UNO_QUERY_THROW );
449     xRefColumn->getPropertyValue( "Width" ) >>= nWidth;
450     CPPUNIT_ASSERT_EQUAL( sal_Int32(9136), nWidth);
451 
452     xDocShRef->DoClose();
453 }
454 
testTdf126324()455 void SdOOXMLExportTest2::testTdf126324()
456 {
457     sd::DrawDocShellRef xDocShRef
458         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf126324.pptx"), PPTX);
459     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
460     uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(),
461                                                      uno::UNO_QUERY);
462     CPPUNIT_ASSERT(xDoc.is());
463     uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
464     CPPUNIT_ASSERT(xPage.is());
465     uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage));
466     CPPUNIT_ASSERT(xShape.is());
467     uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>( xShape, uno::UNO_QUERY_THROW )->getText();
468     CPPUNIT_ASSERT_EQUAL(OUString("17"), xText->getString());
469 
470     xDocShRef->DoClose();
471 }
472 
testTdf119187()473 void SdOOXMLExportTest2::testTdf119187()
474 {
475     std::vector< sd::DrawDocShellRef > xDocShRef;
476     // load document
477     xDocShRef.push_back(loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf119187.pptx"), PPTX));
478     // load resaved document
479     xDocShRef.push_back(saveAndReload( xDocShRef.at(0).get(), PPTX ));
480 
481     // check documents
482     for (const sd::DrawDocShellRef& xDoc : xDocShRef)
483     {
484         // get shape properties
485         const SdrPage* pPage = GetPage(1, xDoc);
486         CPPUNIT_ASSERT(pPage);
487         SdrObject* pObj = pPage->GetObj(0);
488         CPPUNIT_ASSERT(pObj);
489         const sdr::properties::BaseProperties & rProperties = pObj->GetProperties();
490 
491         // check text vertical alignment
492         const SdrTextVertAdjustItem& rSdrTextVertAdjustItem = rProperties.GetItem(SDRATTR_TEXT_VERTADJUST);
493         const SdrTextVertAdjust eTVA = rSdrTextVertAdjustItem.GetValue();
494         CPPUNIT_ASSERT_EQUAL(SDRTEXTVERTADJUST_TOP, eTVA);
495     }
496 }
497 
testTdf132472()498 void SdOOXMLExportTest2::testTdf132472()
499 {
500     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf132472.pptx"), PPTX );
501     const SdrPage *pPage = GetPage( 1, xDocShRef );
502 
503     sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
504     CPPUNIT_ASSERT( pTableObj );
505 
506     uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
507     uno::Reference< beans::XPropertySet > xCell;
508     Color nColor;
509 
510     xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
511     xCell->getPropertyValue("FillColor") >>= nColor;
512     CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), nColor);
513 
514     uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xCell));
515     uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
516     uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY);
517     xPropSet->getPropertyValue("CharColor") >>= nColor;
518 
519     // Without the fix in place, this test would have failed with
520     // - Expected: Color: R:0 G:0 B:0 A:0
521     // - Actual  : Color: R:255 G:255 B:255 A:0
522     CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
523 
524     xDocShRef->DoClose();
525 }
526 
testTdf80224()527 void SdOOXMLExportTest2::testTdf80224()
528 {
529     ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf80224.odp"), ODP);
530     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
531     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
532 
533     uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
534     uno::Reference< beans::XPropertySet > xPropSet( xParagraph->getStart(), uno::UNO_QUERY_THROW );
535 
536     Color nCharColor;
537     xPropSet->getPropertyValue("CharColor") >>= nCharColor;
538     CPPUNIT_ASSERT_EQUAL(Color(0x6562ac), nCharColor);
539     xDocShRef->DoClose();
540 }
541 
testTdf91378()542 void SdOOXMLExportTest2::testTdf91378()
543 {
544 
545     //Check For Import and Export Both
546     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf91378.pptx"), PPTX);
547     for( sal_uInt32 i=0;i<2;i++)
548     {
549       SdDrawDocument *pDoc = xDocShRef->GetDoc();
550       CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
551       uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier( xDocShRef->GetModel(), uno::UNO_QUERY );
552       uno::Reference<document::XDocumentProperties> xProps = xDocumentPropertiesSupplier->getDocumentProperties();
553       uno::Reference<beans::XPropertySet> xUDProps( xProps->getUserDefinedProperties(), uno::UNO_QUERY );
554       OUString propValue;
555       xUDProps->getPropertyValue("Testing") >>= propValue;
556       CPPUNIT_ASSERT(propValue.isEmpty());
557       xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
558     }
559     xDocShRef->DoClose();
560 }
561 
checkTransitionOnPage(uno::Reference<drawing::XDrawPagesSupplier> const & xDoc,sal_Int32 nSlideNumber,sal_Int16 nExpectedTransitionType,sal_Int16 nExpectedTransitionSubType,bool bExpectedDirection=true)562 static bool checkTransitionOnPage(uno::Reference<drawing::XDrawPagesSupplier> const & xDoc, sal_Int32 nSlideNumber,
563                            sal_Int16 nExpectedTransitionType, sal_Int16 nExpectedTransitionSubType,
564                            bool bExpectedDirection = true)
565 {
566     sal_Int32 nSlideIndex = nSlideNumber - 1;
567 
568     CPPUNIT_ASSERT_MESSAGE("Slide/Page index out of range", nSlideIndex < xDoc->getDrawPages()->getCount());
569 
570     uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(nSlideIndex), uno::UNO_QUERY_THROW);
571     uno::Reference<beans::XPropertySet> xPropSet(xPage, uno::UNO_QUERY);
572 
573     sal_Int16 nTransitionType = 0;
574     xPropSet->getPropertyValue("TransitionType") >>= nTransitionType;
575 
576     if (nExpectedTransitionType != nTransitionType)
577     {
578         std::cerr << "Transition type: " << nTransitionType << " " << nExpectedTransitionType << std::endl;
579         return false;
580     }
581 
582     sal_Int16 nTransitionSubtype = 0;
583     xPropSet->getPropertyValue("TransitionSubtype") >>= nTransitionSubtype;
584     if (nExpectedTransitionSubType != nTransitionSubtype)
585     {
586         std::cerr << "Transition Subtype: " << nTransitionSubtype << " " << nExpectedTransitionSubType << std::endl;
587         return false;
588     }
589 
590     bool bDirection = false;
591     xPropSet->getPropertyValue("TransitionDirection") >>= bDirection;
592 
593     if (bExpectedDirection != bDirection)
594     {
595         std::cerr << "Transition Direction: " << (bExpectedDirection ? "normal" : "reversed")
596                   << " "                      << (bDirection ? "normal" : "reversed") << std::endl;
597         return false;
598     }
599 
600     return true;
601 }
602 
testExportTransitionsPPTX()603 void SdOOXMLExportTest2::testExportTransitionsPPTX()
604 {
605     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/AllTransitions.odp"), ODP);
606     xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
607     uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
608 
609     // WIPE TRANSITIONS
610     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 01, TransitionType::BARWIPE, TransitionSubType::TOPTOBOTTOM, false));
611     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 02, TransitionType::BARWIPE, TransitionSubType::LEFTTORIGHT));
612     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 03, TransitionType::BARWIPE, TransitionSubType::LEFTTORIGHT, false));
613     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 04, TransitionType::BARWIPE, TransitionSubType::TOPTOBOTTOM));
614 
615     // CUT THROUGH BLACK
616     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 31, TransitionType::BARWIPE, TransitionSubType::FADEOVERCOLOR));
617 
618     // COMB
619     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 41, TransitionType::PUSHWIPE, TransitionSubType::COMBHORIZONTAL));
620     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 42, TransitionType::PUSHWIPE, TransitionSubType::COMBVERTICAL));
621 
622     // OUTSIDE TURNING CUBE
623     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 57, TransitionType::MISCSHAPEWIPE, TransitionSubType::CORNERSOUT));
624     // INSIDE TURNING CUBE
625     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 60, TransitionType::MISCSHAPEWIPE, TransitionSubType::CORNERSIN));
626 
627     // FALL
628     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 61, TransitionType::MISCSHAPEWIPE, TransitionSubType::LEFTTORIGHT));
629 
630     // VORTEX
631     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 70, TransitionType::MISCSHAPEWIPE, TransitionSubType::VERTICAL));
632 
633     // RIPPLE
634     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 71, TransitionType::MISCSHAPEWIPE, TransitionSubType::HORIZONTAL));
635 
636     // GLITTER
637     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 72, TransitionType::MISCSHAPEWIPE, TransitionSubType::DIAMOND));
638 
639     // HONEYCOMB
640     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 73, TransitionType::MISCSHAPEWIPE, TransitionSubType::HEART));
641 
642     // NEWSFLASH
643     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 74, TransitionType::ZOOM, TransitionSubType::ROTATEIN));
644 
645     // OVAL VERTICAL - cannot be exported to PPTX so fallback to circle
646     //CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 76, TransitionType::ELLIPSEWIPE, TransitionSubType::VERTICAL));
647     CPPUNIT_ASSERT(checkTransitionOnPage(xDoc, 76, TransitionType::ELLIPSEWIPE, TransitionSubType::CIRCLE));
648 
649     xDocShRef->DoClose();
650 }
651 
testPresetShapesExport()652 void SdOOXMLExportTest2::testPresetShapesExport()
653 {
654     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/preset-shapes-export.odp"), ODP);
655     const char *sShapeTypeAndValues[] =
656     {
657         "wedgeEllipseCallout",
658         "adj1","val 45310",
659         "adj2","val 97194",
660         "wedgeRoundRectCallout",
661         "adj1","val 46694",
662         "adj2","val 129726",
663         "adj3","val 16667",
664         "wedgeRectCallout",
665         "adj1","val 40037",
666         "adj2","val 111694",
667         "smileyFace",
668         "adj","val -9282",
669         "can",
670         "adj","val 50000",
671         "frame",
672         "adj1","val 10490",
673         "donut",
674         "adj","val 9601",
675         "bevel",
676         "adj","val 42587",
677         "foldedCorner",
678         "adj","val 10750",
679         "verticalScroll",
680         "adj","val 25000",
681         "horizontalScroll",
682         "adj","val 25000",
683         "cube",
684         "adj","val 85129",
685         "bracketPair",
686         "adj","val 50000",
687         "sun",
688         "adj","val 12500",
689         "bracePair",
690         "adj","val 25000",
691         "cloudCallout",
692         "adj1","val 77611",
693         "adj2","val -47819",
694         "borderCallout1",
695         "adj1","val 18750",
696         "adj2","val -8333",
697         "adj3","val 170013",
698         "adj4","val 143972",
699         "borderCallout2",
700         "adj1","val 18750",
701         "adj2","val -8333",
702         "adj3","val 113768",
703         "adj4","val -81930",
704         "adj5","val -22375",
705         "adj6","val -134550",
706         "blockArc",
707         "adj1","val 13020000",
708         "adj2","val 19380000",
709         "adj3","val 3773",
710     };
711 
712     utl::TempFile tempFile;
713     xDocShRef = saveAndReload( xDocShRef.get(), PPTX, &tempFile );
714 
715     xmlDocUniquePtr pXmlDocCT = parseExport(tempFile, "ppt/slides/slide1.xml");
716     const OString sPattern( "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:prstGeom[@prst='_T_']/a:avLst/a:gd[_N_]" );
717     const OString sT( "_T_" );
718     const OString sN( "_N_" );
719     const OString sPropertyName("name");
720     const OString sPropertyFmla("fmla");
721 
722     size_t i = 0;
723     while(i < SAL_N_ELEMENTS( sShapeTypeAndValues )) {
724         OString sType( sShapeTypeAndValues[ i++ ] );
725         for ( size_t j = 1 ; i < SAL_N_ELEMENTS( sShapeTypeAndValues ) && OString(sShapeTypeAndValues[i]).startsWith("adj") ; ++j ) {
726             OString sXPath= sPattern.replaceFirst( sT, sType).replaceFirst( sN, OString::number(j) );
727             assertXPath(pXmlDocCT, sXPath, sPropertyName , OUString::createFromAscii(sShapeTypeAndValues[ i++ ]) );
728             assertXPath(pXmlDocCT, sXPath, sPropertyFmla , OUString::createFromAscii(sShapeTypeAndValues[ i++ ]) );
729         }
730     }
731 }
732 
testTdf92527()733 void SdOOXMLExportTest2::testTdf92527()
734 {
735     // We draw a diamond in an empty document. A newly created diamond shape does not have
736     // CustomShapeGeometry - Path - Segments property, and previously DrawingML exporter
737     // did not export custom shapes which did not have CustomShapeGeometry - Path - Segments property.
738     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/empty.fodp"), FODG );
739     uno::Reference<css::lang::XMultiServiceFactory> xFactory(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
740     uno::Reference<drawing::XShape> xShape1(xFactory->createInstance("com.sun.star.drawing.CustomShape"), uno::UNO_QUERY);
741     uno::Reference<drawing::XDrawPagesSupplier> xDoc1(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
742     uno::Reference<drawing::XDrawPage> xPage1(xDoc1->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
743     xPage1->add(xShape1);
744     xShape1->setSize(awt::Size(10000, 10000));
745     xShape1->setPosition(awt::Point(1000, 1000));
746     uno::Sequence<beans::PropertyValue> aShapeGeometry(comphelper::InitPropertySequence(
747         {
748             {"Type", uno::makeAny(OUString("diamond"))},
749         }));
750     uno::Reference<beans::XPropertySet> xPropertySet1(xShape1, uno::UNO_QUERY);
751     xPropertySet1->setPropertyValue("CustomShapeGeometry", uno::makeAny(aShapeGeometry));
752 
753     xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
754 
755     uno::Reference<drawing::XDrawPagesSupplier> xDoc2(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
756     uno::Reference<drawing::XDrawPage> xPage2(xDoc2->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
757     uno::Reference<drawing::XShape> xShape2(xPage2->getByIndex(0), uno::UNO_QUERY_THROW);
758     uno::Reference< beans::XPropertySet > xPropertySet2( xShape2, uno::UNO_QUERY_THROW );
759     uno::Sequence<beans::PropertyValue> aProps;
760     xPropertySet2->getPropertyValue("CustomShapeGeometry") >>= aProps;
761     uno::Sequence<beans::PropertyValue> aPathProps;
762     for (beans::PropertyValue const & rProp : std::as_const(aProps))
763     {
764         if (rProp.Name == "Path")
765             aPathProps = rProp.Value.get< uno::Sequence<beans::PropertyValue> >();
766     }
767     uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aCoordinates;
768     for (beans::PropertyValue const & rProp : std::as_const(aPathProps))
769     {
770         if (rProp.Name == "Coordinates")
771             aCoordinates = rProp.Value.get< uno::Sequence<drawing::EnhancedCustomShapeParameterPair> >();
772     }
773 
774     // 5 coordinate pairs, 1 MoveTo, 4 LineTo
775     CPPUNIT_ASSERT_EQUAL(sal_Int32(5), aCoordinates.getLength());
776     xDocShRef->DoClose();
777 }
778 
779 namespace {
780 
matchNumberFormat(int nPage,uno::Reference<text::XTextField> const & xField)781 void matchNumberFormat( int nPage, uno::Reference< text::XTextField > const & xField)
782 {
783     uno::Reference< beans::XPropertySet > xPropSet( xField, uno::UNO_QUERY_THROW );
784     sal_Int32 nNumFmt;
785     xPropSet->getPropertyValue("NumberFormat") >>= nNumFmt;
786     switch( nPage )
787     {
788         case 0:     // 13/02/96
789                     CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date fields don't match", sal_Int32(2), nNumFmt);
790                     break;
791         case 1:     // 13/02/1996
792                     CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date fields don't match", sal_Int32(5), nNumFmt);
793                     break;
794         case 2:     // 13 February 1996
795                     CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Date fields don't match", sal_Int32(3), nNumFmt);
796                     break;
797         case 3:     // 13:49:38
798                     CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time fields don't match", sal_Int32(2), nNumFmt);
799                     break;
800         case 4:     // 13:49
801                     CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time fields don't match", sal_Int32(3), nNumFmt);
802                     break;
803         case 5:     // 01:49 PM
804                     CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time fields don't match", sal_Int32(6), nNumFmt);
805                     break;
806         case 6:     // 01:49:38 PM
807                     CPPUNIT_ASSERT_EQUAL_MESSAGE("Number formats of Time fields don't match", sal_Int32(7), nNumFmt);
808     }
809 }
810 
811 }
812 
testDatetimeFieldNumberFormat()813 void SdOOXMLExportTest2::testDatetimeFieldNumberFormat()
814 {
815     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/numfmt.odp"), ODP);
816 
817     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
818 
819     for(sal_uInt16 i = 0; i <= 6; ++i)
820     {
821         matchNumberFormat( i, getTextFieldFromPage(0, 0, 0, i, xDocShRef) );
822     }
823 
824     xDocShRef->DoClose();
825 }
826 
testDatetimeFieldNumberFormatPPTX()827 void SdOOXMLExportTest2::testDatetimeFieldNumberFormatPPTX()
828 {
829     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/numfmt.pptx"), PPTX);
830 
831     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
832 
833     for(sal_uInt16 i = 0; i <= 6; ++i)
834     {
835         matchNumberFormat( i, getTextFieldFromPage(0, 0, 0, i, xDocShRef) );
836     }
837 
838     xDocShRef->DoClose();
839 }
840 
testSlideNumberField()841 void SdOOXMLExportTest2::testSlideNumberField()
842 {
843     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/slidenum_field.odp"), ODP);
844 
845     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
846 
847     uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef);
848     CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() );
849 
850     xDocShRef->DoClose();
851 }
852 
testSlideNumberFieldPPTX()853 void SdOOXMLExportTest2::testSlideNumberFieldPPTX()
854 {
855     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/slidenum_field.pptx"), PPTX);
856 
857     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
858 
859     uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef);
860     CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() );
861 
862     xDocShRef->DoClose();
863 }
864 
testSlideCountField()865 void SdOOXMLExportTest2::testSlideCountField()
866 {
867     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/slidecount_field.odp"), ODP);
868 
869     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
870 
871     uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef);
872     CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() );
873 
874     xDocShRef->DoClose();
875 }
876 
testSlideNameField()877 void SdOOXMLExportTest2::testSlideNameField()
878 {
879     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/slidename_field.odp"), ODP);
880 
881     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
882 
883     uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef);
884     CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() );
885 
886     xDocShRef->DoClose();
887 }
888 
testExtFileField()889 void SdOOXMLExportTest2::testExtFileField()
890 {
891     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/extfile_field.odp"), ODP);
892 
893     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
894 
895     for(sal_uInt16 i = 0; i <= 3; ++i)
896     {
897         uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, i, 0, xDocShRef);
898         CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() );
899 
900         uno::Reference< beans::XPropertySet > xPropSet( xField, uno::UNO_QUERY_THROW );
901         sal_Int32 nNumFmt;
902         xPropSet->getPropertyValue("FileFormat") >>= nNumFmt;
903         switch( i )
904         {
905             case 0:     // Path/File name
906                         CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(0), nNumFmt);
907                         break;
908             case 1:     // Path
909                         CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(1), nNumFmt);
910                         break;
911             case 2:     // File name without extension
912                         CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(2), nNumFmt);
913                         break;
914             case 3:     // File name with extension
915                         CPPUNIT_ASSERT_EQUAL_MESSAGE("File formats don't match", sal_Int32(3), nNumFmt);
916         }
917     }
918 
919     xDocShRef->DoClose();
920 }
921 
testAuthorField()922 void SdOOXMLExportTest2::testAuthorField()
923 {
924     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/author_field.odp"), ODP);
925 
926     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
927 
928     uno::Reference< text::XTextField > xField = getTextFieldFromPage(0, 0, 0, 0, xDocShRef);
929     CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() );
930 
931     xDocShRef->DoClose();
932 }
933 
testTdf99224()934 void SdOOXMLExportTest2::testTdf99224()
935 {
936     sd::DrawDocShellRef xShell = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf99224.odp"), ODP);
937     xShell = saveAndReload(xShell.get(), PPTX);
938     uno::Reference<drawing::XDrawPage> xPage = getPage(0, xShell);
939     // This was 0: the image with text was lost on export.
940     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xPage->getCount());
941     xShell->DoClose();
942 }
943 
testTdf92076()944 void SdOOXMLExportTest2::testTdf92076()
945 {
946     sd::DrawDocShellRef xShell = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf92076.odp"), ODP);
947     xShell = saveAndReload(xShell.get(), PPTX);
948     uno::Reference<drawing::XDrawPage> xPage = getPage(0, xShell);
949     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xPage->getCount());
950     xShell->DoClose();
951 }
952 
testTdf59046()953 void SdOOXMLExportTest2::testTdf59046()
954 {
955     sd::DrawDocShellRef xShell = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf59046.odp"), ODP);
956     utl::TempFile tempFile;
957     xShell = saveAndReload(xShell.get(), PPTX, &tempFile);
958     xShell->DoClose();
959     xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "ppt/slides/slide1.xml");
960     assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:custGeom/a:pathLst/a:path", 1);
961 }
962 
testTdf133502()963 void SdOOXMLExportTest2::testTdf133502()
964 {
965     sd::DrawDocShellRef xShell = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf133502.odp"), ODP);
966     utl::TempFile tempFile;
967     xShell = saveAndReload(xShell.get(), PPTX, &tempFile);
968     xShell->DoClose();
969     xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "ppt/comments/comment1.xml");
970 
971     assertXPathContent(pXmlDocRels, "/p:cmLst/p:cm/p:text", "Test for creator-initials");
972 
973     // Without the fix in place, the comment position would have been 0,0
974     assertXPath(pXmlDocRels, "/p:cmLst/p:cm/p:pos", "x", "2032");
975     assertXPath(pXmlDocRels, "/p:cmLst/p:cm/p:pos", "y", "1029");
976 }
977 
testTdf105739()978 void SdOOXMLExportTest2::testTdf105739()
979 {
980     // Gradient was lost during saving to ODP
981     sd::DrawDocShellRef xShell = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf105739.pptx"), PPTX);
982     utl::TempFile tempFile;
983     xShell = saveAndReload(xShell.get(), ODP, &tempFile);
984     uno::Reference<drawing::XDrawPage> xPage = getPage(0, xShell);
985     uno::Reference<beans::XPropertySet> xPropSet(xPage, uno::UNO_QUERY);
986     uno::Any aAny = xPropSet->getPropertyValue("Background");
987     CPPUNIT_ASSERT(aAny.hasValue());
988     if (aAny.hasValue())
989     {
990         uno::Reference< beans::XPropertySet > aXBackgroundPropSet;
991         aAny >>= aXBackgroundPropSet;
992 
993         // Test fill type
994         drawing::FillStyle aFillStyle(drawing::FillStyle_NONE);
995         aXBackgroundPropSet->getPropertyValue("FillStyle") >>= aFillStyle;
996         CPPUNIT_ASSERT_EQUAL(int(drawing::FillStyle_GRADIENT), static_cast<int>(aFillStyle));
997 
998         // Test gradient properties
999         com::sun::star::awt::Gradient aFillGradient;
1000         aXBackgroundPropSet->getPropertyValue("FillGradient") >>= aFillGradient;
1001         CPPUNIT_ASSERT_EQUAL(int(awt::GradientStyle_LINEAR), static_cast<int>(aFillGradient.Style));
1002         CPPUNIT_ASSERT_EQUAL(sal_Int32(0xff0000), aFillGradient.StartColor);
1003         CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00b050), aFillGradient.EndColor);
1004     }
1005 
1006     xShell->DoClose();
1007 }
1008 
testPageBitmapWithTransparency()1009 void SdOOXMLExportTest2::testPageBitmapWithTransparency()
1010 {
1011     ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/page_transparent_bitmap.pptx"), PPTX );
1012 
1013     xDocShRef = saveAndReload( xDocShRef.get(), ODP );
1014     uno::Reference< drawing::XDrawPagesSupplier > xDoc(
1015         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
1016     CPPUNIT_ASSERT_EQUAL_MESSAGE( "There should be exactly one page", static_cast<sal_Int32>(1), xDoc->getDrawPages()->getCount() );
1017 
1018     uno::Reference< drawing::XDrawPage > xPage( getPage( 0, xDocShRef ) );
1019 
1020     uno::Reference< beans::XPropertySet > xPropSet( xPage, uno::UNO_QUERY );
1021     uno::Any aAny = xPropSet->getPropertyValue( "Background" );
1022     CPPUNIT_ASSERT_MESSAGE("Slide background is missing", aAny.hasValue());
1023 
1024     uno::Reference< beans::XPropertySet > aXBackgroundPropSet;
1025     aAny >>= aXBackgroundPropSet;
1026     sal_Int32 nTransparence;
1027     aAny = aXBackgroundPropSet->getPropertyValue( "FillTransparence" );
1028     aAny >>= nTransparence;
1029     CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide background transparency is wrong", sal_Int32(49), nTransparence);
1030 
1031     xDocShRef->DoClose();
1032 }
1033 
testPptmContentType()1034 void SdOOXMLExportTest2::testPptmContentType()
1035 {
1036     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptm/macro.pptm"), PPTM);
1037     utl::TempFile tempFile;
1038     xDocShRef = saveAndReload(xDocShRef.get(), PPTM, &tempFile);
1039 
1040     // Assert that the content type is the one of PPTM
1041     xmlDocUniquePtr pXmlContentType = parseExport(tempFile, "[Content_Types].xml");
1042     assertXPath(pXmlContentType,
1043                 "/ContentType:Types/ContentType:Override[@PartName='/ppt/presentation.xml']",
1044                 "ContentType",
1045                 "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml");
1046 
1047     xDocShRef->DoClose();
1048 }
1049 
testTdf111798()1050 void SdOOXMLExportTest2::testTdf111798()
1051 {
1052     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf111798.odp"), ODP);
1053     utl::TempFile tempFile;
1054     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1055     xDocShRef->DoClose();
1056     xmlDocUniquePtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
1057 
1058     const OUString data[][29] =
1059     {
1060         {
1061             "2700000", "2458080", "2414880", "1439640", "1440000",
1062             "moveTo",  "0",    "3000",
1063             "lnTo[1]", "3000", "3000",
1064             "lnTo[2]", "3000", "4000",
1065             "lnTo[3]", "4000", "2000",
1066             "lnTo[4]", "3000", "0",
1067             "lnTo[5]", "3000", "1000",
1068             "lnTo[6]", "0",    "1000",
1069             "lnTo[7]", "0",    "3000"
1070         },
1071         {
1072             "2700000", "6778080", "2414880", "1439640", "1440000",
1073             "moveTo",  "3000", "0",
1074             "lnTo[1]", "3000", "3000",
1075             "lnTo[2]", "4000", "3000",
1076             "lnTo[3]", "2000", "4000",
1077             "lnTo[4]", "0", "3000",
1078             "lnTo[5]", "1000", "3000",
1079             "lnTo[6]", "1000", "0",
1080             "lnTo[7]", "3000", "0"
1081         }
1082     };
1083 
1084     for (size_t nShapeIndex = 0; nShapeIndex < SAL_N_ELEMENTS(data); nShapeIndex++)
1085     {
1086         size_t nDataIndex = 0;
1087 
1088         const OString sSpPr = "/p:sld/p:cSld/p:spTree/p:sp[" + OString::number(nShapeIndex + 1) + "]/p:spPr";
1089         const OString sXfrm = sSpPr + "/a:xfrm";
1090         assertXPath(pXmlDoc, sXfrm, "rot", data[nShapeIndex][nDataIndex++]);
1091         const OString sOff = sXfrm + "/a:off";
1092         assertXPath(pXmlDoc, sOff, "x", data[nShapeIndex][nDataIndex++]);
1093         assertXPath(pXmlDoc, sOff, "y", data[nShapeIndex][nDataIndex++]);
1094         const OString sExt = sXfrm + "/a:ext";
1095         assertXPath(pXmlDoc, sExt, "cx", data[nShapeIndex][nDataIndex++]);
1096         assertXPath(pXmlDoc, sExt, "cy", data[nShapeIndex][nDataIndex++]);
1097 
1098         while (nDataIndex < SAL_N_ELEMENTS(data[nShapeIndex]))
1099         {
1100             const OString sPt = sSpPr + "/a:custGeom/a:pathLst/a:path/a:" + data[nShapeIndex][nDataIndex++].toUtf8() + "/a:pt";
1101             assertXPath(pXmlDoc, sPt, "x", data[nShapeIndex][nDataIndex++]);
1102             assertXPath(pXmlDoc, sPt, "y", data[nShapeIndex][nDataIndex++]);
1103         }
1104     }
1105 }
1106 
testPptmVBAStream()1107 void SdOOXMLExportTest2::testPptmVBAStream()
1108 {
1109     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptm/macro.pptm"), PPTM);
1110     utl::TempFile tempFile;
1111     xDocShRef = saveAndReload(xDocShRef.get(), PPTM, &tempFile);
1112 
1113     uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), tempFile.GetURL());
1114     // This failed: VBA stream was not roundtripped
1115     CPPUNIT_ASSERT(xNameAccess->hasByName("ppt/vbaProject.bin"));
1116 
1117     xDocShRef->DoClose();
1118 }
1119 
testTdf111863()1120 void SdOOXMLExportTest2::testTdf111863()
1121 {
1122     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf111863.pptx"), PPTX);
1123     utl::TempFile tempFile;
1124     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1125     xDocShRef->DoClose();
1126 
1127     // check that transition attribute didn't change from 'out' to 'in'
1128     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1129     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:animEffect",
1130         "transition", "out");
1131 }
1132 
testTdf111518()1133 void SdOOXMLExportTest2::testTdf111518()
1134 {
1135     sd::DrawDocShellRef xShell = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf111518.pptx"), PPTX);
1136     utl::TempFile tempFile;
1137     tempFile.EnableKillingFile(false);
1138     xShell = saveAndReload(xShell.get(), PPTX, &tempFile);
1139     xShell->DoClose();
1140 
1141     xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "ppt/slides/slide1.xml");
1142     OUString sActual = getXPath(pXmlDocRels,
1143             "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:animMotion",
1144             "path");
1145     CPPUNIT_ASSERT_MOTIONPATH("M -3.54167E-6 -4.81481E-6 L 0.39037 -0.00069 E", sActual);
1146 }
1147 
testTdf100387()1148 void SdOOXMLExportTest2::testTdf100387()
1149 {
1150 
1151     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf100387.odp"), ODP);
1152     utl::TempFile tempFile;
1153     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1154     xDocShRef->DoClose();
1155     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1156 
1157     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn", "dur", "indefinite");
1158     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par[1]/p:cTn", "fill", "hold");
1159     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par[1]/p:cTn/p:childTnLst/p:par/p:cTn", "fill", "hold");
1160 
1161     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par[1]"
1162                              "/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt/p:txEl/p:pRg", "st", "0");
1163     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par[1]"
1164                              "/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt/p:txEl/p:pRg", "end", "0");
1165 
1166     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par[2]"
1167                              "/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt/p:txEl/p:pRg", "st", "1");
1168     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par[2]"
1169                              "/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt/p:txEl/p:pRg", "end", "1");
1170 
1171     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par[3]"
1172                              "/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt/p:txEl/p:pRg", "st", "2");
1173     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par[3]"
1174                              "/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt/p:txEl/p:pRg", "end", "2");
1175 }
1176 
1177 // tdf#126746 Add support for Line Caps import and export
testClosingShapesAndLineCaps()1178 void SdOOXMLExportTest2::testClosingShapesAndLineCaps()
1179 {
1180     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/closed-shapes.odp"), ODP);
1181     utl::TempFile tempFile;
1182     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1183     xDocShRef->DoClose();
1184     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1185     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/a:moveTo/a:pt", 1);
1186     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", 1);
1187     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/a:lnTo[2]/a:pt", 1);
1188     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:custGeom/a:pathLst/a:path/a:close", 1);
1189     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:ln", "cap", "rnd");
1190     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:ln/a:miter", 1);
1191 
1192     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:spPr/a:custGeom/a:pathLst/a:path/a:close", 0);
1193     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:spPr/a:ln", "cap", "rnd");
1194     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:spPr/a:ln/a:miter", 1);
1195 
1196     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:custGeom/a:pathLst/a:path/a:close", 0);
1197     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:ln", "cap", "rnd");
1198     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:ln/a:miter", 1);
1199 
1200     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[4]/p:spPr/a:custGeom/a:pathLst/a:path/a:close", 0);
1201     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[4]/p:spPr/a:ln", "cap", "sq");
1202     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[4]/p:spPr/a:ln/a:round", 1);
1203 
1204     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:custGeom/a:pathLst/a:path/a:close", 0);
1205     assertXPathNoAttribute(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:ln", "cap"); // by default it is "flat" cap style
1206     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:ln/a:bevel", 1);
1207 
1208     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[6]/p:spPr/a:custGeom/a:pathLst/a:path/a:close", 0);
1209     assertXPathNoAttribute(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:ln", "cap"); // by default it is "flat" cap style
1210     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[6]/p:spPr/a:ln/a:round", 1);
1211 }
1212 
testRotateFlip()1213 void SdOOXMLExportTest2::testRotateFlip()
1214 {
1215     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/rotate_flip.odp"), ODP);
1216     utl::TempFile tempFile;
1217     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1218     xDocShRef->DoClose();
1219     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1220 
1221     const OUString data[][4] =
1222     {// flipH flipV     x          y
1223         { "0", "1", "1170000", "1035720" },
1224         { "1", "1", "7108560", "1036440" },
1225         { "1", "0", "4140000", "1036440" }
1226     };
1227 
1228     const OUString points[][2] = { {"221", "293"},     {"506", "12" },     {"367", "0"  },     {"29",  "406"},     {"431", "347"},    {"145", "645"},
1229                                    {"99",  "520"},     {"0",   "861"},     {"326", "765"},     {"209", "711"},     {"640", "233"},    {"640", "233"} };
1230 
1231     for (size_t nShapeIndex = 0; nShapeIndex < SAL_N_ELEMENTS(data); nShapeIndex++)
1232     {
1233         size_t nDataIndex = 0;
1234 
1235         const OString sSpPr = "/p:sld/p:cSld/p:spTree/p:sp[" + OString::number(nShapeIndex + 1) + "]/p:spPr";
1236         const OString sXfrm = sSpPr + "/a:xfrm";
1237         if(data[nShapeIndex][nDataIndex++] == "1")
1238             assertXPath(pXmlDocContent, sXfrm, "flipH", "1");
1239         if(data[nShapeIndex][nDataIndex++] == "1")
1240             assertXPath(pXmlDocContent, sXfrm, "flipV", "1");
1241         assertXPath(pXmlDocContent, sXfrm, "rot", "20400000");
1242         const OString sOff = sXfrm + "/a:off";
1243         assertXPath(pXmlDocContent, sOff, "x", data[nShapeIndex][nDataIndex++]);
1244         assertXPath(pXmlDocContent, sOff, "y", data[nShapeIndex][nDataIndex++]);
1245         const OString sExt = sXfrm + "/a:ext";
1246         assertXPath(pXmlDocContent, sExt, "cx", "1800000");
1247         assertXPath(pXmlDocContent, sExt, "cy", "3600000");
1248 
1249         for (size_t nPointIndex = 0; nPointIndex < SAL_N_ELEMENTS(points); nPointIndex++)
1250         {
1251             const OString sPt = sSpPr + "/a:custGeom/a:pathLst/a:path/a:lnTo[" + OString::number(nPointIndex + 1) + "]/a:pt";
1252             assertXPath(pXmlDocContent, sPt, "x", points[nPointIndex][0]);
1253             assertXPath(pXmlDocContent, sPt, "y", points[nPointIndex][1]);
1254         }
1255         assertXPath(pXmlDocContent, sSpPr + "/a:custGeom/a:pathLst/a:path/a:close", 1);
1256     }
1257 }
1258 
testTdf106867()1259 void SdOOXMLExportTest2::testTdf106867()
1260 {
1261     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf106867.pptx"), PPTX);
1262     utl::TempFile tempFile;
1263     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1264 
1265     const SdrPage *pPage = GetPage(1, xDocShRef.get());
1266 
1267     // first check that we have the media object
1268     const SdrMediaObj* pMediaObj = dynamic_cast<SdrMediaObj*>(pPage->GetObj(2));
1269     CPPUNIT_ASSERT_MESSAGE("no media object", pMediaObj != nullptr);
1270     CPPUNIT_ASSERT_EQUAL(OUString("vnd.sun.star.Package:ppt/media/media1.avi"), pMediaObj->getURL());
1271 
1272     xDocShRef->DoClose();
1273 
1274     // additional checks of the output file
1275     uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), tempFile.GetURL());
1276     // check that the document contains the video stream
1277     CPPUNIT_ASSERT(xNameAccess->hasByName("ppt/media/media1.avi"));
1278 
1279     // both the ooxml and the extended markup
1280     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1281     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/a:videoFile");
1282     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:pic/p:nvPicPr/p:nvPr/p:extLst/p:ext/p14:media");
1283 
1284     // target the shape with the video in the command
1285     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:cmd/p:cBhvr/p:tgtEl/p:spTgt",
1286             "spid", "42");
1287 }
1288 
testTdf112280()1289 void SdOOXMLExportTest2::testTdf112280()
1290 {
1291     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf112280.pptx"), PPTX);
1292     utl::TempFile tempFile;
1293     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1294     xDocShRef->DoClose();
1295 
1296     // check the animRot value
1297     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1298     assertXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:animRot",
1299             "by", "21600000");
1300 }
1301 
testTdf112088()1302 void SdOOXMLExportTest2::testTdf112088()
1303 {
1304     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf112088.pptx"), PPTX);
1305     utl::TempFile tempFile;
1306     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1307     xDocShRef->DoClose();
1308 
1309     // check gradient stops
1310     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1311     assertXPathChildren(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[3]/p:spPr/a:gradFill/a:gsLst", 2);
1312 }
1313 
testTdf112333()1314 void SdOOXMLExportTest2::testTdf112333()
1315 {
1316     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf112333.pptx"), PPTX);
1317     utl::TempFile tempFile;
1318     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1319     xDocShRef->DoClose();
1320 
1321     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1322 
1323     OUString sTo = getXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set[1]/p:to/p:strVal", "val");
1324     CPPUNIT_ASSERT_EQUAL(OUString("solid"), sTo);
1325 
1326     OUString sAttributeName = getXPathContent(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set[1]/p:cBhvr/p:attrNameLst/p:attrName");
1327     CPPUNIT_ASSERT_EQUAL(OUString("fill.type"), sAttributeName);
1328 
1329     sTo = getXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set[2]/p:to/p:strVal", "val");
1330     CPPUNIT_ASSERT_EQUAL(OUString("true"), sTo);
1331 
1332     sAttributeName = getXPathContent(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set[2]/p:cBhvr/p:attrNameLst/p:attrName");
1333     CPPUNIT_ASSERT_EQUAL(OUString("fill.on"), sAttributeName);
1334 
1335     sTo = getXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:animClr/p:to/a:srgbClr", "val");
1336     CPPUNIT_ASSERT_EQUAL(OUString("0563c1"), sTo);
1337 
1338     sAttributeName = getXPathContent(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:animClr/p:cBhvr/p:attrNameLst/p:attrName");
1339     CPPUNIT_ASSERT_EQUAL(OUString("fillcolor"), sAttributeName);
1340 }
1341 
testTdf112552()1342 void SdOOXMLExportTest2::testTdf112552()
1343 {
1344     // Background fill was not displayed, but it was because of the wrong geometry
1345     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf112552.odp"), ODP);
1346     utl::TempFile tempFile;
1347     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1348 
1349     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1350     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:custGeom/a:pathLst/a:path", "w", "21600");
1351     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:custGeom/a:pathLst/a:path", "h", "21600");
1352     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", "x", "21600");
1353     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:custGeom/a:pathLst/a:path/a:lnTo[1]/a:pt", "y", "0");
1354     xDocShRef->DoClose();
1355 }
1356 
testTdf112557()1357 void SdOOXMLExportTest2::testTdf112557()
1358 {
1359     // Subtitle shape should be skipped by export.
1360     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf112557.odp"), ODP);
1361     utl::TempFile tempFile;
1362     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1363 
1364     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slideMasters/slideMaster1.xml");
1365     assertXPath(pXmlDocContent, "/p:sldMaster/p:cSld/p:spTree/p:sp", 2); // title and object
1366     xDocShRef->DoClose();
1367 }
1368 
testTdf128049()1369 void SdOOXMLExportTest2::testTdf128049()
1370 {
1371     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf128049.odp"), ODP);
1372     utl::TempFile tempFile;
1373     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1374 
1375     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1376     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:custGeom", 0);
1377     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:prstGeom", "prst", "noSmoking");
1378     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:prstGeom/a:avLst/a:gd", "name", "adj");
1379     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:spPr/a:prstGeom/a:avLst/a:gd", "fmla", "val 12500");
1380     xDocShRef->DoClose();
1381 }
1382 
testTdf106026()1383 void SdOOXMLExportTest2::testTdf106026()
1384 {
1385     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf106026.odp"), ODP);
1386     utl::TempFile tempFile;
1387     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1388 
1389     xmlDocUniquePtr pXmlMasterContent = parseExport(tempFile, "ppt/slideMasters/slideMaster1.xml");
1390     assertXPath(pXmlMasterContent, "/p:sldMaster/p:cSld/p:spTree/p:sp/p:txBody/a:p[1]/a:pPr/a:spcBef/a:spcPts", "val", "1417");
1391     assertXPath(pXmlMasterContent, "/p:sldMaster/p:cSld/p:spTree/p:sp/p:txBody/a:p[2]/a:pPr/a:spcBef/a:spcPts", "val", "1134");
1392     assertXPath(pXmlMasterContent, "/p:sldMaster/p:cSld/p:spTree/p:sp/p:txBody/a:p[3]/a:pPr/a:spcBef/a:spcPts", "val", "850");
1393     assertXPath(pXmlMasterContent, "/p:sldMaster/p:cSld/p:spTree/p:sp/p:txBody/a:p[4]/a:pPr/a:spcBef/a:spcPts", "val", "567");
1394     assertXPath(pXmlMasterContent, "/p:sldMaster/p:cSld/p:spTree/p:sp/p:txBody/a:p[5]/a:pPr/a:spcBef/a:spcPts", "val", "283");
1395     assertXPath(pXmlMasterContent, "/p:sldMaster/p:cSld/p:spTree/p:sp/p:txBody/a:p[6]/a:pPr/a:spcBef/a:spcPts", "val", "283");
1396     assertXPath(pXmlMasterContent, "/p:sldMaster/p:cSld/p:spTree/p:sp/p:txBody/a:p[7]/a:pPr/a:spcBef/a:spcPts", "val", "283");
1397 
1398     xmlDocUniquePtr pXmlSlideContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1399     assertXPath(pXmlSlideContent,
1400                        "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[1]/a:pPr/a:spcAft/a:spcPts", "val", "11339");
1401     assertXPath(pXmlSlideContent,
1402                        "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[2]/a:pPr/a:spcAft/a:spcPts", "val", "11339");
1403     assertXPath(pXmlSlideContent,
1404                        "/p:sld/p:cSld/p:spTree/p:sp[2]/p:txBody/a:p[3]/a:pPr/a:spcAft/a:spcPts", "val", "11339");
1405     xDocShRef->DoClose();
1406 }
1407 
testTdf112334()1408 void SdOOXMLExportTest2::testTdf112334()
1409 {
1410     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf112334.pptx"), PPTX);
1411     utl::TempFile tempFile;
1412     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1413     xDocShRef->DoClose();
1414 
1415     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1416 
1417     OUString sAttributeName = getXPathContent(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:animClr[1]/p:cBhvr/p:attrNameLst/p:attrName");
1418     CPPUNIT_ASSERT_EQUAL(OUString("style.color"), sAttributeName);
1419 }
1420 
testTdf112089()1421 void SdOOXMLExportTest2::testTdf112089()
1422 {
1423     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf112089.pptx"), PPTX);
1424     utl::TempFile tempFile;
1425     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1426     xDocShRef->DoClose();
1427 
1428     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1429 
1430     OUString sID = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:graphicFrame/p:nvGraphicFramePr/p:cNvPr", "id");
1431     OUString sTarget = getXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:set/p:cBhvr/p:tgtEl/p:spTgt", "spid");
1432     CPPUNIT_ASSERT_EQUAL(sID, sTarget);
1433 }
1434 
testTdf112086()1435 void SdOOXMLExportTest2::testTdf112086()
1436 {
1437     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf112086.pptx"), PPTX);
1438     utl::TempFile tempFile;
1439     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1440     xDocShRef->DoClose();
1441 
1442     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1443 
1444     OUString sVal = getXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:anim[2]/p:tavLst/p:tav/p:val/p:fltVal", "val");
1445     CPPUNIT_ASSERT_EQUAL(OUString("0"), sVal);
1446 
1447     OUString sAttributeName = getXPathContent(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:anim[1]/p:cBhvr/p:attrNameLst/p:attrName");
1448     CPPUNIT_ASSERT_EQUAL(OUString("ppt_w"), sAttributeName);
1449 
1450     sVal = getXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:anim[2]/p:tavLst/p:tav/p:val/p:fltVal", "val");
1451     CPPUNIT_ASSERT_EQUAL(OUString("0"), sVal);
1452 
1453     sAttributeName = getXPathContent(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:anim[2]/p:cBhvr/p:attrNameLst/p:attrName");
1454     CPPUNIT_ASSERT_EQUAL(OUString("ppt_h"), sAttributeName);
1455     xDocShRef->DoClose();
1456 }
1457 
testTdf112647()1458 void SdOOXMLExportTest2::testTdf112647()
1459 {
1460     ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf112647.odp"), ODP);
1461     xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
1462     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
1463     uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
1464     uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
1465 
1466     css::style::LineSpacing aLineSpacing;
1467     xPropSet->getPropertyValue("ParaLineSpacing") >>= aLineSpacing;
1468     CPPUNIT_ASSERT_EQUAL(sal_Int16(css::style::LineSpacingMode::FIX), aLineSpacing.Mode);
1469     CPPUNIT_ASSERT_EQUAL(sal_Int16(2117), aLineSpacing.Height);
1470     xDocShRef->DoClose();
1471 }
1472 
testGroupRotation()1473 void SdOOXMLExportTest2::testGroupRotation()
1474 {
1475     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/group_rotation.odp"), ODP);
1476     utl::TempFile tempFile;
1477     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1478     xDocShRef->DoClose();
1479 
1480     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1481     assertXPathNoAttribute(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:grpSpPr/a:xfrm", "rot");
1482     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[1]/p:spPr/a:xfrm", "rot", "20400000");
1483     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[2]/p:spPr/a:xfrm", "rot", "20400000");
1484 }
1485 
testTdf104788()1486 void SdOOXMLExportTest2::testTdf104788()
1487 {
1488     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf104788.pptx"), PPTX);
1489     utl::TempFile tempFile;
1490     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1491     xDocShRef->DoClose();
1492 
1493     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide6.xml");
1494 
1495     OUString sVal = getXPath(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par[2]/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:anim[2]", "to");
1496     CPPUNIT_ASSERT_EQUAL(-1.0, sVal.toDouble());
1497 
1498     OUString sAttributeName = getXPathContent(pXmlDocContent, "/p:sld/p:timing/p:tnLst/p:par/p:cTn/p:childTnLst/p:seq/p:cTn/p:childTnLst/p:par[2]/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:par/p:cTn/p:childTnLst/p:anim[2]/p:cBhvr/p:attrNameLst/p:attrName");
1499     CPPUNIT_ASSERT_EQUAL(OUString("xshear"), sAttributeName);
1500     xDocShRef->DoClose();
1501 }
1502 
testSmartartRotation2()1503 void SdOOXMLExportTest2::testSmartartRotation2()
1504 {
1505     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/smartart-rotation2.pptx"), PPTX);
1506 
1507     // clear SmartArt data to check how group shapes with double-rotated children are exported, not smartart
1508     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
1509     uno::Sequence<beans::PropertyValue> aInteropGrabBag;
1510     xShape->setPropertyValue("InteropGrabBag", uno::makeAny(aInteropGrabBag));
1511 
1512     utl::TempFile tempFile;
1513     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1514     xDocShRef->DoClose();
1515 
1516     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1517     assertXPathContent(pXmlDocContent,
1518                        "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[4]/p:txBody/a:p/a:r/a:t", "Text");
1519     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[4]/p:txBody/a:bodyPr", "rot", "10800000");
1520     double dX = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[4]/p:spPr/a:xfrm/a:off", "x").toDouble();
1521     double dY = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[4]/p:spPr/a:xfrm/a:off", "y").toDouble();
1522     CPPUNIT_ASSERT_DOUBLES_EQUAL( 2276280.0, dX, dX * .001);
1523     CPPUNIT_ASSERT_DOUBLES_EQUAL( 3158280.0, dY, dY * .001);
1524 }
1525 
testTdf91999_rotateShape()1526 void SdOOXMLExportTest2::testTdf91999_rotateShape()
1527 {
1528     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf91999_rotateShape.pptx"), PPTX);
1529     utl::TempFile tempFile;
1530     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1531     xDocShRef->DoClose();
1532 
1533     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1534     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:nvSpPr/p:cNvPr", "name", "CustomShape 2");
1535     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:spPr/a:xfrm", "rot", "10800000");
1536     double dX = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:spPr/a:xfrm/a:off", "x").toDouble();
1537     double dY = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[2]/p:spPr/a:xfrm/a:off", "y").toDouble();
1538     CPPUNIT_ASSERT_DOUBLES_EQUAL( 2960640.0, dX, dX * .001);
1539     CPPUNIT_ASSERT_DOUBLES_EQUAL( 1449000.0, dY, dY * .001);
1540 }
1541 
testTdf114845_rotateShape()1542 void SdOOXMLExportTest2::testTdf114845_rotateShape()
1543 {
1544     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf114845_rotateShape.pptx"), PPTX);
1545     utl::TempFile tempFile;
1546     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1547     xDocShRef->DoClose();
1548 
1549     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1550     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:nvSpPr/p:cNvPr", "name", "Straight Arrow Connector 9");
1551     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:xfrm", "flipV", "1");
1552     double dX = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:xfrm/a:off", "x").toDouble();
1553     double dY = getXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:sp[5]/p:spPr/a:xfrm/a:off", "y").toDouble();
1554     CPPUNIT_ASSERT_DOUBLES_EQUAL( 4059000.0, dX, dX * .001);
1555     CPPUNIT_ASSERT_DOUBLES_EQUAL( 3287520.0, dY, dY * .001);
1556 }
1557 
testGroupsPosition()1558 void SdOOXMLExportTest2::testGroupsPosition()
1559 {
1560     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/group.pptx"), PPTX);
1561     utl::TempFile tempFile;
1562     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1563     xDocShRef->DoClose();
1564 
1565     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1566     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "x", "5004000");
1567     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[1]/p:spPr/a:xfrm/a:off", "y", "3310560");
1568     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "7760160");
1569     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp[1]/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "3310560");
1570 }
1571 
testGroupsRotatedPosition()1572 void SdOOXMLExportTest2::testGroupsRotatedPosition()
1573 {
1574     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/group-rot.pptx"), PPTX);
1575     utl::TempFile tempFile;
1576     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1577     xDocShRef->DoClose();
1578 
1579     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1580     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "x", "2857320");
1581     assertXPath(pXmlDocContent, "/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "y", "4026960");
1582 }
1583 
testAccentColor()1584 void SdOOXMLExportTest2::testAccentColor()
1585 {
1586     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/accent-color.pptx"), PPTX);
1587     utl::TempFile tempFile;
1588     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1589     xDocShRef->DoClose();
1590 
1591     xmlDocUniquePtr pXmlDocContent1 = parseExport(tempFile, "ppt/slides/slide1.xml");
1592     assertXPath(pXmlDocContent1, "/p:sld/p:cSld/p:spTree/p:sp/p:style/a:fillRef/a:schemeClr", "val", "accent6");
1593     xmlDocUniquePtr pXmlDocContent2 = parseExport(tempFile, "ppt/slides/slide2.xml");
1594     assertXPath(pXmlDocContent2, "/p:sld/p:cSld/p:spTree/p:sp/p:style/a:fillRef/a:schemeClr", "val", "accent6");
1595     xmlDocUniquePtr pXmlDocTheme1 = parseExport(tempFile, "ppt/theme/theme1.xml");
1596     assertXPath(pXmlDocTheme1, "/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr", "val", "70ad47");
1597     xmlDocUniquePtr pXmlDocTheme2 = parseExport(tempFile, "ppt/theme/theme2.xml");
1598     assertXPath(pXmlDocTheme2, "/a:theme/a:themeElements/a:clrScheme/a:accent6/a:srgbClr", "val", "deb340");
1599 }
1600 
testThemeColors()1601 void SdOOXMLExportTest2::testThemeColors()
1602 {
1603     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf84205.pptx"), PPTX);
1604     utl::TempFile tempFile;
1605     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1606     xDocShRef->DoClose();
1607 
1608     xmlDocUniquePtr pXmlDocTheme2 = parseExport(tempFile, "ppt/theme/theme2.xml");
1609     assertXPath(pXmlDocTheme2, "/a:theme/a:themeElements/a:clrScheme/a:dk2/a:srgbClr", "val", "44546a");
1610     assertXPath(pXmlDocTheme2, "/a:theme/a:themeElements/a:clrScheme/a:accent3/a:srgbClr", "val", "a5a5a5");
1611 }
1612 
1613 
testTdf118825()1614 void SdOOXMLExportTest2::testTdf118825()
1615 {
1616     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/tdf118825-motionpath.odp"), ODP);
1617     utl::TempFile tempFile;
1618     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1619     xmlDocUniquePtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
1620 
1621 
1622     CPPUNIT_ASSERT_MOTIONPATH("M 0.0449285714285714 0.00368253968253968 C 0.0575714285714285 -0.00095238095238096 0.0704264795523803 -0.00370117418637049 0.0831071428571428 -0.00819047619047622 C 0.0953550597998766 -0.0125265741339082 0.107821870086751 -0.010397536991717 0.120321428571429 -0.0115555555555556 C 0.133179018681433 -0.0127467438724762 0.151318627483861 -0.0158700272533852 0.1585 0.00539682539682542 C 0.16478291361998 0.0240029898688431 0.15828642886492 0.0483806254341085 0.161392857142857 0.0698412698412698 C 0.165179286017685 0.0959996731216037 0.17453898927982 0.119735912694626 0.187142857142857 0.132634920634921 C 0.199788991845377 0.145577185161529 0.215607110490848 0.142889773028431 0.230107142857143 0.142857142857143 C 0.243821417584191 0.142826280916829 0.257716514999779 0.142685979556724 0.271142857142857 0.137777777777778 C 0.286895094567923 0.132019309914514 0.302318190711873 0.122962218306185 0.317928571428571 0.11568253968254 C 0.333496771884547 0.108422531222479 0.348787823719556 0.0990570571890929 0.363714285714286 0.0885079365079364 C 0.374930683062651 0.080580865157908 0.385357142857143 0.0693333333333332 0.396178571428571 0.0596825396825396 L 0.404785714285714 0.0410158730158729 L 0.401892857142857 0.0342222222222221 E", getXPath(pXmlDocContent, "(//p:animMotion)[1]", "path"));
1623     CPPUNIT_ASSERT_MOTIONPATH("M 0.025 0.0571428571428571 L 0.0821428571428571 0.184126984126984 L -0.175 0.234920634920635 L -0.246428571428571 -0.0190476190476191 L -0.0821428571428573 -0.133333333333333 E", getXPath(pXmlDocContent, "(//p:animMotion)[2]", "path"));
1624     CPPUNIT_ASSERT_MOTIONPATH("M -0.0107142857142857 0.00634920634920635 C -0.110714285714286 0.501587301587301 -0.153571428571429 -0.00634920634920635 -0.246428571428572 0.184126984126984 C -0.339285714285715 0.374603174603175 -0.296428571428572 0.514285714285714 -0.267857142857143 0.603174603174603 C -0.239285714285715 0.692063492063492 0.0607142857142858 0.590476190476191 0.0607142857142858 0.590476190476191 E", getXPath(pXmlDocContent, "(//p:animMotion)[3]", "path"));
1625     CPPUNIT_ASSERT_MOTIONPATH("M 0.0535714285714286 -0.0444444444444444 L 0.132142857142857 -0.0444444444444444 L 0.132142857142857 -0.146031746031746 L 0.0964285714285715 -0.146031746031746 E", getXPath(pXmlDocContent, "(//p:animMotion)[4]", "path"));
1626     xDocShRef->DoClose();
1627 }
1628 
1629 
testTextColumns_tdf140852()1630 void SdOOXMLExportTest2::testTextColumns_tdf140852()
1631 {
1632     // The document defines two columns in slideLayout12.xml, but explicitly redefines
1633     // in slide1.xml. Here we check that the redefinition in the slide takes precedence.
1634 
1635     auto xDocShRef = loadURL(
1636         m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf140852.pptx"), PPTX);
1637 
1638     {
1639         uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef);
1640         uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages();
1641         uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW);
1642         uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW);
1643         uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
1644         uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW);
1645         uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps));
1646         CPPUNIT_ASSERT_EQUAL(OUString("Training will be treated as part of sharing the sweet when "
1647                                       "it comes to serving ice cream"),
1648                              xParagraph->getString());
1649         uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"),
1650                                                  uno::UNO_QUERY_THROW);
1651         CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCols->getColumnCount());
1652         uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW);
1653         CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(1000)),
1654                              xColProps->getPropertyValue("AutomaticDistance"));
1655     }
1656 
1657     utl::TempFile tempFile;
1658     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1659 
1660     {
1661         uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef);
1662         uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages();
1663         uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW);
1664         uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW);
1665         uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
1666         uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW);
1667         uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xProps));
1668         CPPUNIT_ASSERT_EQUAL(OUString("Training will be treated as part of sharing the sweet when "
1669                                       "it comes to serving ice cream"),
1670                              xParagraph->getString());
1671         uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"),
1672                                                  uno::UNO_QUERY_THROW);
1673         CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCols->getColumnCount());
1674         uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW);
1675         CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(1000)),
1676                              xColProps->getPropertyValue("AutomaticDistance"));
1677     }
1678 
1679     xDocShRef->DoClose();
1680 
1681     xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "ppt/slides/slide1.xml");
1682     assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "numCol", "1");
1683     assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "spcCol", "360000");
1684 
1685     tempFile.EnableKillingFile();
1686 }
1687 
testTextColumns_3columns()1688 void SdOOXMLExportTest2::testTextColumns_3columns()
1689 {
1690     auto xDocShRef = loadURL(
1691         m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/3columns.pptx"), PPTX);
1692 
1693     {
1694         uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef);
1695         uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages();
1696         uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW);
1697         uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW);
1698         uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
1699         uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW);
1700         uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"),
1701                                                  uno::UNO_QUERY_THROW);
1702         CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCols->getColumnCount());
1703         uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW);
1704         CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(300)),
1705                              xColProps->getPropertyValue("AutomaticDistance"));
1706         // Scale value may be unstable; just test that the text is actually scaled
1707         sal_Int16 nScale;
1708         CPPUNIT_ASSERT(xProps->getPropertyValue("TextFitToSizeScale") >>= nScale);
1709         CPPUNIT_ASSERT_GREATER(sal_Int16(0), nScale);
1710         CPPUNIT_ASSERT_LESS(sal_Int16(100), nScale);
1711     }
1712 
1713     utl::TempFile tempFile;
1714     xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1715 
1716     {
1717         uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier = getDoc(xDocShRef);
1718         uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages();
1719         uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW);
1720         uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW);
1721         uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
1722         uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW);
1723         uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"),
1724                                                  uno::UNO_QUERY_THROW);
1725         CPPUNIT_ASSERT_EQUAL(sal_Int16(3), xCols->getColumnCount());
1726         uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW);
1727         CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(300)),
1728                              xColProps->getPropertyValue("AutomaticDistance"));
1729         // Scale value may be unstable; just test that the text is actually scaled
1730         sal_Int16 nScale;
1731         CPPUNIT_ASSERT(xProps->getPropertyValue("TextFitToSizeScale") >>= nScale);
1732         CPPUNIT_ASSERT_GREATER(sal_Int16(0), nScale);
1733         CPPUNIT_ASSERT_LESS(sal_Int16(100), nScale);
1734     }
1735 
1736     xDocShRef->DoClose();
1737 
1738     xmlDocUniquePtr pXmlDocRels = parseExport(tempFile, "ppt/slides/slide1.xml");
1739     assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "numCol", "3");
1740     assertXPath(pXmlDocRels, "/p:sld/p:cSld/p:spTree/p:sp[1]/p:txBody/a:bodyPr", "spcCol", "108000");
1741 
1742     tempFile.EnableKillingFile();
1743 }
1744 
1745 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest2);
1746 
1747 CPPUNIT_PLUGIN_IMPLEMENT();
1748 
1749 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
1750