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 
10 #include <sal/config.h>
11 
12 #include <config_poppler.h>
13 #include <memory>
14 #include <ostream>
15 #include <sdpage.hxx>
16 
17 #include "sdmodeltestbase.hxx"
18 
19 #include <editeng/eeitem.hxx>
20 #include <editeng/editobj.hxx>
21 #include <editeng/outlobj.hxx>
22 #include <editeng/ulspitem.hxx>
23 #include <editeng/fhgtitem.hxx>
24 #include <editeng/escapementitem.hxx>
25 #include <editeng/colritem.hxx>
26 #include <editeng/numitem.hxx>
27 #include <editeng/unoprnms.hxx>
28 #include <svl/style.hxx>
29 
30 #include <svx/svdotext.hxx>
31 #include <svx/svdoashp.hxx>
32 #include <svx/svdogrp.hxx>
33 #include <svx/svdoole2.hxx>
34 #include <svx/svdotable.hxx>
35 #include <svx/xfillit0.hxx>
36 #include <svx/xflclit.hxx>
37 #include <svx/xlineit0.hxx>
38 #include <svx/xlnclit.hxx>
39 #include <svx/xlnwtit.hxx>
40 #include <svx/sdasitm.hxx>
41 #include <svx/sdmetitm.hxx>
42 #include <svx/sdooitm.hxx>
43 #include <animations/animationnodehelper.hxx>
44 #include <sax/tools/converter.hxx>
45 
46 #include <com/sun/star/awt/Gradient.hpp>
47 #include <com/sun/star/awt/XBitmap.hpp>
48 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
49 #include <com/sun/star/document/XEventsSupplier.hpp>
50 #include <com/sun/star/presentation/ClickAction.hpp>
51 #include <com/sun/star/presentation/XPresentationPage.hpp>
52 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
53 #include <com/sun/star/drawing/BitmapMode.hpp>
54 #include <com/sun/star/drawing/ColorMode.hpp>
55 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
56 #include <com/sun/star/drawing/XDrawPage.hpp>
57 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
58 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
59 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
60 #include <com/sun/star/drawing/GluePoint2.hpp>
61 #include <com/sun/star/container/XIdentifierAccess.hpp>
62 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
63 #include <com/sun/star/animations/XAnimationNode.hpp>
64 #include <com/sun/star/animations/XAnimate.hpp>
65 #include <com/sun/star/beans/XPropertySet.hpp>
66 #include <com/sun/star/chart/DataLabelPlacement.hpp>
67 #include <com/sun/star/chart/XChartDocument.hpp>
68 #include <com/sun/star/chart2/XChartDocument.hpp>
69 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
70 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
71 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
72 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
73 #include <com/sun/star/chart2/data/XDataSequence.hpp>
74 #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
75 #include <com/sun/star/graphic/XGraphic.hpp>
76 #include <com/sun/star/table/BorderLineStyle.hpp>
77 #include <com/sun/star/table/BorderLine2.hpp>
78 #include <com/sun/star/style/ParagraphAdjust.hpp>
79 #include <com/sun/star/style/LineSpacing.hpp>
80 #include <com/sun/star/style/LineSpacingMode.hpp>
81 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
82 #include <com/sun/star/table/XTableRows.hpp>
83 #include <com/sun/star/style/NumberingType.hpp>
84 #include <com/sun/star/frame/Desktop.hpp>
85 #include <com/sun/star/text/GraphicCrop.hpp>
86 #include <com/sun/star/text/XTextCursor.hpp>
87 #include <com/sun/star/text/XTextColumns.hpp>
88 #include <com/sun/star/xml/dom/XDocument.hpp>
89 #include <com/sun/star/container/XNamed.hpp>
90 #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
91 
92 #include <stlpool.hxx>
93 #include <comphelper/processfactory.hxx>
94 #include <comphelper/sequenceashashmap.hxx>
95 #include <comphelper/graphicmimetype.hxx>
96 #include <comphelper/lok.hxx>
97 #include <sfx2/linkmgr.hxx>
98 #include <vcl/filter/PngImageReader.hxx>
99 #include <vcl/BitmapReadAccess.hxx>
100 #include <vcl/dibtools.hxx>
101 #include <svx/svdograf.hxx>
102 #include <vcl/filter/PDFiumLibrary.hxx>
103 
104 using namespace ::com::sun::star;
105 
106 namespace com::sun::star::uno {
107 
108 template<class T>
operator <<(std::ostream & rStrm,const uno::Reference<T> & xRef)109 static std::ostream& operator<<(std::ostream& rStrm, const uno::Reference<T>& xRef)
110 {
111     rStrm << xRef.get();
112     return rStrm;
113 }
114 
115 }
116 
117 
118 /// Impress import filters tests.
119 class SdImportTest : public SdModelTestBase
120 {
121 public:
122     virtual void setUp() override;
123 
124     void testDocumentLayout();
125     void testTdf142645();
126     void testTdf142915();
127     void testTdf142913();
128     void testTdf142590();
129     void testCustomSlideShow();
130     void testInternalHyperlink();
131     void testHyperlinkColor();
132     void testSmoketest();
133     void testTdf131269();
134     void testN759180();
135     void testN778859();
136     void testMasterPageStyleParent();
137     void testGradientAngle();
138     void testTdf97808();
139     void testFillStyleNone();
140     void testFdo64512();
141     void testFdo71075();
142     void testN828390_2();
143     void testN828390_3();
144     void testFdo68594();
145     void testPlaceholderPriority();
146     void testFdo72998();
147     void testFdo77027();
148     void testStrictOOXML();
149     void testN862510_1();
150     void testN862510_2();
151     void testN862510_4();
152     void testBnc870237();
153     void testBnc887225();
154     void testPredefinedTableStyle();
155     void testBnc591147();
156     void testCreationDate();
157     void testMultiColTexts();
158     void testBnc584721_1();
159     void testBnc584721_2();
160     void testBnc584721_4();
161     void testBnc904423();
162     void testShapeLineStyle();
163     void testTableBorderLineStyle();
164     void testBnc862510_6();
165     void testBnc862510_7();
166 #if ENABLE_PDFIMPORT
167     void testPDFImportShared();
168 #if defined(IMPORT_PDF_ELEMENTS)
169     void testPDFImport();
170     void testPDFImportSkipImages();
171 #endif
172 #endif
173     void testBulletSuffix();
174     void testBnc910045();
175     void testRowHeight();
176     void testTdf93830();
177     void testTdf127129();
178     void testTdf93097();
179     void testTdf62255();
180     void testTdf113163();
181     void testTdf93124();
182     void testTdf99729();
183     void testTdf89927();
184     void testTdf93868();
185     void testTdf95932();
186     void testTdf99030();
187     void testTdf49561();
188     void testTdf103473();
189     void testAoo124143();
190     void testTdf103567();
191     void testTdf103792();
192     void testTdf103876();
193     void testTdf79007();
194     void testTdf129686();
195     void testTdf104015();
196     void testTdf104201();
197     void testTdf103477();
198     void testTdf104445();
199     void testTdf105150();
200     void testTdf105150PPT();
201     void testTdf123684();
202     void testTdf100926();
203     void testTdf89064();
204     void testTdf108925();
205     void testTdf109067();
206     void testTdf109187();
207     void testTdf108926();
208     void testTdf100065();
209     void testTdf90626();
210     void testTdf138148();
211     void testTdf114488();
212     void testTdf134174();
213     void testTdf134210();
214     void testTdf114913();
215     void testTdf114821();
216     void testTdf115394();
217     void testTdf115394PPT();
218     void testTdf51340();
219     void testTdf116899();
220     void testTdf77747();
221     void testTdf116266();
222     void testTdf128684();
223     void testShapeGlowEffectPPTXImpoer();
224     void testShapeBlurPPTXImport();
225     void testMirroredGraphic();
226     void testGreysScaleGraphic();
227     void testTdf134210CropPosition();
228 
229     bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
230     void testPatternImport();
231     void testPptCrop();
232     void testTdf120028();
233     void testDescriptionImport();
234     void testTdf83247();
235     void testTdf47365();
236     void testTdf122899();
237     void testOOXTheme();
238     void testCropToShape();
239     void testTdf127964();
240     void testTdf106638();
241     void testTdf113198();
242     void testTdf49856();
243     void testTdf103347();
244 
245     CPPUNIT_TEST_SUITE(SdImportTest);
246 
247     CPPUNIT_TEST(testDocumentLayout);
248     CPPUNIT_TEST(testTdf142645);
249     CPPUNIT_TEST(testTdf142915);
250     CPPUNIT_TEST(testTdf142913);
251     CPPUNIT_TEST(testTdf142590);
252     CPPUNIT_TEST(testCustomSlideShow);
253     CPPUNIT_TEST(testInternalHyperlink);
254     CPPUNIT_TEST(testHyperlinkColor);
255     CPPUNIT_TEST(testSmoketest);
256     CPPUNIT_TEST(testTdf131269);
257     CPPUNIT_TEST(testN759180);
258     CPPUNIT_TEST(testN778859);
259     CPPUNIT_TEST(testMasterPageStyleParent);
260     CPPUNIT_TEST(testGradientAngle);
261     CPPUNIT_TEST(testTdf97808);
262     CPPUNIT_TEST(testFillStyleNone);
263     CPPUNIT_TEST(testFdo64512);
264     CPPUNIT_TEST(testFdo71075);
265     CPPUNIT_TEST(testN828390_2);
266     CPPUNIT_TEST(testN828390_3);
267     CPPUNIT_TEST(testFdo68594);
268     CPPUNIT_TEST(testPlaceholderPriority);
269     CPPUNIT_TEST(testFdo72998);
270     CPPUNIT_TEST(testFdo77027);
271     CPPUNIT_TEST(testStrictOOXML);
272     CPPUNIT_TEST(testN862510_1);
273     CPPUNIT_TEST(testN862510_2);
274     CPPUNIT_TEST(testN862510_4);
275     CPPUNIT_TEST(testBnc870237);
276     CPPUNIT_TEST(testBnc887225);
277     CPPUNIT_TEST(testPredefinedTableStyle);
278     CPPUNIT_TEST(testBnc591147);
279     CPPUNIT_TEST(testCreationDate);
280     CPPUNIT_TEST(testMultiColTexts);
281     CPPUNIT_TEST(testBnc584721_1);
282     CPPUNIT_TEST(testBnc584721_2);
283     CPPUNIT_TEST(testBnc584721_4);
284     CPPUNIT_TEST(testBnc904423);
285     CPPUNIT_TEST(testShapeLineStyle);
286     CPPUNIT_TEST(testTableBorderLineStyle);
287     CPPUNIT_TEST(testBnc862510_6);
288     CPPUNIT_TEST(testBnc862510_7);
289 #if ENABLE_PDFIMPORT
290     CPPUNIT_TEST(testPDFImportShared);
291 #if defined(IMPORT_PDF_ELEMENTS)
292     CPPUNIT_TEST(testPDFImport);
293     CPPUNIT_TEST(testPDFImportSkipImages);
294 #endif
295 #endif
296     CPPUNIT_TEST(testBulletSuffix);
297     CPPUNIT_TEST(testBnc910045);
298     CPPUNIT_TEST(testRowHeight);
299     CPPUNIT_TEST(testTdf93830);
300     CPPUNIT_TEST(testTdf127129);
301     CPPUNIT_TEST(testTdf93097);
302     CPPUNIT_TEST(testTdf62255);
303     CPPUNIT_TEST(testTdf113163);
304     CPPUNIT_TEST(testTdf93124);
305     CPPUNIT_TEST(testTdf99729);
306     CPPUNIT_TEST(testTdf89927);
307     CPPUNIT_TEST(testTdf93868);
308     CPPUNIT_TEST(testTdf95932);
309     CPPUNIT_TEST(testTdf99030);
310     CPPUNIT_TEST(testTdf49561);
311     CPPUNIT_TEST(testTdf103473);
312     CPPUNIT_TEST(testAoo124143);
313     CPPUNIT_TEST(testTdf103567);
314     CPPUNIT_TEST(testTdf103792);
315     CPPUNIT_TEST(testTdf103876);
316     CPPUNIT_TEST(testTdf79007);
317     CPPUNIT_TEST(testTdf129686);
318     CPPUNIT_TEST(testTdf104015);
319     CPPUNIT_TEST(testTdf104201);
320     CPPUNIT_TEST(testTdf103477);
321     CPPUNIT_TEST(testTdf104445);
322     CPPUNIT_TEST(testTdf105150);
323     CPPUNIT_TEST(testTdf105150PPT);
324     CPPUNIT_TEST(testTdf123684);
325     CPPUNIT_TEST(testTdf100926);
326     CPPUNIT_TEST(testPatternImport);
327     CPPUNIT_TEST(testTdf89064);
328     CPPUNIT_TEST(testTdf108925);
329     CPPUNIT_TEST(testTdf109067);
330     CPPUNIT_TEST(testTdf109187);
331     CPPUNIT_TEST(testTdf108926);
332     CPPUNIT_TEST(testTdf100065);
333     CPPUNIT_TEST(testTdf90626);
334     CPPUNIT_TEST(testTdf138148);
335     CPPUNIT_TEST(testTdf114488);
336     CPPUNIT_TEST(testTdf134174);
337     CPPUNIT_TEST(testTdf134210);
338     CPPUNIT_TEST(testTdf114913);
339     CPPUNIT_TEST(testTdf114821);
340     CPPUNIT_TEST(testTdf115394);
341     CPPUNIT_TEST(testTdf115394PPT);
342     CPPUNIT_TEST(testTdf51340);
343     CPPUNIT_TEST(testTdf116899);
344     CPPUNIT_TEST(testTdf77747);
345     CPPUNIT_TEST(testTdf116266);
346     CPPUNIT_TEST(testPptCrop);
347     CPPUNIT_TEST(testTdf120028);
348     CPPUNIT_TEST(testDescriptionImport);
349     CPPUNIT_TEST(testTdf83247);
350     CPPUNIT_TEST(testTdf47365);
351     CPPUNIT_TEST(testTdf122899);
352     CPPUNIT_TEST(testOOXTheme);
353     CPPUNIT_TEST(testCropToShape);
354     CPPUNIT_TEST(testTdf127964);
355     CPPUNIT_TEST(testTdf106638);
356     CPPUNIT_TEST(testTdf128684);
357     CPPUNIT_TEST(testTdf113198);
358     CPPUNIT_TEST(testTdf49856);
359     CPPUNIT_TEST(testShapeGlowEffectPPTXImpoer);
360     CPPUNIT_TEST(testShapeBlurPPTXImport);
361     CPPUNIT_TEST(testMirroredGraphic);
362     CPPUNIT_TEST(testGreysScaleGraphic);
363     CPPUNIT_TEST(testTdf134210CropPosition);
364     CPPUNIT_TEST(testTdf103347);
365 
366     CPPUNIT_TEST_SUITE_END();
367 };
368 
setUp()369 void SdImportTest::setUp()
370 {
371     SdModelTestBase::setUp();
372     mxDesktop.set(frame::Desktop::create(getComponentContext()));
373 }
374 
375 /** Test document against a reference XML dump of shapes.
376 
377 If you want to update one of these tests, or add a new one, set the nUpdateMe
378 to the index of the test, and the dump XML's will be created (or rewritten)
379 instead of checking. Use with care - when the test is failing, first find out
380 why, instead of just updating .xml's blindly.
381 
382 Example: Let's say you are adding a test called fdoABCD.pptx.  You'll place it
383 to the data/ subdirectory, and will add an entry to aFilesToCompare below,
384 the 3rd parameter is for export test - can be -1 (don't export), ODP, PPT or PPTX
385 like:
386 
387         { "fdoABCD.pptx", "xml/fdoABCD_", PPTX },
388 
389 and will count the index in the aFilesToCompare structure (1st is 0, 2nd is 1,
390 etc.)  Temporarily you'll set nUpdateMe to this index (instead of -1), and run
391 
392 make sd
393 
394 This will generate the sd/qa/unit/data/xml/fdoABCD_*.xml for you.  Now you
395 will change nUpdateMe back to -1, and commit your fdoABCD.pptx test, the
396 xml/fdoABCD_*.xml dumps, and the aFilesToCompare addition in one commit.
397 
398 As the last step, you will revert your fix and do 'make sd' again, to check
399 that without your fix, the unit test breaks.  Then clean up, and push :-)
400 
401 NOTE: This approach is suitable only for tests of fixes that actually change
402 the layout - best to check by reverting your fix locally after having added
403 the test, and re-running; it should break.
404 */
testDocumentLayout()405 void SdImportTest::testDocumentLayout()
406 {
407     static const struct { const char *pInput, *pDump; sal_Int32 nFormat; sal_Int32 nExportType; } aFilesToCompare[] =
408     {
409         { "odp/shapes-test.odp", "xml/shapes-test_page", ODP, -1 },
410         { "fdo47434.pptx", "xml/fdo47434_", PPTX, -1 },
411         { "n758621.ppt", "xml/n758621_", PPT, -1 },
412         { "fdo64586.ppt", "xml/fdo64586_", PPT, -1 },
413         { "n819614.pptx", "xml/n819614_", PPTX, -1 },
414         { "n820786.pptx", "xml/n820786_", PPTX, -1 },
415         { "n762695.pptx", "xml/n762695_", PPTX, -1 },
416         { "n593612.pptx", "xml/n593612_", PPTX, -1 },
417         { "fdo71434.pptx", "xml/fdo71434_", PPTX, -1 },
418         { "n902652.pptx", "xml/n902652_", PPTX, -1 },
419         { "tdf90403.pptx", "xml/tdf90403_", PPTX, -1 },
420         { "tdf90338.odp", "xml/tdf90338_", ODP, PPTX },
421         { "tdf92001.odp", "xml/tdf92001_", ODP, PPTX },
422 // GCC -mfpmath=387 rounding issues in lclPushMarkerProperties
423 // (oox/source/drawingml/lineproperties.cxx); see mail sub-thread starting at
424 // <https://lists.freedesktop.org/archives/libreoffice/2016-September/
425 // 075211.html> "Re: Test File: sc/qa/unit/data/functions/fods/chiinv.fods:
426 // fails with Assertion" for how "-mfpmath=sse -msse2" would fix that:
427 #if !(defined LINUX && defined X86)
428         { "tdf100491.pptx", "xml/tdf100491_", PPTX, -1 },
429 #endif
430         { "tdf109317.pptx", "xml/tdf109317_", PPTX, ODP},
431         // { "pptx/n828390.pptx", "pptx/xml/n828390_", PPTX, PPTX }, // Example
432     };
433 
434     for ( int i = 0; i < static_cast< int >( SAL_N_ELEMENTS( aFilesToCompare ) ); ++i )
435     {
436         int const nUpdateMe = -1; // index of test we want to update; supposedly only when the test is created
437 
438         sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc( u"/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pInput ), aFilesToCompare[i].nFormat );
439         if( aFilesToCompare[i].nExportType >= 0 )
440             xDocShRef = saveAndReload( xDocShRef.get(), aFilesToCompare[i].nExportType );
441         compareWithShapesDump( xDocShRef,
442                 OUString(m_directories.getPathFromSrc( u"/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pDump )),
443                 i == nUpdateMe );
444     }
445 }
446 
testTdf142645()447 void SdImportTest::testTdf142645()
448 {
449     sd::DrawDocShellRef xDocShRef
450         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf142645.pptx"), PPTX);
451     uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(),
452                                                      uno::UNO_QUERY_THROW);
453 
454     uno::Reference<drawing::XDrawPage> xPage1(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
455     uno::Reference<container::XNamed> xNamed1(xPage1, uno::UNO_QUERY_THROW);
456     CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xNamed1->getName());
457 
458     xDocShRef->DoClose();
459 }
460 
testTdf142915()461 void SdImportTest::testTdf142915()
462 {
463     ::sd::DrawDocShellRef xDocShRef
464         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf142915.pptx"), PPTX);
465 
466     uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(
467         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
468     uno::Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(),
469                                                            uno::UNO_QUERY_THROW);
470 
471     bool bChangeManually = xPresentationProps->getPropertyValue("IsAutomatic").get<bool>();
472 
473     CPPUNIT_ASSERT_EQUAL(true, bChangeManually);
474 
475     xDocShRef->DoClose();
476 }
477 
testTdf142913()478 void SdImportTest::testTdf142913()
479 {
480     ::sd::DrawDocShellRef xDocShRef
481         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf142913.pptx"), PPTX);
482 
483     uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(
484         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
485     uno::Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(),
486         uno::UNO_QUERY_THROW);
487 
488     OUString sFirstPage = xPresentationProps->getPropertyValue("FirstPage").get<OUString>();
489 
490     CPPUNIT_ASSERT_EQUAL(OUString("Second"), sFirstPage);
491 
492     xDocShRef->DoClose();
493 }
494 
testTdf142590()495 void SdImportTest::testTdf142590()
496 {
497     ::sd::DrawDocShellRef xDocShRef
498         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf142590.pptx"), PPTX);
499 
500     uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(
501         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
502     uno::Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(),
503                                                            uno::UNO_QUERY_THROW);
504     const OUString sCustomShowId
505         = xPresentationProps->getPropertyValue("CustomShow").get<OUString>();
506 
507     CPPUNIT_ASSERT(!sCustomShowId.isEmpty());
508 
509     xDocShRef->DoClose();
510 }
511 
testCustomSlideShow()512 void SdImportTest::testCustomSlideShow()
513 {
514     ::sd::DrawDocShellRef xDocShRef
515         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf131390.pptx"), PPTX);
516 
517     css::uno::Reference<css::presentation::XCustomPresentationSupplier> aXCPSup(
518         xDocShRef->GetModel(), css::uno::UNO_QUERY);
519     css::uno::Reference<css::container::XNameContainer> aXCont(aXCPSup->getCustomPresentations());
520     const css::uno::Sequence< OUString> aNameSeq( aXCont->getElementNames() );
521 
522     // In the document, there are two custom presentations.
523     CPPUNIT_ASSERT_EQUAL(sal_uInt32(2), aNameSeq.size());
524 
525     xDocShRef->DoClose();
526 }
527 
testInternalHyperlink()528 void SdImportTest::testInternalHyperlink()
529 {
530     ::sd::DrawDocShellRef xDocShRef
531         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf65724.pptx"), PPTX);
532 
533     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 1, 0, xDocShRef ) );
534 
535     // Get first paragraph
536     uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
537 
538     // first chunk of text
539     uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) );
540     uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
541 
542     uno::Reference<text::XTextField> xField;
543     xPropSet->getPropertyValue("TextField") >>= xField;
544     CPPUNIT_ASSERT_MESSAGE("The text field is missing!", xField.is() );
545 
546     xPropSet.set(xField, uno::UNO_QUERY);
547     OUString aURL;
548     xPropSet->getPropertyValue("URL") >>= aURL;
549     CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("#Slide2"), aURL);
550 
551     xDocShRef->DoClose();
552 }
553 
testHyperlinkColor()554 void SdImportTest::testHyperlinkColor()
555 {
556     ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf137367.pptx"), PPTX);
557 
558     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
559 
560     // Get first paragraph of the text
561     uno::Reference<text::XTextRange> const xParagraph1( getParagraphFromShape( 0, xShape ) );
562     // Get second paragraph of the text
563     uno::Reference<text::XTextRange> const xParagraph2( getParagraphFromShape( 1, xShape ) );
564     // Get third paragraph of the text
565     uno::Reference<text::XTextRange> const xParagraph3( getParagraphFromShape( 2, xShape ) );
566 
567     // Get run of the first paragraph
568     uno::Reference<text::XTextRange> xRun1( getRunFromParagraph (0, xParagraph1 ) );
569     uno::Reference< beans::XPropertySet > xPropSet1( xRun1, uno::UNO_QUERY_THROW );
570     Color nCharColorBlue;
571     xPropSet1->getPropertyValue( "CharColor" ) >>= nCharColorBlue;
572 
573     // Get run of the second paragraph
574     uno::Reference<text::XTextRange> xRun2( getRunFromParagraph (1, xParagraph2 ) );
575     uno::Reference< beans::XPropertySet > xPropSet2( xRun2, uno::UNO_QUERY_THROW );
576     Color nCharColorRed;
577     xPropSet2->getPropertyValue( "CharColor" ) >>= nCharColorRed;
578 
579     // Get run of the third paragraph
580     uno::Reference<text::XTextRange> xRun3( getRunFromParagraph (2, xParagraph3 ) );
581     uno::Reference< beans::XPropertySet > xPropSet3( xRun3, uno::UNO_QUERY_THROW );
582     Color nCharColorGreen;
583     xPropSet3->getPropertyValue( "CharColor" ) >>= nCharColorGreen;
584 
585     // Hyperlink colors should be blue, red, green.
586     CPPUNIT_ASSERT_EQUAL( Color(0x4472c4), nCharColorBlue );
587     CPPUNIT_ASSERT_EQUAL( Color(0xff0000), nCharColorRed );
588     CPPUNIT_ASSERT_EQUAL( Color(0x548235), nCharColorGreen );
589 
590     xDocShRef->DoClose();
591 }
592 
testSmoketest()593 void SdImportTest::testSmoketest()
594 {
595     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/smoketest.pptx"), PPTX);
596 
597     SdDrawDocument *pDoc = xDocShRef->GetDoc();
598     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
599 
600     // cf. SdrModel svx/svdmodel.hxx ...
601 
602     CPPUNIT_ASSERT_EQUAL_MESSAGE( "wrong page count", static_cast<sal_uInt16>(3), pDoc->GetPageCount());
603 
604     const SdrPage *pPage = pDoc->GetPage (1);
605     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
606 
607     CPPUNIT_ASSERT_MESSAGE( "changed", !pDoc->IsChanged() );
608 
609     xDocShRef->DoClose();
610 }
611 
testTdf131269()612 void SdImportTest::testTdf131269()
613 {
614     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/tdf131269.ppt"), PPT);
615 
616     SdDrawDocument *pDoc = xDocShRef->GetDoc();
617     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
618 
619     // Without the fix in place, this test would have failed with
620     // - Expected: 115
621     // - Actual  : 3
622     CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(115), pDoc->GetPageCount());
623 
624     xDocShRef->DoClose();
625 }
626 
testN759180()627 void SdImportTest::testN759180()
628 {
629     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/n759180.pptx"), PPTX);
630 
631     const SdrPage *pPage = GetPage( 1, xDocShRef );
632 
633     // Get the object
634     SdrObject *pObj = pPage->GetObj(0);
635     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
636     CPPUNIT_ASSERT(pTxtObj);
637     std::vector<EECharAttrib> rLst;
638     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
639     const SvxULSpaceItem *pULSpace = aEdit.GetParaAttribs(0).GetItem(EE_PARA_ULSPACE);
640     CPPUNIT_ASSERT(pULSpace);
641     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Para bottom spacing is wrong!", static_cast<sal_uInt16>(0), pULSpace->GetLower());
642     aEdit.GetCharAttribs(1, rLst);
643     auto it = std::find_if(rLst.rbegin(), rLst.rend(),
644         [](const EECharAttrib& rCharAttr) { return dynamic_cast<const SvxFontHeightItem *>(rCharAttr.pAttr) != nullptr; });
645     if (it != rLst.rend())
646     {
647         const SvxFontHeightItem * pFontHeight = dynamic_cast<const SvxFontHeightItem *>((*it).pAttr);
648         // nStart == 9
649         // font height = 5 => 5*2540/72
650         CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font height is wrong", static_cast<sal_uInt32>(176), pFontHeight->GetHeight() );
651     }
652 
653     xDocShRef->DoClose();
654 }
655 
testN862510_1()656 void SdImportTest::testN862510_1()
657 {
658     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/n862510_1.pptx"), PPTX );
659 
660     const SdrPage *pPage = GetPage( 1, xDocShRef );
661     {
662         std::vector<EECharAttrib> rLst;
663         SdrObject *pObj = pPage->GetObj( 0 );
664         SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
665         CPPUNIT_ASSERT( pTxtObj );
666         const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
667         aEdit.GetCharAttribs( 0, rLst );
668         for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
669         {
670             const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>( (*it).pAttr );
671             CPPUNIT_ASSERT_MESSAGE( "Baseline attribute not handled properly", !(pFontEscapement && pFontEscapement->GetProportionalHeight() != 100) );
672         }
673     }
674 
675     xDocShRef->DoClose();
676 }
677 
testN862510_2()678 void SdImportTest::testN862510_2()
679 {
680     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/n862510_2.pptx"), PPTX );
681 
682     const SdrPage *pPage = GetPage( 1, xDocShRef );
683     {
684         CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
685         SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 0 ) );
686         CPPUNIT_ASSERT( pGrpObj );
687         SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( pGrpObj->GetSubList()->GetObj( 1 ) );
688         CPPUNIT_ASSERT( pObj );
689         CPPUNIT_ASSERT_EQUAL_MESSAGE( "Wrong Text Rotation!", 90.0, pObj->GetExtraTextRotation( true ) );
690     }
691 
692     xDocShRef->DoClose();
693 }
694 
testN862510_4()695 void SdImportTest::testN862510_4()
696 {
697     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/n862510_4.pptx"), PPTX );
698 
699     const SdrPage *pPage = GetPage( 1, xDocShRef );
700     {
701         std::vector<EECharAttrib> rLst;
702         SdrObject *pObj = pPage->GetObj( 0 );
703         SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
704         CPPUNIT_ASSERT( pTxtObj );
705         const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
706         aEdit.GetCharAttribs( 0, rLst );
707         for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it != rLst.rend(); ++it )
708         {
709             const SvxColorItem *pC = dynamic_cast<const SvxColorItem *>( (*it).pAttr );
710             CPPUNIT_ASSERT_MESSAGE( "gradfill for text color not handled!", !( pC && pC->GetValue() == Color(0) ) );
711         }
712     }
713 
714     xDocShRef->DoClose();
715 }
716 
testN828390_2()717 void SdImportTest::testN828390_2()
718 {
719     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/n828390_2.pptx"), PPTX );
720     const SdrPage *pPage = GetPage( 1, xDocShRef );
721 
722     SdrObject *pObj = pPage->GetObj(0);
723     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
724     CPPUNIT_ASSERT( pTxtObj );
725     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
726     CPPUNIT_ASSERT_EQUAL(OUString("Linux  "), aEdit.GetText(0));
727     CPPUNIT_ASSERT_EQUAL(OUString("Standard Platform"), aEdit.GetText(1));
728 
729     xDocShRef->DoClose();
730 }
731 
testN828390_3()732 void SdImportTest::testN828390_3()
733 {
734     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/n828390_3.pptx"), PPTX );
735     const SdrPage *pPage = GetPage( 1, xDocShRef );
736 
737     SdrObject *pObj = pPage->GetObj(0);
738     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
739     CPPUNIT_ASSERT( pTxtObj );
740     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
741     std::vector<EECharAttrib> rLst;
742     aEdit.GetCharAttribs(1, rLst);
743     bool bPassed = std::none_of(rLst.rbegin(), rLst.rend(),
744         [](const EECharAttrib& rCharAttr) {
745             const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>(rCharAttr.pAttr);
746             return pFontEscapement && (pFontEscapement->GetEsc() != 0);
747         });
748     CPPUNIT_ASSERT_MESSAGE("CharEscapment not imported properly", bPassed);
749 
750     xDocShRef->DoClose();
751 }
752 
testMasterPageStyleParent()753 void SdImportTest::testMasterPageStyleParent()
754 {
755     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/masterpage_style_parent.odp"), ODP );
756     SdDrawDocument *pDoc = xDocShRef->GetDoc();
757     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
758 
759     SdStyleSheetPool *const pPool(pDoc->GetSdStyleSheetPool());
760 
761     int parents(0);
762     SfxStyleSheetIterator iter(pPool, SfxStyleFamily::Page);
763     for (SfxStyleSheetBase * pStyle = iter.First(); pStyle; pStyle = iter.Next())
764     {
765         OUString const name(pStyle->GetName());
766         OUString const parent(pStyle->GetParent());
767         if (!parent.isEmpty())
768         {
769             ++parents;
770             // check that parent exists
771             SfxStyleSheetBase *const pParentStyle(
772                     pPool->Find(parent, SfxStyleFamily::Page));
773             CPPUNIT_ASSERT(pParentStyle);
774             CPPUNIT_ASSERT_EQUAL(pParentStyle->GetName(), parent);
775             // check that parent has the same master page as pStyle
776             CPPUNIT_ASSERT(parent.indexOf(SD_LT_SEPARATOR) != -1);
777             CPPUNIT_ASSERT(name.indexOf(SD_LT_SEPARATOR) != -1);
778             CPPUNIT_ASSERT_EQUAL(
779                     parent.copy(0, parent.indexOf(SD_LT_SEPARATOR)),
780                     name.copy(0, name.indexOf(SD_LT_SEPARATOR)));
781         }
782     }
783     // check that there are actually parents...
784     CPPUNIT_ASSERT_EQUAL(16, parents);
785 
786     xDocShRef->DoClose();
787 }
788 
testGradientAngle()789 void SdImportTest::testGradientAngle()
790 {
791     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odg/gradient-angle.fodg"), FODG);
792 
793     uno::Reference<lang::XMultiServiceFactory> const xDoc(
794         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
795 
796     awt::Gradient gradient;
797     uno::Reference<container::XNameAccess> const xGradients(
798         xDoc->createInstance("com.sun.star.drawing.GradientTable"),
799         uno::UNO_QUERY);
800 
801     CPPUNIT_ASSERT(xGradients->getByName("Gradient 38") >>= gradient);
802     CPPUNIT_ASSERT_EQUAL(sal_Int16(0), gradient.Angle); // was: 3600
803 
804     CPPUNIT_ASSERT(xGradients->getByName("Gradient 10") >>= gradient);
805     CPPUNIT_ASSERT_EQUAL(sal_Int16(270), gradient.Angle); // 27deg
806 
807     CPPUNIT_ASSERT(xGradients->getByName("Gradient 11") >>= gradient);
808     CPPUNIT_ASSERT_EQUAL(sal_Int16(1145), gradient.Angle); // 2rad
809 
810     CPPUNIT_ASSERT(xGradients->getByName("Gradient 12") >>= gradient);
811     CPPUNIT_ASSERT_EQUAL(sal_Int16(900), gradient.Angle); // 100grad
812 
813     CPPUNIT_ASSERT(xGradients->getByName("Gradient 13") >>= gradient);
814     CPPUNIT_ASSERT_EQUAL(sal_Int16(3599), gradient.Angle); // -1
815 
816     CPPUNIT_ASSERT(xGradients->getByName("Gradient 14") >>= gradient);
817     CPPUNIT_ASSERT_EQUAL(sal_Int16(3028), gradient.Angle); // -1rad
818 
819     CPPUNIT_ASSERT(xGradients->getByName("Gradient 15") >>= gradient);
820     CPPUNIT_ASSERT_EQUAL(sal_Int16(300), gradient.Angle); // 3900
821 
822     CPPUNIT_ASSERT(xGradients->getByName("Gradient 16") >>= gradient);
823     CPPUNIT_ASSERT_EQUAL(sal_Int16(105), gradient.Angle); // 10.5deg
824 
825     CPPUNIT_ASSERT(xGradients->getByName("Gradient 17") >>= gradient);
826     CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), gradient.Angle); // \pi rad
827 
828     uno::Reference<container::XNameAccess> const xTranspGradients(
829         xDoc->createInstance("com.sun.star.drawing.TransparencyGradientTable"),
830         uno::UNO_QUERY);
831 
832     CPPUNIT_ASSERT(xTranspGradients->getByName("Transparency 2") >>= gradient);
833     CPPUNIT_ASSERT_EQUAL(sal_Int16(10), gradient.Angle); // 1
834 
835     CPPUNIT_ASSERT(xTranspGradients->getByName("Transparency 1") >>= gradient);
836     CPPUNIT_ASSERT_EQUAL(sal_Int16(900), gradient.Angle); // 90deg
837 
838     CPPUNIT_ASSERT(xTranspGradients->getByName("Transparency 3") >>= gradient);
839     CPPUNIT_ASSERT_EQUAL(sal_Int16(572), gradient.Angle); // 1.0rad
840 
841     CPPUNIT_ASSERT(xTranspGradients->getByName("Transparency 4") >>= gradient);
842     CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), gradient.Angle); // 1000grad
843 
844     xDocShRef->DoClose();
845 }
846 
testN778859()847 void SdImportTest::testN778859()
848 {
849     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/n778859.pptx"), PPTX);
850 
851     const SdrPage *pPage = GetPage( 1, xDocShRef );
852     {
853         // Get the object
854         SdrObject *pObj = pPage->GetObj(1);
855         SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
856         CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
857         CPPUNIT_ASSERT(!pTxtObj->IsAutoFit());
858     }
859 
860     xDocShRef->DoClose();
861 }
862 
testFdo68594()863 void SdImportTest::testFdo68594()
864 {
865     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/ppt/fdo68594.ppt"), PPT);
866 
867     const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
868     SdrObject *pObj = pPage->GetObj(1);
869     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
870     CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
871     const SvxColorItem *pC = &pTxtObj->GetMergedItem(EE_CHAR_COLOR);
872     CPPUNIT_ASSERT_MESSAGE( "no color item", pC != nullptr);
873     // Color should be black
874     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Placeholder color mismatch", COL_BLACK, pC->GetValue() );
875 
876     xDocShRef->DoClose();
877 }
878 
testPlaceholderPriority()879 void SdImportTest::testPlaceholderPriority()
880 {
881     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/ppt/placeholder-priority.pptx"), PPTX);
882 
883     const SdrPage* pPage = GetPage( 1, xDocShRef );
884     CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing placeholder", sal_uInt32(2), sal_uInt32(pPage->GetObjCount()));
885 
886     tools::Rectangle pObj1Rect(9100, 3500, 29619, 4038);
887     SdrObject *pObj1 = pPage->GetObj(0);
888     CPPUNIT_ASSERT_EQUAL_MESSAGE("Placeholder position is wrong, check the placeholder priority", pObj1Rect, pObj1->GetCurrentBoundRect());
889 
890     tools::Rectangle pObj2Rect(9102, 8643, 29619, 12642);
891     SdrObject *pObj2 = pPage->GetObj(1);
892     CPPUNIT_ASSERT_EQUAL_MESSAGE("Placeholder position is wrong, check the placeholder priority", pObj2Rect, pObj2->GetCurrentBoundRect());
893 
894     // If the placeholder positions are wrong, please check placeholder priority in Placeholders class.
895 }
896 
testPptCrop()897 void SdImportTest::testPptCrop()
898 {
899     sd::DrawDocShellRef xDocShRef
900         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/ppt/crop.ppt"), PPT);
901 
902     uno::Reference<beans::XPropertySet> xPropertySet(
903         getShapeFromPage(/*nShape=*/1, /*nPage=*/0, xDocShRef));
904     text::GraphicCrop aCrop;
905     xPropertySet->getPropertyValue("GraphicCrop") >>= aCrop;
906     // These were all 0, lazy-loading broke cropping.
907     CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Top);
908     CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Bottom);
909     CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Left);
910     CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Right);
911 
912     xDocShRef->DoClose();
913 }
914 
testFdo72998()915 void SdImportTest::testFdo72998()
916 {
917     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/cshapes.pptx"), PPTX);
918 
919     const SdrPage *pPage = GetPage( 1, xDocShRef );
920     {
921         SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>(pPage->GetObj(2));
922         CPPUNIT_ASSERT( pObj );
923         const SdrCustomShapeGeometryItem& rGeometryItem = pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
924         const css::uno::Any* pViewBox = const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( OUString( "ViewBox" ) );
925         CPPUNIT_ASSERT_MESSAGE( "Missing ViewBox", pViewBox );
926         css::awt::Rectangle aViewBox;
927         CPPUNIT_ASSERT( (*pViewBox >>= aViewBox ) );
928         CPPUNIT_ASSERT_MESSAGE( "Width should be zero - for forcing scale to 1", !aViewBox.Width );
929         CPPUNIT_ASSERT_MESSAGE( "Height should be zero - for forcing scale to 1", !aViewBox.Height );
930     }
931 
932     xDocShRef->DoClose();
933 }
934 
testFdo77027()935 void SdImportTest::testFdo77027()
936 {
937     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/fdo77027.odp"), ODP);
938 
939     const SdrPage *pPage = GetPage( 1, xDocShRef );
940     {
941         SdrOle2Obj *const pObj = dynamic_cast<SdrOle2Obj*>(pPage->GetObj(0));
942         CPPUNIT_ASSERT(pObj);
943 
944         // check that the fill style/color was actually imported
945         const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
946                 pObj->GetMergedItem(XATTR_FILLSTYLE));
947         CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
948         const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
949                 pObj->GetMergedItem(XATTR_FILLCOLOR));
950         CPPUNIT_ASSERT_EQUAL(Color(0xff6600), rColorItem.GetColorValue());
951     }
952 
953     xDocShRef->DoClose();
954 }
955 
testTdf97808()956 void SdImportTest::testTdf97808()
957 {
958     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/tdf97808.fodp"), FODP);
959 
960     uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(
961         xDocShRef->GetModel(), uno::UNO_QUERY);
962     uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
963     uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("graphics"), uno::UNO_QUERY);
964     uno::Reference<beans::XPropertySet> xStyle(xStyleFamily->getByName("objectwithoutfill"), uno::UNO_QUERY);
965     OUString lineend;
966     CPPUNIT_ASSERT(xStyle->getPropertyValue("LineEndName") >>= lineend);
967     CPPUNIT_ASSERT_EQUAL(OUString("Arrow"), lineend);
968 
969     // the draw:marker-end="" did not override the style
970     uno::Reference<drawing::XDrawPagesSupplier> xDoc(
971         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
972     uno::Reference<drawing::XDrawPage> xPage(
973         xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
974     uno::Reference<beans::XPropertySet> xLine(
975         xPage->getByIndex(0), uno::UNO_QUERY_THROW);
976     //uno::Reference<style::XStyle> xParent;
977     uno::Reference<beans::XPropertySet> xParent;
978     CPPUNIT_ASSERT(xLine->getPropertyValue("Style") >>= xParent);
979     CPPUNIT_ASSERT_EQUAL(xStyle, xParent);
980     CPPUNIT_ASSERT(xLine->getPropertyValue("LineEndName") >>= lineend);
981     CPPUNIT_ASSERT_EQUAL(OUString(), lineend);
982 
983     xDocShRef->DoClose();
984 }
testFillStyleNone()985 void SdImportTest::testFillStyleNone()
986 {
987     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/tdf123841.odg"), ODG);
988 
989     const SdrPage* pPage = GetPage(1, xDocShRef);
990     const SdrObject* pObj = pPage->GetObj(0);
991     auto& rFillStyleItem
992         = dynamic_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE));
993     // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual:
994     // 1', i.e. the shape's fill was FillStyle_SOLID, making the text of the shape unreadable.
995     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, rFillStyleItem.GetValue());
996     xDocShRef->DoClose();
997 }
998 
testFdo64512()999 void SdImportTest::testFdo64512()
1000 {
1001     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/fdo64512.odp"), ODP);
1002 
1003     uno::Reference< drawing::XDrawPagesSupplier > xDoc(
1004         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
1005     CPPUNIT_ASSERT_EQUAL_MESSAGE( "not exactly one page", static_cast<sal_Int32>(1), xDoc->getDrawPages()->getCount() );
1006 
1007     uno::Reference< drawing::XDrawPage > xPage(
1008         xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
1009     CPPUNIT_ASSERT_EQUAL_MESSAGE( "not exactly three shapes", static_cast<sal_Int32>(3), xPage->getCount() );
1010 
1011     uno::Reference< beans::XPropertySet > xConnectorShape(
1012         xPage->getByIndex(2), uno::UNO_QUERY );
1013     CPPUNIT_ASSERT_MESSAGE( "no connector shape", xConnectorShape.is() );
1014 
1015     uno::Reference< beans::XPropertySet > xSvgShape(
1016         xConnectorShape->getPropertyValue("StartShape"), uno::UNO_QUERY );
1017     CPPUNIT_ASSERT_MESSAGE( "no start shape", xSvgShape.is() );
1018 
1019     uno::Reference< beans::XPropertySet > xCustomShape(
1020         xConnectorShape->getPropertyValue("EndShape"), uno::UNO_QUERY );
1021     CPPUNIT_ASSERT_MESSAGE( "no end shape", xCustomShape.is() );
1022 
1023     uno::Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier(
1024         xPage, uno::UNO_QUERY_THROW );
1025     uno::Reference< animations::XAnimationNode > xRootNode(
1026         xAnimNodeSupplier->getAnimationNode() );
1027     std::vector< uno::Reference< animations::XAnimationNode > > aAnimVector;
1028     anim::create_deep_vector(xRootNode, aAnimVector);
1029     CPPUNIT_ASSERT_EQUAL_MESSAGE( "not 8 animation nodes", static_cast<std::size_t>(8), aAnimVector.size() );
1030 
1031     uno::Reference< animations::XAnimate > xNode(
1032         aAnimVector[7], uno::UNO_QUERY_THROW );
1033     uno::Reference< drawing::XShape > xTargetShape(
1034         xNode->getTarget(), uno::UNO_QUERY_THROW );
1035     CPPUNIT_ASSERT_MESSAGE( "inner node not referencing svg shape",
1036                             xTargetShape != xSvgShape );
1037 
1038     xDocShRef->DoClose();
1039 }
1040 
1041 // Unit test for importing charts
testFdo71075()1042 void SdImportTest::testFdo71075()
1043 {
1044     double values[] = { 12.0, 13.0, 14.0 };
1045     css::uno::Any aAny;
1046     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/fdo71075.odp"), ODP);
1047 
1048     uno::Reference< beans::XPropertySet > xPropSet( getShapeFromPage( 0, 0, xDocShRef ) );
1049     aAny = xPropSet->getPropertyValue( "Model" );
1050     CPPUNIT_ASSERT_MESSAGE( "The shape doesn't have the property", aAny.hasValue() );
1051 
1052     uno::Reference< chart::XChartDocument > xChartDoc;
1053     aAny >>= xChartDoc;
1054     CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc.is() );
1055     uno::Reference< chart2::XChartDocument > xChart2Doc( xChartDoc, uno::UNO_QUERY );
1056     CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc.is() );
1057 
1058     uno::Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xChart2Doc->getFirstDiagram(), uno::UNO_QUERY );
1059     uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
1060     uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[0], uno::UNO_QUERY );
1061 
1062     uno::Reference< chart2::XDataSeriesContainer > xDSCnt( xCTCnt->getChartTypes()[0], uno::UNO_QUERY );
1063     CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt.is() );
1064     uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
1065     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32>(1), aSeriesSeq.getLength() );
1066     uno::Reference< chart2::data::XDataSource > xSource( aSeriesSeq[0], uno::UNO_QUERY );
1067     uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(xSource->getDataSequences());
1068     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32>(1), aSeqCnt.getLength());
1069     uno::Reference< chart2::data::XDataSequence > xValueSeq( aSeqCnt[0]->getValues() );
1070     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Data count", static_cast<sal_Int32>(SAL_N_ELEMENTS(values)), xValueSeq->getData().getLength());
1071     uno::Reference< chart2::data::XNumericalDataSequence > xNumSeq( xValueSeq, uno::UNO_QUERY );
1072     uno::Sequence< double > aValues( xNumSeq->getNumericalData());
1073     for(sal_Int32 i=0;i<xValueSeq->getData().getLength();i++)
1074         CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", values[i], aValues.getConstArray()[i]);
1075 
1076     xDocShRef->DoClose();
1077 }
1078 
testStrictOOXML()1079 void SdImportTest::testStrictOOXML()
1080 {
1081     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/strict_ooxml.pptx"), PPTX);
1082 
1083     SdDrawDocument *pDoc = xDocShRef->GetDoc();
1084     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
1085     getShapeFromPage( 0, 0, xDocShRef );
1086 
1087     xDocShRef->DoClose();
1088 }
1089 
testBnc870237()1090 void SdImportTest::testBnc870237()
1091 {
1092     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/bnc870237.pptx"), PPTX);
1093     const SdrPage *pPage = GetPage( 1, xDocShRef );
1094 
1095     // Simulate a:ext inside dsp:txXfrm with changing the lower distance
1096     const SdrObjGroup* pGroupObj = dynamic_cast<SdrObjGroup*>( pPage->GetObj( 0 ) );
1097     const SdrObject* pObj = pGroupObj->GetSubList()->GetObj( 1 );
1098     CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
1099     CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST).GetValue());
1100     CPPUNIT_ASSERT_EQUAL( sal_Int32(9919), pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST).GetValue());
1101     CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_RIGHTDIST).GetValue());
1102     CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_LEFTDIST).GetValue());
1103 
1104     xDocShRef->DoClose();
1105 }
1106 
testCreationDate()1107 void SdImportTest::testCreationDate()
1108 {
1109     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/fdo71434.pptx"), PPTX);
1110     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
1111     uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
1112     util::DateTime aDate = xDocumentProperties->getCreationDate();
1113     OUStringBuffer aBuffer;
1114     sax::Converter::convertDateTime(aBuffer, aDate, nullptr);
1115     // Metadata wasn't imported, this was 0000-00-00.
1116     CPPUNIT_ASSERT_EQUAL(OUString("2013-11-09T10:37:56"), aBuffer.makeStringAndClear());
1117     xDocShRef->DoClose();
1118 }
1119 
testMultiColTexts()1120 void SdImportTest::testMultiColTexts()
1121 {
1122     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/multicol.pptx"), PPTX );
1123     const SdrPage *pPage = GetPage( 1, xDocShRef );
1124 
1125     auto pTextObj = dynamic_cast<SdrTextObj*>(pPage->GetObj(0));
1126     CPPUNIT_ASSERT(pTextObj);
1127 
1128     CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pTextObj->GetTextColumnsNumber());
1129     CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), pTextObj->GetTextColumnsSpacing());
1130 
1131     auto pMasterTextObj = dynamic_cast<SdrTextObj*>(pPage->TRG_GetMasterPage().GetObj(0));
1132     CPPUNIT_ASSERT(pMasterTextObj);
1133 
1134     CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pMasterTextObj->GetTextColumnsNumber());
1135     CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), pMasterTextObj->GetTextColumnsSpacing());
1136 
1137     uno::Reference<text::XTextRange> xText(pMasterTextObj->getUnoShape(), uno::UNO_QUERY_THROW);
1138     CPPUNIT_ASSERT_EQUAL(OUString("mastershape1\nmastershape2"), xText->getString());
1139 }
1140 
testPredefinedTableStyle()1141 void SdImportTest::testPredefinedTableStyle()
1142 {
1143     // 073A0DAA-6AF3-43AB-8588-CEC1D06C72B9 (Medium Style 2)
1144     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/predefined-table-style.pptx"), PPTX );
1145     const SdrPage *pPage = GetPage( 1, xDocShRef );
1146 
1147     sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1148     CPPUNIT_ASSERT( pTableObj );
1149 
1150     uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
1151     uno::Reference< beans::XPropertySet > xCell;
1152     Color nColor;
1153 
1154     xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
1155     xCell->getPropertyValue("FillColor") >>= nColor;
1156     CPPUNIT_ASSERT_EQUAL(COL_BLACK, nColor);
1157 
1158     xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
1159     xCell->getPropertyValue("FillColor") >>= nColor;
1160     CPPUNIT_ASSERT_EQUAL(Color(0xcccccc), nColor);
1161 
1162     xCell.set(xTable->getCellByPosition(0, 2), uno::UNO_QUERY_THROW);
1163     xCell->getPropertyValue("FillColor") >>= nColor;
1164     CPPUNIT_ASSERT_EQUAL(Color(0xe7e7e7), nColor);
1165 
1166     xDocShRef->DoClose();
1167 }
1168 
testBnc887225()1169 void SdImportTest::testBnc887225()
1170 {
1171     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/bnc887225.pptx"), PPTX );
1172     // In the document, lastRow and lastCol table properties are used.
1173     // Make sure styles are set properly for individual cells.
1174 
1175     const SdrPage *pPage = GetPage( 1, xDocShRef );
1176 
1177     sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(2));
1178     CPPUNIT_ASSERT( pTableObj );
1179     uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
1180     uno::Reference< beans::XPropertySet > xCell;
1181     Color nColor;
1182 
1183     xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
1184     xCell->getPropertyValue("FillColor") >>= nColor;
1185     CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nColor);
1186 
1187     xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
1188     xCell->getPropertyValue("FillColor") >>= nColor;
1189     CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nColor);
1190 
1191     xCell.set(xTable->getCellByPosition(1, 1), uno::UNO_QUERY_THROW);
1192     xCell->getPropertyValue("FillColor") >>= nColor;
1193     CPPUNIT_ASSERT_EQUAL(Color(0xd1deef), nColor);
1194 
1195     xCell.set(xTable->getCellByPosition(1, 2), uno::UNO_QUERY_THROW);
1196     xCell->getPropertyValue("FillColor") >>= nColor;
1197     CPPUNIT_ASSERT_EQUAL(Color(0xe9eff7), nColor);
1198 
1199     xCell.set(xTable->getCellByPosition(1, 4), uno::UNO_QUERY_THROW);
1200     xCell->getPropertyValue("FillColor") >>= nColor;
1201     CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nColor);
1202 
1203     xCell.set(xTable->getCellByPosition(3, 2), uno::UNO_QUERY_THROW);
1204     xCell->getPropertyValue("FillColor") >>= nColor;
1205     CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nColor);
1206 
1207     xCell.set(xTable->getCellByPosition(3, 4), uno::UNO_QUERY_THROW);
1208     xCell->getPropertyValue("FillColor") >>= nColor;
1209     CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nColor);
1210 
1211     xDocShRef->DoClose();
1212 }
1213 
testBnc584721_1()1214 void SdImportTest::testBnc584721_1()
1215 {
1216     // Title text shape on the master page contained wrong text.
1217 
1218     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX);
1219 
1220     const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
1221     SdrObject *pObj = pPage->GetObj(0);
1222     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
1223     CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
1224     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
1225     CPPUNIT_ASSERT_EQUAL(OUString("Click to edit Master title style"), aEdit.GetText(0));
1226     xDocShRef->DoClose();
1227 }
1228 
testBnc584721_2()1229 void SdImportTest::testBnc584721_2()
1230 {
1231     // Import created an extra/unneeded outliner shape on the master slide next to the imported title shape.
1232 
1233     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX);
1234 
1235     const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
1236     CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
1237 
1238     xDocShRef->DoClose();
1239 }
1240 
testBnc591147()1241 void SdImportTest::testBnc591147()
1242 {
1243     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/bnc591147.pptx"), PPTX);
1244 
1245     // In the document, there are two slides with media files.
1246     uno::Reference< drawing::XDrawPagesSupplier > xDoc(
1247         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
1248     CPPUNIT_ASSERT_EQUAL( sal_Int32(2), xDoc->getDrawPages()->getCount() );
1249 
1250     // First page has video file inserted
1251     uno::Reference< drawing::XDrawPage > xPage(
1252         xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
1253     CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage->getCount() );
1254 
1255     //uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
1256     uno::Reference< beans::XPropertySet > xPropSet( getShape( 0, xPage ) );
1257     OUString sVideoURL("emptyURL");
1258     bool bSuccess = xPropSet->getPropertyValue("MediaURL") >>= sVideoURL;
1259     CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSuccess );
1260     CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sVideoURL.isEmpty());
1261 
1262     // Second page has audio file inserted
1263     xPage.set( xDoc->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
1264     CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage->getCount() );
1265 
1266     xPropSet.set( getShape( 0, xPage ) );
1267     OUString sAudioURL("emptyURL");
1268     bSuccess = xPropSet->getPropertyValue("MediaURL") >>= sAudioURL;
1269     CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSuccess );
1270     CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sAudioURL.isEmpty());
1271 
1272     CPPUNIT_ASSERT_MESSAGE( "sAudioURL and sVideoURL should not be equal", sAudioURL != sVideoURL );
1273 
1274     xDocShRef->DoClose();
1275 }
1276 
testBnc584721_4()1277 void SdImportTest::testBnc584721_4()
1278 {
1279     // Black text was imported as white because of wrong caching mechanism
1280 
1281     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/bnc584721_4.pptx"), PPTX);
1282     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 1, 1, xDocShRef ) );
1283 
1284     // Get first paragraph of the text
1285     uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
1286 
1287     // Get first run of the paragraph
1288     uno::Reference<text::XTextRange> xRun( getRunFromParagraph (0, xParagraph ) );
1289     uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
1290     Color nCharColor;
1291     xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
1292 
1293     // Color should be black
1294     CPPUNIT_ASSERT_EQUAL( COL_BLACK, nCharColor );
1295 
1296     xDocShRef->DoClose();
1297 }
1298 
testBnc904423()1299 void SdImportTest::testBnc904423()
1300 {
1301     // Here the problem was that different fill properties were applied in wrong order on the shape
1302     // Right order: 1) master slide fill style, 2) theme, 3) direct formatting
1303     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/bnc904423.pptx"), PPTX);
1304 
1305     const SdrPage *pPage = GetPage( 1, xDocShRef );
1306     // First shape's background color is defined on master slide
1307     {
1308         SdrObject *const pObj = pPage->GetObj(0);
1309         CPPUNIT_ASSERT(pObj);
1310 
1311         const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1312                 pObj->GetMergedItem(XATTR_FILLSTYLE));
1313         CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1314         const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1315                 pObj->GetMergedItem(XATTR_FILLCOLOR));
1316         CPPUNIT_ASSERT_EQUAL(Color(0x00CC99), rColorItem.GetColorValue());
1317     }
1318 
1319     // Second shape's background color is defined by theme
1320     {
1321         SdrObject *const pObj = pPage->GetObj(1);
1322         CPPUNIT_ASSERT(pObj);
1323 
1324         const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1325                 pObj->GetMergedItem(XATTR_FILLSTYLE));
1326         CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1327         const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1328                 pObj->GetMergedItem(XATTR_FILLCOLOR));
1329         CPPUNIT_ASSERT_EQUAL(Color(0x3333CC), rColorItem.GetColorValue());
1330     }
1331 
1332     // Third shape's background color is defined by direct formatting
1333     {
1334         SdrObject *const pObj = pPage->GetObj(2);
1335         CPPUNIT_ASSERT(pObj);
1336 
1337         const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1338                 pObj->GetMergedItem(XATTR_FILLSTYLE));
1339         CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1340         const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1341                 pObj->GetMergedItem(XATTR_FILLCOLOR));
1342         CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), rColorItem.GetColorValue());
1343     }
1344 
1345     xDocShRef->DoClose();
1346 }
1347 
testShapeLineStyle()1348 void SdImportTest::testShapeLineStyle()
1349 {
1350     // Here the problem was that different line properties were applied in wrong order on the shape
1351     // Right order: 1) master slide line style, 2) theme, 3) direct formatting
1352     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/ShapeLineProperties.pptx"), PPTX);
1353 
1354     const SdrPage *pPage = GetPage( 1, xDocShRef );
1355     // First shape's line style is defined on master slide
1356     {
1357         SdrObject *const pObj = pPage->GetObj(0);
1358         CPPUNIT_ASSERT(pObj);
1359 
1360         const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
1361                 pObj->GetMergedItem(XATTR_LINESTYLE));
1362         CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_DASH, rStyleItem.GetValue());
1363 
1364         const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
1365                 pObj->GetMergedItem(XATTR_LINECOLOR));
1366         CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), rColorItem.GetColorValue());
1367 
1368         const XLineWidthItem& rWidthItem = dynamic_cast<const XLineWidthItem&>(
1369                 pObj->GetMergedItem(XATTR_LINEWIDTH));
1370         CPPUNIT_ASSERT_EQUAL(sal_Int32(132), rWidthItem.GetValue());
1371     }
1372 
1373     // Second shape's line style is defined by theme
1374     {
1375         SdrObject *const pObj = pPage->GetObj(1);
1376         CPPUNIT_ASSERT(pObj);
1377 
1378         const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
1379                 pObj->GetMergedItem(XATTR_LINESTYLE));
1380         CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID, rStyleItem.GetValue());
1381 
1382         const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
1383                 pObj->GetMergedItem(XATTR_LINECOLOR));
1384         CPPUNIT_ASSERT_EQUAL(Color(0x3333CC), rColorItem.GetColorValue());
1385 
1386         const XLineWidthItem& rWidthItem = dynamic_cast<const XLineWidthItem&>(
1387                 pObj->GetMergedItem(XATTR_LINEWIDTH));
1388         CPPUNIT_ASSERT_EQUAL(sal_Int32(35), rWidthItem.GetValue());
1389     }
1390 
1391     // Third shape's line style is defined by direct formatting
1392     {
1393         SdrObject *const pObj = pPage->GetObj(2);
1394         CPPUNIT_ASSERT(pObj);
1395 
1396         const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
1397                 pObj->GetMergedItem(XATTR_LINESTYLE));
1398         CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID, rStyleItem.GetValue());
1399 
1400         const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
1401                 pObj->GetMergedItem(XATTR_LINECOLOR));
1402         CPPUNIT_ASSERT_EQUAL(Color(0x7030A0), rColorItem.GetColorValue());
1403 
1404         const XLineWidthItem& rWidthItem = dynamic_cast<const XLineWidthItem&>(
1405                 pObj->GetMergedItem(XATTR_LINEWIDTH));
1406         CPPUNIT_ASSERT_EQUAL(sal_Int32(176), rWidthItem.GetValue());
1407     }
1408 
1409     xDocShRef->DoClose();
1410 }
1411 
testTableBorderLineStyle()1412 void SdImportTest::testTableBorderLineStyle()
1413 {
1414     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx"), PPTX );
1415 
1416     // TODO: If you are working on improvement of table border line style
1417     // support, then expect this unit test to fail.
1418 
1419     const sal_Int16 nObjBorderLineStyles[] =
1420         {
1421             ::table::BorderLineStyle::DASHED,
1422             ::table::BorderLineStyle::DASH_DOT_DOT,
1423             ::table::BorderLineStyle::DASH_DOT,
1424             ::table::BorderLineStyle::DOTTED,
1425             ::table::BorderLineStyle::DASHED,
1426             ::table::BorderLineStyle::DOTTED,
1427             ::table::BorderLineStyle::DASHED,
1428             ::table::BorderLineStyle::DASH_DOT,
1429             ::table::BorderLineStyle::DASH_DOT,
1430             ::table::BorderLineStyle::SOLID,
1431             ::table::BorderLineStyle::NONE
1432         };
1433 
1434     const SdrPage *pPage = GetPage( 1, xDocShRef );
1435     CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(nObjBorderLineStyles), pPage->GetObjCount());
1436 
1437     sdr::table::SdrTableObj *pTableObj;
1438     uno::Reference< table::XCellRange > xTable;
1439     uno::Reference< beans::XPropertySet > xCell;
1440     table::BorderLine2 aBorderLine;
1441 
1442     for (size_t i = 0; i < SAL_N_ELEMENTS(nObjBorderLineStyles); i++)
1443     {
1444         pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(i));
1445         CPPUNIT_ASSERT( pTableObj );
1446         xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
1447         xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
1448         xCell->getPropertyValue("TopBorder") >>= aBorderLine;
1449         if (aBorderLine.LineWidth > 0) {
1450             CPPUNIT_ASSERT_EQUAL(nObjBorderLineStyles[i], aBorderLine.LineStyle);
1451         }
1452     }
1453 
1454     xDocShRef->DoClose();
1455 }
1456 
testBnc862510_6()1457 void SdImportTest::testBnc862510_6()
1458 {
1459     // Black text was imported instead of gray
1460     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/bnc862510_6.pptx"), PPTX);
1461     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
1462 
1463     // Get first paragraph of the text
1464     uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
1465 
1466     // Get first run of the paragraph
1467     uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) );
1468     uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
1469     Color nCharColor;
1470     xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
1471 
1472     // Color should be gray
1473     CPPUNIT_ASSERT_EQUAL( Color(0x8B8B8B), nCharColor );
1474 
1475     xDocShRef->DoClose();
1476 }
1477 
testBnc862510_7()1478 void SdImportTest::testBnc862510_7()
1479 {
1480     // Title shape's text was aligned to left instead of center.
1481     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/bnc862510_7.pptx"), PPTX);
1482     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
1483 
1484     // Get first paragraph
1485     uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
1486     uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
1487 
1488     sal_Int16 nParaAdjust = 0;
1489     xPropSet->getPropertyValue( "ParaAdjust" ) >>= nParaAdjust;
1490     CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(nParaAdjust));
1491 
1492     xDocShRef->DoClose();
1493 }
1494 
1495 #if ENABLE_PDFIMPORT
1496 // These tests use the old PDF-importing logic, which imports PDF elements as
1497 // SD elements. This suffered many issues, and therefore wasn't ideal.
1498 // The old PDF importer relied on an open-source project (xpdf) with an
1499 // incompatible license (gpl), which has to be interfaced via an out-of-process
1500 // library wrapper process. The resulting imported document was inaccurate
1501 // and often very slow and with large memory footprint.
1502 // Instead, PDFium offers state-of-the-art PDF importing logic,
1503 // which is well-maintained and renders PDFs into images with high accuracy.
1504 // So, the idea is to import PDFs as images using PDFium, which has a very
1505 // high quality (and is much faster) than importing individual editable elements.
1506 // So that's the "new" way of importing.
1507 // The user then breaks the image to editable elements (which is not perfect,
1508 // but very close to the old way), only if they need editing ability.
1509 // PDFium should overall be better, and where it isn't, we just need to improve it.
1510 // So these tests aren't really useful anymore. They should be modified to do
1511 // import+break and then check the results. But that isn't straight-forward and
1512 // currently await volunteering time to implement.
1513 
testPDFImportShared()1514 void SdImportTest::testPDFImportShared()
1515 {
1516     auto pPdfium = vcl::pdf::PDFiumLibrary::get();
1517     if (!pPdfium)
1518     {
1519         return;
1520     }
1521 
1522     comphelper::LibreOfficeKit::setActive();
1523     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pdf/multipage.pdf"), PDF);
1524     SdDrawDocument *pDoc = xDocShRef->GetDoc();
1525     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
1526 
1527     // This test is to verify that we share the PDF stream linked to each
1528     // Graphic instance in the imported document.
1529     // Since we import PDFs as images, we support attaching the original
1530     // PDF with each image to allow for advanced editing.
1531     // Here we iterate over all Graphic instances embedded in the pages
1532     // and verify that they all point to the same object in memory.
1533     std::vector<Graphic> aGraphics;
1534 
1535     for (int nPageIndex = 0; nPageIndex < pDoc->GetPageCount(); ++nPageIndex)
1536     {
1537         const SdrPage* pPage = GetPage(nPageIndex, xDocShRef);
1538         if (pPage == nullptr)
1539             break;
1540 
1541         for (size_t nObjIndex = 0; nObjIndex < pPage->GetObjCount(); ++nObjIndex)
1542         {
1543             SdrObject* pObject = pPage->GetObj(nObjIndex);
1544             if (pObject == nullptr)
1545                 continue;
1546 
1547             SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(pObject);
1548             if (pSdrGrafObj == nullptr)
1549                 continue;
1550 
1551             const GraphicObject& rGraphicObject = pSdrGrafObj->GetGraphicObject().GetGraphic();
1552             const Graphic& rGraphic = rGraphicObject.GetGraphic();
1553             CPPUNIT_ASSERT_MESSAGE("After loading, the PDF shouldn't have the primitive sequence created yet",
1554                                    !rGraphic.getVectorGraphicData()->isPrimitiveSequenceCreated());
1555             aGraphics.push_back(rGraphic);
1556         }
1557     }
1558 
1559     CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected more than one page.", size_t(9), aGraphics.size());
1560 
1561     Graphic const & rFirstGraphic = aGraphics[0];
1562 
1563     for (size_t i = 0; i < aGraphics.size(); ++i)
1564     {
1565         Graphic const & rGraphic = aGraphics[i];
1566         CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected all PDF streams to be identical.",
1567                                      rFirstGraphic.getVectorGraphicData()->getBinaryDataContainer().getData(),
1568                                      rGraphic.getVectorGraphicData()->getBinaryDataContainer().getData());
1569 
1570         CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected all GfxLinks to be identical.",
1571                                      rFirstGraphic.GetSharedGfxLink().get(),
1572                                      rGraphic.GetSharedGfxLink().get());
1573 
1574         CPPUNIT_ASSERT_EQUAL_MESSAGE("Page number doesn't match expected", sal_Int32(i), rGraphic.getPageNumber());
1575     }
1576 
1577     xDocShRef->DoClose();
1578     comphelper::LibreOfficeKit::setActive(false);
1579 }
1580 
1581 #if defined(IMPORT_PDF_ELEMENTS)
1582 
testPDFImport()1583 void SdImportTest::testPDFImport()
1584 {
1585     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pdf/txtpic.pdf"), PDF);
1586     SdDrawDocument *pDoc = xDocShRef->GetDoc();
1587     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
1588     uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
1589     uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
1590     CPPUNIT_ASSERT_EQUAL_MESSAGE( "no exactly two shapes", static_cast<sal_Int32>(2), xPage->getCount() );
1591 
1592     uno::Reference< beans::XPropertySet > xShape( getShape( 0, xPage ) );
1593     uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
1594     CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
1595 
1596     xDocShRef->DoClose();
1597 }
1598 
testPDFImportSkipImages()1599 void SdImportTest::testPDFImportSkipImages()
1600 {
1601     auto pParams = std::make_shared<SfxAllItemSet>( SfxGetpApp()->GetPool() );
1602     pParams->Put( SfxStringItem ( SID_FILE_FILTEROPTIONS, "SkipImages" ) );
1603 
1604     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pdf/txtpic.pdf"), PDF, pParams);
1605     SdDrawDocument *pDoc = xDocShRef->GetDoc();
1606     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
1607     uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
1608     uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
1609     CPPUNIT_ASSERT_EQUAL_MESSAGE( "no exactly one shape", static_cast<sal_Int32>(1), xPage->getCount() );
1610 
1611     uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
1612     uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
1613     CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
1614 
1615     xDocShRef->DoClose();
1616 }
1617 
1618 #endif
1619 #endif
1620 
testBulletSuffix()1621 void SdImportTest::testBulletSuffix()
1622 {
1623     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/n83889.pptx"), PPTX );
1624 
1625     // check suffix of the char bullet
1626     const SdrPage *pPage = GetPage( 1, xDocShRef );
1627     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(0) );
1628     CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
1629     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
1630     const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(1).GetItem(EE_PARA_NUMBULLET);
1631     CPPUNIT_ASSERT(pNumFmt);
1632     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", pNumFmt->GetNumRule().GetLevel(0).GetSuffix(), OUString() );
1633     xDocShRef->DoClose();
1634 }
1635 
testBnc910045()1636 void SdImportTest::testBnc910045()
1637 {
1638     // Problem with table style which defines cell color with fill style
1639     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/bnc910045.pptx"), PPTX );
1640     const SdrPage *pPage = GetPage( 1, xDocShRef );
1641 
1642     sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1643     CPPUNIT_ASSERT( pTableObj );
1644     uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
1645     uno::Reference< beans::XPropertySet > xCell;
1646     Color nColor;
1647 
1648     xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
1649     xCell->getPropertyValue("FillColor") >>= nColor;
1650     CPPUNIT_ASSERT_EQUAL(Color(0x4f81bd), nColor);
1651 
1652     xDocShRef->DoClose();
1653 }
1654 
testRowHeight()1655 void SdImportTest::testRowHeight()
1656 {
1657     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/n80340.pptx"), PPTX );
1658     const SdrPage *pPage = GetPage( 1, xDocShRef );
1659 
1660     sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1661     CPPUNIT_ASSERT( pTableObj );
1662 
1663     sal_Int32 nHeight;
1664     uno::Reference< css::table::XTable > xTable(pTableObj->getTable(), uno::UNO_SET_THROW);
1665     uno::Reference< css::table::XTableRows > xRows( xTable->getRows(), uno::UNO_SET_THROW);
1666     uno::Reference< beans::XPropertySet > xRefRow( xRows->getByIndex(0), uno::UNO_QUERY_THROW );
1667     xRefRow->getPropertyValue( "Height" ) >>= nHeight;
1668     CPPUNIT_ASSERT_EQUAL( sal_Int32(508), nHeight);
1669 
1670     xDocShRef->DoClose();
1671 
1672     sd::DrawDocShellRef xDocShRef2 = loadURL( m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tablescale.pptx"), PPTX );
1673     const SdrPage *pPage2 = GetPage( 1, xDocShRef2 );
1674 
1675     sdr::table::SdrTableObj *pTableObj2 = dynamic_cast<sdr::table::SdrTableObj*>(pPage2->GetObj(0));
1676     CPPUNIT_ASSERT( pTableObj2 );
1677 
1678     uno::Reference< css::table::XTable > xTable2(pTableObj2->getTable(), uno::UNO_SET_THROW);
1679     uno::Reference< css::table::XTableRows > xRows2( xTable2->getRows(), uno::UNO_SET_THROW);
1680 
1681     for(sal_Int32 nRow = 0; nRow < 7; ++nRow)
1682     {
1683         uno::Reference< beans::XPropertySet > xRefRow2( xRows2->getByIndex(nRow), uno::UNO_QUERY_THROW );
1684         xRefRow2->getPropertyValue( "Height" ) >>= nHeight;
1685         CPPUNIT_ASSERT_EQUAL( sal_Int32(800), nHeight);
1686     }
1687 
1688     xDocShRef2->DoClose();
1689 }
1690 
testTdf93830()1691 void SdImportTest::testTdf93830()
1692 {
1693     // Text shape offset was ignored
1694     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf93830.pptx"), PPTX);
1695     uno::Reference< drawing::XDrawPage > xPage( getPage( 0, xDocShRef ) );
1696 
1697     // Get the first text box from group shape
1698     uno::Reference< container::XIndexAccess > xShape( xPage->getByIndex(0), uno::UNO_QUERY );
1699     uno::Reference< beans::XPropertySet > xPropSet( xShape->getByIndex(3), uno::UNO_QUERY );
1700     CPPUNIT_ASSERT_MESSAGE( "no textbox shape", xPropSet.is() );
1701 
1702     sal_Int32 nTextLeftDistance = 0;
1703     xPropSet->getPropertyValue( "TextLeftDistance" ) >>= nTextLeftDistance;
1704     CPPUNIT_ASSERT_EQUAL(sal_Int32(4152), nTextLeftDistance);
1705 
1706     xDocShRef->DoClose();
1707 }
1708 
testTdf127129()1709 void SdImportTest::testTdf127129()
1710 {
1711     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf127129.pptx"), PPTX);
1712     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
1713     uno::Reference< text::XTextRange > xParagraph( getParagraphFromShape( 0, xShape ) );
1714     uno::Reference< text::XTextRange > xRun( getRunFromParagraph( 0, xParagraph ) );
1715     uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
1716 
1717     Color nCharColor;
1718     xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
1719     CPPUNIT_ASSERT_EQUAL( COL_BLACK, nCharColor );
1720 
1721     // Without the accompanying fix in place, the highlight would be -1
1722     Color nCharBackColor;
1723     xPropSet->getPropertyValue( "CharBackColor" ) >>= nCharBackColor;
1724     CPPUNIT_ASSERT_EQUAL( Color(0xFF00), nCharBackColor );
1725 
1726     xDocShRef->DoClose();
1727 }
testTdf93097()1728 void SdImportTest::testTdf93097()
1729 {
1730     // Throwing metadata import aborted the filter, check that metadata is now imported.
1731     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf93097.pptx"), PPTX);
1732     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
1733     uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
1734     CPPUNIT_ASSERT_EQUAL(OUString("ss"), xDocumentProperties->getTitle());
1735     xDocShRef->DoClose();
1736 }
1737 
testTdf62255()1738 void SdImportTest::testTdf62255()
1739 {
1740     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf62255.pptx"), PPTX);
1741     const SdrPage *pPage = GetPage( 1, xDocShRef );
1742 
1743     sdr::table::SdrTableObj *pTableObj;
1744     pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1745     CPPUNIT_ASSERT( pTableObj );
1746 
1747     css::uno::Any aAny;
1748     uno::Reference< table::XCellRange > xTable;
1749     uno::Reference< beans::XPropertySet > xCell;
1750     xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
1751     xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
1752     aAny = xCell->getPropertyValue("FillStyle");
1753 
1754     if (aAny.hasValue())
1755     {
1756         drawing::FillStyle aFillStyle;
1757         aAny >>= aFillStyle;
1758         CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, aFillStyle);
1759     }
1760 
1761     xDocShRef->DoClose();
1762 }
1763 
testTdf113163()1764 void SdImportTest::testTdf113163()
1765 {
1766     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf113163.pptx"), PPTX);
1767     uno::Reference < uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1768     uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create(xContext);
1769 
1770     uno::Sequence< beans::PropertyValue > aFilterData(2);
1771     aFilterData[0].Name = "PixelWidth";
1772     aFilterData[0].Value <<= sal_Int32(100);
1773     aFilterData[1].Name = "PixelHeight";
1774     aFilterData[1].Value <<= sal_Int32(100);
1775 
1776     utl::TempFile aTempFile;
1777     aTempFile.EnableKillingFile();
1778 
1779     uno::Sequence< beans::PropertyValue > aDescriptor(3);
1780     aDescriptor[0].Name = "URL";
1781     aDescriptor[0].Value <<= aTempFile.GetURL();
1782     aDescriptor[1].Name = "FilterName";
1783     aDescriptor[1].Value <<= OUString("PNG");
1784     aDescriptor[2].Name = "FilterData";
1785     aDescriptor[2].Value <<= aFilterData;
1786 
1787     uno::Reference< lang::XComponent > xPage(getPage(0, xDocShRef), uno::UNO_QUERY);
1788     xGraphicExporter->setSourceDocument(xPage);
1789     xGraphicExporter->filter(aDescriptor);
1790 
1791     SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
1792     vcl::PngImageReader aPNGReader(aFileStream);
1793     BitmapEx aBMPEx = aPNGReader.read();
1794 
1795     // make sure the bitmap is not empty and correct size (PNG export->import was successful)
1796     Size aSize = aBMPEx.GetSizePixel();
1797     CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize);
1798     Bitmap aBMP = aBMPEx.GetBitmap();
1799     {
1800         Bitmap::ScopedReadAccess pReadAccess(aBMP);
1801         for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX)
1802         {
1803             for (tools::Long nY = 1; nY < aSize.Height() - 1; ++nY)
1804             {
1805                 // Check all pixels in the image are black
1806                 // Without the fix in place, this test would have failed with
1807                 // - Expected: 0
1808                 // - Actual  : 16777215
1809                 const Color aColor = pReadAccess->GetColor(nX, nY);
1810                 CPPUNIT_ASSERT_EQUAL(COL_BLACK, aColor);
1811             }
1812         }
1813     }
1814     xDocShRef->DoClose();
1815 }
1816 
testTdf93124()1817 void SdImportTest::testTdf93124()
1818 {
1819     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/ppt/tdf93124.ppt"), PPT);
1820     uno::Reference < uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1821     uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create(xContext);
1822 
1823     uno::Sequence< beans::PropertyValue > aFilterData(2);
1824     aFilterData[0].Name = "PixelWidth";
1825     aFilterData[0].Value <<= sal_Int32(320);
1826     aFilterData[1].Name = "PixelHeight";
1827     aFilterData[1].Value <<= sal_Int32(180);
1828 
1829     utl::TempFile aTempFile;
1830     aTempFile.EnableKillingFile();
1831 
1832     uno::Sequence< beans::PropertyValue > aDescriptor(3);
1833     aDescriptor[0].Name = "URL";
1834     aDescriptor[0].Value <<= aTempFile.GetURL();
1835     aDescriptor[1].Name = "FilterName";
1836     aDescriptor[1].Value <<= OUString("PNG");
1837     aDescriptor[2].Name = "FilterData";
1838     aDescriptor[2].Value <<= aFilterData;
1839 
1840     uno::Reference< lang::XComponent > xPage(getPage(0, xDocShRef), uno::UNO_QUERY);
1841     xGraphicExporter->setSourceDocument(xPage);
1842     xGraphicExporter->filter(aDescriptor);
1843 
1844     SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
1845     vcl::PngImageReader aPNGReader(aFileStream);
1846     BitmapEx aBMPEx = aPNGReader.read();
1847 
1848     // make sure the bitmap is not empty and correct size (PNG export->import was successful)
1849     CPPUNIT_ASSERT_EQUAL(Size(320, 180), aBMPEx.GetSizePixel());
1850     Bitmap aBMP = aBMPEx.GetBitmap();
1851     {
1852         Bitmap::ScopedReadAccess pReadAccess(aBMP);
1853         int nNonWhiteCount = 0;
1854         // The word "Top" should be in rectangle 34,4 - 76,30. If text alignment is wrong, the rectangle will be white.
1855         for (tools::Long nY = 4; nY < (4 + 26); ++nY)
1856         {
1857             for (tools::Long nX = 34; nX < (34 + 43); ++nX)
1858             {
1859                 const Color aColor = pReadAccess->GetColor(nY, nX);
1860                 if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff))
1861                     ++nNonWhiteCount;
1862             }
1863         }
1864         CPPUNIT_ASSERT_MESSAGE("Tdf93124: vertical alignment of text is incorrect!", nNonWhiteCount>50);
1865     }
1866     xDocShRef->DoClose();
1867 }
1868 
testTdf99729()1869 void SdImportTest::testTdf99729()
1870 {
1871     const OUString filenames[] = { "/sd/qa/unit/data/odp/tdf99729-new.odp", "/sd/qa/unit/data/odp/tdf99729-legacy.odp" };
1872     int nonwhitecounts[] = { 0, 0 };
1873     for (size_t i = 0; i < SAL_N_ELEMENTS(filenames); ++i)
1874     {
1875         // 1st check for new behaviour - having AnchoredTextOverflowLegacy compatibility flag set to false in settings.xml
1876         uno::Reference<lang::XComponent> xComponent
1877             = loadFromDesktop(m_directories.getURLFromSrc(filenames[i]),
1878                               "com.sun.star.presentation.PresentationDocument");
1879 
1880         uno::Reference<uno::XComponentContext> xContext = getComponentContext();
1881         CPPUNIT_ASSERT(xContext.is());
1882         uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create(xContext);
1883         CPPUNIT_ASSERT(xGraphicExporter.is());
1884 
1885         uno::Sequence< beans::PropertyValue > aFilterData(2);
1886         aFilterData[0].Name = "PixelWidth";
1887         aFilterData[0].Value <<= sal_Int32(320);
1888         aFilterData[1].Name = "PixelHeight";
1889         aFilterData[1].Value <<= sal_Int32(240);
1890 
1891         utl::TempFile aTempFile;
1892         aTempFile.EnableKillingFile();
1893 
1894         uno::Sequence< beans::PropertyValue > aDescriptor(3);
1895         aDescriptor[0].Name = "URL";
1896         aDescriptor[0].Value <<= aTempFile.GetURL();
1897         aDescriptor[1].Name = "FilterName";
1898         aDescriptor[1].Value <<= OUString("PNG");
1899         aDescriptor[2].Name = "FilterData";
1900         aDescriptor[2].Value <<= aFilterData;
1901 
1902         uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY);
1903         uno::Reference<lang::XComponent> xPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
1904                                                uno::UNO_QUERY);
1905         CPPUNIT_ASSERT(xPage.is());
1906         xGraphicExporter->setSourceDocument(xPage);
1907         xGraphicExporter->filter(aDescriptor);
1908 
1909         SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
1910         vcl::PngImageReader aPNGReader(aFileStream);
1911         BitmapEx aBMPEx = aPNGReader.read();
1912         Bitmap aBMP = aBMPEx.GetBitmap();
1913         Bitmap::ScopedReadAccess pRead(aBMP);
1914         for (tools::Long nX = 154; nX < (154 + 12); ++nX)
1915         {
1916             for (tools::Long nY = 16; nY < (16 + 96); ++nY)
1917             {
1918                 const Color aColor = pRead->GetColor(nY, nX);
1919                 if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff))
1920                     ++nonwhitecounts[i];
1921             }
1922         }
1923         xComponent->dispose();
1924     }
1925     // The numbers 1-9 should be above the Text Box in rectangle 154,16 - 170,112.
1926     // If text alignment is wrong, the rectangle will be white.
1927     CPPUNIT_ASSERT_MESSAGE("Tdf99729: vertical alignment of text is incorrect!", nonwhitecounts[0]>100); // it is 134 with cleartype disabled
1928     // The numbers 1-9 should be below the Text Box -> rectangle 154,16 - 170,112 should be white.
1929     CPPUNIT_ASSERT_EQUAL_MESSAGE("Tdf99729: legacy vertical alignment of text is incorrect!", 0, nonwhitecounts[1]);
1930 }
1931 
testTdf89927()1932 void SdImportTest::testTdf89927()
1933 {
1934     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf89927.pptx"), PPTX);
1935     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
1936     uno::Reference< text::XTextRange > xParagraph( getParagraphFromShape( 0, xShape ) );
1937     uno::Reference< text::XTextRange > xRun( getRunFromParagraph( 0, xParagraph ) );
1938     uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
1939 
1940     Color nCharColor;
1941     xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
1942     CPPUNIT_ASSERT_EQUAL( COL_WHITE, nCharColor );
1943 
1944     xDocShRef->DoClose();
1945 }
1946 
testTdf93868()1947 void SdImportTest::testTdf93868()
1948 {
1949     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf93868.pptx"), PPTX);
1950 
1951     const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
1952     CPPUNIT_ASSERT_EQUAL(size_t(5), pPage->GetObjCount());
1953     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, dynamic_cast<const XFillStyleItem&>(pPage->GetObj(0)->GetMergedItem(XATTR_FILLSTYLE)).GetValue());
1954     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, dynamic_cast<const XFillStyleItem&>(pPage->GetObj(1)->GetMergedItem(XATTR_FILLSTYLE)).GetValue());
1955 
1956     xDocShRef->DoClose();
1957 }
1958 
testTdf95932()1959 void SdImportTest::testTdf95932()
1960 {
1961     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf95932.pptx"), PPTX);
1962 
1963     const SdrPage *pPage = GetPage( 1, xDocShRef );
1964     SdrObject *const pObj = pPage->GetObj(2);
1965     CPPUNIT_ASSERT(pObj);
1966 
1967     const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1968         pObj->GetMergedItem(XATTR_FILLSTYLE));
1969     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1970     const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1971         pObj->GetMergedItem(XATTR_FILLCOLOR));
1972     CPPUNIT_ASSERT_EQUAL(Color(0x76bf3d), rColorItem.GetColorValue());
1973 
1974     xDocShRef->DoClose();
1975 }
1976 
testTdf99030()1977 void SdImportTest::testTdf99030()
1978 {
1979     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf99030.pptx"), PPTX);
1980 
1981     uno::Reference< drawing::XMasterPagesSupplier > xDoc(
1982         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
1983     uno::Reference< drawing::XDrawPage > xPage(
1984         xDoc->getMasterPages()->getByIndex( 0 ), uno::UNO_QUERY_THROW );
1985     uno::Reference< beans::XPropertySet > xPropSet( xPage, uno::UNO_QUERY );
1986 
1987     Color nFillColor;
1988     uno::Any aAny = xPropSet->getPropertyValue( "Background" );
1989     if (aAny.hasValue())
1990     {
1991         uno::Reference< beans::XPropertySet > xBackgroundPropSet;
1992         aAny >>= xBackgroundPropSet;
1993         xBackgroundPropSet->getPropertyValue( "FillColor" ) >>= nFillColor;
1994     }
1995     CPPUNIT_ASSERT_EQUAL( Color(0x676A55), nFillColor );
1996 
1997     xDocShRef->DoClose();
1998 }
1999 
testTdf49561()2000 void SdImportTest::testTdf49561()
2001 {
2002     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/ppt/tdf49561.ppt"), PPT);
2003 
2004     uno::Reference< drawing::XMasterPagesSupplier > xDoc(
2005         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
2006     uno::Reference< drawing::XDrawPage > xPage(
2007         xDoc->getMasterPages()->getByIndex( 0 ), uno::UNO_QUERY_THROW );
2008     CPPUNIT_ASSERT_EQUAL( sal_Int32(5), xPage->getCount() );
2009 
2010     uno::Reference< beans::XPropertySet > xShape( getShape( 3, xPage ) );
2011     uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
2012     uno::Reference<text::XTextRange> xRun( getRunFromParagraph (0, xParagraph ) );
2013     uno::Reference< beans::XPropertySet > xPropSet(xRun , uno::UNO_QUERY_THROW );
2014 
2015     float fCharHeight = 0;
2016     CPPUNIT_ASSERT(xPropSet->getPropertyValue("CharHeight") >>= fCharHeight);
2017     CPPUNIT_ASSERT_EQUAL(12.f, fCharHeight);
2018 
2019     OUString aCharFontName;
2020     CPPUNIT_ASSERT(xPropSet->getPropertyValue("CharFontName") >>= aCharFontName);
2021     CPPUNIT_ASSERT_EQUAL(OUString("Stencil"), aCharFontName);
2022 
2023     xDocShRef->DoClose();
2024 }
2025 
testTdf103473()2026 void SdImportTest::testTdf103473()
2027 {
2028     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf103473.pptx"), PPTX);
2029 
2030     const SdrPage *pPage = GetPage(1, xDocShRef);
2031     SdrTextObj *const pObj = dynamic_cast<SdrTextObj *const>(pPage->GetObj(0));
2032     CPPUNIT_ASSERT(pObj);
2033     ::tools::Rectangle aRect = pObj->GetGeoRect();
2034     CPPUNIT_ASSERT_EQUAL(tools::Long(3629), aRect.Left());
2035     CPPUNIT_ASSERT_EQUAL(tools::Long(4431), aRect.Top());
2036     CPPUNIT_ASSERT_EQUAL(tools::Long(8353), aRect.Right());
2037     CPPUNIT_ASSERT_EQUAL(tools::Long(9155), aRect.Bottom());
2038 
2039     xDocShRef->DoClose();
2040 }
2041 
testAoo124143()2042 void SdImportTest::testAoo124143()
2043 {
2044     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odg/ooo124143-1.odg"), ODG);
2045 
2046     uno::Reference<beans::XPropertySet> const xImage(getShapeFromPage(0, 0, xDocShRef));
2047     uno::Reference<drawing::XGluePointsSupplier> const xGPS(xImage, uno::UNO_QUERY);
2048     uno::Reference<container::XIdentifierAccess> const xGluePoints(xGPS->getGluePoints(), uno::UNO_QUERY);
2049 
2050     uno::Sequence<sal_Int32> const ids(xGluePoints->getIdentifiers());
2051     CPPUNIT_ASSERT_EQUAL(sal_Int32(6), ids.getLength());
2052     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ids[0]);
2053     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), ids[1]);
2054     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), ids[2]);
2055     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), ids[3]);
2056     CPPUNIT_ASSERT_EQUAL(sal_Int32(4), ids[4]);
2057     CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ids[5]);
2058 
2059     // interesting ones are custom 4, 5
2060     drawing::GluePoint2 glue4;
2061     xGluePoints->getByIdentifier(4) >>= glue4;
2062     CPPUNIT_ASSERT_EQUAL(sal_Int32( 2470), glue4.Position.X);
2063     CPPUNIT_ASSERT_EQUAL(sal_Int32(-1810), glue4.Position.Y);
2064 
2065     drawing::GluePoint2 glue5;
2066     xGluePoints->getByIdentifier(5) >>= glue5;
2067     CPPUNIT_ASSERT_EQUAL(sal_Int32(-2975), glue5.Position.X);
2068     CPPUNIT_ASSERT_EQUAL(sal_Int32(-2165), glue5.Position.Y);
2069 
2070     // now check connectors
2071     uno::Reference<beans::XPropertySet> const xEllipse(getShapeFromPage(1, 0, xDocShRef));
2072     uno::Reference<beans::XPropertySet> const xConn1(getShapeFromPage(2, 0, xDocShRef));
2073     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xConn1->getPropertyValue("StartGluePointIndex").get<sal_Int32>());
2074     CPPUNIT_ASSERT_EQUAL(xEllipse, xConn1->getPropertyValue("StartShape").get<uno::Reference<beans::XPropertySet>>());
2075     CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xConn1->getPropertyValue("EndGluePointIndex").get<sal_Int32>());
2076     CPPUNIT_ASSERT_EQUAL(xImage, xConn1->getPropertyValue("EndShape").get<uno::Reference<beans::XPropertySet>>());
2077     uno::Reference<beans::XPropertySet> const xConn2(getShapeFromPage(3, 0, xDocShRef));
2078     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xConn2->getPropertyValue("StartGluePointIndex").get<sal_Int32>());
2079     CPPUNIT_ASSERT_EQUAL(xEllipse, xConn2->getPropertyValue("StartShape").get<uno::Reference<beans::XPropertySet>>());
2080     CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xConn2->getPropertyValue("EndGluePointIndex").get<sal_Int32>());
2081     CPPUNIT_ASSERT_EQUAL(xImage, xConn2->getPropertyValue("EndShape").get<uno::Reference<beans::XPropertySet>>());
2082 
2083     xDocShRef->DoClose();
2084 }
2085 
testTdf103567()2086 void SdImportTest::testTdf103567()
2087 {
2088     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf103567.odp"), ODP);
2089     for (int i = 0; i < 4; ++i)
2090     {
2091         uno::Reference<beans::XPropertySet> const xShape(getShapeFromPage(i, 0, xDocShRef));
2092         uno::Reference<document::XEventsSupplier> const xEventsSupplier(xShape, uno::UNO_QUERY);
2093         uno::Reference<container::XNameAccess> const xEvents(xEventsSupplier->getEvents());
2094         OString const msg("shape " + OString::number(i) + ": ");
2095 
2096         CPPUNIT_ASSERT(xEvents->hasByName("OnClick"));
2097         uno::Sequence<beans::PropertyValue> props;
2098         xEvents->getByName("OnClick") >>= props;
2099         comphelper::SequenceAsHashMap const map(props);
2100         {
2101             auto iter(map.find("EventType"));
2102             CPPUNIT_ASSERT_MESSAGE(OString(msg + "no EventType").getStr(), iter != map.end());
2103             CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), OUString("Presentation"), iter->second.get<OUString>());
2104         }
2105         {
2106             auto iter(map.find("ClickAction"));
2107             CPPUNIT_ASSERT_MESSAGE(OString(msg + "no ClickAction").getStr(), iter != map.end());
2108             if (i % 2 == 0)
2109             {
2110                 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), css::presentation::ClickAction_DOCUMENT, iter->second.get<css::presentation::ClickAction>());
2111             }
2112             else
2113             {
2114                 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), css::presentation::ClickAction_NEXTPAGE, iter->second.get<css::presentation::ClickAction>());
2115             }
2116         }
2117         if (i % 2 == 0)
2118         {
2119             auto iter(map.find("Bookmark"));
2120             CPPUNIT_ASSERT_MESSAGE(OString(msg + "no Bookmark").getStr(), iter != map.end());
2121             CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), OUString("http://example.com/"), iter->second.get<OUString>());
2122         }
2123     }
2124 
2125     xDocShRef->DoClose();
2126 }
2127 
testTdf103792()2128 void SdImportTest::testTdf103792()
2129 {
2130     // Title text shape on the actual slide contained no text neither a placeholder text.
2131     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf103792.pptx"), PPTX);
2132 
2133     const SdrPage *pPage = GetPage(1, xDocShRef);
2134     CPPUNIT_ASSERT_MESSAGE("No page found", pPage != nullptr);
2135     SdrObject *pObj = pPage->GetObj(0);
2136     CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr);
2137     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(pObj);
2138     CPPUNIT_ASSERT_MESSAGE("Not a text object", pTxtObj != nullptr);
2139 
2140     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
2141     CPPUNIT_ASSERT_EQUAL(OUString("Click to add Title"), aEdit.GetText(0));
2142 
2143     xDocShRef->DoClose();
2144 }
2145 
testTdf103876()2146 void SdImportTest::testTdf103876()
2147 {
2148     // Title text shape's placeholder text did not inherit the corresponding text properties
2149     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf103876.pptx"), PPTX);
2150     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
2151 
2152     // Check paragraph alignment
2153     sal_Int16 nParaAdjust = 0;
2154     xShape->getPropertyValue( "ParaAdjust" ) >>= nParaAdjust;
2155     CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(nParaAdjust));
2156 
2157     // Check character color
2158     Color nCharColor;
2159     xShape->getPropertyValue( "CharColor" ) >>= nCharColor;
2160     CPPUNIT_ASSERT_EQUAL( Color(0xFF0000), nCharColor );
2161 
2162     xDocShRef->DoClose();
2163 }
2164 
testTdf79007()2165 void SdImportTest::testTdf79007()
2166 {
2167     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf79007.pptx"), PPTX);
2168 
2169     uno::Reference<beans::XPropertySet> xShape1(getShapeFromPage(0, 0, xDocShRef));
2170     CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape1.is());
2171 
2172     // Check we map mso washout to our watermark
2173     drawing::ColorMode aColorMode1;
2174     xShape1->getPropertyValue("GraphicColorMode") >>= aColorMode1;
2175     CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_WATERMARK, aColorMode1);
2176 
2177     sal_Int16 nContrast1;
2178     xShape1->getPropertyValue("AdjustContrast") >>= nContrast1;
2179     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nContrast1);
2180 
2181     sal_Int16 nLuminance1;
2182     xShape1->getPropertyValue("AdjustLuminance") >>= nLuminance1;
2183     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nLuminance1);
2184 
2185     uno::Reference<beans::XPropertySet> xShape2(getShapeFromPage(1, 0, xDocShRef));
2186     CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape2.is());
2187 
2188     // Check we map mso grayscale to our grayscale
2189     drawing::ColorMode aColorMode2;
2190     xShape2->getPropertyValue("GraphicColorMode") >>= aColorMode2;
2191     CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_GREYS, aColorMode2);
2192 
2193     sal_Int16 nContrast2;
2194     xShape2->getPropertyValue("AdjustContrast") >>= nContrast2;
2195     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nContrast2);
2196 
2197     sal_Int16 nLuminance2;
2198     xShape2->getPropertyValue("AdjustLuminance") >>= nLuminance2;
2199     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nLuminance2);
2200 
2201     uno::Reference<beans::XPropertySet> xShape3(getShapeFromPage(2, 0, xDocShRef));
2202     CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape3.is());
2203 
2204     // Check we map mso black/white to our black/white
2205     drawing::ColorMode aColorMode3;
2206     xShape3->getPropertyValue("GraphicColorMode") >>= aColorMode3;
2207     CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_MONO, aColorMode3);
2208 
2209     sal_Int16 nContrast3;
2210     xShape3->getPropertyValue("AdjustContrast") >>= nContrast3;
2211     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nContrast3);
2212 
2213     sal_Int16 nLuminance3;
2214     xShape3->getPropertyValue("AdjustLuminance") >>= nLuminance3;
2215     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nLuminance3);
2216 
2217     xDocShRef->DoClose();
2218 }
2219 
testTdf129686()2220 void SdImportTest::testTdf129686()
2221 {
2222     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf129686.pptx"), PPTX);
2223     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
2224 
2225     // Get first paragraph of the text
2226     uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
2227 
2228     // Get first run of the paragraph
2229     uno::Reference<text::XTextRange> xRun( getRunFromParagraph (0, xParagraph ) );
2230     uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
2231     sal_Int16 nTransparency = 0;
2232     xPropSet->getPropertyValue("CharTransparence") >>= nTransparency;
2233 
2234     // 100 = no transparency
2235     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(100), nTransparency);
2236 
2237     xDocShRef->DoClose();
2238 }
2239 
testTdf104015()2240 void SdImportTest::testTdf104015()
2241 {
2242     // Shape fill, line and effect properties were not inherited from master slide shape
2243     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf104015.pptx"), PPTX);
2244 
2245     const SdrPage *pPage = GetPage( 1, xDocShRef );
2246     CPPUNIT_ASSERT_MESSAGE("No page found", pPage != nullptr);
2247     SdrObject *const pObj = pPage->GetObj(0);
2248     CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr);
2249     // Should have a red fill color
2250     {
2251         const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
2252                 pObj->GetMergedItem(XATTR_FILLSTYLE));
2253         CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
2254         const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
2255                 pObj->GetMergedItem(XATTR_FILLCOLOR));
2256         CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), rColorItem.GetColorValue());
2257     }
2258     // Should have a blue line
2259     {
2260         const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
2261                 pObj->GetMergedItem(XATTR_LINESTYLE));
2262         CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID, rStyleItem.GetValue());
2263 
2264         const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
2265                 pObj->GetMergedItem(XATTR_LINECOLOR));
2266         CPPUNIT_ASSERT_EQUAL(Color(0x0000FF), rColorItem.GetColorValue());
2267     }
2268     // Should have some shadow
2269     {
2270         const SdrOnOffItem& rShadowItem = dynamic_cast<const SdrOnOffItem&>(
2271                 pObj->GetMergedItem(SDRATTR_SHADOW));
2272         CPPUNIT_ASSERT(rShadowItem.GetValue());
2273     }
2274 
2275     xDocShRef->DoClose();
2276 }
2277 
testTdf104201()2278 void SdImportTest::testTdf104201()
2279 {
2280     // Group shape properties did not overwrite the child shapes' fill
2281     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf104201.pptx"), PPTX);
2282 
2283     const SdrPage *pPage = GetPage(1, xDocShRef);
2284     CPPUNIT_ASSERT_MESSAGE("No page found", pPage != nullptr);
2285 
2286     // First shape has red fill, but this should be overwritten by green group fill
2287     {
2288         SdrObject *const pObj = pPage->GetObj(0);
2289         CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr);
2290         const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
2291             pObj->GetMergedItem(XATTR_FILLSTYLE));
2292         CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
2293         const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
2294             pObj->GetMergedItem(XATTR_FILLCOLOR));
2295         CPPUNIT_ASSERT_EQUAL(Color(0x00FF00), rColorItem.GetColorValue());
2296     }
2297     // Second shape has blue fill, but this should be overwritten by green group fill
2298     {
2299         SdrObject *const pObj = pPage->GetObj(0);
2300         CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr);
2301         const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
2302             pObj->GetMergedItem(XATTR_FILLSTYLE));
2303         CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
2304         const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
2305             pObj->GetMergedItem(XATTR_FILLCOLOR));
2306         CPPUNIT_ASSERT_EQUAL(Color(0x00FF00), rColorItem.GetColorValue());
2307     }
2308 
2309     xDocShRef->DoClose();
2310 }
2311 
testTdf103477()2312 void SdImportTest::testTdf103477()
2313 {
2314     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf103477.pptx"), PPTX);
2315 
2316     const SdrPage *pPage = GetPage( 1, xDocShRef );
2317 
2318     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(6) );
2319     CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr );
2320 
2321     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
2322     const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
2323     CPPUNIT_ASSERT(pNumFmt);
2324     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", Color(0x000000), pNumFmt->GetNumRule().GetLevel(1).GetBulletColor());
2325 
2326     xDocShRef->DoClose();
2327 }
2328 
testTdf105150()2329 void SdImportTest::testTdf105150()
2330 {
2331     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf105150.pptx"), PPTX);
2332     const SdrPage* pPage = GetPage(1, xDocShRef);
2333     const SdrObject* pObj = pPage->GetObj(1);
2334     auto& rFillStyleItem = dynamic_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE));
2335     // This was drawing::FillStyle_NONE, <p:sp useBgFill="1"> was ignored when
2336     // the slide didn't have an explicit background fill.
2337     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rFillStyleItem.GetValue());
2338     xDocShRef->DoClose();
2339 }
2340 
testTdf123684()2341 void SdImportTest::testTdf123684()
2342 {
2343     sd::DrawDocShellRef xDocShRef
2344         = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf123684.pptx"), PPTX);
2345     const SdrPage* pPage = GetPage(1, xDocShRef);
2346     const SdrObject* pObj = pPage->GetObj(0);
2347     auto& rFillStyleItem
2348         = dynamic_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE));
2349     // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual:
2350     // 1', i.e. the shape's fill was FillStyle_SOLID, making the text of the shape unreadable.
2351     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, rFillStyleItem.GetValue());
2352     xDocShRef->DoClose();
2353 }
2354 
testTdf105150PPT()2355 void SdImportTest::testTdf105150PPT()
2356 {
2357     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/ppt/tdf105150.ppt"), PPT);
2358     const SdrPage* pPage = GetPage(1, xDocShRef);
2359     const SdrObject* pObj = pPage->GetObj(1);
2360     // This was drawing::FillStyle_NONE, the shape's mso_fillBackground was
2361     // ignored when the slide didn't have an explicit background fill.
2362     auto& rFillStyleItem = dynamic_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE));
2363     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rFillStyleItem.GetValue());
2364     xDocShRef->DoClose();
2365 }
2366 
testTdf104445()2367 void SdImportTest::testTdf104445()
2368 {
2369     // Extra bullets were added to the first shape
2370     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf104445.pptx"), PPTX);
2371 
2372     // First shape should not have bullet
2373     {
2374         uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(0, 0, xDocShRef));
2375         uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
2376         CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
2377         uno::Reference< beans::XPropertySet > xPropSet(xText, uno::UNO_QUERY_THROW);
2378 
2379         uno::Reference< container::XIndexAccess > xNumRule;
2380         xPropSet->getPropertyValue("NumberingRules") >>= xNumRule;
2381         uno::Sequence<beans::PropertyValue> aBulletProps;
2382         xNumRule->getByIndex(0) >>= aBulletProps;
2383 
2384         for (beans::PropertyValue const & rProp : std::as_const(aBulletProps))
2385         {
2386             if(rProp.Name == "NumberingType")
2387                 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::NUMBER_NONE), rProp.Value.get<sal_Int16>());
2388             if(rProp.Name == "LeftMargin")
2389                 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get<sal_Int32>());
2390         }
2391     }
2392     // Second shape should have bullet set
2393     {
2394         uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(1, 0, xDocShRef));
2395         uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
2396         CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
2397         uno::Reference< beans::XPropertySet > xPropSet(xText, uno::UNO_QUERY_THROW);
2398 
2399         uno::Reference< container::XIndexAccess > xNumRule;
2400         xPropSet->getPropertyValue("NumberingRules") >>= xNumRule;
2401         uno::Sequence<beans::PropertyValue> aBulletProps;
2402         xNumRule->getByIndex(0) >>= aBulletProps;
2403 
2404         for(beans::PropertyValue const & rProp : std::as_const(aBulletProps))
2405         {
2406             if(rProp.Name == "NumberingType")
2407                 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::CHAR_SPECIAL), rProp.Value.get<sal_Int16>());
2408             if(rProp.Name == "LeftMargin")
2409                 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), rProp.Value.get<sal_Int32>());
2410         }
2411     }
2412     xDocShRef->DoClose();
2413 }
2414 
2415 namespace
2416 {
2417 
checkPatternValues(std::vector<sal_uInt8> & rExpected,Bitmap & rBitmap)2418 bool checkPatternValues(std::vector<sal_uInt8>& rExpected, Bitmap& rBitmap)
2419 {
2420     bool bResult = true;
2421 
2422     const Color aFGColor(0xFF0000);
2423     const Color aBGColor(0xFFFFFF);
2424 
2425     Bitmap::ScopedReadAccess pAccess(rBitmap);
2426     for (tools::Long y = 0; y < pAccess->Height(); ++y)
2427     {
2428         Scanline pScanline = pAccess->GetScanline( y );
2429         for (tools::Long x = 0; x < pAccess->Width(); ++x)
2430         {
2431             Color aColor = pAccess->GetPixelFromData(pScanline, x);
2432             sal_uInt8 aValue = rExpected[y*8+x];
2433 
2434             if (aValue == 1 && aColor != aFGColor)
2435                 bResult = false;
2436             else if (aValue == 0 && aColor != aBGColor)
2437                 bResult = false;
2438         }
2439     }
2440 
2441     return bResult;
2442 }
2443 
2444 } // end anonymous namespace
2445 
checkPattern(sd::DrawDocShellRef const & rDocRef,int nShapeNumber,std::vector<sal_uInt8> & rExpected)2446 bool SdImportTest::checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected)
2447 {
2448     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(nShapeNumber, 0, rDocRef));
2449     CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape.is());
2450 
2451     Bitmap aBitmap;
2452     if (xShape.is())
2453     {
2454         uno::Any aBitmapAny = xShape->getPropertyValue("FillBitmap");
2455         uno::Reference<awt::XBitmap> xBitmap;
2456         if (aBitmapAny >>= xBitmap)
2457         {
2458             uno::Sequence<sal_Int8> aBitmapSequence(xBitmap->getDIB());
2459             SvMemoryStream aBitmapStream(aBitmapSequence.getArray(),
2460                                          aBitmapSequence.getLength(),
2461                                          StreamMode::READ);
2462             ReadDIB(aBitmap, aBitmapStream, true);
2463         }
2464     }
2465     CPPUNIT_ASSERT_EQUAL(tools::Long(8), aBitmap.GetSizePixel().Width());
2466     CPPUNIT_ASSERT_EQUAL(tools::Long(8), aBitmap.GetSizePixel().Height());
2467     return checkPatternValues(rExpected, aBitmap);
2468 }
2469 
2470 /* Test checks that importing a PPT file with all supported fill patterns is
2471  * correctly imported as a tiled fill bitmap with the expected pattern.
2472  */
testPatternImport()2473 void SdImportTest::testPatternImport()
2474 {
2475     sd::DrawDocShellRef xDocRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/ppt/FillPatterns.ppt"), PPT);
2476 
2477     std::vector<sal_uInt8> aExpectedPattern1 = {
2478         1,0,0,0,0,0,0,0,
2479         0,0,0,0,0,0,0,0,
2480         0,0,0,0,0,0,0,0,
2481         0,0,0,0,0,0,0,0,
2482         0,0,0,0,1,0,0,0,
2483         0,0,0,0,0,0,0,0,
2484         0,0,0,0,0,0,0,0,
2485         0,0,0,0,0,0,0,0,
2486     };
2487     std::vector<sal_uInt8> aExpectedPattern2 = {
2488         1,0,0,0,0,0,0,0,
2489         0,0,0,0,0,0,0,0,
2490         0,0,0,0,1,0,0,0,
2491         0,0,0,0,0,0,0,0,
2492         1,0,0,0,0,0,0,0,
2493         0,0,0,0,0,0,0,0,
2494         0,0,0,0,1,0,0,0,
2495         0,0,0,0,0,0,0,0,
2496     };
2497     std::vector<sal_uInt8> aExpectedPattern3 = {
2498         1,0,0,0,1,0,0,0,
2499         0,0,0,0,0,0,0,0,
2500         0,0,1,0,0,0,1,0,
2501         0,0,0,0,0,0,0,0,
2502         1,0,0,0,1,0,0,0,
2503         0,0,0,0,0,0,0,0,
2504         0,0,1,0,0,0,1,0,
2505         0,0,0,0,0,0,0,0,
2506     };
2507     std::vector<sal_uInt8> aExpectedPattern4 = {
2508         1,0,0,0,1,0,0,0,
2509         0,0,1,0,0,0,1,0,
2510         1,0,0,0,1,0,0,0,
2511         0,0,1,0,0,0,1,0,
2512         1,0,0,0,1,0,0,0,
2513         0,0,1,0,0,0,1,0,
2514         1,0,0,0,1,0,0,0,
2515         0,0,1,0,0,0,1,0,
2516     };
2517     std::vector<sal_uInt8> aExpectedPattern5 = {
2518         1,0,1,0,1,0,1,0,
2519         0,1,0,0,0,1,0,0,
2520         1,0,1,0,1,0,1,0,
2521         0,0,0,1,0,0,0,1,
2522         1,0,1,0,1,0,1,0,
2523         0,1,0,0,0,1,0,0,
2524         1,0,1,0,1,0,1,0,
2525         0,0,0,1,0,0,0,1,
2526     };
2527     std::vector<sal_uInt8> aExpectedPattern6 = {
2528         1,0,1,0,1,0,1,0,
2529         0,1,0,1,0,1,0,1,
2530         1,0,1,0,1,0,1,0,
2531         0,1,0,1,0,0,0,1,
2532         1,0,1,0,1,0,1,0,
2533         0,1,0,1,0,1,0,1,
2534         1,0,1,0,1,0,1,0,
2535         0,0,0,1,0,1,0,1,
2536     };
2537     std::vector<sal_uInt8> aExpectedPattern7 = {
2538         1,0,1,0,1,0,1,0,
2539         0,1,0,1,0,1,0,1,
2540         1,0,1,0,1,0,1,0,
2541         0,1,0,1,0,1,0,1,
2542         1,0,1,0,1,0,1,0,
2543         0,1,0,1,0,1,0,1,
2544         1,0,1,0,1,0,1,0,
2545         0,1,0,1,0,1,0,1,
2546     };
2547     std::vector<sal_uInt8> aExpectedPattern8 = {
2548         1,1,1,0,1,1,1,0,
2549         0,1,0,1,0,1,0,1,
2550         1,0,1,1,1,0,1,1,
2551         0,1,0,1,0,1,0,1,
2552         1,1,1,0,1,1,1,0,
2553         0,1,0,1,0,1,0,1,
2554         1,0,1,1,1,0,1,1,
2555         0,1,0,1,0,1,0,1,
2556     };
2557     std::vector<sal_uInt8> aExpectedPattern9 = {
2558         0,1,1,1,0,1,1,1,
2559         1,1,0,1,1,1,0,1,
2560         0,1,1,1,0,1,1,1,
2561         1,1,0,1,1,1,0,1,
2562         0,1,1,1,0,1,1,1,
2563         1,1,0,1,1,1,0,1,
2564         0,1,1,1,0,1,1,1,
2565         1,1,0,1,1,1,0,1,
2566     };
2567     std::vector<sal_uInt8> aExpectedPattern10 = {
2568         0,1,1,1,0,1,1,1,
2569         1,1,1,1,1,1,1,1,
2570         1,1,0,1,1,1,0,1,
2571         1,1,1,1,1,1,1,1,
2572         0,1,1,1,0,1,1,1,
2573         1,1,1,1,1,1,1,1,
2574         1,1,0,1,1,1,0,1,
2575         1,1,1,1,1,1,1,1,
2576     };
2577     std::vector<sal_uInt8> aExpectedPattern11 = {
2578         1,1,1,0,1,1,1,1,
2579         1,1,1,1,1,1,1,1,
2580         1,1,1,1,1,1,1,0,
2581         1,1,1,1,1,1,1,1,
2582         1,1,1,0,1,1,1,1,
2583         1,1,1,1,1,1,1,1,
2584         1,1,1,1,1,1,1,0,
2585         1,1,1,1,1,1,1,1,
2586     };
2587     std::vector<sal_uInt8> aExpectedPattern12 = {
2588         1,1,1,1,1,1,1,1,
2589         1,1,1,1,1,1,1,1,
2590         1,1,1,1,1,1,1,1,
2591         1,1,1,1,0,1,1,1,
2592         1,1,1,1,1,1,1,1,
2593         1,1,1,1,1,1,1,1,
2594         1,1,1,1,1,1,1,1,
2595         0,1,1,1,1,1,1,1,
2596     };
2597     std::vector<sal_uInt8> aExpectedPatternLine1 = {
2598         1,0,0,0,1,0,0,0,
2599         0,1,0,0,0,1,0,0,
2600         0,0,1,0,0,0,1,0,
2601         0,0,0,1,0,0,0,1,
2602         1,0,0,0,1,0,0,0,
2603         0,1,0,0,0,1,0,0,
2604         0,0,1,0,0,0,1,0,
2605         0,0,0,1,0,0,0,1,
2606     };
2607     std::vector<sal_uInt8> aExpectedPatternLine2 = {
2608         0,0,0,1,0,0,0,1,
2609         0,0,1,0,0,0,1,0,
2610         0,1,0,0,0,1,0,0,
2611         1,0,0,0,1,0,0,0,
2612         0,0,0,1,0,0,0,1,
2613         0,0,1,0,0,0,1,0,
2614         0,1,0,0,0,1,0,0,
2615         1,0,0,0,1,0,0,0,
2616     };
2617     std::vector<sal_uInt8> aExpectedPatternLine3 = {
2618         1,1,0,0,1,1,0,0,
2619         0,1,1,0,0,1,1,0,
2620         0,0,1,1,0,0,1,1,
2621         1,0,0,1,1,0,0,1,
2622         1,1,0,0,1,1,0,0,
2623         0,1,1,0,0,1,1,0,
2624         0,0,1,1,0,0,1,1,
2625         1,0,0,1,1,0,0,1,
2626     };
2627     std::vector<sal_uInt8> aExpectedPatternLine4 = {
2628         0,0,1,1,0,0,1,1,
2629         0,1,1,0,0,1,1,0,
2630         1,1,0,0,1,1,0,0,
2631         1,0,0,1,1,0,0,1,
2632         0,0,1,1,0,0,1,1,
2633         0,1,1,0,0,1,1,0,
2634         1,1,0,0,1,1,0,0,
2635         1,0,0,1,1,0,0,1,
2636     };
2637     std::vector<sal_uInt8> aExpectedPatternLine5 = {
2638         1,1,0,0,0,0,0,1,
2639         1,1,1,0,0,0,0,0,
2640         0,1,1,1,0,0,0,0,
2641         0,0,1,1,1,0,0,0,
2642         0,0,0,1,1,1,0,0,
2643         0,0,0,0,1,1,1,0,
2644         0,0,0,0,0,1,1,1,
2645         1,0,0,0,0,0,1,1,
2646     };
2647     std::vector<sal_uInt8> aExpectedPatternLine6 = {
2648         1,0,0,0,0,0,1,1,
2649         0,0,0,0,0,1,1,1,
2650         0,0,0,0,1,1,1,0,
2651         0,0,0,1,1,1,0,0,
2652         0,0,1,1,1,0,0,0,
2653         0,1,1,1,0,0,0,0,
2654         1,1,1,0,0,0,0,0,
2655         1,1,0,0,0,0,0,1,
2656     };
2657     std::vector<sal_uInt8> aExpectedPatternLine7 = {
2658         1,0,0,0,1,0,0,0,
2659         1,0,0,0,1,0,0,0,
2660         1,0,0,0,1,0,0,0,
2661         1,0,0,0,1,0,0,0,
2662         1,0,0,0,1,0,0,0,
2663         1,0,0,0,1,0,0,0,
2664         1,0,0,0,1,0,0,0,
2665         1,0,0,0,1,0,0,0,
2666     };
2667     std::vector<sal_uInt8> aExpectedPatternLine8 = {
2668         1,1,1,1,1,1,1,1,
2669         0,0,0,0,0,0,0,0,
2670         0,0,0,0,0,0,0,0,
2671         0,0,0,0,0,0,0,0,
2672         1,1,1,1,1,1,1,1,
2673         0,0,0,0,0,0,0,0,
2674         0,0,0,0,0,0,0,0,
2675         0,0,0,0,0,0,0,0,
2676     };
2677     std::vector<sal_uInt8> aExpectedPatternLine9 = {
2678         0,1,0,1,0,1,0,1,
2679         0,1,0,1,0,1,0,1,
2680         0,1,0,1,0,1,0,1,
2681         0,1,0,1,0,1,0,1,
2682         0,1,0,1,0,1,0,1,
2683         0,1,0,1,0,1,0,1,
2684         0,1,0,1,0,1,0,1,
2685         0,1,0,1,0,1,0,1,
2686     };
2687     std::vector<sal_uInt8> aExpectedPatternLine10 = {
2688         1,1,1,1,1,1,1,1,
2689         0,0,0,0,0,0,0,0,
2690         1,1,1,1,1,1,1,1,
2691         0,0,0,0,0,0,0,0,
2692         1,1,1,1,1,1,1,1,
2693         0,0,0,0,0,0,0,0,
2694         1,1,1,1,1,1,1,1,
2695         0,0,0,0,0,0,0,0,
2696     };
2697     std::vector<sal_uInt8> aExpectedPatternLine11 = {
2698         1,1,0,0,1,1,0,0,
2699         1,1,0,0,1,1,0,0,
2700         1,1,0,0,1,1,0,0,
2701         1,1,0,0,1,1,0,0,
2702         1,1,0,0,1,1,0,0,
2703         1,1,0,0,1,1,0,0,
2704         1,1,0,0,1,1,0,0,
2705         1,1,0,0,1,1,0,0,
2706     };
2707     std::vector<sal_uInt8> aExpectedPatternLine12 = {
2708         1,1,1,1,1,1,1,1,
2709         1,1,1,1,1,1,1,1,
2710         0,0,0,0,0,0,0,0,
2711         0,0,0,0,0,0,0,0,
2712         1,1,1,1,1,1,1,1,
2713         1,1,1,1,1,1,1,1,
2714         0,0,0,0,0,0,0,0,
2715         0,0,0,0,0,0,0,0,
2716     };
2717 
2718     CPPUNIT_ASSERT_MESSAGE("Pattern1 - 5%" ,  checkPattern(xDocRef, 0,  aExpectedPattern1));
2719     CPPUNIT_ASSERT_MESSAGE("Pattern2 - 10%",  checkPattern(xDocRef, 1,  aExpectedPattern2));
2720     CPPUNIT_ASSERT_MESSAGE("Pattern3 - 20%",  checkPattern(xDocRef, 2,  aExpectedPattern3));
2721     CPPUNIT_ASSERT_MESSAGE("Pattern4 - 25%",  checkPattern(xDocRef, 3,  aExpectedPattern4));
2722     CPPUNIT_ASSERT_MESSAGE("Pattern5 - 30%",  checkPattern(xDocRef, 4,  aExpectedPattern5));
2723     CPPUNIT_ASSERT_MESSAGE("Pattern6 - 40%",  checkPattern(xDocRef, 5,  aExpectedPattern6));
2724     CPPUNIT_ASSERT_MESSAGE("Pattern7 - 50%",  checkPattern(xDocRef, 6,  aExpectedPattern7));
2725     CPPUNIT_ASSERT_MESSAGE("Pattern8 - 60%",  checkPattern(xDocRef, 7,  aExpectedPattern8));
2726     CPPUNIT_ASSERT_MESSAGE("Pattern9 - 70%",  checkPattern(xDocRef, 8,  aExpectedPattern9));
2727     CPPUNIT_ASSERT_MESSAGE("Pattern10 - 75%", checkPattern(xDocRef, 9,  aExpectedPattern10));
2728     CPPUNIT_ASSERT_MESSAGE("Pattern11 - 80%", checkPattern(xDocRef, 10, aExpectedPattern11));
2729     CPPUNIT_ASSERT_MESSAGE("Pattern12 - 90%", checkPattern(xDocRef, 11, aExpectedPattern12));
2730 
2731     CPPUNIT_ASSERT_MESSAGE("Pattern13 - Light downward diagonal", checkPattern(xDocRef, 12, aExpectedPatternLine1));
2732     CPPUNIT_ASSERT_MESSAGE("Pattern14 - Light upward diagonal",   checkPattern(xDocRef, 13, aExpectedPatternLine2));
2733     CPPUNIT_ASSERT_MESSAGE("Pattern15 - Dark downward diagonal",  checkPattern(xDocRef, 14, aExpectedPatternLine3));
2734     CPPUNIT_ASSERT_MESSAGE("Pattern16 - Dark upward diagonal",    checkPattern(xDocRef, 15, aExpectedPatternLine4));
2735     CPPUNIT_ASSERT_MESSAGE("Pattern17 - Wide downward diagonal",  checkPattern(xDocRef, 16, aExpectedPatternLine5));
2736     CPPUNIT_ASSERT_MESSAGE("Pattern18 - Wide upward diagonal",    checkPattern(xDocRef, 17, aExpectedPatternLine6));
2737 
2738     CPPUNIT_ASSERT_MESSAGE("Pattern19 - Light vertical",    checkPattern(xDocRef, 18, aExpectedPatternLine7));
2739     CPPUNIT_ASSERT_MESSAGE("Pattern20 - Light horizontal",  checkPattern(xDocRef, 19, aExpectedPatternLine8));
2740     CPPUNIT_ASSERT_MESSAGE("Pattern21 - Narrow vertical",   checkPattern(xDocRef, 20, aExpectedPatternLine9));
2741     CPPUNIT_ASSERT_MESSAGE("Pattern22 - Narrow horizontal", checkPattern(xDocRef, 21, aExpectedPatternLine10));
2742     CPPUNIT_ASSERT_MESSAGE("Pattern23 - Dark vertical",     checkPattern(xDocRef, 22, aExpectedPatternLine11));
2743     CPPUNIT_ASSERT_MESSAGE("Pattern24 - Dark horizontal",   checkPattern(xDocRef, 23, aExpectedPatternLine12));
2744 
2745     // TODO: other patterns in the test document
2746 
2747     xDocRef->DoClose();
2748 }
2749 
testTdf100926()2750 void SdImportTest::testTdf100926()
2751 {
2752     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf100926.pptx"), PPTX);
2753     const SdrPage* pPage = GetPage(1, xDocShRef);
2754     CPPUNIT_ASSERT(pPage != nullptr);
2755 
2756     sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
2757     CPPUNIT_ASSERT(pTableObj != nullptr);
2758     uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
2759 
2760     sal_Int32 nRotation = 0;
2761     uno::Reference< beans::XPropertySet > xCell(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
2762     xCell->getPropertyValue("RotateAngle") >>= nRotation;
2763     CPPUNIT_ASSERT_EQUAL(sal_Int32(27000), nRotation);
2764 
2765     xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
2766     xCell->getPropertyValue("RotateAngle") >>= nRotation;
2767     CPPUNIT_ASSERT_EQUAL(sal_Int32(9000), nRotation);
2768 
2769     xCell.set(xTable->getCellByPosition(2, 0), uno::UNO_QUERY_THROW);
2770     xCell->getPropertyValue("RotateAngle") >>= nRotation;
2771     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRotation);
2772 
2773     xDocShRef->DoClose();
2774 }
2775 
testTdf89064()2776 void SdImportTest::testTdf89064()
2777 {
2778     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf89064.pptx"), PPTX);
2779     uno::Reference< presentation::XPresentationPage > xPage (getPage(0, xDocShRef), uno::UNO_QUERY_THROW);
2780     uno::Reference< drawing::XDrawPage > xNotesPage (xPage->getNotesPage(), uno::UNO_SET_THROW);
2781     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xNotesPage->getCount());
2782 
2783     xDocShRef->DoClose();
2784 }
2785 
testTdf108925()2786 void SdImportTest::testTdf108925()
2787 {
2788     // Test document contains bulleting with too small bullet size (1%) which breaks the lower constraint
2789     // So it should be converted to the lowest allowed value (25%).
2790     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odp/tdf108925.odp"), ODP);
2791     const SdrPage *pPage = GetPage(1, xDocShRef);
2792     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(pPage->GetObj(0));
2793     CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr);
2794     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
2795 
2796     const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
2797     CPPUNIT_ASSERT(pNumFmt);
2798     CPPUNIT_ASSERT_EQUAL(sal_uInt16(25), pNumFmt->GetNumRule().GetLevel(0).GetBulletRelSize());
2799 
2800     xDocShRef->DoClose();
2801 }
2802 
testTdf109067()2803 void SdImportTest::testTdf109067()
2804 {
2805     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf109067.pptx"), PPTX);
2806     uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
2807     awt::Gradient gradient;
2808     CPPUNIT_ASSERT(xShape->getPropertyValue("FillGradient") >>= gradient);
2809     CPPUNIT_ASSERT_EQUAL(sal_Int16(450), gradient.Angle);
2810 
2811     xDocShRef->DoClose();
2812 }
2813 
testTdf109187()2814 void SdImportTest::testTdf109187()
2815 {
2816     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf109187.pptx"), PPTX);
2817     uno::Reference< beans::XPropertySet > xArrow1(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
2818     awt::Gradient aGradient1;
2819     CPPUNIT_ASSERT(xArrow1->getPropertyValue("FillGradient") >>= aGradient1);
2820     CPPUNIT_ASSERT_EQUAL(sal_Int16(2250), aGradient1.Angle);
2821     uno::Reference< beans::XPropertySet > xArrow2(getShapeFromPage(1, 0, xDocShRef), uno::UNO_SET_THROW);
2822     awt::Gradient aGradient2;
2823     CPPUNIT_ASSERT(xArrow2->getPropertyValue("FillGradient") >>= aGradient2);
2824     CPPUNIT_ASSERT_EQUAL(sal_Int16(1350), aGradient2.Angle);
2825 
2826     xDocShRef->DoClose();
2827 }
2828 
testTdf108926()2829 void SdImportTest::testTdf108926()
2830 {
2831     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf108926.ppt"), PPT);
2832     uno::Reference< presentation::XPresentationPage > xPage (getPage(0, xDocShRef), uno::UNO_QUERY_THROW);
2833     uno::Reference< drawing::XDrawPage > xNotesPage (xPage->getNotesPage(), uno::UNO_SET_THROW);
2834     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xNotesPage->getCount());
2835 
2836     // Second object should be imported as an empty presentation shape
2837     uno::Reference< beans::XPropertySet > xPresentationShape(xNotesPage->getByIndex(1), uno::UNO_QUERY);
2838     CPPUNIT_ASSERT(xPresentationShape.is());
2839     bool bIsEmptyPresObject = false;
2840     xPresentationShape->getPropertyValue( "IsEmptyPresentationObject" )  >>= bIsEmptyPresObject;
2841     CPPUNIT_ASSERT(bIsEmptyPresObject);
2842 
2843     xDocShRef->DoClose();
2844 }
2845 
testTdf100065()2846 void SdImportTest::testTdf100065()
2847 {
2848     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf100065.pptx"), PPTX);
2849 
2850     uno::Reference< container::XIndexAccess > xGroupShape1(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
2851     uno::Reference< beans::XPropertySet > xShape1(xGroupShape1->getByIndex(1), uno::UNO_QUERY_THROW);
2852     sal_Int32 nAngle1;
2853     CPPUNIT_ASSERT(xShape1->getPropertyValue("RotateAngle") >>= nAngle1);
2854     CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), nAngle1);
2855 
2856     uno::Reference< container::XIndexAccess > xGroupShape2(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
2857     uno::Reference< beans::XPropertySet > xShape2(xGroupShape2->getByIndex(0), uno::UNO_QUERY_THROW);
2858     sal_Int32 nAngle2;
2859     CPPUNIT_ASSERT(xShape2->getPropertyValue("RotateAngle") >>= nAngle2);
2860     CPPUNIT_ASSERT_EQUAL(sal_Int32(18000), nAngle2);
2861 
2862     xDocShRef->DoClose();
2863 }
2864 
testTdf90626()2865 void SdImportTest::testTdf90626()
2866 {
2867     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf90626.pptx"), PPTX);
2868     const SdrPage *pPage = GetPage(1, xDocShRef);
2869     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(pPage->GetObj(1));
2870     CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr);
2871     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
2872     for(int i = 0; i < 4; i++)
2873     {
2874         const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(i).GetItem(EE_PARA_NUMBULLET);
2875         CPPUNIT_ASSERT(pNumFmt);
2876         CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(372), pNumFmt->GetNumRule().GetLevel(0).GetGraphicSize().getHeight(), tools::Long(1));
2877     }
2878 
2879     xDocShRef->DoClose();
2880 }
2881 
testTdf138148()2882 void SdImportTest::testTdf138148()
2883 {
2884     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf138148.pptx"), PPTX);
2885     const SdrPage *pPage = GetPage(1, xDocShRef);
2886     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(pPage->GetObj(0));
2887     CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr);
2888     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
2889     for(int i = 0; i < 2; i++)
2890     {
2891         const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(i).GetItem(EE_PARA_NUMBULLET);
2892         CPPUNIT_ASSERT(pNumFmt);
2893         CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(444), pNumFmt->GetNumRule().GetLevel(0).GetGraphicSize().getHeight(), tools::Long(1));
2894 
2895         // Without the fix in place, this test would have failed with
2896         // - Expected: 148
2897         // - Actual  : 444
2898         CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(148), pNumFmt->GetNumRule().GetLevel(0).GetGraphicSize().getWidth(), tools::Long(1));
2899     }
2900 
2901     xDocShRef->DoClose();
2902 }
2903 
testTdf114488()2904 void SdImportTest::testTdf114488()
2905 {
2906     // This doc has two images - one WMF and the other PNG (fallback image).
2907     // When loading this doc, the WMF image should be preferred over the PNG image.
2908     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/odg/tdf114488.fodg"), FODG);
2909     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
2910     uno::Reference<graphic::XGraphic> xGraphic;
2911     xShape->getPropertyValue("Graphic") >>= xGraphic;
2912     CPPUNIT_ASSERT(xGraphic.is());
2913     OUString sMimeType(comphelper::GraphicMimeTypeHelper::GetMimeTypeForXGraphic(xGraphic));
2914     CPPUNIT_ASSERT_EQUAL(OUString("image/x-wmf"), sMimeType);
2915 
2916     xDocShRef->DoClose();
2917 }
2918 
testTdf134174()2919 void SdImportTest::testTdf134174()
2920 {
2921     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf134174.pptx"), PPTX);
2922     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
2923     CPPUNIT_ASSERT(xShape.is());
2924 
2925     uno::Reference<graphic::XGraphic> xGraphic;
2926     xShape->getPropertyValue("FillBitmap") >>= xGraphic;
2927     CPPUNIT_ASSERT(xGraphic.is());
2928 
2929     Graphic aGraphic(xGraphic);
2930     BitmapEx aBitmap(aGraphic.GetBitmapEx());
2931     CPPUNIT_ASSERT_EQUAL( Color(0x8b21db), aBitmap.GetPixelColor( 0, 0 ));
2932 
2933     xDocShRef->DoClose();
2934 }
2935 
testTdf134210()2936 void SdImportTest::testTdf134210()
2937 {
2938     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf134210.pptx"), PPTX);
2939     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
2940     CPPUNIT_ASSERT(xShape.is());
2941 
2942     uno::Reference<graphic::XGraphic> xGraphic;
2943     xShape->getPropertyValue("FillBitmap") >>= xGraphic;
2944     CPPUNIT_ASSERT(xGraphic.is());
2945 
2946     Graphic aGraphic(xGraphic);
2947     BitmapEx aBitmap(aGraphic.GetBitmapEx());
2948     CPPUNIT_ASSERT_EQUAL( Color(0x60563e), aBitmap.GetPixelColor( 0, 0 ));
2949 
2950     xDocShRef->DoClose();
2951 }
2952 
testTdf114913()2953 void SdImportTest::testTdf114913()
2954 {
2955     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf114913.pptx"), PPTX);
2956     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(GetPage(1, xDocShRef)->GetObj(1));
2957     CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr);
2958     const SvxNumBulletItem *pItem = pTxtObj->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
2959     CPPUNIT_ASSERT(pItem);
2960     CPPUNIT_ASSERT_EQUAL(tools::Long(692), pItem->GetNumRule().GetLevel(0).GetGraphicSize().getHeight());
2961 
2962     xDocShRef->DoClose();
2963 }
2964 
testTdf114821()2965 void SdImportTest::testTdf114821()
2966 {
2967     css::uno::Any aAny;
2968     sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc( u"/sd/qa/unit/data/pptx/tdf114821.pptx" ), PPTX );
2969 
2970     uno::Reference< beans::XPropertySet > xPropSet( getShapeFromPage( 0, 0, xDocShRef ) );
2971     aAny = xPropSet->getPropertyValue( "Model" );
2972     CPPUNIT_ASSERT_MESSAGE( "The shape doesn't have the property", aAny.hasValue() );
2973 
2974     uno::Reference< chart::XChartDocument > xChartDoc;
2975     aAny >>= xChartDoc;
2976     CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc.is() );
2977     uno::Reference< chart2::XChartDocument > xChart2Doc( xChartDoc, uno::UNO_QUERY );
2978     CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc.is() );
2979 
2980     uno::Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xChart2Doc->getFirstDiagram(), uno::UNO_QUERY );
2981     uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xBCooSysCnt->getCoordinateSystems() );
2982     uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[0], uno::UNO_QUERY );
2983 
2984     uno::Reference< chart2::XDataSeriesContainer > xDSCnt( xCTCnt->getChartTypes()[0], uno::UNO_QUERY );
2985     CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt.is() );
2986     uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() );
2987     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32>( 1 ), aSeriesSeq.getLength() );
2988 
2989     // These Labels have custom position, so the exported LabelPlacement (reference point) by MSO is OUTSIDE/OUTEND
2990     // Check the first label
2991     const css::uno::Reference< css::beans::XPropertySet >& rPropSet0( aSeriesSeq[0]->getDataPointByIndex( 0 ) );
2992     CPPUNIT_ASSERT( rPropSet0.is() );
2993     sal_Int32 aPlacement;
2994     rPropSet0->getPropertyValue( "LabelPlacement" ) >>= aPlacement;
2995     CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::OUTSIDE, aPlacement );
2996 
2997     // Check the second label
2998     const css::uno::Reference< css::beans::XPropertySet >& rPropSet1( aSeriesSeq[0]->getDataPointByIndex( 1 ) );
2999     CPPUNIT_ASSERT( rPropSet1.is() );
3000     rPropSet1->getPropertyValue( "LabelPlacement" ) >>= aPlacement;
3001     CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::OUTSIDE, aPlacement );
3002 
3003     // Check the third label
3004     const css::uno::Reference< css::beans::XPropertySet >& rPropSet2( aSeriesSeq[0]->getDataPointByIndex( 2 ) );
3005     CPPUNIT_ASSERT( rPropSet2.is() );
3006     rPropSet2->getPropertyValue( "LabelPlacement") >>= aPlacement;
3007     CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::OUTSIDE, aPlacement );
3008 
3009     xDocShRef->DoClose();
3010 }
3011 
testTdf115394()3012 void SdImportTest::testTdf115394()
3013 {
3014     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf115394.pptx"), PPTX);
3015     double fTransitionDuration;
3016 
3017     // Slow in MS formats
3018     SdPage* pPage1 = xDocShRef->GetDoc()->GetSdPage(0, PageKind::Standard);
3019     fTransitionDuration = pPage1->getTransitionDuration();
3020     CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration);
3021 
3022     // Medium in MS formats
3023     SdPage* pPage2 = xDocShRef->GetDoc()->GetSdPage(1, PageKind::Standard);
3024     fTransitionDuration = pPage2->getTransitionDuration();
3025     CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration);
3026 
3027     // Fast in MS formats
3028     SdPage* pPage3 = xDocShRef->GetDoc()->GetSdPage(2, PageKind::Standard);
3029     fTransitionDuration = pPage3->getTransitionDuration();
3030     CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration);
3031 
3032     // Custom values
3033     SdPage* pPage4 = xDocShRef->GetDoc()->GetSdPage(3, PageKind::Standard);
3034     fTransitionDuration = pPage4->getTransitionDuration();
3035     CPPUNIT_ASSERT_EQUAL(0.25, fTransitionDuration);
3036 
3037     SdPage* pPage5 = xDocShRef->GetDoc()->GetSdPage(4, PageKind::Standard);
3038     fTransitionDuration = pPage5->getTransitionDuration();
3039     CPPUNIT_ASSERT_EQUAL(4.25, fTransitionDuration);
3040 
3041     xDocShRef->DoClose();
3042 }
3043 
testTdf115394PPT()3044 void SdImportTest::testTdf115394PPT()
3045 {
3046     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/ppt/tdf115394.ppt"), PPT);
3047     double fTransitionDuration;
3048 
3049     // Fast
3050     SdPage* pPage1 = xDocShRef->GetDoc()->GetSdPage(0, PageKind::Standard);
3051     fTransitionDuration = pPage1->getTransitionDuration();
3052     CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration);
3053 
3054     // Medium
3055     SdPage* pPage2 = xDocShRef->GetDoc()->GetSdPage(1, PageKind::Standard);
3056     fTransitionDuration = pPage2->getTransitionDuration();
3057     CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration);
3058 
3059     // Slow
3060     SdPage* pPage3 = xDocShRef->GetDoc()->GetSdPage(2, PageKind::Standard);
3061     fTransitionDuration = pPage3->getTransitionDuration();
3062     CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration);
3063 
3064     xDocShRef->DoClose();
3065 }
3066 
testTdf51340()3067 void SdImportTest::testTdf51340()
3068 {
3069     // Line spacing was not inherited from upper levels (slide layout, master slide)
3070     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf51340.pptx"), PPTX);
3071     uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 1, 0, xDocShRef ) );
3072 
3073     // First paragraph has a 90% line spacing set on master slide
3074     uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
3075     uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
3076     css::style::LineSpacing aSpacing;
3077     xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
3078     CPPUNIT_ASSERT_EQUAL( css::style::LineSpacingMode::PROP, aSpacing.Mode );
3079     CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(90), aSpacing.Height );
3080 
3081     // Second paragraph has a 125% line spacing set on slide layout
3082     xParagraph.set( getParagraphFromShape( 1, xShape ) );
3083     xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
3084     xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
3085     CPPUNIT_ASSERT_EQUAL( css::style::LineSpacingMode::PROP, aSpacing.Mode );
3086     CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(125), aSpacing.Height );
3087 
3088     // Third paragraph has a 70% line spacing set directly on normal slide (master slide property is overridden)
3089     xParagraph.set( getParagraphFromShape( 2, xShape ) );
3090     xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
3091     xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
3092     CPPUNIT_ASSERT_EQUAL( css::style::LineSpacingMode::PROP, aSpacing.Mode );
3093     CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(70), aSpacing.Height );
3094 
3095     // Fourth paragraph has a 190% line spacing set directly on normal slide (slide layout property is overridden)
3096     xParagraph.set( getParagraphFromShape( 3, xShape ) );
3097     xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
3098     xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
3099     CPPUNIT_ASSERT_EQUAL( css::style::LineSpacingMode::PROP, aSpacing.Mode );
3100     CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(190), aSpacing.Height );
3101 
3102     xDocShRef->DoClose();
3103 }
3104 
testTdf116899()3105 void SdImportTest::testTdf116899()
3106 {
3107     // This is a PPT created in Impress and roundtripped in PP, the key times become [1, -1] in PP,
3108     //  a time of -1 (-1000) in PPT means key times have to be distributed evenly between 0 and 1
3109     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/ppt/tdf116899.ppt"), PPT);
3110 
3111     uno::Reference< drawing::XDrawPagesSupplier > xDoc(
3112         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
3113     uno::Reference< drawing::XDrawPage > xPage(
3114         xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
3115     uno::Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier(
3116         xPage, uno::UNO_QUERY_THROW );
3117     uno::Reference< animations::XAnimationNode > xRootNode(
3118         xAnimNodeSupplier->getAnimationNode() );
3119     std::vector< uno::Reference< animations::XAnimationNode > > aAnimVector;
3120     anim::create_deep_vector(xRootNode, aAnimVector);
3121     uno::Reference< animations::XAnimate > xNode(
3122         aAnimVector[8], uno::UNO_QUERY_THROW );
3123     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of key times in the animation node isn't 2.", static_cast<sal_Int32>(2), xNode->getKeyTimes().getLength() );
3124     CPPUNIT_ASSERT_EQUAL_MESSAGE( "First key time in the animation node isn't 0, key times aren't normalized.", 0., xNode->getKeyTimes()[0] );
3125     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second key time in the animation node isn't 1, key times aren't normalized.", 1., xNode->getKeyTimes()[1] );
3126 
3127     xDocShRef->DoClose();
3128 }
3129 
testTdf77747()3130 void SdImportTest::testTdf77747()
3131 {
3132     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/ppt/tdf77747.ppt"), PPT);
3133     CPPUNIT_ASSERT(xDocShRef.is());
3134     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(GetPage(1, xDocShRef)->GetObj(0));
3135     CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr);
3136     const SvxNumBulletItem *pNumFmt = pTxtObj->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
3137     CPPUNIT_ASSERT(pNumFmt);
3138     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", OUString("-"), pNumFmt->GetNumRule().GetLevel(0).GetSuffix() );
3139     CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's numbering type is wrong!", SVX_NUM_NUMBER_HEBREW,
3140             pNumFmt->GetNumRule().GetLevel(0).GetNumberingType());
3141 
3142     xDocShRef->DoClose();
3143 }
3144 
testTdf116266()3145 void SdImportTest::testTdf116266()
3146 {
3147     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf116266.odp"), ODP);
3148     SdDrawDocument *pDoc = xDocShRef->GetDoc();
3149     sfx2::LinkManager* rLinkManager = pDoc->GetLinkManager();
3150     // The document contains one SVG stored as a link.
3151     CPPUNIT_ASSERT_EQUAL(size_t(1), rLinkManager->GetLinks().size());
3152 
3153     xDocShRef->DoClose();
3154 }
3155 
testTdf120028()3156 void SdImportTest::testTdf120028()
3157 {
3158     // Check that the text shape has 4 columns.
3159     ::sd::DrawDocShellRef xDocShRef
3160         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf120028.pptx"), PPTX);
3161     uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(),
3162                                                      uno::UNO_QUERY);
3163     CPPUNIT_ASSERT(xDoc.is());
3164 
3165     uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
3166     CPPUNIT_ASSERT(xPage.is());
3167 
3168     uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage));
3169     uno::Reference<text::XTextColumns> xCols(xShape->getPropertyValue("TextColumns"),
3170                                              uno::UNO_QUERY_THROW);
3171     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(4), xCols->getColumnCount());
3172     uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW);
3173     CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xColProps->getPropertyValue("AutomaticDistance"));
3174 
3175     // Check font size in the shape.
3176     uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xShape));
3177     uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
3178     uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW);
3179     double fCharHeight = 0;
3180     xPropSet->getPropertyValue("CharHeight") >>= fCharHeight;
3181     CPPUNIT_ASSERT_DOUBLES_EQUAL(13.5, fCharHeight, 1E-12);
3182     // 13.5 * 86% is approx. 11.6 (the correct scaled font size)
3183     CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int16(86)), xShape->getPropertyValue("TextFitToSizeScale"));
3184 
3185     xDocShRef->DoClose();
3186 }
3187 
testDescriptionImport()3188 void SdImportTest::testDescriptionImport()
3189 {
3190     sd::DrawDocShellRef xDocShRef
3191         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/altdescription.pptx"), PPTX);
3192 
3193     uno::Reference<beans::XPropertySet> xPropertySet(
3194         getShapeFromPage(/*nShape=*/2, /*nPage=*/0, xDocShRef));
3195     OUString sDesc;
3196 
3197     xPropertySet->getPropertyValue("Description") >>= sDesc;
3198 
3199     CPPUNIT_ASSERT_EQUAL(OUString("We Can Do It!"), sDesc);
3200 
3201     xDocShRef->DoClose();
3202 }
3203 
testTdf83247()3204 void SdImportTest::testTdf83247()
3205 {
3206     auto GetPause = [this](const OUString& sSrc, sal_Int32 nFormat) {
3207         sd::DrawDocShellRef xDocShRef
3208             = loadURL(m_directories.getURLFromSrc(sSrc), nFormat);
3209         uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(
3210             xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
3211         uno::Reference<beans::XPropertySet> xPresentationProps(
3212             xPresentationSupplier->getPresentation(), uno::UNO_QUERY_THROW);
3213 
3214         auto retVal = xPresentationProps->getPropertyValue("Pause");
3215         xDocShRef->DoClose();
3216         return retVal.get<sal_Int32>();
3217     };
3218 
3219     // 1. Check that presentation:pause attribute is imported correctly
3220     CPPUNIT_ASSERT_EQUAL(sal_Int32(10), GetPause("/sd/qa/unit/data/odp/loopPause10.odp", ODP));
3221 
3222     // 2. ODF compliance: if presentation:pause attribute is absent, it must be treated as 0
3223     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause("/sd/qa/unit/data/odp/loopNoPause.odp", ODP));
3224 
3225     // 3. Import PPT: pause should be 0
3226     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause("/sd/qa/unit/data/ppt/loopNoPause.ppt", PPT));
3227 }
3228 
testTdf47365()3229 void SdImportTest::testTdf47365()
3230 {
3231     sd::DrawDocShellRef xDocShRef
3232         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/loopNoPause.pptx"), PPTX);
3233     uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(
3234         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
3235     uno::Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(),
3236                                                            uno::UNO_QUERY_THROW);
3237 
3238     const bool bEndlessVal = xPresentationProps->getPropertyValue("IsEndless").get<bool>();
3239     const sal_Int32 nPauseVal = xPresentationProps->getPropertyValue("Pause").get<sal_Int32>();
3240 
3241     // Check that we import "loop" attribute of the presentation, and don't introduce any pauses
3242     CPPUNIT_ASSERT(bEndlessVal);
3243     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPauseVal);
3244 
3245     xDocShRef->DoClose();
3246 }
3247 
testTdf122899()3248 void SdImportTest::testTdf122899()
3249 {
3250     // tdf122899 FILEOPEN: ppt: old kind arc from MS Office 97 is broken
3251     // Error was, that the path coordinates of a mso_sptArc shape were read as sal_Int16
3252     // although they are unsigned 16 bit. This leads to wrong positions of start and end
3253     // point and results to a huge shape width in the test document.
3254     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/ppt/tdf122899_Arc_90_to_91_clockwise.ppt"), PPT);
3255     uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(
3256         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
3257     CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
3258     uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
3259     uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
3260     CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage.is());
3261     uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
3262     CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape.is());
3263     awt::Rectangle aFrameRect;
3264     uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
3265     CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps.is());
3266     xShapeProps->getPropertyValue(UNO_NAME_MISC_OBJ_FRAMERECT) >>= aFrameRect;
3267     // original width is 9cm, add some tolerance
3268     CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(9020), aFrameRect.Width);
3269 
3270     xDocShRef->DoClose();
3271 }
3272 
testOOXTheme()3273 void SdImportTest::testOOXTheme()
3274 {
3275     sd::DrawDocShellRef xDocShRef
3276         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/ooxtheme.pptx"), PPTX);
3277 
3278     uno::Reference<beans::XPropertySet> xPropSet(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
3279     uno::Sequence<beans::PropertyValue> aGrabBag;
3280     xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
3281 
3282     bool bTheme = false;
3283     for (beans::PropertyValue const & prop : std::as_const(aGrabBag))
3284     {
3285         if (prop.Name == "OOXTheme")
3286         {
3287             bTheme = true;
3288             uno::Reference<xml::dom::XDocument> aThemeDom;
3289             CPPUNIT_ASSERT(prop.Value >>= aThemeDom); // PropertyValue of proper type
3290             CPPUNIT_ASSERT(aThemeDom); // Reference not empty
3291         }
3292     }
3293     CPPUNIT_ASSERT(bTheme); // Grab Bag has all the expected elements
3294 
3295     xDocShRef->DoClose();
3296 }
3297 
testCropToShape()3298 void SdImportTest::testCropToShape()
3299 {
3300     sd::DrawDocShellRef xDocShRef
3301         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/crop-to-shape.pptx"), PPTX);
3302     uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(
3303         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
3304     CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
3305     uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
3306     uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
3307     CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage.is());
3308     uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
3309     CPPUNIT_ASSERT_EQUAL(OUString{"com.sun.star.drawing.CustomShape"}, xShape->getShapeType());
3310     CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape.is());
3311     uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
3312     css::drawing::FillStyle fillStyle;
3313     xShapeProps->getPropertyValue("FillStyle") >>= fillStyle;
3314     CPPUNIT_ASSERT_EQUAL(css::drawing::FillStyle_BITMAP, fillStyle);
3315     css::drawing::BitmapMode bitmapmode;
3316     xShapeProps->getPropertyValue("FillBitmapMode") >>= bitmapmode;
3317     CPPUNIT_ASSERT_EQUAL(css::drawing::BitmapMode_STRETCH, bitmapmode);
3318 }
3319 
testTdf127964()3320 void SdImportTest::testTdf127964()
3321 {
3322     sd::DrawDocShellRef xDocShRef
3323         = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf127964.pptx"), PPTX);
3324     const SdrPage* pPage = GetPage(1, xDocShRef);
3325     const SdrObject* pObj = pPage->GetObj(0);
3326     auto& rFillStyleItem
3327         = dynamic_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE));
3328     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rFillStyleItem.GetValue());
3329 
3330     auto& rFillColorItem
3331         = dynamic_cast<const XFillColorItem&>(pObj->GetMergedItem(XATTR_FILLCOLOR));
3332     // Without the accompanying fix in place, this test would have failed with:
3333     // - Expected: 4294967295
3334     // - Actual  : 5210557
3335     // i.e. instead of transparent (which then got rendered as white), the shape fill color was
3336     // blue.
3337     CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, rFillColorItem.GetColorValue());
3338     xDocShRef->DoClose();
3339 }
3340 
testTdf106638()3341 void SdImportTest::testTdf106638()
3342 {
3343     sd::DrawDocShellRef xDocShRef
3344         = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf106638.pptx"), PPTX);
3345     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
3346     uno::Reference<text::XTextRange> const xPara(getParagraphFromShape(1, xShape));
3347     uno::Reference<text::XText> xText= xPara->getText();
3348     uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursorByRange(xPara->getStart());
3349     uno::Reference<beans::XPropertySet> xPropSet(xTextCursor, uno::UNO_QUERY_THROW );
3350     OUString aCharFontName;
3351     CPPUNIT_ASSERT(xTextCursor->goRight(1, true));
3352     // First character U+f0fe that uses Wingding
3353     xPropSet->getPropertyValue("CharFontName") >>= aCharFontName;
3354     CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), aCharFontName);
3355 
3356     // The rest characters that do not use Wingding.
3357     CPPUNIT_ASSERT(xTextCursor->goRight(45, true));
3358     xPropSet->getPropertyValue("CharFontName") >>= aCharFontName;
3359     CPPUNIT_ASSERT(aCharFontName != "Wingdings");
3360 }
3361 
testTdf128684()3362 void SdImportTest::testTdf128684()
3363 {
3364     sd::DrawDocShellRef xDocShRef
3365         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf128684.pptx"), PPTX);
3366     uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(),
3367                                                      uno::UNO_QUERY);
3368     CPPUNIT_ASSERT(xDoc.is());
3369     uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
3370     CPPUNIT_ASSERT(xPage.is());
3371     uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage));
3372     CPPUNIT_ASSERT(xShape.is());
3373     uno::Any aAny = xShape->getPropertyValue("CustomShapeGeometry");
3374     CPPUNIT_ASSERT(aAny.hasValue());
3375     uno::Sequence<beans::PropertyValue> aProps;
3376     CPPUNIT_ASSERT(aAny >>= aProps);
3377     sal_Int32 nRotateAngle = 0;
3378     for( const auto& rProp : std::as_const(aProps) )
3379     {
3380         if( rProp.Name == "TextPreRotateAngle")
3381         {
3382             rProp.Value >>= nRotateAngle;
3383         }
3384     }
3385     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-90), nRotateAngle);
3386 }
3387 
testTdf113198()3388 void SdImportTest::testTdf113198()
3389 {
3390     sd::DrawDocShellRef xDocShRef
3391         = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/tdf113198.pptx"), PPTX);
3392 
3393     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
3394     sal_Int16 nParaAdjust = -1;
3395     xShape->getPropertyValue("ParaAdjust") >>= nParaAdjust;
3396     CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(nParaAdjust));
3397 }
3398 
3399 
testTdf49856()3400 void SdImportTest::testTdf49856()
3401 {
3402     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/ppt/tdf49856.ppt"), PPT);
3403     const SdrPage *pPage = GetPage(1, xDocShRef);
3404     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(pPage->GetObj(1));
3405     CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr);
3406     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
3407     const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET);
3408     CPPUNIT_ASSERT(pNumFmt);
3409     const sal_UCS4 aBullet = pNumFmt->GetNumRule().GetLevel(0).GetBulletChar();
3410     CPPUNIT_ASSERT_EQUAL(OUString("More level 2"), aEdit.GetText(2));
3411     CPPUNIT_ASSERT_EQUAL(sal_UCS4(0x2022), aBullet);
3412 
3413     xDocShRef->DoClose();
3414 }
3415 
testShapeGlowEffectPPTXImpoer()3416 void SdImportTest::testShapeGlowEffectPPTXImpoer()
3417 {
3418     sd::DrawDocShellRef xDocShRef
3419         = loadURL(
3420             m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/shape-glow-effect.pptx"), PPTX);
3421 
3422     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
3423     sal_Int32 nRadius = -1;
3424     xShape->getPropertyValue("GlowEffectRadius") >>= nRadius;
3425     CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRadius); // 139700 EMU = 388.0556 mm/100
3426     Color nColor;
3427     xShape->getPropertyValue("GlowEffectColor") >>= nColor;
3428     CPPUNIT_ASSERT_EQUAL(Color(0xFFC000), nColor);
3429     sal_Int16 nTransparency;
3430     xShape->getPropertyValue("GlowEffectTransparency") >>= nTransparency;
3431     CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nTransparency);
3432 }
3433 
testShapeBlurPPTXImport()3434 void SdImportTest::testShapeBlurPPTXImport()
3435 {
3436     sd::DrawDocShellRef xDocShRef
3437             = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/shape-blur-effect.pptx"), PPTX);
3438 
3439     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
3440     bool bHasShadow = false;
3441     xShape->getPropertyValue("Shadow") >>= bHasShadow;
3442     CPPUNIT_ASSERT(bHasShadow);
3443 
3444     sal_Int32 nRadius = -1;
3445     xShape->getPropertyValue("ShadowBlur") >>= nRadius;
3446     CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRadius); // 584200EMU=46pt - 139700EMU = 388Hmm = 11pt
3447 
3448 }
3449 
testMirroredGraphic()3450 void SdImportTest::testMirroredGraphic()
3451 {
3452     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/mirrored-graphic.pptx"), PPTX);
3453     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
3454     CPPUNIT_ASSERT(xShape.is());
3455     uno::Reference<graphic::XGraphic> xGraphic;
3456     xShape->getPropertyValue("FillBitmap") >>= xGraphic;
3457     CPPUNIT_ASSERT(xGraphic.is());
3458     Graphic aGraphic(xGraphic);
3459     BitmapEx aBitmap(aGraphic.GetBitmapEx());
3460     CPPUNIT_ASSERT_EQUAL( Color(0x4f4955), aBitmap.GetPixelColor( 0, 0 ));
3461     xDocShRef->DoClose();
3462 }
3463 
testTdf134210CropPosition()3464 void SdImportTest::testTdf134210CropPosition()
3465 {
3466     // We are testing crop position of bitmap in custom shapes. We should see only green with proper fix.
3467     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/crop-position.pptx"), PPTX);
3468     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
3469     CPPUNIT_ASSERT(xShape.is());
3470     uno::Reference<graphic::XGraphic> xGraphic;
3471     xShape->getPropertyValue("FillBitmap") >>= xGraphic;
3472     CPPUNIT_ASSERT(xGraphic.is());
3473     Graphic aGraphic(xGraphic);
3474     BitmapEx aBitmap(aGraphic.GetBitmapEx());
3475     CPPUNIT_ASSERT_EQUAL( Color(0x81d41a), aBitmap.GetPixelColor( 0, 0 ));
3476     xDocShRef->DoClose();
3477 }
3478 
testGreysScaleGraphic()3479 void SdImportTest::testGreysScaleGraphic()
3480 {
3481     sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/greysscale-graphic.pptx"), PPTX);
3482     uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
3483     CPPUNIT_ASSERT(xShape.is());
3484     uno::Reference<graphic::XGraphic> xGraphic;
3485     xShape->getPropertyValue("FillBitmap") >>= xGraphic;
3486     CPPUNIT_ASSERT(xGraphic.is());
3487     Graphic aGraphic(xGraphic);
3488     BitmapEx aBitmap(aGraphic.GetBitmapEx());
3489     CPPUNIT_ASSERT_EQUAL( Color(0x3c3c3c), aBitmap.GetPixelColor( 0, 0 ));
3490     xDocShRef->DoClose();
3491 }
3492 
testTdf103347()3493 void SdImportTest::testTdf103347()
3494 {
3495     sd::DrawDocShellRef xDocShRef
3496         = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf103347.pptx"), PPTX);
3497     uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(),
3498                                                      uno::UNO_QUERY_THROW);
3499 
3500     uno::Reference<drawing::XDrawPage> xPage1(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
3501     uno::Reference<container::XNamed> xNamed1(xPage1, uno::UNO_QUERY_THROW);
3502     CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xNamed1->getName());
3503 
3504     uno::Reference<drawing::XDrawPage> xPage2(xDoc->getDrawPages()->getByIndex(1), uno::UNO_QUERY);
3505     uno::Reference<container::XNamed> xNamed2(xPage2, uno::UNO_QUERY_THROW);
3506     CPPUNIT_ASSERT_EQUAL(OUString("Hello (2)"), xNamed2->getName());
3507 
3508     uno::Reference<drawing::XDrawPage> xPage3(xDoc->getDrawPages()->getByIndex(2), uno::UNO_QUERY);
3509     uno::Reference<container::XNamed> xNamed3(xPage3, uno::UNO_QUERY_THROW);
3510     CPPUNIT_ASSERT_EQUAL(OUString("Hello (3)"), xNamed3->getName());
3511 
3512     xDocShRef->DoClose();
3513 }
3514 
3515 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
3516 
3517 CPPUNIT_PLUGIN_IMPLEMENT();
3518 
3519 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
3520