Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / sd / qa / unit / import-tests.cxx
blob191592bbc592fe457805e9291cb4312e77bb27c9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #include <config_poppler.h>
11 #include <ostream>
12 #include <sdpage.hxx>
14 #include "sdmodeltestbase.hxx"
16 #include <svl/stritem.hxx>
17 #include <editeng/eeitem.hxx>
18 #include <editeng/editobj.hxx>
19 #include <editeng/outlobj.hxx>
20 #include <editeng/ulspitem.hxx>
21 #include <editeng/fhgtitem.hxx>
22 #include <editeng/escapementitem.hxx>
23 #include <editeng/colritem.hxx>
24 #include <editeng/numitem.hxx>
25 #include <editeng/unoprnms.hxx>
26 #include <svl/style.hxx>
28 #include <svx/svdotext.hxx>
29 #include <svx/svdoashp.hxx>
30 #include <svx/svdogrp.hxx>
31 #include <svx/svdoole2.hxx>
32 #include <svx/svdotable.hxx>
33 #include <svx/xfillit0.hxx>
34 #include <svx/xflclit.hxx>
35 #include <svx/xlineit0.hxx>
36 #include <svx/xlnclit.hxx>
37 #include <svx/xlnwtit.hxx>
38 #include <svx/sdasitm.hxx>
39 #include <svx/sdmetitm.hxx>
40 #include <svx/sdooitm.hxx>
41 #include <animations/animationnodehelper.hxx>
42 #include <sax/tools/converter.hxx>
44 #include <com/sun/star/awt/Gradient.hpp>
45 #include <com/sun/star/awt/XBitmap.hpp>
46 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
47 #include <com/sun/star/document/XEventsSupplier.hpp>
48 #include <com/sun/star/presentation/ClickAction.hpp>
49 #include <com/sun/star/presentation/XPresentationPage.hpp>
50 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
51 #include <com/sun/star/drawing/BitmapMode.hpp>
52 #include <com/sun/star/drawing/ColorMode.hpp>
53 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
54 #include <com/sun/star/drawing/XDrawPage.hpp>
55 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
56 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
57 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
58 #include <com/sun/star/drawing/GluePoint2.hpp>
59 #include <com/sun/star/container/XIdentifierAccess.hpp>
60 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
61 #include <com/sun/star/animations/XAnimationNode.hpp>
62 #include <com/sun/star/animations/XAnimate.hpp>
63 #include <com/sun/star/beans/XPropertySet.hpp>
64 #include <com/sun/star/chart/DataLabelPlacement.hpp>
65 #include <com/sun/star/chart/XChartDocument.hpp>
66 #include <com/sun/star/chart2/XChartDocument.hpp>
67 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
68 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
69 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
70 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
71 #include <com/sun/star/chart2/data/XDataSequence.hpp>
72 #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
73 #include <com/sun/star/graphic/XGraphic.hpp>
74 #include <com/sun/star/table/BorderLineStyle.hpp>
75 #include <com/sun/star/table/BorderLine2.hpp>
76 #include <com/sun/star/style/ParagraphAdjust.hpp>
77 #include <com/sun/star/style/LineSpacing.hpp>
78 #include <com/sun/star/style/LineSpacingMode.hpp>
79 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
80 #include <com/sun/star/table/XTableRows.hpp>
81 #include <com/sun/star/style/NumberingType.hpp>
82 #include <com/sun/star/frame/Desktop.hpp>
83 #include <com/sun/star/text/GraphicCrop.hpp>
84 #include <com/sun/star/text/XTextCursor.hpp>
85 #include <com/sun/star/xml/dom/XDocument.hpp>
87 #include <stlpool.hxx>
88 #include <comphelper/processfactory.hxx>
89 #include <comphelper/sequenceashashmap.hxx>
90 #include <comphelper/graphicmimetype.hxx>
91 #include <comphelper/lok.hxx>
92 #include <vcl/pngread.hxx>
93 #include <vcl/bitmapaccess.hxx>
94 #include <vcl/dibtools.hxx>
95 #include <svx/svdograf.hxx>
97 using namespace ::com::sun::star;
99 namespace com { namespace sun { namespace star { namespace uno {
101 template<class T>
102 static std::ostream& operator<<(std::ostream& rStrm, const uno::Reference<T>& xRef)
104 rStrm << xRef.get();
105 return rStrm;
108 } } } }
111 /// Impress import filters tests.
112 class SdImportTest : public SdModelTestBase
114 public:
115 virtual void setUp() override;
117 void testDocumentLayout();
118 void testSmoketest();
119 void testN759180();
120 void testN778859();
121 void testMasterPageStyleParent();
122 void testGradientAngle();
123 void testTdf97808();
124 void testFdo64512();
125 void testFdo71075();
126 void testN828390_2();
127 void testN828390_3();
128 void testFdo68594();
129 void testFdo72998();
130 void testFdo77027();
131 void testStrictOOXML();
132 void testN862510_1();
133 void testN862510_2();
134 void testN862510_4();
135 void testBnc870237();
136 void testBnc887225();
137 void testBnc591147();
138 void testCreationDate();
139 void testBnc584721_1();
140 void testBnc584721_2();
141 void testBnc584721_4();
142 void testBnc904423();
143 void testShapeLineStyle();
144 void testTableBorderLineStyle();
145 void testBnc862510_6();
146 void testBnc862510_7();
147 #if ENABLE_PDFIMPORT
148 void testPDFImportShared();
149 #if defined(IMPORT_PDF_ELEMENTS)
150 void testPDFImport();
151 void testPDFImportSkipImages();
152 #endif
153 #endif
154 void testBulletSuffix();
155 void testBnc910045();
156 void testRowHeight();
157 void testTdf93830();
158 void testTdf127129();
159 void testTdf93097();
160 void testTdf62255();
161 void testTdf93124();
162 void testTdf99729();
163 void testTdf89927();
164 void testTdf93868();
165 void testTdf95932();
166 void testTdf99030();
167 void testTdf49561();
168 void testTdf103473();
169 void testAoo124143();
170 void testTdf103567();
171 void testTdf103792();
172 void testTdf103876();
173 void testTdf79007();
174 void testTdf104015();
175 void testTdf104201();
176 void testTdf103477();
177 void testTdf104445();
178 void testTdf105150();
179 void testTdf105150PPT();
180 void testTdf123684();
181 void testTdf100926();
182 void testTdf89064();
183 void testTdf108925();
184 void testTdf109067();
185 void testTdf109187();
186 void testTdf108926();
187 void testTdf100065();
188 void testTdf90626();
189 void testTdf114488();
190 void testTdf114913();
191 void testTdf114821();
192 void testTdf115394();
193 void testTdf115394PPT();
194 void testTdf51340();
195 void testTdf116899();
196 void testTdf77747();
197 void testTdf116266();
198 void testTdf126324();
200 bool checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected);
201 void testPatternImport();
202 void testPptCrop();
203 void testTdf119015();
204 void testTdf123090();
205 void testTdf120028();
206 void testTdf120028b();
207 void testDescriptionImport();
208 void testTdf83247();
209 void testTdf47365();
210 void testTdf122899();
211 void testOOXTheme();
212 void testCropToShape();
213 void testTdf127964();
214 void testTdf106638();
216 CPPUNIT_TEST_SUITE(SdImportTest);
218 CPPUNIT_TEST(testDocumentLayout);
219 CPPUNIT_TEST(testSmoketest);
220 CPPUNIT_TEST(testN759180);
221 CPPUNIT_TEST(testN778859);
222 CPPUNIT_TEST(testMasterPageStyleParent);
223 CPPUNIT_TEST(testGradientAngle);
224 CPPUNIT_TEST(testTdf97808);
225 CPPUNIT_TEST(testFdo64512);
226 CPPUNIT_TEST(testFdo71075);
227 CPPUNIT_TEST(testN828390_2);
228 CPPUNIT_TEST(testN828390_3);
229 CPPUNIT_TEST(testFdo68594);
230 CPPUNIT_TEST(testFdo72998);
231 CPPUNIT_TEST(testFdo77027);
232 CPPUNIT_TEST(testStrictOOXML);
233 CPPUNIT_TEST(testN862510_1);
234 CPPUNIT_TEST(testN862510_2);
235 CPPUNIT_TEST(testN862510_4);
236 CPPUNIT_TEST(testBnc870237);
237 CPPUNIT_TEST(testBnc887225);
238 CPPUNIT_TEST(testBnc591147);
239 CPPUNIT_TEST(testCreationDate);
240 CPPUNIT_TEST(testBnc584721_1);
241 CPPUNIT_TEST(testBnc584721_2);
242 CPPUNIT_TEST(testBnc584721_4);
243 CPPUNIT_TEST(testBnc904423);
244 CPPUNIT_TEST(testShapeLineStyle);
245 CPPUNIT_TEST(testTableBorderLineStyle);
246 CPPUNIT_TEST(testBnc862510_6);
247 CPPUNIT_TEST(testBnc862510_7);
248 #if ENABLE_PDFIMPORT
249 CPPUNIT_TEST(testPDFImportShared);
250 #if defined(IMPORT_PDF_ELEMENTS)
251 CPPUNIT_TEST(testPDFImport);
252 CPPUNIT_TEST(testPDFImportSkipImages);
253 #endif
254 #endif
255 CPPUNIT_TEST(testBulletSuffix);
256 CPPUNIT_TEST(testBnc910045);
257 CPPUNIT_TEST(testRowHeight);
258 CPPUNIT_TEST(testTdf93830);
259 CPPUNIT_TEST(testTdf127129);
260 CPPUNIT_TEST(testTdf93097);
261 CPPUNIT_TEST(testTdf62255);
262 CPPUNIT_TEST(testTdf93124);
263 CPPUNIT_TEST(testTdf99729);
264 CPPUNIT_TEST(testTdf89927);
265 CPPUNIT_TEST(testTdf93868);
266 CPPUNIT_TEST(testTdf95932);
267 CPPUNIT_TEST(testTdf99030);
268 CPPUNIT_TEST(testTdf49561);
269 CPPUNIT_TEST(testTdf103473);
270 CPPUNIT_TEST(testAoo124143);
271 CPPUNIT_TEST(testTdf103567);
272 CPPUNIT_TEST(testTdf103792);
273 CPPUNIT_TEST(testTdf103876);
274 CPPUNIT_TEST(testTdf79007);
275 CPPUNIT_TEST(testTdf104015);
276 CPPUNIT_TEST(testTdf104201);
277 CPPUNIT_TEST(testTdf103477);
278 CPPUNIT_TEST(testTdf104445);
279 CPPUNIT_TEST(testTdf105150);
280 CPPUNIT_TEST(testTdf105150PPT);
281 CPPUNIT_TEST(testTdf123684);
282 CPPUNIT_TEST(testTdf100926);
283 CPPUNIT_TEST(testPatternImport);
284 CPPUNIT_TEST(testTdf89064);
285 CPPUNIT_TEST(testTdf108925);
286 CPPUNIT_TEST(testTdf109067);
287 CPPUNIT_TEST(testTdf109187);
288 CPPUNIT_TEST(testTdf108926);
289 CPPUNIT_TEST(testTdf100065);
290 CPPUNIT_TEST(testTdf90626);
291 CPPUNIT_TEST(testTdf114488);
292 CPPUNIT_TEST(testTdf114913);
293 CPPUNIT_TEST(testTdf114821);
294 CPPUNIT_TEST(testTdf115394);
295 CPPUNIT_TEST(testTdf126324);
296 CPPUNIT_TEST(testTdf115394PPT);
297 CPPUNIT_TEST(testTdf51340);
298 CPPUNIT_TEST(testTdf116899);
299 CPPUNIT_TEST(testTdf77747);
300 CPPUNIT_TEST(testTdf116266);
301 CPPUNIT_TEST(testPptCrop);
302 CPPUNIT_TEST(testTdf119015);
303 CPPUNIT_TEST(testTdf123090);
304 CPPUNIT_TEST(testTdf120028);
305 CPPUNIT_TEST(testTdf120028b);
306 CPPUNIT_TEST(testDescriptionImport);
307 CPPUNIT_TEST(testTdf83247);
308 CPPUNIT_TEST(testTdf47365);
309 CPPUNIT_TEST(testTdf122899);
310 CPPUNIT_TEST(testOOXTheme);
311 CPPUNIT_TEST(testCropToShape);
312 CPPUNIT_TEST(testTdf127964);
313 CPPUNIT_TEST(testTdf106638);
315 CPPUNIT_TEST_SUITE_END();
318 void SdImportTest::setUp()
320 SdModelTestBase::setUp();
321 mxDesktop.set(frame::Desktop::create(getComponentContext()));
324 /** Test document against a reference XML dump of shapes.
326 If you want to update one of these tests, or add a new one, set the nUpdateMe
327 to the index of the test, and the dump XML's will be created (or rewritten)
328 instead of checking. Use with care - when the test is failing, first find out
329 why, instead of just updating .xml's blindly.
331 Example: Let's say you are adding a test called fdoABCD.pptx. You'll place it
332 to the data/ subdirectory, and will add an entry to aFilesToCompare below,
333 the 3rd parameter is for export test - can be -1 (don't export), ODP, PPT or PPTX
334 like:
336 { "fdoABCD.pptx", "xml/fdoABCD_", PPTX },
338 and will count the index in the aFilesToCompare structure (1st is 0, 2nd is 1,
339 etc.) Temporarily you'll set nUpdateMe to this index (instead of -1), and run
341 make sd
343 This will generate the sd/qa/unit/data/xml/fdoABCD_*.xml for you. Now you
344 will change nUpdateMe back to -1, and commit your fdoABCD.pptx test, the
345 xml/fdoABCD_*.xml dumps, and the aFilesToCompare addition in one commit.
347 As the last step, you will revert your fix and do 'make sd' again, to check
348 that without your fix, the unit test breaks. Then clean up, and push :-)
350 NOTE: This approach is suitable only for tests of fixes that actually change
351 the layout - best to check by reverting your fix locally after having added
352 the test, and re-running; it should break.
354 void SdImportTest::testDocumentLayout()
356 static const struct { const char *pInput, *pDump; sal_Int32 nFormat; sal_Int32 nExportType; } aFilesToCompare[] =
358 { "odp/shapes-test.odp", "xml/shapes-test_page", ODP, -1 },
359 { "fdo47434.pptx", "xml/fdo47434_", PPTX, -1 },
360 { "n758621.ppt", "xml/n758621_", PPT, -1 },
361 { "fdo64586.ppt", "xml/fdo64586_", PPT, -1 },
362 { "n819614.pptx", "xml/n819614_", PPTX, -1 },
363 { "n820786.pptx", "xml/n820786_", PPTX, -1 },
364 { "n762695.pptx", "xml/n762695_", PPTX, -1 },
365 { "n593612.pptx", "xml/n593612_", PPTX, -1 },
366 { "fdo71434.pptx", "xml/fdo71434_", PPTX, -1 },
367 { "n902652.pptx", "xml/n902652_", PPTX, -1 },
368 { "tdf90403.pptx", "xml/tdf90403_", PPTX, -1 },
369 { "tdf90338.odp", "xml/tdf90338_", ODP, PPTX },
370 { "tdf92001.odp", "xml/tdf92001_", ODP, PPTX },
371 // GCC -mfpmath=387 rounding issues in lclPushMarkerProperties
372 // (oox/source/drawingml/lineproperties.cxx); see mail sub-thread starting at
373 // <https://lists.freedesktop.org/archives/libreoffice/2016-September/
374 // 075211.html> "Re: Test File: sc/qa/unit/data/functions/fods/chiinv.fods:
375 // fails with Assertion" for how "-mfpmath=sse -msse2" would fix that:
376 #if !(defined LINUX && defined X86)
377 { "tdf100491.pptx", "xml/tdf100491_", PPTX, -1 },
378 #endif
379 { "tdf109317.pptx", "xml/tdf109317_", PPTX, ODP},
380 // { "pptx/n828390.pptx", "pptx/xml/n828390_", PPTX, PPTX }, // Example
383 for ( int i = 0; i < static_cast< int >( SAL_N_ELEMENTS( aFilesToCompare ) ); ++i )
385 int const nUpdateMe = -1; // index of test we want to update; supposedly only when the test is created
387 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pInput ), aFilesToCompare[i].nFormat );
388 if( aFilesToCompare[i].nExportType >= 0 )
389 xDocShRef = saveAndReload( xDocShRef.get(), aFilesToCompare[i].nExportType );
390 compareWithShapesDump( xDocShRef,
391 m_directories.getPathFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pDump ),
392 i == nUpdateMe );
396 void SdImportTest::testSmoketest()
398 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/smoketest.pptx"), PPTX);
400 SdDrawDocument *pDoc = xDocShRef->GetDoc();
401 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
403 // cf. SdrModel svx/svdmodel.hxx ...
405 CPPUNIT_ASSERT_EQUAL_MESSAGE( "wrong page count", static_cast<sal_uInt16>(3), pDoc->GetPageCount());
407 const SdrPage *pPage = pDoc->GetPage (1);
408 CPPUNIT_ASSERT_MESSAGE( "no page", pPage != nullptr );
410 CPPUNIT_ASSERT_MESSAGE( "changed", !pDoc->IsChanged() );
412 xDocShRef->DoClose();
415 void SdImportTest::testN759180()
417 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/n759180.pptx"), PPTX);
419 const SdrPage *pPage = GetPage( 1, xDocShRef );
421 //sal_uIntPtr nObjs = pPage->GetObjCount();
422 //for (sal_uIntPtr i = 0; i < nObjs; i++)
424 // Get the object
425 SdrObject *pObj = pPage->GetObj(0);
426 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
427 CPPUNIT_ASSERT(pTxtObj);
428 std::vector<EECharAttrib> rLst;
429 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
430 const SvxULSpaceItem *pULSpace = aEdit.GetParaAttribs(0).GetItem(EE_PARA_ULSPACE);
431 CPPUNIT_ASSERT(pULSpace);
432 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Para bottom spacing is wrong!", static_cast<sal_uInt16>(0), pULSpace->GetLower());
433 aEdit.GetCharAttribs(1, rLst);
434 auto it = std::find_if(rLst.rbegin(), rLst.rend(),
435 [](const EECharAttrib& rCharAttr) { return dynamic_cast<const SvxFontHeightItem *>(rCharAttr.pAttr) != nullptr; });
436 if (it != rLst.rend())
438 const SvxFontHeightItem * pFontHeight = dynamic_cast<const SvxFontHeightItem *>((*it).pAttr);
439 // nStart == 9
440 // font height = 5 => 5*2540/72
441 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font height is wrong", static_cast<sal_uInt32>(176), pFontHeight->GetHeight() );
445 xDocShRef->DoClose();
448 void SdImportTest::testN862510_1()
450 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n862510_1.pptx"), PPTX );
452 const SdrPage *pPage = GetPage( 1, xDocShRef );
454 std::vector<EECharAttrib> rLst;
455 SdrObject *pObj = pPage->GetObj( 0 );
456 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
457 CPPUNIT_ASSERT( pTxtObj );
458 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
459 aEdit.GetCharAttribs( 0, rLst );
460 for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
462 const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>( (*it).pAttr );
463 CPPUNIT_ASSERT_MESSAGE( "Baseline attribute not handled properly", !(pFontEscapement && pFontEscapement->GetProportionalHeight() != 100) );
467 xDocShRef->DoClose();
470 void SdImportTest::testN862510_2()
472 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n862510_2.pptx"), PPTX );
474 const SdrPage *pPage = GetPage( 1, xDocShRef );
476 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
477 SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 0 ) );
478 CPPUNIT_ASSERT( pGrpObj );
479 SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( pGrpObj->GetSubList()->GetObj( 1 ) );
480 CPPUNIT_ASSERT( pObj );
481 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Wrong Text Rotation!", 90.0, pObj->GetExtraTextRotation( true ) );
484 xDocShRef->DoClose();
487 void SdImportTest::testN862510_4()
489 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n862510_4.pptx"), PPTX );
491 const SdrPage *pPage = GetPage( 1, xDocShRef );
493 std::vector<EECharAttrib> rLst;
494 SdrObject *pObj = pPage->GetObj( 0 );
495 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
496 CPPUNIT_ASSERT( pTxtObj );
497 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
498 aEdit.GetCharAttribs( 0, rLst );
499 for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it != rLst.rend(); ++it )
501 const SvxColorItem *pC = dynamic_cast<const SvxColorItem *>( (*it).pAttr );
502 CPPUNIT_ASSERT_MESSAGE( "gradfill for text color not handled!", !( pC && pC->GetValue() == Color(0) ) );
506 xDocShRef->DoClose();
509 void SdImportTest::testN828390_2()
511 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n828390_2.pptx"), PPTX );
512 const SdrPage *pPage = GetPage( 1, xDocShRef );
514 SdrObject *pObj = pPage->GetObj(0);
515 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
516 CPPUNIT_ASSERT( pTxtObj );
517 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
518 CPPUNIT_ASSERT_EQUAL(OUString("Linux "), aEdit.GetText(0));
519 CPPUNIT_ASSERT_EQUAL(OUString("Standard Platform"), aEdit.GetText(1));
521 xDocShRef->DoClose();
524 void SdImportTest::testN828390_3()
526 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n828390_3.pptx"), PPTX );
527 const SdrPage *pPage = GetPage( 1, xDocShRef );
529 SdrObject *pObj = pPage->GetObj(0);
530 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
531 CPPUNIT_ASSERT( pTxtObj );
532 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
533 std::vector<EECharAttrib> rLst;
534 aEdit.GetCharAttribs(1, rLst);
535 bool bPassed = std::none_of(rLst.rbegin(), rLst.rend(),
536 [](const EECharAttrib& rCharAttr) {
537 const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>(rCharAttr.pAttr);
538 return pFontEscapement && (pFontEscapement->GetEsc() != 0);
540 CPPUNIT_ASSERT_MESSAGE("CharEscapment not imported properly", bPassed);
542 xDocShRef->DoClose();
545 void SdImportTest::testMasterPageStyleParent()
547 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/odp/masterpage_style_parent.odp"), ODP );
548 SdDrawDocument *pDoc = xDocShRef->GetDoc();
549 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
551 SdStyleSheetPool *const pPool(pDoc->GetSdStyleSheetPool());
553 int parents(0);
554 SfxStyleSheetIterator iter(pPool, SfxStyleFamily::Page);
555 for (SfxStyleSheetBase * pStyle = iter.First(); pStyle; pStyle = iter.Next())
557 OUString const name(pStyle->GetName());
558 OUString const parent(pStyle->GetParent());
559 if (!parent.isEmpty())
561 ++parents;
562 // check that parent exists
563 SfxStyleSheetBase *const pParentStyle(
564 pPool->Find(parent, SfxStyleFamily::Page));
565 CPPUNIT_ASSERT(pParentStyle);
566 CPPUNIT_ASSERT_EQUAL(pParentStyle->GetName(), parent);
567 // check that parent has the same master page as pStyle
568 CPPUNIT_ASSERT(parent.indexOf(SD_LT_SEPARATOR) != -1);
569 CPPUNIT_ASSERT(name.indexOf(SD_LT_SEPARATOR) != -1);
570 CPPUNIT_ASSERT_EQUAL(
571 parent.copy(0, parent.indexOf(SD_LT_SEPARATOR)),
572 name.copy(0, name.indexOf(SD_LT_SEPARATOR)));
575 // check that there are actually parents...
576 CPPUNIT_ASSERT_EQUAL(16, parents);
578 xDocShRef->DoClose();
581 void SdImportTest::testGradientAngle()
583 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odg/gradient-angle.fodg"), FODG);
585 uno::Reference<lang::XMultiServiceFactory> const xDoc(
586 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
588 awt::Gradient gradient;
589 uno::Reference<container::XNameAccess> const xGradients(
590 xDoc->createInstance("com.sun.star.drawing.GradientTable"),
591 uno::UNO_QUERY);
593 CPPUNIT_ASSERT(xGradients->getByName("Gradient 38") >>= gradient);
594 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), gradient.Angle); // was: 3600
596 CPPUNIT_ASSERT(xGradients->getByName("Gradient 10") >>= gradient);
597 CPPUNIT_ASSERT_EQUAL(sal_Int16(270), gradient.Angle); // 27deg
599 CPPUNIT_ASSERT(xGradients->getByName("Gradient 11") >>= gradient);
600 CPPUNIT_ASSERT_EQUAL(sal_Int16(1145), gradient.Angle); // 2rad
602 CPPUNIT_ASSERT(xGradients->getByName("Gradient 12") >>= gradient);
603 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), gradient.Angle); // 100grad
605 CPPUNIT_ASSERT(xGradients->getByName("Gradient 13") >>= gradient);
606 CPPUNIT_ASSERT_EQUAL(sal_Int16(3599), gradient.Angle); // -1
608 CPPUNIT_ASSERT(xGradients->getByName("Gradient 14") >>= gradient);
609 CPPUNIT_ASSERT_EQUAL(sal_Int16(3028), gradient.Angle); // -1rad
611 CPPUNIT_ASSERT(xGradients->getByName("Gradient 15") >>= gradient);
612 CPPUNIT_ASSERT_EQUAL(sal_Int16(300), gradient.Angle); // 3900
614 CPPUNIT_ASSERT(xGradients->getByName("Gradient 16") >>= gradient);
615 CPPUNIT_ASSERT_EQUAL(sal_Int16(105), gradient.Angle); // 10.5deg
617 CPPUNIT_ASSERT(xGradients->getByName("Gradient 17") >>= gradient);
618 CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), gradient.Angle); // \pi rad
620 uno::Reference<container::XNameAccess> const xTranspGradients(
621 xDoc->createInstance("com.sun.star.drawing.TransparencyGradientTable"),
622 uno::UNO_QUERY);
624 CPPUNIT_ASSERT(xTranspGradients->getByName("Transparency 2") >>= gradient);
625 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), gradient.Angle); // 1
627 CPPUNIT_ASSERT(xTranspGradients->getByName("Transparency 1") >>= gradient);
628 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), gradient.Angle); // 90deg
630 CPPUNIT_ASSERT(xTranspGradients->getByName("Transparency 3") >>= gradient);
631 CPPUNIT_ASSERT_EQUAL(sal_Int16(572), gradient.Angle); // 1.0rad
633 CPPUNIT_ASSERT(xTranspGradients->getByName("Transparency 4") >>= gradient);
634 CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), gradient.Angle); // 1000grad
636 xDocShRef->DoClose();
639 void SdImportTest::testN778859()
641 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"), PPTX);
643 const SdrPage *pPage = GetPage( 1, xDocShRef );
645 // Get the object
646 SdrObject *pObj = pPage->GetObj(1);
647 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
648 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
649 CPPUNIT_ASSERT(!pTxtObj->IsAutoFit());
652 xDocShRef->DoClose();
655 void SdImportTest::testFdo68594()
657 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/fdo68594.ppt"), PPT);
659 const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
660 SdrObject *pObj = pPage->GetObj(1);
661 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
662 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
663 const SvxColorItem *pC = &pTxtObj->GetMergedItem(EE_CHAR_COLOR);
664 CPPUNIT_ASSERT_MESSAGE( "no color item", pC != nullptr);
665 // Color should be black
666 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Placeholder color mismatch", sal_uInt32(0), sal_uInt32(pC->GetValue()) );
668 xDocShRef->DoClose();
671 void SdImportTest::testPptCrop()
673 sd::DrawDocShellRef xDocShRef
674 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/crop.ppt"), PPT);
676 uno::Reference<beans::XPropertySet> xPropertySet(
677 getShapeFromPage(/*nShape=*/1, /*nPage=*/0, xDocShRef));
678 text::GraphicCrop aCrop;
679 xPropertySet->getPropertyValue("GraphicCrop") >>= aCrop;
680 // These were all 0, lazy-loading broke cropping.
681 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Top);
682 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Bottom);
683 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Left);
684 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(0), aCrop.Right);
686 xDocShRef->DoClose();
689 void SdImportTest::testFdo72998()
691 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/cshapes.pptx"), PPTX);
693 const SdrPage *pPage = GetPage( 1, xDocShRef );
695 SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>(pPage->GetObj(2));
696 CPPUNIT_ASSERT( pObj );
697 const SdrCustomShapeGeometryItem& rGeometryItem = pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
698 const css::uno::Any* pViewBox = const_cast<SdrCustomShapeGeometryItem&>(rGeometryItem).GetPropertyValueByName( OUString( "ViewBox" ) );
699 CPPUNIT_ASSERT_MESSAGE( "Missing ViewBox", pViewBox );
700 css::awt::Rectangle aViewBox;
701 CPPUNIT_ASSERT( (*pViewBox >>= aViewBox ) );
702 CPPUNIT_ASSERT_MESSAGE( "Width should be zero - for forcing scale to 1", !aViewBox.Width );
703 CPPUNIT_ASSERT_MESSAGE( "Height should be zero - for forcing scale to 1", !aViewBox.Height );
706 xDocShRef->DoClose();
709 void SdImportTest::testFdo77027()
711 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/fdo77027.odp"), ODP);
713 const SdrPage *pPage = GetPage( 1, xDocShRef );
715 SdrOle2Obj *const pObj = dynamic_cast<SdrOle2Obj*>(pPage->GetObj(0));
716 CPPUNIT_ASSERT(pObj);
718 // check that the fill style/color was actually imported
719 const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
720 pObj->GetMergedItem(XATTR_FILLSTYLE));
721 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
722 const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
723 pObj->GetMergedItem(XATTR_FILLCOLOR));
724 CPPUNIT_ASSERT_EQUAL(Color(0xff6600), rColorItem.GetColorValue());
727 xDocShRef->DoClose();
730 void SdImportTest::testTdf97808()
732 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/tdf97808.fodp"), FODP);
734 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(
735 xDocShRef->GetModel(), uno::UNO_QUERY);
736 uno::Reference<container::XNameAccess> xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies();
737 uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("graphics"), uno::UNO_QUERY);
738 uno::Reference<beans::XPropertySet> xStyle(xStyleFamily->getByName("objectwithoutfill"), uno::UNO_QUERY);
739 OUString lineend;
740 CPPUNIT_ASSERT(xStyle->getPropertyValue("LineEndName") >>= lineend);
741 CPPUNIT_ASSERT_EQUAL(OUString("Arrow"), lineend);
743 // the draw:marker-end="" did not override the style
744 uno::Reference<drawing::XDrawPagesSupplier> xDoc(
745 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
746 uno::Reference<drawing::XDrawPage> xPage(
747 xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
748 uno::Reference<beans::XPropertySet> xLine(
749 xPage->getByIndex(0), uno::UNO_QUERY_THROW);
750 //uno::Reference<style::XStyle> xParent;
751 uno::Reference<beans::XPropertySet> xParent;
752 CPPUNIT_ASSERT(xLine->getPropertyValue("Style") >>= xParent);
753 CPPUNIT_ASSERT_EQUAL(xStyle, xParent);
754 CPPUNIT_ASSERT(xLine->getPropertyValue("LineEndName") >>= lineend);
755 CPPUNIT_ASSERT_EQUAL(OUString(), lineend);
757 xDocShRef->DoClose();
760 void SdImportTest::testFdo64512()
762 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/fdo64512.odp"), ODP);
764 uno::Reference< drawing::XDrawPagesSupplier > xDoc(
765 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
766 CPPUNIT_ASSERT_EQUAL_MESSAGE( "not exactly one page", static_cast<sal_Int32>(1), xDoc->getDrawPages()->getCount() );
768 uno::Reference< drawing::XDrawPage > xPage(
769 xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
770 CPPUNIT_ASSERT_EQUAL_MESSAGE( "no exactly three shapes", static_cast<sal_Int32>(3), xPage->getCount() );
772 uno::Reference< beans::XPropertySet > xConnectorShape(
773 xPage->getByIndex(2), uno::UNO_QUERY );
774 CPPUNIT_ASSERT_MESSAGE( "no connector shape", xConnectorShape.is() );
776 uno::Reference< beans::XPropertySet > xSvgShape(
777 xConnectorShape->getPropertyValue("StartShape"), uno::UNO_QUERY );
778 CPPUNIT_ASSERT_MESSAGE( "no start shape", xSvgShape.is() );
780 uno::Reference< beans::XPropertySet > xCustomShape(
781 xConnectorShape->getPropertyValue("EndShape"), uno::UNO_QUERY );
782 CPPUNIT_ASSERT_MESSAGE( "no end shape", xCustomShape.is() );
784 uno::Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier(
785 xPage, uno::UNO_QUERY_THROW );
786 uno::Reference< animations::XAnimationNode > xRootNode(
787 xAnimNodeSupplier->getAnimationNode() );
788 std::vector< uno::Reference< animations::XAnimationNode > > aAnimVector;
789 anim::create_deep_vector(xRootNode, aAnimVector);
790 CPPUNIT_ASSERT_EQUAL_MESSAGE( "not 8 animation nodes", static_cast<std::size_t>(8), aAnimVector.size() );
792 uno::Reference< animations::XAnimate > xNode(
793 aAnimVector[7], uno::UNO_QUERY_THROW );
794 uno::Reference< drawing::XShape > xTargetShape(
795 xNode->getTarget(), uno::UNO_QUERY_THROW );
796 CPPUNIT_ASSERT_MESSAGE( "inner node not referencing svg shape",
797 xTargetShape != xSvgShape );
799 xDocShRef->DoClose();
802 // Unit test for importing charts
803 void SdImportTest::testFdo71075()
805 double values[] = { 12.0, 13.0, 14.0 };
806 css::uno::Any aAny;
807 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/fdo71075.odp"), ODP);
809 uno::Reference< beans::XPropertySet > xPropSet( getShapeFromPage( 0, 0, xDocShRef ) );
810 aAny = xPropSet->getPropertyValue( "Model" );
811 CPPUNIT_ASSERT_MESSAGE( "The shape doesn't have the property", aAny.hasValue() );
813 uno::Reference< chart::XChartDocument > xChartDoc;
814 aAny >>= xChartDoc;
815 CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc.is() );
816 uno::Reference< chart2::XChartDocument > xChart2Doc( xChartDoc, uno::UNO_QUERY );
817 CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc.is() );
819 uno::Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xChart2Doc->getFirstDiagram(), uno::UNO_QUERY );
820 uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
821 uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[0], uno::UNO_QUERY );
823 uno::Reference< chart2::XDataSeriesContainer > xDSCnt( xCTCnt->getChartTypes()[0], uno::UNO_QUERY );
824 CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt.is() );
825 uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
826 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32>(1), aSeriesSeq.getLength() );
827 uno::Reference< chart2::data::XDataSource > xSource( aSeriesSeq[0], uno::UNO_QUERY );
828 uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(xSource->getDataSequences());
829 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32>(1), aSeqCnt.getLength());
830 uno::Reference< chart2::data::XDataSequence > xValueSeq( aSeqCnt[0]->getValues() );
831 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Data count", static_cast<sal_Int32>(SAL_N_ELEMENTS(values)), xValueSeq->getData().getLength());
832 uno::Reference< chart2::data::XNumericalDataSequence > xNumSeq( xValueSeq, uno::UNO_QUERY );
833 uno::Sequence< double > aValues( xNumSeq->getNumericalData());
834 for(sal_Int32 i=0;i<xValueSeq->getData().getLength();i++)
835 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", values[i], aValues.getConstArray()[i]);
837 xDocShRef->DoClose();
840 void SdImportTest::testStrictOOXML()
842 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/strict_ooxml.pptx"), PPTX);
844 SdDrawDocument *pDoc = xDocShRef->GetDoc();
845 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
846 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
848 xDocShRef->DoClose();
851 void SdImportTest::testBnc870237()
853 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc870237.pptx"), PPTX);
854 const SdrPage *pPage = GetPage( 1, xDocShRef );
856 // Simulate a:ext inside dsp:txXfrm with changing the lower distance
857 const SdrObjGroup* pGroupObj = dynamic_cast<SdrObjGroup*>( pPage->GetObj( 0 ) );
858 const SdrObject* pObj = pGroupObj->GetSubList()->GetObj( 1 );
859 CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
860 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST).GetValue());
861 CPPUNIT_ASSERT_EQUAL( sal_Int32(9919), pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST).GetValue());
862 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_RIGHTDIST).GetValue());
863 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_LEFTDIST).GetValue());
865 xDocShRef->DoClose();
868 void SdImportTest::testCreationDate()
870 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/fdo71434.pptx"), PPTX);
871 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
872 uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
873 util::DateTime aDate = xDocumentProperties->getCreationDate();
874 OUStringBuffer aBuffer;
875 sax::Converter::convertDateTime(aBuffer, aDate, nullptr);
876 // Metadata wasn't imported, this was 0000-00-00.
877 CPPUNIT_ASSERT_EQUAL(OUString("2013-11-09T10:37:56"), aBuffer.makeStringAndClear());
878 xDocShRef->DoClose();
881 void SdImportTest::testBnc887225()
883 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc887225.pptx"), PPTX );
884 // In the document, lastRow and lastCol table properties are used.
885 // Make sure styles are set properly for individual cells.
887 const SdrPage *pPage = GetPage( 1, xDocShRef );
889 sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(2));
890 CPPUNIT_ASSERT( pTableObj );
891 uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
892 uno::Reference< beans::XPropertySet > xCell;
893 sal_Int32 nColor;
895 xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
896 xCell->getPropertyValue("FillColor") >>= nColor;
897 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor);
899 xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
900 xCell->getPropertyValue("FillColor") >>= nColor;
901 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor);
903 xCell.set(xTable->getCellByPosition(1, 1), uno::UNO_QUERY_THROW);
904 xCell->getPropertyValue("FillColor") >>= nColor;
905 CPPUNIT_ASSERT_EQUAL(sal_Int32(13754095), nColor);
907 xCell.set(xTable->getCellByPosition(1, 2), uno::UNO_QUERY_THROW);
908 xCell->getPropertyValue("FillColor") >>= nColor;
909 CPPUNIT_ASSERT_EQUAL(sal_Int32(15331319), nColor);
911 xCell.set(xTable->getCellByPosition(1, 4), uno::UNO_QUERY_THROW);
912 xCell->getPropertyValue("FillColor") >>= nColor;
913 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor);
915 xCell.set(xTable->getCellByPosition(3, 2), uno::UNO_QUERY_THROW);
916 xCell->getPropertyValue("FillColor") >>= nColor;
917 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor);
919 xCell.set(xTable->getCellByPosition(3, 4), uno::UNO_QUERY_THROW);
920 xCell->getPropertyValue("FillColor") >>= nColor;
921 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor);
923 xDocShRef->DoClose();
926 void SdImportTest::testBnc584721_1()
928 // Title text shape on the master page contained wrong text.
930 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX);
932 const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
933 SdrObject *pObj = pPage->GetObj(0);
934 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
935 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
936 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
937 CPPUNIT_ASSERT_EQUAL(OUString("Click to edit Master title style"), aEdit.GetText(0));
938 xDocShRef->DoClose();
941 void SdImportTest::testBnc584721_2()
943 // Import created an extra/unneeded outliner shape on the master slide next to the imported title shape.
945 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX);
947 const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
948 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
950 xDocShRef->DoClose();
953 void SdImportTest::testBnc591147()
955 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc591147.pptx"), PPTX);
957 // In the document, there are two slides with media files.
958 uno::Reference< drawing::XDrawPagesSupplier > xDoc(
959 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
960 CPPUNIT_ASSERT_EQUAL( sal_Int32(2), xDoc->getDrawPages()->getCount() );
962 // First page has video file inserted
963 uno::Reference< drawing::XDrawPage > xPage(
964 xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
965 CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage->getCount() );
967 //uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
968 uno::Reference< beans::XPropertySet > xPropSet( getShape( 0, xPage ) );
969 OUString sVideoURL("emptyURL");
970 bool bSuccess = xPropSet->getPropertyValue("MediaURL") >>= sVideoURL;
971 CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSuccess );
972 CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sVideoURL.isEmpty());
974 // Second page has audio file inserted
975 xPage.set( xDoc->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
976 CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage->getCount() );
978 xPropSet.set( getShape( 0, xPage ) );
979 OUString sAudioURL("emptyURL");
980 bSuccess = xPropSet->getPropertyValue("MediaURL") >>= sAudioURL;
981 CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSuccess );
982 CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sAudioURL.isEmpty());
984 CPPUNIT_ASSERT_MESSAGE( "sAudioURL and sVideoURL should not be equal", sAudioURL != sVideoURL );
986 xDocShRef->DoClose();
989 void SdImportTest::testBnc584721_4()
991 // Black text was imported as white because of wrong caching mechanism
993 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_4.pptx"), PPTX);
994 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 1, 1, xDocShRef ) );
996 // Get first paragraph of the text
997 uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
999 // Get first run of the paragraph
1000 uno::Reference<text::XTextRange> xRun( getRunFromParagraph (0, xParagraph ) );
1001 uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
1002 Color nCharColor;
1003 xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
1005 // Color should be black
1006 CPPUNIT_ASSERT_EQUAL( COL_BLACK, nCharColor );
1008 xDocShRef->DoClose();
1011 void SdImportTest::testBnc904423()
1013 // Here the problem was that different fill properties were applied in wrong order on the shape
1014 // Right order: 1) master slide fill style, 2) theme, 3) direct formatting
1015 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/bnc904423.pptx"), PPTX);
1017 const SdrPage *pPage = GetPage( 1, xDocShRef );
1018 // First shape's background color is defined on master slide
1020 SdrObject *const pObj = pPage->GetObj(0);
1021 CPPUNIT_ASSERT(pObj);
1023 const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1024 pObj->GetMergedItem(XATTR_FILLSTYLE));
1025 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1026 const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1027 pObj->GetMergedItem(XATTR_FILLCOLOR));
1028 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00CC99), sal_uInt32(rColorItem.GetColorValue()));
1031 // Second shape's background color is defined by theme
1033 SdrObject *const pObj = pPage->GetObj(1);
1034 CPPUNIT_ASSERT(pObj);
1036 const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1037 pObj->GetMergedItem(XATTR_FILLSTYLE));
1038 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1039 const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1040 pObj->GetMergedItem(XATTR_FILLCOLOR));
1041 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x3333CC), sal_uInt32(rColorItem.GetColorValue()));
1044 // Third shape's background color is defined by direct formatting
1046 SdrObject *const pObj = pPage->GetObj(2);
1047 CPPUNIT_ASSERT(pObj);
1049 const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1050 pObj->GetMergedItem(XATTR_FILLSTYLE));
1051 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1052 const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1053 pObj->GetMergedItem(XATTR_FILLCOLOR));
1054 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), sal_uInt32(rColorItem.GetColorValue()));
1057 xDocShRef->DoClose();
1060 void SdImportTest::testShapeLineStyle()
1062 // Here the problem was that different line properties were applied in wrong order on the shape
1063 // Right order: 1) master slide line style, 2) theme, 3) direct formatting
1064 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/ShapeLineProperties.pptx"), PPTX);
1066 const SdrPage *pPage = GetPage( 1, xDocShRef );
1067 // First shape's line style is defined on master slide
1069 SdrObject *const pObj = pPage->GetObj(0);
1070 CPPUNIT_ASSERT(pObj);
1072 const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
1073 pObj->GetMergedItem(XATTR_LINESTYLE));
1074 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_DASH, rStyleItem.GetValue());
1076 const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
1077 pObj->GetMergedItem(XATTR_LINECOLOR));
1078 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), sal_uInt32(rColorItem.GetColorValue()));
1080 const XLineWidthItem& rWidthItem = dynamic_cast<const XLineWidthItem&>(
1081 pObj->GetMergedItem(XATTR_LINEWIDTH));
1082 CPPUNIT_ASSERT_EQUAL(sal_Int32(132), rWidthItem.GetValue());
1085 // Second shape's line style is defined by theme
1087 SdrObject *const pObj = pPage->GetObj(1);
1088 CPPUNIT_ASSERT(pObj);
1090 const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
1091 pObj->GetMergedItem(XATTR_LINESTYLE));
1092 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID, rStyleItem.GetValue());
1094 const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
1095 pObj->GetMergedItem(XATTR_LINECOLOR));
1096 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x3333CC), sal_uInt32(rColorItem.GetColorValue()));
1098 const XLineWidthItem& rWidthItem = dynamic_cast<const XLineWidthItem&>(
1099 pObj->GetMergedItem(XATTR_LINEWIDTH));
1100 CPPUNIT_ASSERT_EQUAL(sal_Int32(35), rWidthItem.GetValue());
1103 // Third shape's line style is defined by direct formatting
1105 SdrObject *const pObj = pPage->GetObj(2);
1106 CPPUNIT_ASSERT(pObj);
1108 const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
1109 pObj->GetMergedItem(XATTR_LINESTYLE));
1110 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID, rStyleItem.GetValue());
1112 const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
1113 pObj->GetMergedItem(XATTR_LINECOLOR));
1114 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x7030A0), sal_uInt32(rColorItem.GetColorValue()));
1116 const XLineWidthItem& rWidthItem = dynamic_cast<const XLineWidthItem&>(
1117 pObj->GetMergedItem(XATTR_LINEWIDTH));
1118 CPPUNIT_ASSERT_EQUAL(sal_Int32(176), rWidthItem.GetValue());
1121 xDocShRef->DoClose();
1124 void SdImportTest::testTableBorderLineStyle()
1126 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx"), PPTX );
1128 // TODO: If you are working on improvement of table border line style
1129 // support, then expect this unit test to fail.
1131 const sal_Int16 nObjBorderLineStyles[] =
1133 ::table::BorderLineStyle::DASHED,
1134 ::table::BorderLineStyle::DASH_DOT_DOT,
1135 ::table::BorderLineStyle::DASH_DOT,
1136 ::table::BorderLineStyle::DOTTED,
1137 ::table::BorderLineStyle::DASHED,
1138 ::table::BorderLineStyle::DOTTED,
1139 ::table::BorderLineStyle::DASHED,
1140 ::table::BorderLineStyle::DASH_DOT,
1141 ::table::BorderLineStyle::DASH_DOT,
1142 ::table::BorderLineStyle::SOLID,
1143 ::table::BorderLineStyle::NONE
1146 const SdrPage *pPage = GetPage( 1, xDocShRef );
1147 CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(nObjBorderLineStyles), pPage->GetObjCount());
1149 sdr::table::SdrTableObj *pTableObj;
1150 uno::Reference< table::XCellRange > xTable;
1151 uno::Reference< beans::XPropertySet > xCell;
1152 table::BorderLine2 aBorderLine;
1154 for (size_t i = 0; i < SAL_N_ELEMENTS(nObjBorderLineStyles); i++)
1156 pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(i));
1157 CPPUNIT_ASSERT( pTableObj );
1158 xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
1159 xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
1160 xCell->getPropertyValue("TopBorder") >>= aBorderLine;
1161 if (aBorderLine.LineWidth > 0) {
1162 CPPUNIT_ASSERT_EQUAL(nObjBorderLineStyles[i], aBorderLine.LineStyle);
1166 xDocShRef->DoClose();
1169 void SdImportTest::testBnc862510_6()
1171 // Black text was imported instead of gray
1172 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_6.pptx"), PPTX);
1173 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
1175 // Get first paragraph of the text
1176 uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
1178 // Get first run of the paragraph
1179 uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) );
1180 uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
1181 sal_Int32 nCharColor;
1182 xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
1184 // Color should be gray
1185 CPPUNIT_ASSERT_EQUAL( sal_Int32(0x8B8B8B), nCharColor );
1187 xDocShRef->DoClose();
1190 void SdImportTest::testBnc862510_7()
1192 // Title shape's text was aligned to left instead of center.
1193 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_7.pptx"), PPTX);
1194 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
1196 // Get first paragraph
1197 uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
1198 uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
1200 sal_Int16 nParaAdjust = 0;
1201 xPropSet->getPropertyValue( "ParaAdjust" ) >>= nParaAdjust;
1202 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(nParaAdjust));
1204 xDocShRef->DoClose();
1207 #if ENABLE_PDFIMPORT
1209 void SdImportTest::testPDFImportShared()
1211 comphelper::LibreOfficeKit::setActive();
1212 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pdf/multipage.pdf"), PDF);
1213 SdDrawDocument *pDoc = xDocShRef->GetDoc();
1214 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
1216 // This test is to verify that we share the PDF stream linked to each
1217 // Graphic instance in the imported document.
1218 // Since we import PDFs as images, we support attaching the original
1219 // PDF with each image to allow for advanced editing.
1220 // Here we iterate over all Graphic instances embedded in the pages
1221 // and verify that they all point to the same object in memory.
1222 std::vector<std::shared_ptr<std::vector<sal_Int8>>> aPdfSeqSharedPtrs;
1223 std::vector<std::shared_ptr<GfxLink>> aGfxLinkSharedPtrs;
1225 for (int nPageIndex = 0; nPageIndex < pDoc->GetPageCount(); ++nPageIndex)
1227 const SdrPage* pPage = GetPage(nPageIndex, xDocShRef);
1228 if (pPage == nullptr)
1229 break;
1231 for (size_t nObjIndex = 0; nObjIndex < pPage->GetObjCount(); ++nObjIndex)
1233 SdrObject* pObject = pPage->GetObj(nObjIndex);
1234 if (pObject == nullptr)
1235 continue;
1237 SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(pObject);
1238 if (pSdrGrafObj == nullptr)
1239 continue;
1241 const GraphicObject& rGraphicObject = pSdrGrafObj->GetGraphicObject().GetGraphic();
1242 const Graphic& rGraphic = rGraphicObject.GetGraphic();
1243 aPdfSeqSharedPtrs.push_back(rGraphic.getPdfData());
1244 aGfxLinkSharedPtrs.push_back(rGraphic.GetSharedGfxLink());
1248 CPPUNIT_ASSERT_MESSAGE("Expected more than one page.", aPdfSeqSharedPtrs.size() > 1);
1249 CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected as many PDF streams as GfxLinks.",
1250 aPdfSeqSharedPtrs.size(), aGfxLinkSharedPtrs.size());
1252 const std::shared_ptr<std::vector<sal_Int8>> pPdfSeq = aPdfSeqSharedPtrs[0];
1253 const std::shared_ptr<GfxLink> pGfxLink = aGfxLinkSharedPtrs[0];
1254 for (size_t i = 0; i < aPdfSeqSharedPtrs.size(); ++i)
1256 CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected all PDF streams to be identical.",
1257 aPdfSeqSharedPtrs[i].get(), pPdfSeq.get());
1258 CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected all GfxLinks to be identical.",
1259 aGfxLinkSharedPtrs[i].get(), pGfxLink.get());
1262 xDocShRef->DoClose();
1263 comphelper::LibreOfficeKit::setActive(false);
1266 #if defined(IMPORT_PDF_ELEMENTS)
1268 void SdImportTest::testPDFImport()
1270 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pdf/txtpic.pdf"), PDF);
1271 SdDrawDocument *pDoc = xDocShRef->GetDoc();
1272 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
1273 uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
1274 uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
1275 CPPUNIT_ASSERT_EQUAL_MESSAGE( "no exactly two shapes", static_cast<sal_Int32>(2), xPage->getCount() );
1277 uno::Reference< beans::XPropertySet > xShape( getShape( 0, xPage ) );
1278 uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
1279 CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
1281 xDocShRef->DoClose();
1284 void SdImportTest::testPDFImportSkipImages()
1286 SfxAllItemSet *pParams = new SfxAllItemSet( SfxGetpApp()->GetPool() );
1287 pParams->Put( SfxStringItem ( SID_FILE_FILTEROPTIONS, "SkipImages" ) );
1289 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pdf/txtpic.pdf"), PDF, pParams);
1290 SdDrawDocument *pDoc = xDocShRef->GetDoc();
1291 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
1292 uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
1293 uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
1294 CPPUNIT_ASSERT_EQUAL_MESSAGE( "no exactly one shape", static_cast<sal_Int32>(1), xPage->getCount() );
1296 uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
1297 uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
1298 CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText.is() );
1300 xDocShRef->DoClose();
1303 #endif
1304 #endif
1306 void SdImportTest::testBulletSuffix()
1308 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n83889.pptx"), PPTX );
1310 // check suffix of the char bullet
1311 const SdrPage *pPage = GetPage( 1, xDocShRef );
1312 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(0) );
1313 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
1314 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
1315 const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(1).GetItem(EE_PARA_NUMBULLET);
1316 CPPUNIT_ASSERT(pNumFmt);
1317 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", pNumFmt->GetNumRule()->GetLevel(0).GetSuffix(), OUString() );
1318 xDocShRef->DoClose();
1321 void SdImportTest::testBnc910045()
1323 // Problem with table style which defines cell color with fill style
1324 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc910045.pptx"), PPTX );
1325 const SdrPage *pPage = GetPage( 1, xDocShRef );
1327 sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1328 CPPUNIT_ASSERT( pTableObj );
1329 uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
1330 uno::Reference< beans::XPropertySet > xCell;
1331 sal_Int32 nColor;
1333 xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
1334 xCell->getPropertyValue("FillColor") >>= nColor;
1335 CPPUNIT_ASSERT_EQUAL(sal_Int32(5210557), nColor);
1337 xDocShRef->DoClose();
1340 void SdImportTest::testRowHeight()
1342 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n80340.pptx"), PPTX );
1343 const SdrPage *pPage = GetPage( 1, xDocShRef );
1345 sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1346 CPPUNIT_ASSERT( pTableObj );
1348 sal_Int32 nHeight;
1349 const OUString sHeight("Height");
1350 uno::Reference< css::table::XTable > xTable(pTableObj->getTable(), uno::UNO_SET_THROW);
1351 uno::Reference< css::table::XTableRows > xRows( xTable->getRows(), uno::UNO_SET_THROW);
1352 uno::Reference< beans::XPropertySet > xRefRow( xRows->getByIndex(0), uno::UNO_QUERY_THROW );
1353 xRefRow->getPropertyValue( sHeight ) >>= nHeight;
1354 CPPUNIT_ASSERT_EQUAL( sal_Int32(507), nHeight);
1356 xDocShRef->DoClose();
1359 void SdImportTest::testTdf93830()
1361 // Text shape offset was ignored
1362 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf93830.pptx"), PPTX);
1363 uno::Reference< drawing::XDrawPage > xPage( getPage( 0, xDocShRef ) );
1365 // Get the first text box from group shape
1366 uno::Reference< container::XIndexAccess > xShape( xPage->getByIndex(0), uno::UNO_QUERY );
1367 uno::Reference< beans::XPropertySet > xPropSet( xShape->getByIndex(3), uno::UNO_QUERY );
1368 CPPUNIT_ASSERT_MESSAGE( "no textbox shape", xPropSet.is() );
1370 sal_Int32 nTextLeftDistance = 0;
1371 xPropSet->getPropertyValue( "TextLeftDistance" ) >>= nTextLeftDistance;
1372 CPPUNIT_ASSERT_EQUAL(sal_Int32(4152), nTextLeftDistance);
1374 xDocShRef->DoClose();
1377 void SdImportTest::testTdf127129()
1379 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf127129.pptx"), PPTX);
1380 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
1381 uno::Reference< text::XTextRange > xParagraph( getParagraphFromShape( 0, xShape ) );
1382 uno::Reference< text::XTextRange > xRun( getRunFromParagraph( 0, xParagraph ) );
1383 uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
1385 sal_Int32 nCharColor;
1386 xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
1387 CPPUNIT_ASSERT_EQUAL( sal_Int32(0x000000), nCharColor );
1389 // Without the accompanying fix in place, the highlight would be -1
1390 sal_Int32 nCharBackColor;
1391 xPropSet->getPropertyValue( "CharBackColor" ) >>= nCharBackColor;
1392 CPPUNIT_ASSERT_EQUAL( sal_Int32(0xFF00), nCharBackColor );
1394 xDocShRef->DoClose();
1396 void SdImportTest::testTdf93097()
1398 // Throwing metadata import aborted the filter, check that metadata is now imported.
1399 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf93097.pptx"), PPTX);
1400 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
1401 uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
1402 CPPUNIT_ASSERT_EQUAL(OUString("ss"), xDocumentProperties->getTitle());
1403 xDocShRef->DoClose();
1406 void SdImportTest::testTdf62255()
1408 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf62255.pptx"), PPTX);
1409 const SdrPage *pPage = GetPage( 1, xDocShRef );
1411 sdr::table::SdrTableObj *pTableObj;
1412 pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1413 CPPUNIT_ASSERT( pTableObj );
1415 css::uno::Any aAny;
1416 uno::Reference< table::XCellRange > xTable;
1417 uno::Reference< beans::XPropertySet > xCell;
1418 xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
1419 xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
1420 aAny = xCell->getPropertyValue("FillStyle");
1422 if (aAny.hasValue())
1424 drawing::FillStyle aFillStyle;
1425 aAny >>= aFillStyle;
1426 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, aFillStyle);
1429 xDocShRef->DoClose();
1432 void SdImportTest::testTdf93124()
1434 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf93124.ppt"), PPT);
1435 uno::Reference < uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
1436 uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create(xContext);
1438 uno::Sequence< beans::PropertyValue > aFilterData(2);
1439 aFilterData[0].Name = "PixelWidth";
1440 aFilterData[0].Value <<= sal_Int32(320);
1441 aFilterData[1].Name = "PixelHeight";
1442 aFilterData[1].Value <<= sal_Int32(180);
1444 utl::TempFile aTempFile;
1445 aTempFile.EnableKillingFile();
1447 uno::Sequence< beans::PropertyValue > aDescriptor(3);
1448 aDescriptor[0].Name = "URL";
1449 aDescriptor[0].Value <<= aTempFile.GetURL();
1450 aDescriptor[1].Name = "FilterName";
1451 aDescriptor[1].Value <<= OUString("PNG");
1452 aDescriptor[2].Name = "FilterData";
1453 aDescriptor[2].Value <<= aFilterData;
1455 uno::Reference< lang::XComponent > xPage(getPage(0, xDocShRef), uno::UNO_QUERY);
1456 xGraphicExporter->setSourceDocument(xPage);
1457 xGraphicExporter->filter(aDescriptor);
1459 SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
1460 vcl::PNGReader aPNGReader(aFileStream);
1461 BitmapEx aBMPEx = aPNGReader.Read();
1463 // make sure the bitmap is not empty and correct size (PNG export->import was successful)
1464 CPPUNIT_ASSERT_EQUAL(Size(320, 180), aBMPEx.GetSizePixel());
1465 Bitmap aBMP = aBMPEx.GetBitmap();
1467 Bitmap::ScopedReadAccess pReadAccess(aBMP);
1468 int nNonWhiteCount = 0;
1469 // The word "Top" should be in rectangle 34,4 - 76,30. If text alignment is wrong, the rectangle will be white.
1470 for (long nY = 4; nY < (4 + 26); ++nY)
1472 for (long nX = 34; nX < (34 + 43); ++nX)
1474 const Color aColor = pReadAccess->GetColor(nY, nX);
1475 if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff))
1476 ++nNonWhiteCount;
1479 CPPUNIT_ASSERT_MESSAGE("Tdf93124: vertical alignment of text is incorrect!", nNonWhiteCount>50);
1481 xDocShRef->DoClose();
1484 void SdImportTest::testTdf99729()
1486 const OUString filenames[] = { "/sd/qa/unit/data/odp/tdf99729-new.odp", "/sd/qa/unit/data/odp/tdf99729-legacy.odp" };
1487 int nonwhitecounts[] = { 0, 0 };
1488 for (size_t i = 0; i < SAL_N_ELEMENTS(filenames); ++i)
1490 // 1st check for new behaviour - having AnchoredTextOverflowLegacy compatibility flag set to false in settings.xml
1491 uno::Reference<lang::XComponent> xComponent
1492 = loadFromDesktop(m_directories.getURLFromSrc(filenames[i]),
1493 "com.sun.star.presentation.PresentationDocument");
1495 uno::Reference<uno::XComponentContext> xContext = getComponentContext();
1496 CPPUNIT_ASSERT(xContext.is());
1497 uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create(xContext);
1498 CPPUNIT_ASSERT(xGraphicExporter.is());
1500 uno::Sequence< beans::PropertyValue > aFilterData(2);
1501 aFilterData[0].Name = "PixelWidth";
1502 aFilterData[0].Value <<= sal_Int32(320);
1503 aFilterData[1].Name = "PixelHeight";
1504 aFilterData[1].Value <<= sal_Int32(240);
1506 utl::TempFile aTempFile;
1507 aTempFile.EnableKillingFile();
1509 uno::Sequence< beans::PropertyValue > aDescriptor(3);
1510 aDescriptor[0].Name = "URL";
1511 aDescriptor[0].Value <<= aTempFile.GetURL();
1512 aDescriptor[1].Name = "FilterName";
1513 aDescriptor[1].Value <<= OUString("PNG");
1514 aDescriptor[2].Name = "FilterData";
1515 aDescriptor[2].Value <<= aFilterData;
1517 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(xComponent, uno::UNO_QUERY);
1518 uno::Reference<lang::XComponent> xPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
1519 uno::UNO_QUERY);
1520 CPPUNIT_ASSERT(xPage.is());
1521 xGraphicExporter->setSourceDocument(xPage);
1522 xGraphicExporter->filter(aDescriptor);
1524 SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
1525 vcl::PNGReader aPNGReader(aFileStream);
1526 BitmapEx aBMPEx = aPNGReader.Read();
1527 Bitmap aBMP = aBMPEx.GetBitmap();
1528 Bitmap::ScopedReadAccess pRead(aBMP);
1529 for (long nX = 154; nX < (154 + 12); ++nX)
1531 for (long nY = 16; nY < (16 + 96); ++nY)
1533 const Color aColor = pRead->GetColor(nY, nX);
1534 if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff))
1535 ++nonwhitecounts[i];
1538 xComponent->dispose();
1540 // The numbers 1-9 should be above the Text Box in rectangle 154,16 - 170,112.
1541 // If text alignment is wrong, the rectangle will be white.
1542 CPPUNIT_ASSERT_MESSAGE("Tdf99729: vertical alignment of text is incorrect!", nonwhitecounts[0]>100); // it is 134 with cleartype disabled
1543 // The numbers 1-9 should be below the Text Box -> rectangle 154,16 - 170,112 should be white.
1544 CPPUNIT_ASSERT_EQUAL_MESSAGE("Tdf99729: legacy vertical alignment of text is incorrect!", 0, nonwhitecounts[1]);
1547 void SdImportTest::testTdf89927()
1549 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf89927.pptx"), PPTX);
1550 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
1551 uno::Reference< text::XTextRange > xParagraph( getParagraphFromShape( 0, xShape ) );
1552 uno::Reference< text::XTextRange > xRun( getRunFromParagraph( 0, xParagraph ) );
1553 uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
1555 sal_Int32 nCharColor;
1556 xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
1557 CPPUNIT_ASSERT_EQUAL( sal_Int32(0xFFFFFF), nCharColor );
1559 xDocShRef->DoClose();
1562 void SdImportTest::testTdf93868()
1564 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf93868.pptx"), PPTX);
1566 const SdrPage *pPage = &(GetPage( 1, xDocShRef )->TRG_GetMasterPage());
1567 CPPUNIT_ASSERT_EQUAL(size_t(5), pPage->GetObjCount());
1568 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, dynamic_cast<const XFillStyleItem&>(pPage->GetObj(0)->GetMergedItem(XATTR_FILLSTYLE)).GetValue());
1569 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, dynamic_cast<const XFillStyleItem&>(pPage->GetObj(1)->GetMergedItem(XATTR_FILLSTYLE)).GetValue());
1571 xDocShRef->DoClose();
1574 void SdImportTest::testTdf95932()
1576 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf95932.pptx"), PPTX);
1578 const SdrPage *pPage = GetPage( 1, xDocShRef );
1579 SdrObject *const pObj = pPage->GetObj(2);
1580 CPPUNIT_ASSERT(pObj);
1582 const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1583 pObj->GetMergedItem(XATTR_FILLSTYLE));
1584 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1585 const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1586 pObj->GetMergedItem(XATTR_FILLCOLOR));
1587 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x76bf3d), sal_uInt32(rColorItem.GetColorValue()));
1589 xDocShRef->DoClose();
1592 void SdImportTest::testTdf99030()
1594 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf99030.pptx"), PPTX);
1596 uno::Reference< drawing::XMasterPagesSupplier > xDoc(
1597 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
1598 uno::Reference< drawing::XDrawPage > xPage(
1599 xDoc->getMasterPages()->getByIndex( 0 ), uno::UNO_QUERY_THROW );
1600 uno::Reference< beans::XPropertySet > xPropSet( xPage, uno::UNO_QUERY );
1602 sal_Int32 nFillColor(0);
1603 uno::Any aAny = xPropSet->getPropertyValue( "Background" );
1604 if (aAny.hasValue())
1606 uno::Reference< beans::XPropertySet > xBackgroundPropSet;
1607 aAny >>= xBackgroundPropSet;
1608 xBackgroundPropSet->getPropertyValue( "FillColor" ) >>= nFillColor;
1610 CPPUNIT_ASSERT_EQUAL( sal_Int32(0x676A55), nFillColor );
1612 xDocShRef->DoClose();
1615 void SdImportTest::testTdf49561()
1617 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf49561.ppt"), PPT);
1619 uno::Reference< drawing::XMasterPagesSupplier > xDoc(
1620 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
1621 uno::Reference< drawing::XDrawPage > xPage(
1622 xDoc->getMasterPages()->getByIndex( 0 ), uno::UNO_QUERY_THROW );
1623 CPPUNIT_ASSERT_EQUAL( sal_Int32(5), xPage->getCount() );
1625 uno::Reference< beans::XPropertySet > xShape( getShape( 3, xPage ) );
1626 uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
1627 uno::Reference<text::XTextRange> xRun( getRunFromParagraph (0, xParagraph ) );
1628 uno::Reference< beans::XPropertySet > xPropSet(xRun , uno::UNO_QUERY_THROW );
1630 float fCharHeight = 0;
1631 CPPUNIT_ASSERT(xPropSet->getPropertyValue("CharHeight") >>= fCharHeight);
1632 CPPUNIT_ASSERT_EQUAL(12.f, fCharHeight);
1634 OUString aCharFontName;
1635 CPPUNIT_ASSERT(xPropSet->getPropertyValue("CharFontName") >>= aCharFontName);
1636 CPPUNIT_ASSERT_EQUAL(OUString("Stencil"), aCharFontName);
1638 xDocShRef->DoClose();
1641 void SdImportTest::testTdf103473()
1643 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf103473.pptx"), PPTX);
1645 const SdrPage *pPage = GetPage(1, xDocShRef);
1646 SdrTextObj *const pObj = dynamic_cast<SdrTextObj *const>(pPage->GetObj(0));
1647 CPPUNIT_ASSERT(pObj);
1648 ::tools::Rectangle aRect = pObj->GetGeoRect();
1649 CPPUNIT_ASSERT_EQUAL(3629L, aRect.Left());
1650 CPPUNIT_ASSERT_EQUAL(4431L, aRect.Top());
1651 CPPUNIT_ASSERT_EQUAL(8353L, aRect.Right());
1652 CPPUNIT_ASSERT_EQUAL(9155L, aRect.Bottom());
1654 xDocShRef->DoClose();
1657 void SdImportTest::testAoo124143()
1659 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odg/ooo124143-1.odg"), ODG);
1661 uno::Reference<beans::XPropertySet> const xImage(getShapeFromPage(0, 0, xDocShRef));
1662 uno::Reference<drawing::XGluePointsSupplier> const xGPS(xImage, uno::UNO_QUERY);
1663 uno::Reference<container::XIdentifierAccess> const xGluePoints(xGPS->getGluePoints(), uno::UNO_QUERY);
1665 uno::Sequence<sal_Int32> const ids(xGluePoints->getIdentifiers());
1666 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), ids.getLength());
1667 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ids[0]);
1668 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), ids[1]);
1669 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), ids[2]);
1670 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), ids[3]);
1671 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), ids[4]);
1672 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ids[5]);
1674 // interesting ones are custom 4, 5
1675 drawing::GluePoint2 glue4;
1676 xGluePoints->getByIdentifier(4) >>= glue4;
1677 CPPUNIT_ASSERT_EQUAL(sal_Int32( 2470), glue4.Position.X);
1678 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1810), glue4.Position.Y);
1680 drawing::GluePoint2 glue5;
1681 xGluePoints->getByIdentifier(5) >>= glue5;
1682 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2975), glue5.Position.X);
1683 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2165), glue5.Position.Y);
1685 // now check connectors
1686 uno::Reference<beans::XPropertySet> const xEllipse(getShapeFromPage(1, 0, xDocShRef));
1687 uno::Reference<beans::XPropertySet> const xConn1(getShapeFromPage(2, 0, xDocShRef));
1688 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xConn1->getPropertyValue("StartGluePointIndex").get<sal_Int32>());
1689 CPPUNIT_ASSERT_EQUAL(xEllipse, xConn1->getPropertyValue("StartShape").get<uno::Reference<beans::XPropertySet>>());
1690 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xConn1->getPropertyValue("EndGluePointIndex").get<sal_Int32>());
1691 CPPUNIT_ASSERT_EQUAL(xImage, xConn1->getPropertyValue("EndShape").get<uno::Reference<beans::XPropertySet>>());
1692 uno::Reference<beans::XPropertySet> const xConn2(getShapeFromPage(3, 0, xDocShRef));
1693 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xConn2->getPropertyValue("StartGluePointIndex").get<sal_Int32>());
1694 CPPUNIT_ASSERT_EQUAL(xEllipse, xConn2->getPropertyValue("StartShape").get<uno::Reference<beans::XPropertySet>>());
1695 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xConn2->getPropertyValue("EndGluePointIndex").get<sal_Int32>());
1696 CPPUNIT_ASSERT_EQUAL(xImage, xConn2->getPropertyValue("EndShape").get<uno::Reference<beans::XPropertySet>>());
1698 xDocShRef->DoClose();
1701 void SdImportTest::testTdf103567()
1703 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf103567.odp"), ODP);
1704 for (int i = 0; i < 4; ++i)
1706 uno::Reference<beans::XPropertySet> const xShape(getShapeFromPage(i, 0, xDocShRef));
1707 uno::Reference<document::XEventsSupplier> const xEventsSupplier(xShape, uno::UNO_QUERY);
1708 uno::Reference<container::XNameAccess> const xEvents(xEventsSupplier->getEvents());
1709 OString const msg("shape " + OString::number(i) + ": ");
1711 CPPUNIT_ASSERT(xEvents->hasByName("OnClick"));
1712 uno::Sequence<beans::PropertyValue> props;
1713 xEvents->getByName("OnClick") >>= props;
1714 comphelper::SequenceAsHashMap const map(props);
1716 auto iter(map.find("EventType"));
1717 CPPUNIT_ASSERT_MESSAGE(OString(msg + "no EventType").getStr(), iter != map.end());
1718 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), OUString("Presentation"), iter->second.get<OUString>());
1721 auto iter(map.find("ClickAction"));
1722 CPPUNIT_ASSERT_MESSAGE(OString(msg + "no ClickAction").getStr(), iter != map.end());
1723 if (i % 2 == 0)
1725 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), css::presentation::ClickAction_DOCUMENT, iter->second.get<css::presentation::ClickAction>());
1727 else
1729 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), css::presentation::ClickAction_NEXTPAGE, iter->second.get<css::presentation::ClickAction>());
1732 if (i % 2 == 0)
1734 auto iter(map.find("Bookmark"));
1735 CPPUNIT_ASSERT_MESSAGE(OString(msg + "no Bookmark").getStr(), iter != map.end());
1736 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg.getStr(), OUString("http://example.com/"), iter->second.get<OUString>());
1740 xDocShRef->DoClose();
1743 void SdImportTest::testTdf103792()
1745 // Title text shape on the actual slide contained no text neither a placeholder text.
1746 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf103792.pptx"), PPTX);
1748 const SdrPage *pPage = GetPage(1, xDocShRef);
1749 CPPUNIT_ASSERT_MESSAGE("No page found", pPage != nullptr);
1750 SdrObject *pObj = pPage->GetObj(0);
1751 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr);
1752 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(pObj);
1753 CPPUNIT_ASSERT_MESSAGE("Not a text object", pTxtObj != nullptr);
1755 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
1756 CPPUNIT_ASSERT_EQUAL(OUString("Click to add Title"), aEdit.GetText(0));
1758 xDocShRef->DoClose();
1761 void SdImportTest::testTdf103876()
1763 // Title text shape's placeholder text did not inherit the corresponding text properties
1764 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf103876.pptx"), PPTX);
1765 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
1767 // Check paragraph alignment
1768 sal_Int16 nParaAdjust = 0;
1769 xShape->getPropertyValue( "ParaAdjust" ) >>= nParaAdjust;
1770 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(nParaAdjust));
1772 // Check character color
1773 sal_Int32 nCharColor;
1774 xShape->getPropertyValue( "CharColor" ) >>= nCharColor;
1775 CPPUNIT_ASSERT_EQUAL( sal_Int32(0xFF0000), nCharColor );
1777 xDocShRef->DoClose();
1780 void SdImportTest::testTdf79007()
1782 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf79007.pptx"), PPTX);
1784 uno::Reference<beans::XPropertySet> xShape1(getShapeFromPage(0, 0, xDocShRef));
1785 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape1.is());
1787 // Check we map mso washout to our watermark
1788 drawing::ColorMode aColorMode1;
1789 xShape1->getPropertyValue("GraphicColorMode") >>= aColorMode1;
1790 CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_WATERMARK, aColorMode1);
1792 sal_Int16 nContrast1;
1793 xShape1->getPropertyValue("AdjustContrast") >>= nContrast1;
1794 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nContrast1);
1796 sal_Int16 nLuminance1;
1797 xShape1->getPropertyValue("AdjustLuminance") >>= nLuminance1;
1798 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nLuminance1);
1800 uno::Reference<beans::XPropertySet> xShape2(getShapeFromPage(1, 0, xDocShRef));
1801 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape2.is());
1803 // Check we map mso grayscale to our grayscale
1804 drawing::ColorMode aColorMode2;
1805 xShape2->getPropertyValue("GraphicColorMode") >>= aColorMode2;
1806 CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_GREYS, aColorMode2);
1808 sal_Int16 nContrast2;
1809 xShape2->getPropertyValue("AdjustContrast") >>= nContrast2;
1810 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nContrast2);
1812 sal_Int16 nLuminance2;
1813 xShape2->getPropertyValue("AdjustLuminance") >>= nLuminance2;
1814 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nLuminance2);
1816 uno::Reference<beans::XPropertySet> xShape3(getShapeFromPage(2, 0, xDocShRef));
1817 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape3.is());
1819 // Check we map mso black/white to our black/white
1820 drawing::ColorMode aColorMode3;
1821 xShape3->getPropertyValue("GraphicColorMode") >>= aColorMode3;
1822 CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_MONO, aColorMode3);
1824 sal_Int16 nContrast3;
1825 xShape3->getPropertyValue("AdjustContrast") >>= nContrast3;
1826 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nContrast3);
1828 sal_Int16 nLuminance3;
1829 xShape3->getPropertyValue("AdjustLuminance") >>= nLuminance3;
1830 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(0), nLuminance3);
1832 xDocShRef->DoClose();
1835 void SdImportTest::testTdf104015()
1837 // Shape fill, line and effect properties were not inherited from master slide shape
1838 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf104015.pptx"), PPTX);
1840 const SdrPage *pPage = GetPage( 1, xDocShRef );
1841 CPPUNIT_ASSERT_MESSAGE("No page found", pPage != nullptr);
1842 SdrObject *const pObj = pPage->GetObj(0);
1843 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr);
1844 // Should have a red fill color
1846 const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1847 pObj->GetMergedItem(XATTR_FILLSTYLE));
1848 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1849 const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1850 pObj->GetMergedItem(XATTR_FILLCOLOR));
1851 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), sal_uInt32(rColorItem.GetColorValue()));
1853 // Should have a blue line
1855 const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
1856 pObj->GetMergedItem(XATTR_LINESTYLE));
1857 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID, rStyleItem.GetValue());
1859 const XLineColorItem& rColorItem = dynamic_cast<const XLineColorItem&>(
1860 pObj->GetMergedItem(XATTR_LINECOLOR));
1861 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x0000FF), sal_uInt32(rColorItem.GetColorValue()));
1863 // Should have some shadow
1865 const SdrOnOffItem& rShadowItem = dynamic_cast<const SdrOnOffItem&>(
1866 pObj->GetMergedItem(SDRATTR_SHADOW));
1867 CPPUNIT_ASSERT(rShadowItem.GetValue());
1870 xDocShRef->DoClose();
1873 void SdImportTest::testTdf104201()
1875 // Group shape properties did not overwrite the child shapes' fill
1876 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf104201.pptx"), PPTX);
1878 const SdrPage *pPage = GetPage(1, xDocShRef);
1879 CPPUNIT_ASSERT_MESSAGE("No page found", pPage != nullptr);
1881 // First shape has red fill, but this should be overwritten by green group fill
1883 SdrObject *const pObj = pPage->GetObj(0);
1884 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr);
1885 const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1886 pObj->GetMergedItem(XATTR_FILLSTYLE));
1887 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1888 const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1889 pObj->GetMergedItem(XATTR_FILLCOLOR));
1890 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FF00), sal_uInt32(rColorItem.GetColorValue()));
1892 // Second shape has blue fill, but this should be overwritten by green group fill
1894 SdrObject *const pObj = pPage->GetObj(0);
1895 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj != nullptr);
1896 const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
1897 pObj->GetMergedItem(XATTR_FILLSTYLE));
1898 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
1899 const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
1900 pObj->GetMergedItem(XATTR_FILLCOLOR));
1901 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FF00), sal_uInt32(rColorItem.GetColorValue()));
1904 xDocShRef->DoClose();
1907 void SdImportTest::testTdf103477()
1909 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf103477.pptx"), PPTX);
1911 const SdrPage *pPage = GetPage( 1, xDocShRef );
1913 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(6) );
1914 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr );
1916 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
1917 const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
1918 CPPUNIT_ASSERT(pNumFmt);
1919 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", Color(0x000000), pNumFmt->GetNumRule()->GetLevel(1).GetBulletColor());
1921 xDocShRef->DoClose();
1924 void SdImportTest::testTdf105150()
1926 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf105150.pptx"), PPTX);
1927 const SdrPage* pPage = GetPage(1, xDocShRef);
1928 const SdrObject* pObj = pPage->GetObj(1);
1929 auto& rFillStyleItem = dynamic_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE));
1930 // This was drawing::FillStyle_NONE, <p:sp useBgFill="1"> was ignored when
1931 // the slide didn't have an explicit background fill.
1932 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rFillStyleItem.GetValue());
1933 xDocShRef->DoClose();
1936 void SdImportTest::testTdf123684()
1938 sd::DrawDocShellRef xDocShRef
1939 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf123684.pptx"), PPTX);
1940 const SdrPage* pPage = GetPage(1, xDocShRef);
1941 const SdrObject* pObj = pPage->GetObj(0);
1942 auto& rFillStyleItem
1943 = dynamic_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE));
1944 // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual:
1945 // 1', i.e. the shape's fill was FillStyle_SOLID, making the text of the shape unreadable.
1946 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, rFillStyleItem.GetValue());
1947 xDocShRef->DoClose();
1950 void SdImportTest::testTdf105150PPT()
1952 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/ppt/tdf105150.ppt"), PPT);
1953 const SdrPage* pPage = GetPage(1, xDocShRef);
1954 const SdrObject* pObj = pPage->GetObj(1);
1955 // This was drawing::FillStyle_NONE, the shape's mso_fillBackground was
1956 // ignored when the slide didn't have an explicit background fill.
1957 auto& rFillStyleItem = dynamic_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE));
1958 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rFillStyleItem.GetValue());
1959 xDocShRef->DoClose();
1962 void SdImportTest::testTdf104445()
1964 // Extra bullets were added to the first shape
1965 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf104445.pptx"), PPTX);
1967 // First shape should not have bullet
1969 uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(0, 0, xDocShRef));
1970 uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
1971 CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
1972 uno::Reference< beans::XPropertySet > xPropSet(xText, uno::UNO_QUERY_THROW);
1974 uno::Reference< container::XIndexAccess > xNumRule;
1975 xPropSet->getPropertyValue("NumberingRules") >>= xNumRule;
1976 uno::Sequence<beans::PropertyValue> aBulletProps;
1977 xNumRule->getByIndex(0) >>= aBulletProps;
1979 for (int i = 0; i < aBulletProps.getLength(); ++i)
1981 const beans::PropertyValue& rProp = aBulletProps[i];
1982 if(rProp.Name == "NumberingType")
1983 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::NUMBER_NONE), rProp.Value.get<sal_Int16>());
1984 if(rProp.Name == "LeftMargin")
1985 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp.Value.get<sal_Int32>());
1988 // Second shape should have bullet set
1990 uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(1, 0, xDocShRef));
1991 uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
1992 CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText.is());
1993 uno::Reference< beans::XPropertySet > xPropSet(xText, uno::UNO_QUERY_THROW);
1995 uno::Reference< container::XIndexAccess > xNumRule;
1996 xPropSet->getPropertyValue("NumberingRules") >>= xNumRule;
1997 uno::Sequence<beans::PropertyValue> aBulletProps;
1998 xNumRule->getByIndex(0) >>= aBulletProps;
2000 for(int i = 0; i < aBulletProps.getLength(); ++i)
2002 const beans::PropertyValue& rProp = aBulletProps[i];
2003 if(rProp.Name == "NumberingType")
2004 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::CHAR_SPECIAL), rProp.Value.get<sal_Int16>());
2005 if(rProp.Name == "LeftMargin")
2006 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), rProp.Value.get<sal_Int32>());
2009 xDocShRef->DoClose();
2012 namespace
2015 bool checkPatternValues(std::vector<sal_uInt8>& rExpected, Bitmap& rBitmap)
2017 bool bResult = true;
2019 const Color aFGColor(0xFF0000);
2020 const Color aBGColor(0xFFFFFF);
2022 Bitmap::ScopedReadAccess pAccess(rBitmap);
2023 for (long y = 0; y < pAccess->Height(); ++y)
2025 Scanline pScanline = pAccess->GetScanline( y );
2026 for (long x = 0; x < pAccess->Width(); ++x)
2028 Color aColor = pAccess->GetPixelFromData(pScanline, x);
2029 sal_uInt8 aValue = rExpected[y*8+x];
2031 if (aValue == 1 && aColor != aFGColor)
2032 bResult = false;
2033 else if (aValue == 0 && aColor != aBGColor)
2034 bResult = false;
2038 return bResult;
2041 } // end anonymous namespace
2043 bool SdImportTest::checkPattern(sd::DrawDocShellRef const & rDocRef, int nShapeNumber, std::vector<sal_uInt8>& rExpected)
2045 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(nShapeNumber, 0, rDocRef));
2046 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape.is());
2048 Bitmap aBitmap;
2049 if (xShape.is())
2051 uno::Any aBitmapAny = xShape->getPropertyValue("FillBitmap");
2052 uno::Reference<awt::XBitmap> xBitmap;
2053 if (aBitmapAny >>= xBitmap)
2055 uno::Sequence<sal_Int8> aBitmapSequence(xBitmap->getDIB());
2056 SvMemoryStream aBitmapStream(aBitmapSequence.getArray(),
2057 aBitmapSequence.getLength(),
2058 StreamMode::READ);
2059 ReadDIB(aBitmap, aBitmapStream, true);
2062 CPPUNIT_ASSERT_EQUAL(8L, aBitmap.GetSizePixel().Width());
2063 CPPUNIT_ASSERT_EQUAL(8L, aBitmap.GetSizePixel().Height());
2064 return checkPatternValues(rExpected, aBitmap);
2067 /* Test checks that importing a PPT file with all supported fill patterns is
2068 * correctly imported as a tiled fill bitmap with the expected pattern.
2070 void SdImportTest::testPatternImport()
2072 sd::DrawDocShellRef xDocRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/ppt/FillPatterns.ppt"), PPT);
2074 std::vector<sal_uInt8> aExpectedPattern1 = {
2075 1,0,0,0,0,0,0,0,
2076 0,0,0,0,0,0,0,0,
2077 0,0,0,0,0,0,0,0,
2078 0,0,0,0,0,0,0,0,
2079 0,0,0,0,1,0,0,0,
2080 0,0,0,0,0,0,0,0,
2081 0,0,0,0,0,0,0,0,
2082 0,0,0,0,0,0,0,0,
2084 std::vector<sal_uInt8> aExpectedPattern2 = {
2085 1,0,0,0,0,0,0,0,
2086 0,0,0,0,0,0,0,0,
2087 0,0,0,0,1,0,0,0,
2088 0,0,0,0,0,0,0,0,
2089 1,0,0,0,0,0,0,0,
2090 0,0,0,0,0,0,0,0,
2091 0,0,0,0,1,0,0,0,
2092 0,0,0,0,0,0,0,0,
2094 std::vector<sal_uInt8> aExpectedPattern3 = {
2095 1,0,0,0,1,0,0,0,
2096 0,0,0,0,0,0,0,0,
2097 0,0,1,0,0,0,1,0,
2098 0,0,0,0,0,0,0,0,
2099 1,0,0,0,1,0,0,0,
2100 0,0,0,0,0,0,0,0,
2101 0,0,1,0,0,0,1,0,
2102 0,0,0,0,0,0,0,0,
2104 std::vector<sal_uInt8> aExpectedPattern4 = {
2105 1,0,0,0,1,0,0,0,
2106 0,0,1,0,0,0,1,0,
2107 1,0,0,0,1,0,0,0,
2108 0,0,1,0,0,0,1,0,
2109 1,0,0,0,1,0,0,0,
2110 0,0,1,0,0,0,1,0,
2111 1,0,0,0,1,0,0,0,
2112 0,0,1,0,0,0,1,0,
2114 std::vector<sal_uInt8> aExpectedPattern5 = {
2115 1,0,1,0,1,0,1,0,
2116 0,1,0,0,0,1,0,0,
2117 1,0,1,0,1,0,1,0,
2118 0,0,0,1,0,0,0,1,
2119 1,0,1,0,1,0,1,0,
2120 0,1,0,0,0,1,0,0,
2121 1,0,1,0,1,0,1,0,
2122 0,0,0,1,0,0,0,1,
2124 std::vector<sal_uInt8> aExpectedPattern6 = {
2125 1,0,1,0,1,0,1,0,
2126 0,1,0,1,0,1,0,1,
2127 1,0,1,0,1,0,1,0,
2128 0,1,0,1,0,0,0,1,
2129 1,0,1,0,1,0,1,0,
2130 0,1,0,1,0,1,0,1,
2131 1,0,1,0,1,0,1,0,
2132 0,0,0,1,0,1,0,1,
2134 std::vector<sal_uInt8> aExpectedPattern7 = {
2135 1,0,1,0,1,0,1,0,
2136 0,1,0,1,0,1,0,1,
2137 1,0,1,0,1,0,1,0,
2138 0,1,0,1,0,1,0,1,
2139 1,0,1,0,1,0,1,0,
2140 0,1,0,1,0,1,0,1,
2141 1,0,1,0,1,0,1,0,
2142 0,1,0,1,0,1,0,1,
2144 std::vector<sal_uInt8> aExpectedPattern8 = {
2145 1,1,1,0,1,1,1,0,
2146 0,1,0,1,0,1,0,1,
2147 1,0,1,1,1,0,1,1,
2148 0,1,0,1,0,1,0,1,
2149 1,1,1,0,1,1,1,0,
2150 0,1,0,1,0,1,0,1,
2151 1,0,1,1,1,0,1,1,
2152 0,1,0,1,0,1,0,1,
2154 std::vector<sal_uInt8> aExpectedPattern9 = {
2155 0,1,1,1,0,1,1,1,
2156 1,1,0,1,1,1,0,1,
2157 0,1,1,1,0,1,1,1,
2158 1,1,0,1,1,1,0,1,
2159 0,1,1,1,0,1,1,1,
2160 1,1,0,1,1,1,0,1,
2161 0,1,1,1,0,1,1,1,
2162 1,1,0,1,1,1,0,1,
2164 std::vector<sal_uInt8> aExpectedPattern10 = {
2165 0,1,1,1,0,1,1,1,
2166 1,1,1,1,1,1,1,1,
2167 1,1,0,1,1,1,0,1,
2168 1,1,1,1,1,1,1,1,
2169 0,1,1,1,0,1,1,1,
2170 1,1,1,1,1,1,1,1,
2171 1,1,0,1,1,1,0,1,
2172 1,1,1,1,1,1,1,1,
2174 std::vector<sal_uInt8> aExpectedPattern11 = {
2175 1,1,1,0,1,1,1,1,
2176 1,1,1,1,1,1,1,1,
2177 1,1,1,1,1,1,1,0,
2178 1,1,1,1,1,1,1,1,
2179 1,1,1,0,1,1,1,1,
2180 1,1,1,1,1,1,1,1,
2181 1,1,1,1,1,1,1,0,
2182 1,1,1,1,1,1,1,1,
2184 std::vector<sal_uInt8> aExpectedPattern12 = {
2185 1,1,1,1,1,1,1,1,
2186 1,1,1,1,1,1,1,1,
2187 1,1,1,1,1,1,1,1,
2188 1,1,1,1,0,1,1,1,
2189 1,1,1,1,1,1,1,1,
2190 1,1,1,1,1,1,1,1,
2191 1,1,1,1,1,1,1,1,
2192 0,1,1,1,1,1,1,1,
2194 std::vector<sal_uInt8> aExpectedPatternLine1 = {
2195 1,0,0,0,1,0,0,0,
2196 0,1,0,0,0,1,0,0,
2197 0,0,1,0,0,0,1,0,
2198 0,0,0,1,0,0,0,1,
2199 1,0,0,0,1,0,0,0,
2200 0,1,0,0,0,1,0,0,
2201 0,0,1,0,0,0,1,0,
2202 0,0,0,1,0,0,0,1,
2204 std::vector<sal_uInt8> aExpectedPatternLine2 = {
2205 0,0,0,1,0,0,0,1,
2206 0,0,1,0,0,0,1,0,
2207 0,1,0,0,0,1,0,0,
2208 1,0,0,0,1,0,0,0,
2209 0,0,0,1,0,0,0,1,
2210 0,0,1,0,0,0,1,0,
2211 0,1,0,0,0,1,0,0,
2212 1,0,0,0,1,0,0,0,
2214 std::vector<sal_uInt8> aExpectedPatternLine3 = {
2215 1,1,0,0,1,1,0,0,
2216 0,1,1,0,0,1,1,0,
2217 0,0,1,1,0,0,1,1,
2218 1,0,0,1,1,0,0,1,
2219 1,1,0,0,1,1,0,0,
2220 0,1,1,0,0,1,1,0,
2221 0,0,1,1,0,0,1,1,
2222 1,0,0,1,1,0,0,1,
2224 std::vector<sal_uInt8> aExpectedPatternLine4 = {
2225 0,0,1,1,0,0,1,1,
2226 0,1,1,0,0,1,1,0,
2227 1,1,0,0,1,1,0,0,
2228 1,0,0,1,1,0,0,1,
2229 0,0,1,1,0,0,1,1,
2230 0,1,1,0,0,1,1,0,
2231 1,1,0,0,1,1,0,0,
2232 1,0,0,1,1,0,0,1,
2234 std::vector<sal_uInt8> aExpectedPatternLine5 = {
2235 1,1,0,0,0,0,0,1,
2236 1,1,1,0,0,0,0,0,
2237 0,1,1,1,0,0,0,0,
2238 0,0,1,1,1,0,0,0,
2239 0,0,0,1,1,1,0,0,
2240 0,0,0,0,1,1,1,0,
2241 0,0,0,0,0,1,1,1,
2242 1,0,0,0,0,0,1,1,
2244 std::vector<sal_uInt8> aExpectedPatternLine6 = {
2245 1,0,0,0,0,0,1,1,
2246 0,0,0,0,0,1,1,1,
2247 0,0,0,0,1,1,1,0,
2248 0,0,0,1,1,1,0,0,
2249 0,0,1,1,1,0,0,0,
2250 0,1,1,1,0,0,0,0,
2251 1,1,1,0,0,0,0,0,
2252 1,1,0,0,0,0,0,1,
2254 std::vector<sal_uInt8> aExpectedPatternLine7 = {
2255 1,0,0,0,1,0,0,0,
2256 1,0,0,0,1,0,0,0,
2257 1,0,0,0,1,0,0,0,
2258 1,0,0,0,1,0,0,0,
2259 1,0,0,0,1,0,0,0,
2260 1,0,0,0,1,0,0,0,
2261 1,0,0,0,1,0,0,0,
2262 1,0,0,0,1,0,0,0,
2264 std::vector<sal_uInt8> aExpectedPatternLine8 = {
2265 1,1,1,1,1,1,1,1,
2266 0,0,0,0,0,0,0,0,
2267 0,0,0,0,0,0,0,0,
2268 0,0,0,0,0,0,0,0,
2269 1,1,1,1,1,1,1,1,
2270 0,0,0,0,0,0,0,0,
2271 0,0,0,0,0,0,0,0,
2272 0,0,0,0,0,0,0,0,
2274 std::vector<sal_uInt8> aExpectedPatternLine9 = {
2275 0,1,0,1,0,1,0,1,
2276 0,1,0,1,0,1,0,1,
2277 0,1,0,1,0,1,0,1,
2278 0,1,0,1,0,1,0,1,
2279 0,1,0,1,0,1,0,1,
2280 0,1,0,1,0,1,0,1,
2281 0,1,0,1,0,1,0,1,
2282 0,1,0,1,0,1,0,1,
2284 std::vector<sal_uInt8> aExpectedPatternLine10 = {
2285 1,1,1,1,1,1,1,1,
2286 0,0,0,0,0,0,0,0,
2287 1,1,1,1,1,1,1,1,
2288 0,0,0,0,0,0,0,0,
2289 1,1,1,1,1,1,1,1,
2290 0,0,0,0,0,0,0,0,
2291 1,1,1,1,1,1,1,1,
2292 0,0,0,0,0,0,0,0,
2294 std::vector<sal_uInt8> aExpectedPatternLine11 = {
2295 1,1,0,0,1,1,0,0,
2296 1,1,0,0,1,1,0,0,
2297 1,1,0,0,1,1,0,0,
2298 1,1,0,0,1,1,0,0,
2299 1,1,0,0,1,1,0,0,
2300 1,1,0,0,1,1,0,0,
2301 1,1,0,0,1,1,0,0,
2302 1,1,0,0,1,1,0,0,
2304 std::vector<sal_uInt8> aExpectedPatternLine12 = {
2305 1,1,1,1,1,1,1,1,
2306 1,1,1,1,1,1,1,1,
2307 0,0,0,0,0,0,0,0,
2308 0,0,0,0,0,0,0,0,
2309 1,1,1,1,1,1,1,1,
2310 1,1,1,1,1,1,1,1,
2311 0,0,0,0,0,0,0,0,
2312 0,0,0,0,0,0,0,0,
2315 CPPUNIT_ASSERT_MESSAGE("Pattern1 - 5%" , checkPattern(xDocRef, 0, aExpectedPattern1));
2316 CPPUNIT_ASSERT_MESSAGE("Pattern2 - 10%", checkPattern(xDocRef, 1, aExpectedPattern2));
2317 CPPUNIT_ASSERT_MESSAGE("Pattern3 - 20%", checkPattern(xDocRef, 2, aExpectedPattern3));
2318 CPPUNIT_ASSERT_MESSAGE("Pattern4 - 25%", checkPattern(xDocRef, 3, aExpectedPattern4));
2319 CPPUNIT_ASSERT_MESSAGE("Pattern5 - 30%", checkPattern(xDocRef, 4, aExpectedPattern5));
2320 CPPUNIT_ASSERT_MESSAGE("Pattern6 - 40%", checkPattern(xDocRef, 5, aExpectedPattern6));
2321 CPPUNIT_ASSERT_MESSAGE("Pattern7 - 50%", checkPattern(xDocRef, 6, aExpectedPattern7));
2322 CPPUNIT_ASSERT_MESSAGE("Pattern8 - 60%", checkPattern(xDocRef, 7, aExpectedPattern8));
2323 CPPUNIT_ASSERT_MESSAGE("Pattern9 - 70%", checkPattern(xDocRef, 8, aExpectedPattern9));
2324 CPPUNIT_ASSERT_MESSAGE("Pattern10 - 75%", checkPattern(xDocRef, 9, aExpectedPattern10));
2325 CPPUNIT_ASSERT_MESSAGE("Pattern11 - 80%", checkPattern(xDocRef, 10, aExpectedPattern11));
2326 CPPUNIT_ASSERT_MESSAGE("Pattern12 - 90%", checkPattern(xDocRef, 11, aExpectedPattern12));
2328 CPPUNIT_ASSERT_MESSAGE("Pattern13 - Light downward diagonal", checkPattern(xDocRef, 12, aExpectedPatternLine1));
2329 CPPUNIT_ASSERT_MESSAGE("Pattern14 - Light upward diagonal", checkPattern(xDocRef, 13, aExpectedPatternLine2));
2330 CPPUNIT_ASSERT_MESSAGE("Pattern15 - Dark downward diagonal", checkPattern(xDocRef, 14, aExpectedPatternLine3));
2331 CPPUNIT_ASSERT_MESSAGE("Pattern16 - Dark upward diagonal", checkPattern(xDocRef, 15, aExpectedPatternLine4));
2332 CPPUNIT_ASSERT_MESSAGE("Pattern17 - Wide downward diagonal", checkPattern(xDocRef, 16, aExpectedPatternLine5));
2333 CPPUNIT_ASSERT_MESSAGE("Pattern18 - Wide upward diagonal", checkPattern(xDocRef, 17, aExpectedPatternLine6));
2335 CPPUNIT_ASSERT_MESSAGE("Pattern19 - Light vertical", checkPattern(xDocRef, 18, aExpectedPatternLine7));
2336 CPPUNIT_ASSERT_MESSAGE("Pattern20 - Light horizontal", checkPattern(xDocRef, 19, aExpectedPatternLine8));
2337 CPPUNIT_ASSERT_MESSAGE("Pattern21 - Narrow vertical", checkPattern(xDocRef, 20, aExpectedPatternLine9));
2338 CPPUNIT_ASSERT_MESSAGE("Pattern22 - Narrow horizontal", checkPattern(xDocRef, 21, aExpectedPatternLine10));
2339 CPPUNIT_ASSERT_MESSAGE("Pattern23 - Dark vertical", checkPattern(xDocRef, 22, aExpectedPatternLine11));
2340 CPPUNIT_ASSERT_MESSAGE("Pattern24 - Dark horizontal", checkPattern(xDocRef, 23, aExpectedPatternLine12));
2342 // TODO: other patterns in the test document
2344 xDocRef->DoClose();
2347 void SdImportTest::testTdf100926()
2349 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf100926.pptx"), PPTX);
2350 const SdrPage* pPage = GetPage(1, xDocShRef);
2351 CPPUNIT_ASSERT(pPage != nullptr);
2353 sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
2354 CPPUNIT_ASSERT(pTableObj != nullptr);
2355 uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
2357 sal_Int32 nRotation = 0;
2358 uno::Reference< beans::XPropertySet > xCell(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
2359 xCell->getPropertyValue("RotateAngle") >>= nRotation;
2360 CPPUNIT_ASSERT_EQUAL(sal_Int32(27000), nRotation);
2362 xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
2363 xCell->getPropertyValue("RotateAngle") >>= nRotation;
2364 CPPUNIT_ASSERT_EQUAL(sal_Int32(9000), nRotation);
2366 xCell.set(xTable->getCellByPosition(2, 0), uno::UNO_QUERY_THROW);
2367 xCell->getPropertyValue("RotateAngle") >>= nRotation;
2368 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRotation);
2370 xDocShRef->DoClose();
2373 void SdImportTest::testTdf89064()
2375 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf89064.pptx"), PPTX);
2376 uno::Reference< presentation::XPresentationPage > xPage (getPage(0, xDocShRef), uno::UNO_QUERY_THROW);
2377 uno::Reference< drawing::XDrawPage > xNotesPage (xPage->getNotesPage(), uno::UNO_SET_THROW);
2378 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xNotesPage->getCount());
2380 xDocShRef->DoClose();
2383 void SdImportTest::testTdf108925()
2385 // Test document contains bulleting with too small bullet size (1%) which breaks the lower constraint
2386 // So it should be converted to the lowest allowed value (25%).
2387 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf108925.odp"), ODP);
2388 const SdrPage *pPage = GetPage(1, xDocShRef);
2389 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(pPage->GetObj(0));
2390 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr);
2391 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
2393 const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
2394 CPPUNIT_ASSERT(pNumFmt);
2395 CPPUNIT_ASSERT_EQUAL(sal_uInt16(25), pNumFmt->GetNumRule()->GetLevel(0).GetBulletRelSize());
2397 xDocShRef->DoClose();
2400 void SdImportTest::testTdf109067()
2402 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf109067.pptx"), PPTX);
2403 uno::Reference< beans::XPropertySet > xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
2404 awt::Gradient gradient;
2405 CPPUNIT_ASSERT(xShape->getPropertyValue("FillGradient") >>= gradient);
2406 CPPUNIT_ASSERT_EQUAL(sal_Int16(450), gradient.Angle);
2408 xDocShRef->DoClose();
2411 void SdImportTest::testTdf109187()
2413 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf109187.pptx"), PPTX);
2414 uno::Reference< beans::XPropertySet > xArrow1(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
2415 awt::Gradient aGradient1;
2416 CPPUNIT_ASSERT(xArrow1->getPropertyValue("FillGradient") >>= aGradient1);
2417 CPPUNIT_ASSERT_EQUAL(sal_Int16(2250), aGradient1.Angle);
2418 uno::Reference< beans::XPropertySet > xArrow2(getShapeFromPage(1, 0, xDocShRef), uno::UNO_SET_THROW);
2419 awt::Gradient aGradient2;
2420 CPPUNIT_ASSERT(xArrow2->getPropertyValue("FillGradient") >>= aGradient2);
2421 CPPUNIT_ASSERT_EQUAL(sal_Int16(1350), aGradient2.Angle);
2423 xDocShRef->DoClose();
2426 void SdImportTest::testTdf108926()
2428 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf108926.ppt"), PPT);
2429 uno::Reference< presentation::XPresentationPage > xPage (getPage(0, xDocShRef), uno::UNO_QUERY_THROW);
2430 uno::Reference< drawing::XDrawPage > xNotesPage (xPage->getNotesPage(), uno::UNO_SET_THROW);
2431 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xNotesPage->getCount());
2433 // Second object should be imported as an empty presentation shape
2434 uno::Reference< beans::XPropertySet > xPresentationShape(xNotesPage->getByIndex(1), uno::UNO_QUERY);
2435 CPPUNIT_ASSERT(xPresentationShape.is());
2436 bool bIsEmptyPresObject = false;
2437 xPresentationShape->getPropertyValue( "IsEmptyPresentationObject" ) >>= bIsEmptyPresObject;
2438 CPPUNIT_ASSERT(bIsEmptyPresObject);
2440 xDocShRef->DoClose();
2443 void SdImportTest::testTdf100065()
2445 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf100065.pptx"), PPTX);
2447 uno::Reference< container::XIndexAccess > xGroupShape1(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY_THROW);
2448 uno::Reference< beans::XPropertySet > xShape1(xGroupShape1->getByIndex(1), uno::UNO_QUERY_THROW);
2449 sal_Int32 nAngle1;
2450 CPPUNIT_ASSERT(xShape1->getPropertyValue("RotateAngle") >>= nAngle1);
2451 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), nAngle1);
2453 uno::Reference< container::XIndexAccess > xGroupShape2(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY_THROW);
2454 uno::Reference< beans::XPropertySet > xShape2(xGroupShape2->getByIndex(0), uno::UNO_QUERY_THROW);
2455 sal_Int32 nAngle2;
2456 CPPUNIT_ASSERT(xShape2->getPropertyValue("RotateAngle") >>= nAngle2);
2457 CPPUNIT_ASSERT_EQUAL(sal_Int32(18000), nAngle2);
2459 xDocShRef->DoClose();
2462 void SdImportTest::testTdf90626()
2464 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf90626.pptx"), PPTX);
2465 const SdrPage *pPage = GetPage(1, xDocShRef);
2466 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(pPage->GetObj(1));
2467 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr);
2468 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
2469 for(int i = 0; i < 4; i++)
2471 const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(i).GetItem(EE_PARA_NUMBULLET);
2472 CPPUNIT_ASSERT(pNumFmt);
2473 CPPUNIT_ASSERT_DOUBLES_EQUAL(long(371), pNumFmt->GetNumRule()->GetLevel(0).GetGraphicSize().getHeight(), long(1));
2476 xDocShRef->DoClose();
2479 void SdImportTest::testTdf114488()
2481 // This doc has two images - one WMF and the other PNG (fallback image).
2482 // When loading this doc, the WMF image should be preferred over the PNG image.
2483 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odg/tdf114488.fodg"), FODG);
2484 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef), uno::UNO_SET_THROW);
2485 uno::Reference<graphic::XGraphic> xGraphic;
2486 xShape->getPropertyValue("Graphic") >>= xGraphic;
2487 CPPUNIT_ASSERT(xGraphic.is());
2488 Graphic aGraphic(xGraphic);
2489 OUString sMimeType(comphelper::GraphicMimeTypeHelper::GetMimeTypeForXGraphic(xGraphic));
2490 CPPUNIT_ASSERT_EQUAL(OUString("image/x-wmf"), sMimeType);
2492 xDocShRef->DoClose();
2495 void SdImportTest::testTdf114913()
2497 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf114913.pptx"), PPTX);
2498 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(GetPage(1, xDocShRef)->GetObj(1));
2499 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr);
2500 const SvxNumBulletItem *pItem = pTxtObj->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
2501 CPPUNIT_ASSERT(pItem);
2502 CPPUNIT_ASSERT_EQUAL(long(691), pItem->GetNumRule()->GetLevel(0).GetGraphicSize().getHeight());
2504 xDocShRef->DoClose();
2507 void SdImportTest::testTdf114821()
2509 css::uno::Any aAny;
2510 sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc( "/sd/qa/unit/data/pptx/tdf114821.pptx" ), PPTX );
2512 uno::Reference< beans::XPropertySet > xPropSet( getShapeFromPage( 0, 0, xDocShRef ) );
2513 aAny = xPropSet->getPropertyValue( "Model" );
2514 CPPUNIT_ASSERT_MESSAGE( "The shape doesn't have the property", aAny.hasValue() );
2516 uno::Reference< chart::XChartDocument > xChartDoc;
2517 aAny >>= xChartDoc;
2518 CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc.is() );
2519 uno::Reference< chart2::XChartDocument > xChart2Doc( xChartDoc, uno::UNO_QUERY );
2520 CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc.is() );
2522 uno::Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xChart2Doc->getFirstDiagram(), uno::UNO_QUERY );
2523 uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xBCooSysCnt->getCoordinateSystems() );
2524 uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[0], uno::UNO_QUERY );
2526 uno::Reference< chart2::XDataSeriesContainer > xDSCnt( xCTCnt->getChartTypes()[0], uno::UNO_QUERY );
2527 CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt.is() );
2528 uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() );
2529 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32>( 1 ), aSeriesSeq.getLength() );
2531 // Check the first label
2532 const css::uno::Reference< css::beans::XPropertySet >& rPropSet0( aSeriesSeq[0]->getDataPointByIndex( 0 ) );
2533 CPPUNIT_ASSERT( rPropSet0.is() );
2534 sal_Int32 aPlacement;
2535 rPropSet0->getPropertyValue( "LabelPlacement" ) >>= aPlacement;
2536 CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::TOP, aPlacement );
2538 // Check the second label
2539 const css::uno::Reference< css::beans::XPropertySet >& rPropSet1( aSeriesSeq[0]->getDataPointByIndex( 1 ) );
2540 CPPUNIT_ASSERT( rPropSet1.is() );
2541 rPropSet1->getPropertyValue( "LabelPlacement" ) >>= aPlacement;
2542 CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::CENTER, aPlacement );
2544 // Check the third label
2545 const css::uno::Reference< css::beans::XPropertySet >& rPropSet2( aSeriesSeq[0]->getDataPointByIndex( 2 ) );
2546 CPPUNIT_ASSERT( rPropSet2.is() );
2547 rPropSet2->getPropertyValue( "LabelPlacement") >>= aPlacement;
2548 CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::TOP, aPlacement );
2550 xDocShRef->DoClose();
2553 void SdImportTest::testTdf115394()
2555 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf115394.pptx"), PPTX);
2556 double fTransitionDuration;
2558 // Slow in MS formats
2559 SdPage* pPage1 = xDocShRef->GetDoc()->GetSdPage(0, PageKind::Standard);
2560 fTransitionDuration = pPage1->getTransitionDuration();
2561 CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration);
2563 // Medium in MS formats
2564 SdPage* pPage2 = xDocShRef->GetDoc()->GetSdPage(1, PageKind::Standard);
2565 fTransitionDuration = pPage2->getTransitionDuration();
2566 CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration);
2568 // Fast in MS formats
2569 SdPage* pPage3 = xDocShRef->GetDoc()->GetSdPage(2, PageKind::Standard);
2570 fTransitionDuration = pPage3->getTransitionDuration();
2571 CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration);
2573 // Custom values
2574 SdPage* pPage4 = xDocShRef->GetDoc()->GetSdPage(3, PageKind::Standard);
2575 fTransitionDuration = pPage4->getTransitionDuration();
2576 CPPUNIT_ASSERT_EQUAL(0.25, fTransitionDuration);
2578 SdPage* pPage5 = xDocShRef->GetDoc()->GetSdPage(4, PageKind::Standard);
2579 fTransitionDuration = pPage5->getTransitionDuration();
2580 CPPUNIT_ASSERT_EQUAL(4.25, fTransitionDuration);
2582 xDocShRef->DoClose();
2585 void SdImportTest::testTdf115394PPT()
2587 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf115394.ppt"), PPT);
2588 double fTransitionDuration;
2590 // Fast
2591 SdPage* pPage1 = xDocShRef->GetDoc()->GetSdPage(0, PageKind::Standard);
2592 fTransitionDuration = pPage1->getTransitionDuration();
2593 CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration);
2595 // Medium
2596 SdPage* pPage2 = xDocShRef->GetDoc()->GetSdPage(1, PageKind::Standard);
2597 fTransitionDuration = pPage2->getTransitionDuration();
2598 CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration);
2600 // Slow
2601 SdPage* pPage3 = xDocShRef->GetDoc()->GetSdPage(2, PageKind::Standard);
2602 fTransitionDuration = pPage3->getTransitionDuration();
2603 CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration);
2605 xDocShRef->DoClose();
2608 void SdImportTest::testTdf51340()
2610 // Line spacing was not inherited from upper levels (slide layout, master slide)
2611 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf51340.pptx"), PPTX);
2612 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 1, 0, xDocShRef ) );
2614 // First paragraph has a 90% line spacing set on master slide
2615 uno::Reference<text::XTextRange> xParagraph( getParagraphFromShape( 0, xShape ) );
2616 uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
2617 css::style::LineSpacing aSpacing;
2618 xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
2619 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
2620 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(90), aSpacing.Height );
2622 // Second paragraph has a 125% line spacing set on slide layout
2623 xParagraph.set( getParagraphFromShape( 1, xShape ) );
2624 xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
2625 xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
2626 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
2627 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(125), aSpacing.Height );
2629 // Third paragraph has a 70% line spacing set directly on normal slide (master slide property is overridden)
2630 xParagraph.set( getParagraphFromShape( 2, xShape ) );
2631 xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
2632 xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
2633 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
2634 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(70), aSpacing.Height );
2636 // Fourth paragraph has a 190% line spacing set directly on normal slide (slide layout property is overridden)
2637 xParagraph.set( getParagraphFromShape( 3, xShape ) );
2638 xPropSet.set( xParagraph, uno::UNO_QUERY_THROW );
2639 xPropSet->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing;
2640 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(css::style::LineSpacingMode::PROP), aSpacing.Mode );
2641 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16>(190), aSpacing.Height );
2643 xDocShRef->DoClose();
2646 void SdImportTest::testTdf116899()
2648 // This is a PPT created in Impress and roundtripped in PP, the key times become [1, -1] in PP,
2649 // a time of -1 (-1000) in PPT means key times have to be distributed evenly between 0 and 1
2650 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf116899.ppt"), PPT);
2652 uno::Reference< drawing::XDrawPagesSupplier > xDoc(
2653 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
2654 uno::Reference< drawing::XDrawPage > xPage(
2655 xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
2656 uno::Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier(
2657 xPage, uno::UNO_QUERY_THROW );
2658 uno::Reference< animations::XAnimationNode > xRootNode(
2659 xAnimNodeSupplier->getAnimationNode() );
2660 std::vector< uno::Reference< animations::XAnimationNode > > aAnimVector;
2661 anim::create_deep_vector(xRootNode, aAnimVector);
2662 uno::Reference< animations::XAnimate > xNode(
2663 aAnimVector[8], uno::UNO_QUERY_THROW );
2664 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of key times in the animation node isn't 2.", static_cast<sal_Int32>(2), xNode->getKeyTimes().getLength() );
2665 CPPUNIT_ASSERT_EQUAL_MESSAGE( "First key time in the animation node isn't 0, key times aren't normalized.", 0., xNode->getKeyTimes()[0] );
2666 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second key time in the animation node isn't 1, key times aren't normalized.", 1., xNode->getKeyTimes()[1] );
2668 xDocShRef->DoClose();
2671 void SdImportTest::testTdf77747()
2673 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/ppt/tdf77747.ppt"), PPT);
2674 CPPUNIT_ASSERT(xDocShRef.is());
2675 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>(GetPage(1, xDocShRef)->GetObj(0));
2676 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj != nullptr);
2677 const SvxNumBulletItem *pNumFmt = pTxtObj->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
2678 CPPUNIT_ASSERT(pNumFmt);
2679 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", OUString("-"), pNumFmt->GetNumRule()->GetLevel(0).GetSuffix() );
2680 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's numbering type is wrong!", SVX_NUM_NUMBER_HEBREW,
2681 pNumFmt->GetNumRule()->GetLevel(0).GetNumberingType());
2683 xDocShRef->DoClose();
2686 void SdImportTest::testTdf116266()
2688 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/tdf116266.odp"), ODP);
2689 SdDrawDocument *pDoc = xDocShRef->GetDoc();
2690 sfx2::LinkManager* rLinkManager = pDoc->GetLinkManager();
2691 // The document contains one SVG stored as a link.
2692 CPPUNIT_ASSERT_EQUAL(size_t(1), rLinkManager->GetLinks().size());
2694 xDocShRef->DoClose();
2697 void SdImportTest::testTdf119015()
2699 ::sd::DrawDocShellRef xDocShRef
2700 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf119015.pptx"), PPTX);
2702 const SdrPage* pPage = GetPage(1, xDocShRef);
2704 sdr::table::SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
2705 CPPUNIT_ASSERT(pTableObj);
2706 // The position was previously not properly initialized: (0, 0, 100, 100)
2707 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(6991, 6902), Size(14099, 1999)),
2708 pTableObj->GetLogicRect());
2709 uno::Reference<table::XTable> xTable(pTableObj->getTable());
2711 // Test that we actually have three cells: this threw css.lang.IndexOutOfBoundsException
2712 uno::Reference<text::XTextRange> xTextRange(xTable->getCellByPosition(1, 0),
2713 uno::UNO_QUERY_THROW);
2714 CPPUNIT_ASSERT_EQUAL(OUString("A3"), xTextRange->getString());
2716 xDocShRef->DoClose();
2719 void SdImportTest::testTdf123090()
2721 ::sd::DrawDocShellRef xDocShRef
2722 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf123090.pptx"), PPTX);
2724 const SdrPage* pPage = GetPage(1, xDocShRef);
2726 sdr::table::SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
2727 CPPUNIT_ASSERT(pTableObj);
2729 uno::Reference<table::XTable> xTable(pTableObj->getTable());
2731 // Test that we actually have two cells: this threw css.lang.IndexOutOfBoundsException
2732 uno::Reference<text::XTextRange> xTextRange(xTable->getCellByPosition(1, 0),
2733 uno::UNO_QUERY_THROW);
2734 CPPUNIT_ASSERT_EQUAL(OUString("aaa"), xTextRange->getString());
2736 sal_Int32 nWidth;
2737 const OUString sWidth("Width");
2738 uno::Reference< css::table::XTableColumns > xColumns( xTable->getColumns(), uno::UNO_SET_THROW);
2739 uno::Reference< beans::XPropertySet > xRefColumn( xColumns->getByIndex(1), uno::UNO_QUERY_THROW );
2740 xRefColumn->getPropertyValue( sWidth ) >>= nWidth;
2741 CPPUNIT_ASSERT_EQUAL( sal_Int32(9136), nWidth);
2743 xDocShRef->DoClose();
2746 void SdImportTest::testTdf120028()
2748 // Check that the table shape has 4 columns.
2749 ::sd::DrawDocShellRef xDocShRef
2750 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf120028.pptx"), PPTX);
2751 uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(),
2752 uno::UNO_QUERY);
2753 CPPUNIT_ASSERT(xDoc.is());
2755 uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
2756 CPPUNIT_ASSERT(xPage.is());
2758 // This failed, shape was not a table, all text was rendered in a single
2759 // column.
2760 uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage));
2761 uno::Reference<table::XColumnRowRange> xModel(xShape->getPropertyValue("Model"),
2762 uno::UNO_QUERY);
2763 CPPUNIT_ASSERT(xModel.is());
2765 uno::Reference<table::XTableColumns> xColumns = xModel->getColumns();
2766 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xColumns->getCount());
2768 // Check font size in the A1 cell.
2769 uno::Reference<table::XCellRange> xCells(xModel, uno::UNO_QUERY);
2770 uno::Reference<beans::XPropertySet> xCell(xCells->getCellByPosition(0, 0), uno::UNO_QUERY);
2771 uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xCell));
2772 uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
2773 uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY);
2774 double fCharHeight = 0;
2775 xPropSet->getPropertyValue("CharHeight") >>= fCharHeight;
2776 // This failed, non-scaled height was 13.5.
2777 CPPUNIT_ASSERT_DOUBLES_EQUAL(11.5, fCharHeight, 1E-12);
2779 xDocShRef->DoClose();
2782 void SdImportTest::testTdf120028b()
2784 // Check that the table shape has 4 columns.
2785 ::sd::DrawDocShellRef xDocShRef
2786 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf120028b.pptx"), PPTX);
2787 uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(),
2788 uno::UNO_QUERY);
2789 CPPUNIT_ASSERT(xDoc.is());
2791 uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
2792 CPPUNIT_ASSERT(xPage.is());
2794 uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage));
2795 CPPUNIT_ASSERT(xShape.is());
2797 uno::Reference<table::XColumnRowRange> xModel(xShape->getPropertyValue("Model"),
2798 uno::UNO_QUERY);
2799 CPPUNIT_ASSERT(xModel.is());
2801 uno::Reference<table::XTableColumns> xColumns = xModel->getColumns();
2802 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xColumns->getCount());
2804 // Check font color in the A1 cell.
2805 uno::Reference<table::XCellRange> xCells(xModel, uno::UNO_QUERY);
2806 uno::Reference<beans::XPropertySet> xCell(xCells->getCellByPosition(0, 0), uno::UNO_QUERY);
2807 uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xCell));
2808 uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
2809 uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY);
2810 sal_Int32 nCharColor = 0;
2811 xPropSet->getPropertyValue("CharColor") >>= nCharColor;
2812 // This was 0x1f497d, not white: text list style from placeholder shape
2813 // from slide layout was ignored.
2814 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffff), nCharColor);
2816 xDocShRef->DoClose();
2819 void SdImportTest::testTdf126324()
2821 sd::DrawDocShellRef xDocShRef
2822 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf126324.pptx"), PPTX);
2823 uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(),
2824 uno::UNO_QUERY);
2825 CPPUNIT_ASSERT(xDoc.is());
2826 uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
2827 CPPUNIT_ASSERT(xPage.is());
2828 uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage));
2829 CPPUNIT_ASSERT(xShape.is());
2830 uno::Reference< text::XText > xText = uno::Reference< text::XTextRange>( xShape, uno::UNO_QUERY_THROW )->getText();
2831 CPPUNIT_ASSERT_EQUAL(OUString{"17"}, xText->getString());
2834 void SdImportTest::testDescriptionImport()
2836 sd::DrawDocShellRef xDocShRef
2837 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/altdescription.pptx"), PPTX);
2839 uno::Reference<beans::XPropertySet> xPropertySet(
2840 getShapeFromPage(/*nShape=*/2, /*nPage=*/0, xDocShRef));
2841 OUString sDesc;
2843 xPropertySet->getPropertyValue("Description") >>= sDesc;
2845 CPPUNIT_ASSERT_EQUAL(OUString("We Can Do It!"), sDesc);
2847 xDocShRef->DoClose();
2850 void SdImportTest::testTdf83247()
2852 auto GetPause = [this](const OUString& sSrc, sal_Int32 nFormat) {
2853 sd::DrawDocShellRef xDocShRef
2854 = loadURL(m_directories.getURLFromSrc(sSrc), nFormat);
2855 uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(
2856 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
2857 uno::Reference<beans::XPropertySet> xPresentationProps(
2858 xPresentationSupplier->getPresentation(), uno::UNO_QUERY_THROW);
2860 auto retVal = xPresentationProps->getPropertyValue("Pause");
2861 xDocShRef->DoClose();
2862 return retVal.get<sal_Int32>();
2865 // 1. Check that presentation:pause attribute is imported correctly
2866 CPPUNIT_ASSERT_EQUAL(sal_Int32(10), GetPause("/sd/qa/unit/data/odp/loopPause10.odp", ODP));
2868 // 2. ODF compliance: if presentation:pause attribute is absent, it must be treated as 0
2869 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause("/sd/qa/unit/data/odp/loopNoPause.odp", ODP));
2871 // 3. Import PPT: pause should be 0
2872 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause("/sd/qa/unit/data/ppt/loopNoPause.ppt", PPT));
2875 void SdImportTest::testTdf47365()
2877 sd::DrawDocShellRef xDocShRef
2878 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/loopNoPause.pptx"), PPTX);
2879 uno::Reference<presentation::XPresentationSupplier> xPresentationSupplier(
2880 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
2881 uno::Reference<beans::XPropertySet> xPresentationProps(xPresentationSupplier->getPresentation(),
2882 uno::UNO_QUERY_THROW);
2884 const bool bEndlessVal = xPresentationProps->getPropertyValue("IsEndless").get<bool>();
2885 const sal_Int32 nPauseVal = xPresentationProps->getPropertyValue("Pause").get<sal_Int32>();
2887 // Check that we import "loop" attribute of the presentation, and don't introduce any pauses
2888 CPPUNIT_ASSERT(bEndlessVal);
2889 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPauseVal);
2891 xDocShRef->DoClose();
2894 void SdImportTest::testTdf122899()
2896 // tdf122899 FILEOPEN: ppt: old kind arc from MS Office 97 is broken
2897 // Error was, that the path coordinates of a mso_sptArc shape were read as sal_Int16
2898 // although they are unsigned 16 bit. This leads to wrong positions of start and end
2899 // point and results to a huge shape width in the test document.
2900 OUString aSrc="sd/qa/unit/data/ppt/tdf122899_Arc_90_to_91_clockwise.ppt";
2901 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(aSrc), PPT);
2902 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(
2903 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
2904 CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
2905 uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
2906 uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
2907 CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage.is());
2908 uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
2909 CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape.is());
2910 awt::Rectangle aFrameRect;
2911 uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
2912 CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps.is());
2913 xShapeProps->getPropertyValue(UNO_NAME_MISC_OBJ_FRAMERECT) >>= aFrameRect;
2914 // original width is 9cm, add some tolerance
2915 CPPUNIT_ASSERT_LESS(static_cast<sal_Int32>(9020), aFrameRect.Width);
2917 xDocShRef->DoClose();
2920 void SdImportTest::testOOXTheme()
2922 sd::DrawDocShellRef xDocShRef
2923 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/ooxtheme.pptx"), PPTX);
2925 uno::Reference<beans::XPropertySet> xPropSet(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
2926 uno::Sequence<beans::PropertyValue> aGrabBag;
2927 xPropSet->getPropertyValue("InteropGrabBag") >>= aGrabBag;
2929 bool bTheme = false;
2930 for (int i = 0; i < aGrabBag.getLength(); i++)
2932 if (aGrabBag[i].Name == "OOXTheme")
2934 bTheme = true;
2935 uno::Reference<xml::dom::XDocument> aThemeDom;
2936 CPPUNIT_ASSERT(aGrabBag[i].Value >>= aThemeDom); // PropertyValue of proper type
2937 CPPUNIT_ASSERT(aThemeDom.get()); // Reference not empty
2940 CPPUNIT_ASSERT(bTheme); // Grab Bag has all the expected elements
2942 xDocShRef->DoClose();
2945 void SdImportTest::testCropToShape()
2947 sd::DrawDocShellRef xDocShRef
2948 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/crop-to-shape.pptx"), PPTX);
2949 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(
2950 xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW);
2951 CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier.is());
2952 uno::Reference<drawing::XDrawPages> xDrawPages(xDrawPagesSupplier->getDrawPages());
2953 uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPages->getByIndex(0), uno::UNO_QUERY_THROW);
2954 CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage.is());
2955 uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
2956 CPPUNIT_ASSERT_EQUAL(OUString{"com.sun.star.drawing.CustomShape"}, xShape->getShapeType());
2957 CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape.is());
2958 uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
2959 css::drawing::FillStyle fillStyle;
2960 xShapeProps->getPropertyValue("FillStyle") >>= fillStyle;
2961 CPPUNIT_ASSERT_EQUAL(css::drawing::FillStyle_BITMAP, fillStyle);
2962 css::drawing::BitmapMode bitmapmode;
2963 xShapeProps->getPropertyValue("FillBitmapMode") >>= bitmapmode;
2964 CPPUNIT_ASSERT_EQUAL(css::drawing::BitmapMode_STRETCH, bitmapmode);
2967 void SdImportTest::testTdf127964()
2969 sd::DrawDocShellRef xDocShRef
2970 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf127964.pptx"), PPTX);
2971 const SdrPage* pPage = GetPage(1, xDocShRef);
2972 const SdrObject* pObj = pPage->GetObj(0);
2973 auto& rFillStyleItem
2974 = dynamic_cast<const XFillStyleItem&>(pObj->GetMergedItem(XATTR_FILLSTYLE));
2975 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rFillStyleItem.GetValue());
2977 auto& rFillColorItem
2978 = dynamic_cast<const XFillColorItem&>(pObj->GetMergedItem(XATTR_FILLCOLOR));
2979 // Without the accompanying fix in place, this test would have failed with:
2980 // - Expected: 4294967295
2981 // - Actual : 5210557
2982 // i.e. instead of transparent (which then got rendered as white), the shape fill color was
2983 // blue.
2984 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT, rFillColorItem.GetColorValue());
2985 xDocShRef->DoClose();
2988 void SdImportTest::testTdf106638()
2990 sd::DrawDocShellRef xDocShRef
2991 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf106638.pptx"), PPTX);
2992 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0, xDocShRef));
2993 uno::Reference<text::XTextRange> const xPara(getParagraphFromShape(1, xShape));
2994 uno::Reference<text::XText> xText= xPara->getText();
2995 uno::Reference<text::XTextCursor> xTextCursor = xText->createTextCursorByRange(xPara->getStart());
2996 uno::Reference<beans::XPropertySet> xPropSet(xTextCursor, uno::UNO_QUERY_THROW );
2997 OUString aCharFontName;
2998 CPPUNIT_ASSERT(xTextCursor->goRight(1, true));
2999 // First character U+f0fe that uses Wingding
3000 xPropSet->getPropertyValue("CharFontName") >>= aCharFontName;
3001 CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), aCharFontName);
3003 // The rest characters that do not use Wingding.
3004 CPPUNIT_ASSERT(xTextCursor->goRight(45, true));
3005 xPropSet->getPropertyValue("CharFontName") >>= aCharFontName;
3006 CPPUNIT_ASSERT(aCharFontName != "Wingdings");
3009 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
3011 CPPUNIT_PLUGIN_IMPLEMENT();
3013 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */