1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <sal/config.h>
12 #include <config_features.h>
13 #include <config_poppler.h>
18 #include "sdmodeltestbase.hxx"
20 #include <o3tl/cppunittraitshelper.hxx>
21 #include <svl/stritem.hxx>
22 #include <editeng/eeitem.hxx>
23 #include <editeng/editobj.hxx>
24 #include <editeng/outlobj.hxx>
25 #include <editeng/ulspitem.hxx>
26 #include <editeng/fhgtitem.hxx>
27 #include <editeng/escapementitem.hxx>
28 #include <editeng/colritem.hxx>
29 #include <editeng/numitem.hxx>
30 #include <editeng/unoprnms.hxx>
31 #include <sfx2/app.hxx>
32 #include <sfx2/sfxsids.hrc>
33 #include <svl/style.hxx>
35 #include <svx/svdotext.hxx>
36 #include <svx/svdoashp.hxx>
37 #include <svx/svdogrp.hxx>
38 #include <svx/svdoole2.hxx>
39 #include <svx/svdotable.hxx>
40 #include <svx/xfillit0.hxx>
41 #include <svx/xflclit.hxx>
42 #include <svx/xlineit0.hxx>
43 #include <svx/xlnclit.hxx>
44 #include <svx/xlnwtit.hxx>
45 #include <svx/sdasitm.hxx>
46 #include <svx/sdmetitm.hxx>
47 #include <svx/sdooitm.hxx>
48 #include <animations/animationnodehelper.hxx>
49 #include <sax/tools/converter.hxx>
51 #include <com/sun/star/awt/Gradient.hpp>
52 #include <com/sun/star/awt/XBitmap.hpp>
53 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
54 #include <com/sun/star/document/XEventsSupplier.hpp>
55 #include <com/sun/star/presentation/ClickAction.hpp>
56 #include <com/sun/star/presentation/XPresentationPage.hpp>
57 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
58 #include <com/sun/star/drawing/BitmapMode.hpp>
59 #include <com/sun/star/drawing/ColorMode.hpp>
60 #include <com/sun/star/drawing/GraphicExportFilter.hpp>
61 #include <com/sun/star/drawing/XDrawPage.hpp>
62 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
63 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
64 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
65 #include <com/sun/star/drawing/GluePoint2.hpp>
66 #include <com/sun/star/container/XIdentifierAccess.hpp>
67 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
68 #include <com/sun/star/animations/XAnimationNode.hpp>
69 #include <com/sun/star/animations/XAnimate.hpp>
70 #include <com/sun/star/beans/XPropertySet.hpp>
71 #include <com/sun/star/chart/DataLabelPlacement.hpp>
72 #include <com/sun/star/chart/XChartDocument.hpp>
73 #include <com/sun/star/chart2/XChartDocument.hpp>
74 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
75 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
76 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
77 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
78 #include <com/sun/star/chart2/data/XDataSequence.hpp>
79 #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
80 #include <com/sun/star/graphic/XGraphic.hpp>
81 #include <com/sun/star/table/BorderLineStyle.hpp>
82 #include <com/sun/star/table/BorderLine2.hpp>
83 #include <com/sun/star/style/ParagraphAdjust.hpp>
84 #include <com/sun/star/style/LineSpacing.hpp>
85 #include <com/sun/star/style/LineSpacingMode.hpp>
86 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
87 #include <com/sun/star/table/XTableRows.hpp>
88 #include <com/sun/star/style/NumberingType.hpp>
89 #include <com/sun/star/frame/Desktop.hpp>
90 #include <com/sun/star/text/GraphicCrop.hpp>
91 #include <com/sun/star/text/XTextCursor.hpp>
92 #include <com/sun/star/xml/dom/XDocument.hpp>
94 #include <stlpool.hxx>
95 #include <comphelper/processfactory.hxx>
96 #include <comphelper/sequenceashashmap.hxx>
97 #include <comphelper/graphicmimetype.hxx>
98 #include <comphelper/lok.hxx>
99 #include <vcl/pngread.hxx>
100 #include <vcl/bitmapaccess.hxx>
101 #include <vcl/dibtools.hxx>
102 #include <svx/svdograf.hxx>
104 using namespace ::com::sun::star
;
106 namespace com::sun::star::uno
{
109 static std::ostream
& operator<<(std::ostream
& rStrm
, const uno::Reference
<T
>& xRef
)
118 /// Impress import filters tests.
119 class SdImportTest
: public SdModelTestBase
122 virtual void setUp() override
;
124 void testDocumentLayout();
125 void testHyperlinkColor();
126 void testSmoketest();
129 void testMasterPageStyleParent();
130 void testGradientAngle();
132 void testFillStyleNone();
135 void testN828390_2();
136 void testN828390_3();
138 void testPlaceholderPriority();
141 void testStrictOOXML();
142 void testN862510_1();
143 void testN862510_2();
144 void testN862510_4();
145 void testBnc870237();
146 void testBnc887225();
147 void testPredefinedTableStyle();
148 void testBnc591147();
149 void testCreationDate();
150 void testMultiColTexts();
151 void testBnc584721_1();
152 void testBnc584721_2();
153 void testBnc584721_4();
154 void testBnc904423();
155 void testShapeLineStyle();
156 void testTableBorderLineStyle();
157 void testBnc862510_6();
158 void testBnc862510_7();
160 #if HAVE_FEATURE_PDFIUM
161 void testPDFImportShared();
163 #if defined(IMPORT_PDF_ELEMENTS)
164 void testPDFImport();
165 void testPDFImportSkipImages();
168 void testBulletSuffix();
169 void testBnc910045();
170 void testRowHeight();
172 void testTdf127129();
175 void testTdf113163();
183 void testTdf103473();
184 void testAoo124143();
185 void testTdf103567();
186 void testTdf103792();
187 void testTdf103876();
189 void testTdf129686();
190 void testTdf104015();
191 void testTdf104201();
192 void testTdf103477();
193 void testTdf104445();
194 void testTdf105150();
195 void testTdf105150PPT();
196 void testTdf123684();
197 void testTdf100926();
199 void testTdf108925();
200 void testTdf109067();
201 void testTdf109187();
202 void testTdf108926();
203 void testTdf100065();
205 void testTdf138148();
206 void testTdf114488();
207 void testTdf134174();
208 void testTdf134210();
209 void testTdf114913();
210 void testTdf114821();
211 void testTdf115394();
212 void testTdf115394PPT();
214 void testTdf116899();
216 void testTdf116266();
217 void testTdf128684();
218 void testShapeGlowEffectPPTXImpoer();
219 void testShapeBlurPPTXImport();
220 void testMirroredGraphic();
221 void testGreysScaleGraphic();
222 void testTdf134210CropPosition();
224 bool checkPattern(sd::DrawDocShellRef
const & rDocRef
, int nShapeNumber
, std::vector
<sal_uInt8
>& rExpected
);
225 void testPatternImport();
227 void testTdf120028();
228 void testTdf120028b();
229 void testDescriptionImport();
232 void testTdf122899();
234 void testCropToShape();
235 void testTdf127964();
236 void testTdf106638();
237 void testTdf113198();
240 CPPUNIT_TEST_SUITE(SdImportTest
);
242 CPPUNIT_TEST(testDocumentLayout
);
243 CPPUNIT_TEST(testHyperlinkColor
);
244 CPPUNIT_TEST(testSmoketest
);
245 CPPUNIT_TEST(testN759180
);
246 CPPUNIT_TEST(testN778859
);
247 CPPUNIT_TEST(testMasterPageStyleParent
);
248 CPPUNIT_TEST(testGradientAngle
);
249 CPPUNIT_TEST(testTdf97808
);
250 CPPUNIT_TEST(testFillStyleNone
);
251 CPPUNIT_TEST(testFdo64512
);
252 CPPUNIT_TEST(testFdo71075
);
253 CPPUNIT_TEST(testN828390_2
);
254 CPPUNIT_TEST(testN828390_3
);
255 CPPUNIT_TEST(testFdo68594
);
256 CPPUNIT_TEST(testPlaceholderPriority
);
257 CPPUNIT_TEST(testFdo72998
);
258 CPPUNIT_TEST(testFdo77027
);
259 CPPUNIT_TEST(testStrictOOXML
);
260 CPPUNIT_TEST(testN862510_1
);
261 CPPUNIT_TEST(testN862510_2
);
262 CPPUNIT_TEST(testN862510_4
);
263 CPPUNIT_TEST(testBnc870237
);
264 CPPUNIT_TEST(testBnc887225
);
265 CPPUNIT_TEST(testPredefinedTableStyle
);
266 CPPUNIT_TEST(testBnc591147
);
267 CPPUNIT_TEST(testCreationDate
);
268 CPPUNIT_TEST(testMultiColTexts
);
269 CPPUNIT_TEST(testBnc584721_1
);
270 CPPUNIT_TEST(testBnc584721_2
);
271 CPPUNIT_TEST(testBnc584721_4
);
272 CPPUNIT_TEST(testBnc904423
);
273 CPPUNIT_TEST(testShapeLineStyle
);
274 CPPUNIT_TEST(testTableBorderLineStyle
);
275 CPPUNIT_TEST(testBnc862510_6
);
276 CPPUNIT_TEST(testBnc862510_7
);
278 #if HAVE_FEATURE_PDFIUM
279 CPPUNIT_TEST(testPDFImportShared
);
281 #if defined(IMPORT_PDF_ELEMENTS)
282 CPPUNIT_TEST(testPDFImport
);
283 CPPUNIT_TEST(testPDFImportSkipImages
);
286 CPPUNIT_TEST(testBulletSuffix
);
287 CPPUNIT_TEST(testBnc910045
);
288 CPPUNIT_TEST(testRowHeight
);
289 CPPUNIT_TEST(testTdf93830
);
290 CPPUNIT_TEST(testTdf127129
);
291 CPPUNIT_TEST(testTdf93097
);
292 CPPUNIT_TEST(testTdf62255
);
293 CPPUNIT_TEST(testTdf113163
);
294 CPPUNIT_TEST(testTdf93124
);
295 CPPUNIT_TEST(testTdf99729
);
296 CPPUNIT_TEST(testTdf89927
);
297 CPPUNIT_TEST(testTdf93868
);
298 CPPUNIT_TEST(testTdf95932
);
299 CPPUNIT_TEST(testTdf99030
);
300 CPPUNIT_TEST(testTdf49561
);
301 CPPUNIT_TEST(testTdf103473
);
302 CPPUNIT_TEST(testAoo124143
);
303 CPPUNIT_TEST(testTdf103567
);
304 CPPUNIT_TEST(testTdf103792
);
305 CPPUNIT_TEST(testTdf103876
);
306 CPPUNIT_TEST(testTdf79007
);
307 CPPUNIT_TEST(testTdf129686
);
308 CPPUNIT_TEST(testTdf104015
);
309 CPPUNIT_TEST(testTdf104201
);
310 CPPUNIT_TEST(testTdf103477
);
311 CPPUNIT_TEST(testTdf104445
);
312 CPPUNIT_TEST(testTdf105150
);
313 CPPUNIT_TEST(testTdf105150PPT
);
314 CPPUNIT_TEST(testTdf123684
);
315 CPPUNIT_TEST(testTdf100926
);
316 CPPUNIT_TEST(testPatternImport
);
317 CPPUNIT_TEST(testTdf89064
);
318 CPPUNIT_TEST(testTdf108925
);
319 CPPUNIT_TEST(testTdf109067
);
320 CPPUNIT_TEST(testTdf109187
);
321 CPPUNIT_TEST(testTdf108926
);
322 CPPUNIT_TEST(testTdf100065
);
323 CPPUNIT_TEST(testTdf90626
);
324 CPPUNIT_TEST(testTdf138148
);
325 CPPUNIT_TEST(testTdf114488
);
326 CPPUNIT_TEST(testTdf134174
);
327 CPPUNIT_TEST(testTdf134210
);
328 CPPUNIT_TEST(testTdf114913
);
329 CPPUNIT_TEST(testTdf114821
);
330 CPPUNIT_TEST(testTdf115394
);
331 CPPUNIT_TEST(testTdf115394PPT
);
332 CPPUNIT_TEST(testTdf51340
);
333 CPPUNIT_TEST(testTdf116899
);
334 CPPUNIT_TEST(testTdf77747
);
335 CPPUNIT_TEST(testTdf116266
);
336 CPPUNIT_TEST(testPptCrop
);
337 CPPUNIT_TEST(testTdf120028
);
338 CPPUNIT_TEST(testTdf120028b
);
339 CPPUNIT_TEST(testDescriptionImport
);
340 CPPUNIT_TEST(testTdf83247
);
341 CPPUNIT_TEST(testTdf47365
);
342 CPPUNIT_TEST(testTdf122899
);
343 CPPUNIT_TEST(testOOXTheme
);
344 CPPUNIT_TEST(testCropToShape
);
345 CPPUNIT_TEST(testTdf127964
);
346 CPPUNIT_TEST(testTdf106638
);
347 CPPUNIT_TEST(testTdf128684
);
348 CPPUNIT_TEST(testTdf113198
);
349 CPPUNIT_TEST(testTdf49856
);
350 CPPUNIT_TEST(testShapeGlowEffectPPTXImpoer
);
351 CPPUNIT_TEST(testShapeBlurPPTXImport
);
352 CPPUNIT_TEST(testMirroredGraphic
);
353 CPPUNIT_TEST(testGreysScaleGraphic
);
354 CPPUNIT_TEST(testTdf134210CropPosition
);
356 CPPUNIT_TEST_SUITE_END();
359 void SdImportTest::setUp()
361 SdModelTestBase::setUp();
362 mxDesktop
.set(frame::Desktop::create(getComponentContext()));
365 /** Test document against a reference XML dump of shapes.
367 If you want to update one of these tests, or add a new one, set the nUpdateMe
368 to the index of the test, and the dump XML's will be created (or rewritten)
369 instead of checking. Use with care - when the test is failing, first find out
370 why, instead of just updating .xml's blindly.
372 Example: Let's say you are adding a test called fdoABCD.pptx. You'll place it
373 to the data/ subdirectory, and will add an entry to aFilesToCompare below,
374 the 3rd parameter is for export test - can be -1 (don't export), ODP, PPT or PPTX
377 { "fdoABCD.pptx", "xml/fdoABCD_", PPTX },
379 and will count the index in the aFilesToCompare structure (1st is 0, 2nd is 1,
380 etc.) Temporarily you'll set nUpdateMe to this index (instead of -1), and run
384 This will generate the sd/qa/unit/data/xml/fdoABCD_*.xml for you. Now you
385 will change nUpdateMe back to -1, and commit your fdoABCD.pptx test, the
386 xml/fdoABCD_*.xml dumps, and the aFilesToCompare addition in one commit.
388 As the last step, you will revert your fix and do 'make sd' again, to check
389 that without your fix, the unit test breaks. Then clean up, and push :-)
391 NOTE: This approach is suitable only for tests of fixes that actually change
392 the layout - best to check by reverting your fix locally after having added
393 the test, and re-running; it should break.
395 void SdImportTest::testDocumentLayout()
397 static const struct { const char *pInput
, *pDump
; sal_Int32 nFormat
; sal_Int32 nExportType
; } aFilesToCompare
[] =
399 { "odp/shapes-test.odp", "xml/shapes-test_page", ODP
, -1 },
400 { "fdo47434.pptx", "xml/fdo47434_", PPTX
, -1 },
401 { "n758621.ppt", "xml/n758621_", PPT
, -1 },
402 { "fdo64586.ppt", "xml/fdo64586_", PPT
, -1 },
403 { "n819614.pptx", "xml/n819614_", PPTX
, -1 },
404 { "n820786.pptx", "xml/n820786_", PPTX
, -1 },
405 { "n762695.pptx", "xml/n762695_", PPTX
, -1 },
406 { "n593612.pptx", "xml/n593612_", PPTX
, -1 },
407 { "fdo71434.pptx", "xml/fdo71434_", PPTX
, -1 },
408 { "n902652.pptx", "xml/n902652_", PPTX
, -1 },
409 { "tdf90403.pptx", "xml/tdf90403_", PPTX
, -1 },
410 { "tdf90338.odp", "xml/tdf90338_", ODP
, PPTX
},
411 { "tdf92001.odp", "xml/tdf92001_", ODP
, PPTX
},
412 // GCC -mfpmath=387 rounding issues in lclPushMarkerProperties
413 // (oox/source/drawingml/lineproperties.cxx); see mail sub-thread starting at
414 // <https://lists.freedesktop.org/archives/libreoffice/2016-September/
415 // 075211.html> "Re: Test File: sc/qa/unit/data/functions/fods/chiinv.fods:
416 // fails with Assertion" for how "-mfpmath=sse -msse2" would fix that:
417 #if !(defined LINUX && defined X86)
418 { "tdf100491.pptx", "xml/tdf100491_", PPTX
, -1 },
420 { "tdf109317.pptx", "xml/tdf109317_", PPTX
, ODP
},
421 // { "pptx/n828390.pptx", "pptx/xml/n828390_", PPTX, PPTX }, // Example
424 for ( int i
= 0; i
< static_cast< int >( SAL_N_ELEMENTS( aFilesToCompare
) ); ++i
)
426 int const nUpdateMe
= -1; // index of test we want to update; supposedly only when the test is created
428 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare
[i
].pInput
), aFilesToCompare
[i
].nFormat
);
429 if( aFilesToCompare
[i
].nExportType
>= 0 )
430 xDocShRef
= saveAndReload( xDocShRef
.get(), aFilesToCompare
[i
].nExportType
);
431 compareWithShapesDump( xDocShRef
,
432 m_directories
.getPathFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare
[i
].pDump
),
437 void SdImportTest::testHyperlinkColor()
439 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc(u
"/sd/qa/unit/data/pptx/tdf137367.pptx"), PPTX
);
441 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
443 // Get first paragraph of the text
444 uno::Reference
<text::XTextRange
> const xParagraph1( getParagraphFromShape( 0, xShape
) );
445 // Get second paragraph of the text
446 uno::Reference
<text::XTextRange
> const xParagraph2( getParagraphFromShape( 1, xShape
) );
447 // Get third paragraph of the text
448 uno::Reference
<text::XTextRange
> const xParagraph3( getParagraphFromShape( 2, xShape
) );
450 // Get run of the first paragraph
451 uno::Reference
<text::XTextRange
> xRun1( getRunFromParagraph (0, xParagraph1
) );
452 uno::Reference
< beans::XPropertySet
> xPropSet1( xRun1
, uno::UNO_QUERY_THROW
);
453 sal_Int32 nCharColorBlue
;
454 xPropSet1
->getPropertyValue( "CharColor" ) >>= nCharColorBlue
;
456 // Get run of the second paragraph
457 uno::Reference
<text::XTextRange
> xRun2( getRunFromParagraph (1, xParagraph2
) );
458 uno::Reference
< beans::XPropertySet
> xPropSet2( xRun2
, uno::UNO_QUERY_THROW
);
459 sal_Int32 nCharColorRed
;
460 xPropSet2
->getPropertyValue( "CharColor" ) >>= nCharColorRed
;
462 // Get run of the third paragraph
463 uno::Reference
<text::XTextRange
> xRun3( getRunFromParagraph (2, xParagraph3
) );
464 uno::Reference
< beans::XPropertySet
> xPropSet3( xRun3
, uno::UNO_QUERY_THROW
);
465 sal_Int32 nCharColorGreen
;
466 xPropSet3
->getPropertyValue( "CharColor" ) >>= nCharColorGreen
;
468 // Hyperlink colors should be blue, red, green.
469 CPPUNIT_ASSERT_EQUAL( sal_Int32(4485828), nCharColorBlue
);
470 CPPUNIT_ASSERT_EQUAL( sal_Int32(16711680), nCharColorRed
);
471 CPPUNIT_ASSERT_EQUAL( sal_Int32(5538357), nCharColorGreen
);
473 xDocShRef
->DoClose();
476 void SdImportTest::testSmoketest()
478 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/smoketest.pptx"), PPTX
);
480 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
481 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= nullptr );
483 // cf. SdrModel svx/svdmodel.hxx ...
485 CPPUNIT_ASSERT_EQUAL_MESSAGE( "wrong page count", static_cast<sal_uInt16
>(3), pDoc
->GetPageCount());
487 const SdrPage
*pPage
= pDoc
->GetPage (1);
488 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= nullptr );
490 CPPUNIT_ASSERT_MESSAGE( "changed", !pDoc
->IsChanged() );
492 xDocShRef
->DoClose();
495 void SdImportTest::testN759180()
497 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/n759180.pptx"), PPTX
);
499 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
502 SdrObject
*pObj
= pPage
->GetObj(0);
503 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
504 CPPUNIT_ASSERT(pTxtObj
);
505 std::vector
<EECharAttrib
> rLst
;
506 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
507 const SvxULSpaceItem
*pULSpace
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_ULSPACE
);
508 CPPUNIT_ASSERT(pULSpace
);
509 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Para bottom spacing is wrong!", static_cast<sal_uInt16
>(0), pULSpace
->GetLower());
510 aEdit
.GetCharAttribs(1, rLst
);
511 auto it
= std::find_if(rLst
.rbegin(), rLst
.rend(),
512 [](const EECharAttrib
& rCharAttr
) { return dynamic_cast<const SvxFontHeightItem
*>(rCharAttr
.pAttr
) != nullptr; });
513 if (it
!= rLst
.rend())
515 const SvxFontHeightItem
* pFontHeight
= dynamic_cast<const SvxFontHeightItem
*>((*it
).pAttr
);
517 // font height = 5 => 5*2540/72
518 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font height is wrong", static_cast<sal_uInt32
>(176), pFontHeight
->GetHeight() );
521 xDocShRef
->DoClose();
524 void SdImportTest::testN862510_1()
526 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/n862510_1.pptx"), PPTX
);
528 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
530 std::vector
<EECharAttrib
> rLst
;
531 SdrObject
*pObj
= pPage
->GetObj( 0 );
532 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
533 CPPUNIT_ASSERT( pTxtObj
);
534 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
535 aEdit
.GetCharAttribs( 0, rLst
);
536 for( std::vector
<EECharAttrib
>::reverse_iterator it
= rLst
.rbegin(); it
!=rLst
.rend(); ++it
)
538 const SvxEscapementItem
*pFontEscapement
= dynamic_cast<const SvxEscapementItem
*>( (*it
).pAttr
);
539 CPPUNIT_ASSERT_MESSAGE( "Baseline attribute not handled properly", !(pFontEscapement
&& pFontEscapement
->GetProportionalHeight() != 100) );
543 xDocShRef
->DoClose();
546 void SdImportTest::testN862510_2()
548 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/n862510_2.pptx"), PPTX
);
550 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
552 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage
->GetObjCount());
553 SdrObjGroup
*pGrpObj
= dynamic_cast<SdrObjGroup
*>( pPage
->GetObj( 0 ) );
554 CPPUNIT_ASSERT( pGrpObj
);
555 SdrObjCustomShape
*pObj
= dynamic_cast<SdrObjCustomShape
*>( pGrpObj
->GetSubList()->GetObj( 1 ) );
556 CPPUNIT_ASSERT( pObj
);
557 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Wrong Text Rotation!", 90.0, pObj
->GetExtraTextRotation( true ) );
560 xDocShRef
->DoClose();
563 void SdImportTest::testN862510_4()
565 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/n862510_4.pptx"), PPTX
);
567 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
569 std::vector
<EECharAttrib
> rLst
;
570 SdrObject
*pObj
= pPage
->GetObj( 0 );
571 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
572 CPPUNIT_ASSERT( pTxtObj
);
573 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
574 aEdit
.GetCharAttribs( 0, rLst
);
575 for( std::vector
<EECharAttrib
>::reverse_iterator it
= rLst
.rbegin(); it
!= rLst
.rend(); ++it
)
577 const SvxColorItem
*pC
= dynamic_cast<const SvxColorItem
*>( (*it
).pAttr
);
578 CPPUNIT_ASSERT_MESSAGE( "gradfill for text color not handled!", !( pC
&& pC
->GetValue() == Color(0) ) );
582 xDocShRef
->DoClose();
585 void SdImportTest::testN828390_2()
587 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/n828390_2.pptx"), PPTX
);
588 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
590 SdrObject
*pObj
= pPage
->GetObj(0);
591 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
592 CPPUNIT_ASSERT( pTxtObj
);
593 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
594 CPPUNIT_ASSERT_EQUAL(OUString("Linux "), aEdit
.GetText(0));
595 CPPUNIT_ASSERT_EQUAL(OUString("Standard Platform"), aEdit
.GetText(1));
597 xDocShRef
->DoClose();
600 void SdImportTest::testN828390_3()
602 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/n828390_3.pptx"), PPTX
);
603 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
605 SdrObject
*pObj
= pPage
->GetObj(0);
606 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
607 CPPUNIT_ASSERT( pTxtObj
);
608 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
609 std::vector
<EECharAttrib
> rLst
;
610 aEdit
.GetCharAttribs(1, rLst
);
611 bool bPassed
= std::none_of(rLst
.rbegin(), rLst
.rend(),
612 [](const EECharAttrib
& rCharAttr
) {
613 const SvxEscapementItem
*pFontEscapement
= dynamic_cast<const SvxEscapementItem
*>(rCharAttr
.pAttr
);
614 return pFontEscapement
&& (pFontEscapement
->GetEsc() != 0);
616 CPPUNIT_ASSERT_MESSAGE("CharEscapment not imported properly", bPassed
);
618 xDocShRef
->DoClose();
621 void SdImportTest::testMasterPageStyleParent()
623 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/odp/masterpage_style_parent.odp"), ODP
);
624 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
625 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= nullptr );
627 SdStyleSheetPool
*const pPool(pDoc
->GetSdStyleSheetPool());
630 SfxStyleSheetIterator
iter(pPool
, SfxStyleFamily::Page
);
631 for (SfxStyleSheetBase
* pStyle
= iter
.First(); pStyle
; pStyle
= iter
.Next())
633 OUString
const name(pStyle
->GetName());
634 OUString
const parent(pStyle
->GetParent());
635 if (!parent
.isEmpty())
638 // check that parent exists
639 SfxStyleSheetBase
*const pParentStyle(
640 pPool
->Find(parent
, SfxStyleFamily::Page
));
641 CPPUNIT_ASSERT(pParentStyle
);
642 CPPUNIT_ASSERT_EQUAL(pParentStyle
->GetName(), parent
);
643 // check that parent has the same master page as pStyle
644 CPPUNIT_ASSERT(parent
.indexOf(SD_LT_SEPARATOR
) != -1);
645 CPPUNIT_ASSERT(name
.indexOf(SD_LT_SEPARATOR
) != -1);
646 CPPUNIT_ASSERT_EQUAL(
647 parent
.copy(0, parent
.indexOf(SD_LT_SEPARATOR
)),
648 name
.copy(0, name
.indexOf(SD_LT_SEPARATOR
)));
651 // check that there are actually parents...
652 CPPUNIT_ASSERT_EQUAL(16, parents
);
654 xDocShRef
->DoClose();
657 void SdImportTest::testGradientAngle()
659 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/odg/gradient-angle.fodg"), FODG
);
661 uno::Reference
<lang::XMultiServiceFactory
> const xDoc(
662 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY
);
664 awt::Gradient gradient
;
665 uno::Reference
<container::XNameAccess
> const xGradients(
666 xDoc
->createInstance("com.sun.star.drawing.GradientTable"),
669 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 38") >>= gradient
);
670 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), gradient
.Angle
); // was: 3600
672 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 10") >>= gradient
);
673 CPPUNIT_ASSERT_EQUAL(sal_Int16(270), gradient
.Angle
); // 27deg
675 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 11") >>= gradient
);
676 CPPUNIT_ASSERT_EQUAL(sal_Int16(1145), gradient
.Angle
); // 2rad
678 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 12") >>= gradient
);
679 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), gradient
.Angle
); // 100grad
681 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 13") >>= gradient
);
682 CPPUNIT_ASSERT_EQUAL(sal_Int16(3599), gradient
.Angle
); // -1
684 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 14") >>= gradient
);
685 CPPUNIT_ASSERT_EQUAL(sal_Int16(3028), gradient
.Angle
); // -1rad
687 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 15") >>= gradient
);
688 CPPUNIT_ASSERT_EQUAL(sal_Int16(300), gradient
.Angle
); // 3900
690 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 16") >>= gradient
);
691 CPPUNIT_ASSERT_EQUAL(sal_Int16(105), gradient
.Angle
); // 10.5deg
693 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 17") >>= gradient
);
694 CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), gradient
.Angle
); // \pi rad
696 uno::Reference
<container::XNameAccess
> const xTranspGradients(
697 xDoc
->createInstance("com.sun.star.drawing.TransparencyGradientTable"),
700 CPPUNIT_ASSERT(xTranspGradients
->getByName("Transparency 2") >>= gradient
);
701 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), gradient
.Angle
); // 1
703 CPPUNIT_ASSERT(xTranspGradients
->getByName("Transparency 1") >>= gradient
);
704 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), gradient
.Angle
); // 90deg
706 CPPUNIT_ASSERT(xTranspGradients
->getByName("Transparency 3") >>= gradient
);
707 CPPUNIT_ASSERT_EQUAL(sal_Int16(572), gradient
.Angle
); // 1.0rad
709 CPPUNIT_ASSERT(xTranspGradients
->getByName("Transparency 4") >>= gradient
);
710 CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), gradient
.Angle
); // 1000grad
712 xDocShRef
->DoClose();
715 void SdImportTest::testN778859()
717 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"), PPTX
);
719 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
722 SdrObject
*pObj
= pPage
->GetObj(1);
723 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
724 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
725 CPPUNIT_ASSERT(!pTxtObj
->IsAutoFit());
728 xDocShRef
->DoClose();
731 void SdImportTest::testFdo68594()
733 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/ppt/fdo68594.ppt"), PPT
);
735 const SdrPage
*pPage
= &(GetPage( 1, xDocShRef
)->TRG_GetMasterPage());
736 SdrObject
*pObj
= pPage
->GetObj(1);
737 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
738 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
739 const SvxColorItem
*pC
= &pTxtObj
->GetMergedItem(EE_CHAR_COLOR
);
740 CPPUNIT_ASSERT_MESSAGE( "no color item", pC
!= nullptr);
741 // Color should be black
742 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Placeholder color mismatch", sal_uInt32(0), sal_uInt32(pC
->GetValue()) );
744 xDocShRef
->DoClose();
747 void SdImportTest::testPlaceholderPriority()
749 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/ppt/placeholder-priority.pptx"), PPTX
);
751 const SdrPage
* pPage
= GetPage( 1, xDocShRef
);
752 CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing placeholder", sal_uInt32(2), sal_uInt32(pPage
->GetObjCount()));
754 tools::Rectangle
pObj1Rect(9100, 3500, 29619, 4038);
755 SdrObject
*pObj1
= pPage
->GetObj(0);
756 CPPUNIT_ASSERT_EQUAL_MESSAGE("Placeholder position is wrong, check the placeholder priority", pObj1Rect
, pObj1
->GetCurrentBoundRect());
758 tools::Rectangle
pObj2Rect(9102, 8643, 29619, 12642);
759 SdrObject
*pObj2
= pPage
->GetObj(1);
760 CPPUNIT_ASSERT_EQUAL_MESSAGE("Placeholder position is wrong, check the placeholder priority", pObj2Rect
, pObj2
->GetCurrentBoundRect());
762 // If the placeholder positions are wrong, please check placeholder priority in Placeholders class.
765 void SdImportTest::testPptCrop()
767 sd::DrawDocShellRef xDocShRef
768 = loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/ppt/crop.ppt"), PPT
);
770 uno::Reference
<beans::XPropertySet
> xPropertySet(
771 getShapeFromPage(/*nShape=*/1, /*nPage=*/0, xDocShRef
));
772 text::GraphicCrop aCrop
;
773 xPropertySet
->getPropertyValue("GraphicCrop") >>= aCrop
;
774 // These were all 0, lazy-loading broke cropping.
775 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(0), aCrop
.Top
);
776 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(0), aCrop
.Bottom
);
777 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(0), aCrop
.Left
);
778 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(0), aCrop
.Right
);
780 xDocShRef
->DoClose();
783 void SdImportTest::testFdo72998()
785 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/cshapes.pptx"), PPTX
);
787 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
789 SdrObjCustomShape
*pObj
= dynamic_cast<SdrObjCustomShape
*>(pPage
->GetObj(2));
790 CPPUNIT_ASSERT( pObj
);
791 const SdrCustomShapeGeometryItem
& rGeometryItem
= pObj
->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY
);
792 const css::uno::Any
* pViewBox
= const_cast<SdrCustomShapeGeometryItem
&>(rGeometryItem
).GetPropertyValueByName( OUString( "ViewBox" ) );
793 CPPUNIT_ASSERT_MESSAGE( "Missing ViewBox", pViewBox
);
794 css::awt::Rectangle aViewBox
;
795 CPPUNIT_ASSERT( (*pViewBox
>>= aViewBox
) );
796 CPPUNIT_ASSERT_MESSAGE( "Width should be zero - for forcing scale to 1", !aViewBox
.Width
);
797 CPPUNIT_ASSERT_MESSAGE( "Height should be zero - for forcing scale to 1", !aViewBox
.Height
);
800 xDocShRef
->DoClose();
803 void SdImportTest::testFdo77027()
805 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/odp/fdo77027.odp"), ODP
);
807 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
809 SdrOle2Obj
*const pObj
= dynamic_cast<SdrOle2Obj
*>(pPage
->GetObj(0));
810 CPPUNIT_ASSERT(pObj
);
812 // check that the fill style/color was actually imported
813 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
814 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
815 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
816 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
817 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
818 CPPUNIT_ASSERT_EQUAL(Color(0xff6600), rColorItem
.GetColorValue());
821 xDocShRef
->DoClose();
824 void SdImportTest::testTdf97808()
826 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/tdf97808.fodp"), FODP
);
828 uno::Reference
<style::XStyleFamiliesSupplier
> xStyleFamiliesSupplier(
829 xDocShRef
->GetModel(), uno::UNO_QUERY
);
830 uno::Reference
<container::XNameAccess
> xStyleFamilies
= xStyleFamiliesSupplier
->getStyleFamilies();
831 uno::Reference
<container::XNameAccess
> xStyleFamily(xStyleFamilies
->getByName("graphics"), uno::UNO_QUERY
);
832 uno::Reference
<beans::XPropertySet
> xStyle(xStyleFamily
->getByName("objectwithoutfill"), uno::UNO_QUERY
);
834 CPPUNIT_ASSERT(xStyle
->getPropertyValue("LineEndName") >>= lineend
);
835 CPPUNIT_ASSERT_EQUAL(OUString("Arrow"), lineend
);
837 // the draw:marker-end="" did not override the style
838 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(
839 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
840 uno::Reference
<drawing::XDrawPage
> xPage(
841 xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
842 uno::Reference
<beans::XPropertySet
> xLine(
843 xPage
->getByIndex(0), uno::UNO_QUERY_THROW
);
844 //uno::Reference<style::XStyle> xParent;
845 uno::Reference
<beans::XPropertySet
> xParent
;
846 CPPUNIT_ASSERT(xLine
->getPropertyValue("Style") >>= xParent
);
847 CPPUNIT_ASSERT_EQUAL(xStyle
, xParent
);
848 CPPUNIT_ASSERT(xLine
->getPropertyValue("LineEndName") >>= lineend
);
849 CPPUNIT_ASSERT_EQUAL(OUString(), lineend
);
851 xDocShRef
->DoClose();
853 void SdImportTest::testFillStyleNone()
855 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/tdf123841.odg"), ODG
);
857 const SdrPage
* pPage
= GetPage(1, xDocShRef
);
858 const SdrObject
* pObj
= pPage
->GetObj(0);
860 = dynamic_cast<const XFillStyleItem
&>(pObj
->GetMergedItem(XATTR_FILLSTYLE
));
861 // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual:
862 // 1', i.e. the shape's fill was FillStyle_SOLID, making the text of the shape unreadable.
863 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rFillStyleItem
.GetValue());
864 xDocShRef
->DoClose();
867 void SdImportTest::testFdo64512()
869 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/fdo64512.odp"), ODP
);
871 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(
872 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
873 CPPUNIT_ASSERT_EQUAL_MESSAGE( "not exactly one page", static_cast<sal_Int32
>(1), xDoc
->getDrawPages()->getCount() );
875 uno::Reference
< drawing::XDrawPage
> xPage(
876 xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
877 CPPUNIT_ASSERT_EQUAL_MESSAGE( "not exactly three shapes", static_cast<sal_Int32
>(3), xPage
->getCount() );
879 uno::Reference
< beans::XPropertySet
> xConnectorShape(
880 xPage
->getByIndex(2), uno::UNO_QUERY
);
881 CPPUNIT_ASSERT_MESSAGE( "no connector shape", xConnectorShape
.is() );
883 uno::Reference
< beans::XPropertySet
> xSvgShape(
884 xConnectorShape
->getPropertyValue("StartShape"), uno::UNO_QUERY
);
885 CPPUNIT_ASSERT_MESSAGE( "no start shape", xSvgShape
.is() );
887 uno::Reference
< beans::XPropertySet
> xCustomShape(
888 xConnectorShape
->getPropertyValue("EndShape"), uno::UNO_QUERY
);
889 CPPUNIT_ASSERT_MESSAGE( "no end shape", xCustomShape
.is() );
891 uno::Reference
< animations::XAnimationNodeSupplier
> xAnimNodeSupplier(
892 xPage
, uno::UNO_QUERY_THROW
);
893 uno::Reference
< animations::XAnimationNode
> xRootNode(
894 xAnimNodeSupplier
->getAnimationNode() );
895 std::vector
< uno::Reference
< animations::XAnimationNode
> > aAnimVector
;
896 anim::create_deep_vector(xRootNode
, aAnimVector
);
897 CPPUNIT_ASSERT_EQUAL_MESSAGE( "not 8 animation nodes", static_cast<std::size_t>(8), aAnimVector
.size() );
899 uno::Reference
< animations::XAnimate
> xNode(
900 aAnimVector
[7], uno::UNO_QUERY_THROW
);
901 uno::Reference
< drawing::XShape
> xTargetShape(
902 xNode
->getTarget(), uno::UNO_QUERY_THROW
);
903 CPPUNIT_ASSERT_MESSAGE( "inner node not referencing svg shape",
904 xTargetShape
!= xSvgShape
);
906 xDocShRef
->DoClose();
909 // Unit test for importing charts
910 void SdImportTest::testFdo71075()
912 double values
[] = { 12.0, 13.0, 14.0 };
914 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/fdo71075.odp"), ODP
);
916 uno::Reference
< beans::XPropertySet
> xPropSet( getShapeFromPage( 0, 0, xDocShRef
) );
917 aAny
= xPropSet
->getPropertyValue( "Model" );
918 CPPUNIT_ASSERT_MESSAGE( "The shape doesn't have the property", aAny
.hasValue() );
920 uno::Reference
< chart::XChartDocument
> xChartDoc
;
922 CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc
.is() );
923 uno::Reference
< chart2::XChartDocument
> xChart2Doc( xChartDoc
, uno::UNO_QUERY
);
924 CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc
.is() );
926 uno::Reference
< chart2::XCoordinateSystemContainer
> xBCooSysCnt( xChart2Doc
->getFirstDiagram(), uno::UNO_QUERY
);
927 uno::Sequence
< uno::Reference
< chart2::XCoordinateSystem
> > aCooSysSeq( xBCooSysCnt
->getCoordinateSystems());
928 uno::Reference
< chart2::XChartTypeContainer
> xCTCnt( aCooSysSeq
[0], uno::UNO_QUERY
);
930 uno::Reference
< chart2::XDataSeriesContainer
> xDSCnt( xCTCnt
->getChartTypes()[0], uno::UNO_QUERY
);
931 CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt
.is() );
932 uno::Sequence
< uno::Reference
< chart2::XDataSeries
> > aSeriesSeq( xDSCnt
->getDataSeries());
933 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32
>(1), aSeriesSeq
.getLength() );
934 uno::Reference
< chart2::data::XDataSource
> xSource( aSeriesSeq
[0], uno::UNO_QUERY
);
935 uno::Sequence
< uno::Reference
< chart2::data::XLabeledDataSequence
> > aSeqCnt(xSource
->getDataSequences());
936 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32
>(1), aSeqCnt
.getLength());
937 uno::Reference
< chart2::data::XDataSequence
> xValueSeq( aSeqCnt
[0]->getValues() );
938 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Data count", static_cast<sal_Int32
>(SAL_N_ELEMENTS(values
)), xValueSeq
->getData().getLength());
939 uno::Reference
< chart2::data::XNumericalDataSequence
> xNumSeq( xValueSeq
, uno::UNO_QUERY
);
940 uno::Sequence
< double > aValues( xNumSeq
->getNumericalData());
941 for(sal_Int32 i
=0;i
<xValueSeq
->getData().getLength();i
++)
942 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", values
[i
], aValues
.getConstArray()[i
]);
944 xDocShRef
->DoClose();
947 void SdImportTest::testStrictOOXML()
949 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/strict_ooxml.pptx"), PPTX
);
951 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
952 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= nullptr );
953 getShapeFromPage( 0, 0, xDocShRef
);
955 xDocShRef
->DoClose();
958 void SdImportTest::testBnc870237()
960 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc870237.pptx"), PPTX
);
961 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
963 // Simulate a:ext inside dsp:txXfrm with changing the lower distance
964 const SdrObjGroup
* pGroupObj
= dynamic_cast<SdrObjGroup
*>( pPage
->GetObj( 0 ) );
965 const SdrObject
* pObj
= pGroupObj
->GetSubList()->GetObj( 1 );
966 CPPUNIT_ASSERT_MESSAGE( "no object", pObj
!= nullptr);
967 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj
->GetMergedItem(SDRATTR_TEXT_UPPERDIST
).GetValue());
968 CPPUNIT_ASSERT_EQUAL( sal_Int32(9919), pObj
->GetMergedItem(SDRATTR_TEXT_LOWERDIST
).GetValue());
969 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj
->GetMergedItem(SDRATTR_TEXT_RIGHTDIST
).GetValue());
970 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj
->GetMergedItem(SDRATTR_TEXT_LEFTDIST
).GetValue());
972 xDocShRef
->DoClose();
975 void SdImportTest::testCreationDate()
977 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/fdo71434.pptx"), PPTX
);
978 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(xDocShRef
->GetModel(), uno::UNO_QUERY
);
979 uno::Reference
<document::XDocumentProperties
> xDocumentProperties
= xDocumentPropertiesSupplier
->getDocumentProperties();
980 util::DateTime aDate
= xDocumentProperties
->getCreationDate();
981 OUStringBuffer aBuffer
;
982 sax::Converter::convertDateTime(aBuffer
, aDate
, nullptr);
983 // Metadata wasn't imported, this was 0000-00-00.
984 CPPUNIT_ASSERT_EQUAL(OUString("2013-11-09T10:37:56"), aBuffer
.makeStringAndClear());
985 xDocShRef
->DoClose();
988 void SdImportTest::testMultiColTexts()
990 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/multicol.pptx"), PPTX
);
991 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
993 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
994 CPPUNIT_ASSERT( pTableObj
);
996 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pTableObj
->getRowCount());
997 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pTableObj
->getColumnCount());
999 sdr::table::SdrTableObj
*pMasterTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->TRG_GetMasterPage().GetObj(0));
1000 CPPUNIT_ASSERT( pMasterTableObj
);
1002 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pMasterTableObj
->getRowCount());
1003 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), pMasterTableObj
->getColumnCount());
1005 uno::Reference
< table::XCellRange
> xTable(pMasterTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1006 uno::Reference
< beans::XPropertySet
> xCell
;
1007 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1008 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xCell
));
1009 uno::Reference
<text::XTextRange
> xRun( getRunFromParagraph (0, xParagraph
) );
1010 OUString sText
= xRun
->getString();
1012 CPPUNIT_ASSERT_EQUAL(OUString(""), sText
); //We don't import master table text for multicolumn case.
1015 void SdImportTest::testPredefinedTableStyle()
1017 // 073A0DAA-6AF3-43AB-8588-CEC1D06C72B9 (Medium Style 2)
1018 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/predefined-table-style.pptx"), PPTX
);
1019 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
1021 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1022 CPPUNIT_ASSERT( pTableObj
);
1024 uno::Reference
< table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1025 uno::Reference
< beans::XPropertySet
> xCell
;
1028 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1029 xCell
->getPropertyValue("FillColor") >>= nColor
;
1030 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nColor
);
1032 xCell
.set(xTable
->getCellByPosition(0, 1), uno::UNO_QUERY_THROW
);
1033 xCell
->getPropertyValue("FillColor") >>= nColor
;
1034 CPPUNIT_ASSERT_EQUAL(sal_Int32(13421772), nColor
);
1036 xCell
.set(xTable
->getCellByPosition(0, 2), uno::UNO_QUERY_THROW
);
1037 xCell
->getPropertyValue("FillColor") >>= nColor
;
1038 CPPUNIT_ASSERT_EQUAL(sal_Int32(15198183), nColor
);
1040 xDocShRef
->DoClose();
1043 void SdImportTest::testBnc887225()
1045 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc887225.pptx"), PPTX
);
1046 // In the document, lastRow and lastCol table properties are used.
1047 // Make sure styles are set properly for individual cells.
1049 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
1051 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(2));
1052 CPPUNIT_ASSERT( pTableObj
);
1053 uno::Reference
< table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1054 uno::Reference
< beans::XPropertySet
> xCell
;
1057 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1058 xCell
->getPropertyValue("FillColor") >>= nColor
;
1059 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor
);
1061 xCell
.set(xTable
->getCellByPosition(0, 1), uno::UNO_QUERY_THROW
);
1062 xCell
->getPropertyValue("FillColor") >>= nColor
;
1063 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor
);
1065 xCell
.set(xTable
->getCellByPosition(1, 1), uno::UNO_QUERY_THROW
);
1066 xCell
->getPropertyValue("FillColor") >>= nColor
;
1067 CPPUNIT_ASSERT_EQUAL(sal_Int32(13754095), nColor
);
1069 xCell
.set(xTable
->getCellByPosition(1, 2), uno::UNO_QUERY_THROW
);
1070 xCell
->getPropertyValue("FillColor") >>= nColor
;
1071 CPPUNIT_ASSERT_EQUAL(sal_Int32(15331319), nColor
);
1073 xCell
.set(xTable
->getCellByPosition(1, 4), uno::UNO_QUERY_THROW
);
1074 xCell
->getPropertyValue("FillColor") >>= nColor
;
1075 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor
);
1077 xCell
.set(xTable
->getCellByPosition(3, 2), uno::UNO_QUERY_THROW
);
1078 xCell
->getPropertyValue("FillColor") >>= nColor
;
1079 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor
);
1081 xCell
.set(xTable
->getCellByPosition(3, 4), uno::UNO_QUERY_THROW
);
1082 xCell
->getPropertyValue("FillColor") >>= nColor
;
1083 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor
);
1085 xDocShRef
->DoClose();
1088 void SdImportTest::testBnc584721_1()
1090 // Title text shape on the master page contained wrong text.
1092 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX
);
1094 const SdrPage
*pPage
= &(GetPage( 1, xDocShRef
)->TRG_GetMasterPage());
1095 SdrObject
*pObj
= pPage
->GetObj(0);
1096 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
1097 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
1098 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
1099 CPPUNIT_ASSERT_EQUAL(OUString("Click to edit Master title style"), aEdit
.GetText(0));
1100 xDocShRef
->DoClose();
1103 void SdImportTest::testBnc584721_2()
1105 // Import created an extra/unneeded outliner shape on the master slide next to the imported title shape.
1107 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX
);
1109 const SdrPage
*pPage
= &(GetPage( 1, xDocShRef
)->TRG_GetMasterPage());
1110 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage
->GetObjCount());
1112 xDocShRef
->DoClose();
1115 void SdImportTest::testBnc591147()
1117 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc591147.pptx"), PPTX
);
1119 // In the document, there are two slides with media files.
1120 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(
1121 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
1122 CPPUNIT_ASSERT_EQUAL( sal_Int32(2), xDoc
->getDrawPages()->getCount() );
1124 // First page has video file inserted
1125 uno::Reference
< drawing::XDrawPage
> xPage(
1126 xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
1127 CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage
->getCount() );
1129 //uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
1130 uno::Reference
< beans::XPropertySet
> xPropSet( getShape( 0, xPage
) );
1131 OUString
sVideoURL("emptyURL");
1132 bool bSuccess
= xPropSet
->getPropertyValue("MediaURL") >>= sVideoURL
;
1133 CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSuccess
);
1134 CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sVideoURL
.isEmpty());
1136 // Second page has audio file inserted
1137 xPage
.set( xDoc
->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW
);
1138 CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage
->getCount() );
1140 xPropSet
.set( getShape( 0, xPage
) );
1141 OUString
sAudioURL("emptyURL");
1142 bSuccess
= xPropSet
->getPropertyValue("MediaURL") >>= sAudioURL
;
1143 CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSuccess
);
1144 CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sAudioURL
.isEmpty());
1146 CPPUNIT_ASSERT_MESSAGE( "sAudioURL and sVideoURL should not be equal", sAudioURL
!= sVideoURL
);
1148 xDocShRef
->DoClose();
1151 void SdImportTest::testBnc584721_4()
1153 // Black text was imported as white because of wrong caching mechanism
1155 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_4.pptx"), PPTX
);
1156 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 1, 1, xDocShRef
) );
1158 // Get first paragraph of the text
1159 uno::Reference
<text::XTextRange
> const xParagraph( getParagraphFromShape( 0, xShape
) );
1161 // Get first run of the paragraph
1162 uno::Reference
<text::XTextRange
> xRun( getRunFromParagraph (0, xParagraph
) );
1163 uno::Reference
< beans::XPropertySet
> xPropSet( xRun
, uno::UNO_QUERY_THROW
);
1165 xPropSet
->getPropertyValue( "CharColor" ) >>= nCharColor
;
1167 // Color should be black
1168 CPPUNIT_ASSERT_EQUAL( COL_BLACK
, nCharColor
);
1170 xDocShRef
->DoClose();
1173 void SdImportTest::testBnc904423()
1175 // Here the problem was that different fill properties were applied in wrong order on the shape
1176 // Right order: 1) master slide fill style, 2) theme, 3) direct formatting
1177 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/bnc904423.pptx"), PPTX
);
1179 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
1180 // First shape's background color is defined on master slide
1182 SdrObject
*const pObj
= pPage
->GetObj(0);
1183 CPPUNIT_ASSERT(pObj
);
1185 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
1186 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
1187 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
1188 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
1189 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
1190 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00CC99), sal_uInt32(rColorItem
.GetColorValue()));
1193 // Second shape's background color is defined by theme
1195 SdrObject
*const pObj
= pPage
->GetObj(1);
1196 CPPUNIT_ASSERT(pObj
);
1198 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
1199 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
1200 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
1201 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
1202 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
1203 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x3333CC), sal_uInt32(rColorItem
.GetColorValue()));
1206 // Third shape's background color is defined by direct formatting
1208 SdrObject
*const pObj
= pPage
->GetObj(2);
1209 CPPUNIT_ASSERT(pObj
);
1211 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
1212 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
1213 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
1214 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
1215 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
1216 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), sal_uInt32(rColorItem
.GetColorValue()));
1219 xDocShRef
->DoClose();
1222 void SdImportTest::testShapeLineStyle()
1224 // Here the problem was that different line properties were applied in wrong order on the shape
1225 // Right order: 1) master slide line style, 2) theme, 3) direct formatting
1226 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/ShapeLineProperties.pptx"), PPTX
);
1228 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
1229 // First shape's line style is defined on master slide
1231 SdrObject
*const pObj
= pPage
->GetObj(0);
1232 CPPUNIT_ASSERT(pObj
);
1234 const XLineStyleItem
& rStyleItem
= dynamic_cast<const XLineStyleItem
&>(
1235 pObj
->GetMergedItem(XATTR_LINESTYLE
));
1236 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_DASH
, rStyleItem
.GetValue());
1238 const XLineColorItem
& rColorItem
= dynamic_cast<const XLineColorItem
&>(
1239 pObj
->GetMergedItem(XATTR_LINECOLOR
));
1240 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), sal_uInt32(rColorItem
.GetColorValue()));
1242 const XLineWidthItem
& rWidthItem
= dynamic_cast<const XLineWidthItem
&>(
1243 pObj
->GetMergedItem(XATTR_LINEWIDTH
));
1244 CPPUNIT_ASSERT_EQUAL(sal_Int32(132), rWidthItem
.GetValue());
1247 // Second shape's line style is defined by theme
1249 SdrObject
*const pObj
= pPage
->GetObj(1);
1250 CPPUNIT_ASSERT(pObj
);
1252 const XLineStyleItem
& rStyleItem
= dynamic_cast<const XLineStyleItem
&>(
1253 pObj
->GetMergedItem(XATTR_LINESTYLE
));
1254 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, rStyleItem
.GetValue());
1256 const XLineColorItem
& rColorItem
= dynamic_cast<const XLineColorItem
&>(
1257 pObj
->GetMergedItem(XATTR_LINECOLOR
));
1258 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x3333CC), sal_uInt32(rColorItem
.GetColorValue()));
1260 const XLineWidthItem
& rWidthItem
= dynamic_cast<const XLineWidthItem
&>(
1261 pObj
->GetMergedItem(XATTR_LINEWIDTH
));
1262 CPPUNIT_ASSERT_EQUAL(sal_Int32(35), rWidthItem
.GetValue());
1265 // Third shape's line style is defined by direct formatting
1267 SdrObject
*const pObj
= pPage
->GetObj(2);
1268 CPPUNIT_ASSERT(pObj
);
1270 const XLineStyleItem
& rStyleItem
= dynamic_cast<const XLineStyleItem
&>(
1271 pObj
->GetMergedItem(XATTR_LINESTYLE
));
1272 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, rStyleItem
.GetValue());
1274 const XLineColorItem
& rColorItem
= dynamic_cast<const XLineColorItem
&>(
1275 pObj
->GetMergedItem(XATTR_LINECOLOR
));
1276 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x7030A0), sal_uInt32(rColorItem
.GetColorValue()));
1278 const XLineWidthItem
& rWidthItem
= dynamic_cast<const XLineWidthItem
&>(
1279 pObj
->GetMergedItem(XATTR_LINEWIDTH
));
1280 CPPUNIT_ASSERT_EQUAL(sal_Int32(176), rWidthItem
.GetValue());
1283 xDocShRef
->DoClose();
1286 void SdImportTest::testTableBorderLineStyle()
1288 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tableBorderLineStyle.pptx"), PPTX
);
1290 // TODO: If you are working on improvement of table border line style
1291 // support, then expect this unit test to fail.
1293 const sal_Int16 nObjBorderLineStyles
[] =
1295 ::table::BorderLineStyle::DASHED
,
1296 ::table::BorderLineStyle::DASH_DOT_DOT
,
1297 ::table::BorderLineStyle::DASH_DOT
,
1298 ::table::BorderLineStyle::DOTTED
,
1299 ::table::BorderLineStyle::DASHED
,
1300 ::table::BorderLineStyle::DOTTED
,
1301 ::table::BorderLineStyle::DASHED
,
1302 ::table::BorderLineStyle::DASH_DOT
,
1303 ::table::BorderLineStyle::DASH_DOT
,
1304 ::table::BorderLineStyle::SOLID
,
1305 ::table::BorderLineStyle::NONE
1308 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
1309 CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(nObjBorderLineStyles
), pPage
->GetObjCount());
1311 sdr::table::SdrTableObj
*pTableObj
;
1312 uno::Reference
< table::XCellRange
> xTable
;
1313 uno::Reference
< beans::XPropertySet
> xCell
;
1314 table::BorderLine2 aBorderLine
;
1316 for (size_t i
= 0; i
< SAL_N_ELEMENTS(nObjBorderLineStyles
); i
++)
1318 pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(i
));
1319 CPPUNIT_ASSERT( pTableObj
);
1320 xTable
.set(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1321 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1322 xCell
->getPropertyValue("TopBorder") >>= aBorderLine
;
1323 if (aBorderLine
.LineWidth
> 0) {
1324 CPPUNIT_ASSERT_EQUAL(nObjBorderLineStyles
[i
], aBorderLine
.LineStyle
);
1328 xDocShRef
->DoClose();
1331 void SdImportTest::testBnc862510_6()
1333 // Black text was imported instead of gray
1334 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_6.pptx"), PPTX
);
1335 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
1337 // Get first paragraph of the text
1338 uno::Reference
<text::XTextRange
> const xParagraph( getParagraphFromShape( 0, xShape
) );
1340 // Get first run of the paragraph
1341 uno::Reference
<text::XTextRange
> xRun( getRunFromParagraph( 0, xParagraph
) );
1342 uno::Reference
< beans::XPropertySet
> xPropSet( xRun
, uno::UNO_QUERY_THROW
);
1343 sal_Int32 nCharColor
;
1344 xPropSet
->getPropertyValue( "CharColor" ) >>= nCharColor
;
1346 // Color should be gray
1347 CPPUNIT_ASSERT_EQUAL( sal_Int32(0x8B8B8B), nCharColor
);
1349 xDocShRef
->DoClose();
1352 void SdImportTest::testBnc862510_7()
1354 // Title shape's text was aligned to left instead of center.
1355 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_7.pptx"), PPTX
);
1356 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
1358 // Get first paragraph
1359 uno::Reference
<text::XTextRange
> const xParagraph( getParagraphFromShape( 0, xShape
) );
1360 uno::Reference
< beans::XPropertySet
> xPropSet( xParagraph
, uno::UNO_QUERY_THROW
);
1362 sal_Int16 nParaAdjust
= 0;
1363 xPropSet
->getPropertyValue( "ParaAdjust" ) >>= nParaAdjust
;
1364 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(nParaAdjust
));
1366 xDocShRef
->DoClose();
1369 #if ENABLE_PDFIMPORT
1370 // These tests use the old PDF-importing logic, which imports PDF elements as
1371 // SD elements. This suffered many issues, and therefore wasn't ideal.
1372 // The old PDF importer relied on an open-source project (xpdf) with an
1373 // incompatible license (gpl), which has to be interfaced via an out-of-process
1374 // library wrapper process. The resulting imported document was inaccurate
1375 // and often very slow and with large memory footprint.
1376 // Instead, PDFium offers state-of-the-art PDF importing logic,
1377 // which is well-maintained and renders PDFs into images with high accuracy.
1378 // So, the idea is to import PDFs as images using PDFium, which has a very
1379 // high quality (and is much faster) than importing individual editable elements.
1380 // So that's the "new" way of importing.
1381 // The user then breaks the image to editable elements (which is not perfect,
1382 // but very close to the old way), only if they need editing ability.
1383 // PDFium should overall be better, and where it isn't, we just need to improve it.
1384 // So these tests aren't really useful anymore. They should be modified to do
1385 // import+break and then check the results. But that isn't straight-forward and
1386 // currently await volunteering time to implement.
1388 #if HAVE_FEATURE_PDFIUM
1389 void SdImportTest::testPDFImportShared()
1391 comphelper::LibreOfficeKit::setActive();
1392 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pdf/multipage.pdf"), PDF
);
1393 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
1394 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= nullptr );
1396 // This test is to verify that we share the PDF stream linked to each
1397 // Graphic instance in the imported document.
1398 // Since we import PDFs as images, we support attaching the original
1399 // PDF with each image to allow for advanced editing.
1400 // Here we iterate over all Graphic instances embedded in the pages
1401 // and verify that they all point to the same object in memory.
1402 std::vector
<Graphic
> aGraphics
;
1404 for (int nPageIndex
= 0; nPageIndex
< pDoc
->GetPageCount(); ++nPageIndex
)
1406 const SdrPage
* pPage
= GetPage(nPageIndex
, xDocShRef
);
1407 if (pPage
== nullptr)
1410 for (size_t nObjIndex
= 0; nObjIndex
< pPage
->GetObjCount(); ++nObjIndex
)
1412 SdrObject
* pObject
= pPage
->GetObj(nObjIndex
);
1413 if (pObject
== nullptr)
1416 SdrGrafObj
* pSdrGrafObj
= dynamic_cast<SdrGrafObj
*>(pObject
);
1417 if (pSdrGrafObj
== nullptr)
1420 const GraphicObject
& rGraphicObject
= pSdrGrafObj
->GetGraphicObject().GetGraphic();
1421 const Graphic
& rGraphic
= rGraphicObject
.GetGraphic();
1422 CPPUNIT_ASSERT_MESSAGE("After loading, the PDF shouldn't have the primitive sequence created yet",
1423 !rGraphic
.getVectorGraphicData()->isPrimitiveSequenceCreated());
1424 aGraphics
.push_back(rGraphic
);
1428 CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected more than one page.", size_t(9), aGraphics
.size());
1430 Graphic
const & rFirstGraphic
= aGraphics
[0];
1432 for (size_t i
= 0; i
< aGraphics
.size(); ++i
)
1434 Graphic
const & rGraphic
= aGraphics
[i
];
1435 CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected all PDF streams to be identical.",
1436 rFirstGraphic
.getVectorGraphicData()->getVectorGraphicDataArray().getConstArray(),
1437 rGraphic
.getVectorGraphicData()->getVectorGraphicDataArray().getConstArray());
1439 CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected all GfxLinks to be identical.",
1440 rFirstGraphic
.GetSharedGfxLink().get(),
1441 rGraphic
.GetSharedGfxLink().get());
1443 CPPUNIT_ASSERT_EQUAL_MESSAGE("Page number doesn't match expected", sal_Int32(i
), rGraphic
.getPageNumber());
1446 xDocShRef
->DoClose();
1447 comphelper::LibreOfficeKit::setActive(false);
1451 #if defined(IMPORT_PDF_ELEMENTS)
1453 void SdImportTest::testPDFImport()
1455 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pdf/txtpic.pdf"), PDF
);
1456 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
1457 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= nullptr );
1458 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
1459 uno::Reference
< drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
1460 CPPUNIT_ASSERT_EQUAL_MESSAGE( "no exactly two shapes", static_cast<sal_Int32
>(2), xPage
->getCount() );
1462 uno::Reference
< beans::XPropertySet
> xShape( getShape( 0, xPage
) );
1463 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY_THROW
)->getText();
1464 CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText
.is() );
1466 xDocShRef
->DoClose();
1469 void SdImportTest::testPDFImportSkipImages()
1471 auto pParams
= std::make_shared
<SfxAllItemSet
>( SfxGetpApp()->GetPool() );
1472 pParams
->Put( SfxStringItem ( SID_FILE_FILTEROPTIONS
, "SkipImages" ) );
1474 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pdf/txtpic.pdf"), PDF
, pParams
);
1475 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
1476 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= nullptr );
1477 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
1478 uno::Reference
< drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
1479 CPPUNIT_ASSERT_EQUAL_MESSAGE( "no exactly one shape", static_cast<sal_Int32
>(1), xPage
->getCount() );
1481 uno::Reference
< drawing::XShape
> xShape(xPage
->getByIndex(0), uno::UNO_QUERY_THROW
);
1482 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY_THROW
)->getText();
1483 CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText
.is() );
1485 xDocShRef
->DoClose();
1491 void SdImportTest::testBulletSuffix()
1493 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/n83889.pptx"), PPTX
);
1495 // check suffix of the char bullet
1496 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
1497 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj(0) );
1498 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
1499 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
1500 const SvxNumBulletItem
*pNumFmt
= aEdit
.GetParaAttribs(1).GetItem(EE_PARA_NUMBULLET
);
1501 CPPUNIT_ASSERT(pNumFmt
);
1502 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", pNumFmt
->GetNumRule()->GetLevel(0).GetSuffix(), OUString() );
1503 xDocShRef
->DoClose();
1506 void SdImportTest::testBnc910045()
1508 // Problem with table style which defines cell color with fill style
1509 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc910045.pptx"), PPTX
);
1510 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
1512 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1513 CPPUNIT_ASSERT( pTableObj
);
1514 uno::Reference
< table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1515 uno::Reference
< beans::XPropertySet
> xCell
;
1518 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1519 xCell
->getPropertyValue("FillColor") >>= nColor
;
1520 CPPUNIT_ASSERT_EQUAL(sal_Int32(5210557), nColor
);
1522 xDocShRef
->DoClose();
1525 void SdImportTest::testRowHeight()
1527 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/n80340.pptx"), PPTX
);
1528 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
1530 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1531 CPPUNIT_ASSERT( pTableObj
);
1534 uno::Reference
< css::table::XTable
> xTable(pTableObj
->getTable(), uno::UNO_SET_THROW
);
1535 uno::Reference
< css::table::XTableRows
> xRows( xTable
->getRows(), uno::UNO_SET_THROW
);
1536 uno::Reference
< beans::XPropertySet
> xRefRow( xRows
->getByIndex(0), uno::UNO_QUERY_THROW
);
1537 xRefRow
->getPropertyValue( "Height" ) >>= nHeight
;
1538 CPPUNIT_ASSERT_EQUAL( sal_Int32(508), nHeight
);
1540 xDocShRef
->DoClose();
1542 sd::DrawDocShellRef xDocShRef2
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tablescale.pptx"), PPTX
);
1543 const SdrPage
*pPage2
= GetPage( 1, xDocShRef2
);
1545 sdr::table::SdrTableObj
*pTableObj2
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage2
->GetObj(0));
1546 CPPUNIT_ASSERT( pTableObj2
);
1548 uno::Reference
< css::table::XTable
> xTable2(pTableObj2
->getTable(), uno::UNO_SET_THROW
);
1549 uno::Reference
< css::table::XTableRows
> xRows2( xTable2
->getRows(), uno::UNO_SET_THROW
);
1551 for(sal_Int32 nRow
= 0; nRow
< 7; ++nRow
)
1553 uno::Reference
< beans::XPropertySet
> xRefRow2( xRows2
->getByIndex(nRow
), uno::UNO_QUERY_THROW
);
1554 xRefRow2
->getPropertyValue( "Height" ) >>= nHeight
;
1555 CPPUNIT_ASSERT_EQUAL( sal_Int32(800), nHeight
);
1558 xDocShRef2
->DoClose();
1561 void SdImportTest::testTdf93830()
1563 // Text shape offset was ignored
1564 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf93830.pptx"), PPTX
);
1565 uno::Reference
< drawing::XDrawPage
> xPage( getPage( 0, xDocShRef
) );
1567 // Get the first text box from group shape
1568 uno::Reference
< container::XIndexAccess
> xShape( xPage
->getByIndex(0), uno::UNO_QUERY
);
1569 uno::Reference
< beans::XPropertySet
> xPropSet( xShape
->getByIndex(3), uno::UNO_QUERY
);
1570 CPPUNIT_ASSERT_MESSAGE( "no textbox shape", xPropSet
.is() );
1572 sal_Int32 nTextLeftDistance
= 0;
1573 xPropSet
->getPropertyValue( "TextLeftDistance" ) >>= nTextLeftDistance
;
1574 CPPUNIT_ASSERT_EQUAL(sal_Int32(4152), nTextLeftDistance
);
1576 xDocShRef
->DoClose();
1579 void SdImportTest::testTdf127129()
1581 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf127129.pptx"), PPTX
);
1582 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
1583 uno::Reference
< text::XTextRange
> xParagraph( getParagraphFromShape( 0, xShape
) );
1584 uno::Reference
< text::XTextRange
> xRun( getRunFromParagraph( 0, xParagraph
) );
1585 uno::Reference
< beans::XPropertySet
> xPropSet( xRun
, uno::UNO_QUERY_THROW
);
1587 sal_Int32 nCharColor
;
1588 xPropSet
->getPropertyValue( "CharColor" ) >>= nCharColor
;
1589 CPPUNIT_ASSERT_EQUAL( sal_Int32(0x000000), nCharColor
);
1591 // Without the accompanying fix in place, the highlight would be -1
1592 sal_Int32 nCharBackColor
;
1593 xPropSet
->getPropertyValue( "CharBackColor" ) >>= nCharBackColor
;
1594 CPPUNIT_ASSERT_EQUAL( sal_Int32(0xFF00), nCharBackColor
);
1596 xDocShRef
->DoClose();
1598 void SdImportTest::testTdf93097()
1600 // Throwing metadata import aborted the filter, check that metadata is now imported.
1601 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf93097.pptx"), PPTX
);
1602 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(xDocShRef
->GetModel(), uno::UNO_QUERY
);
1603 uno::Reference
<document::XDocumentProperties
> xDocumentProperties
= xDocumentPropertiesSupplier
->getDocumentProperties();
1604 CPPUNIT_ASSERT_EQUAL(OUString("ss"), xDocumentProperties
->getTitle());
1605 xDocShRef
->DoClose();
1608 void SdImportTest::testTdf62255()
1610 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf62255.pptx"), PPTX
);
1611 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
1613 sdr::table::SdrTableObj
*pTableObj
;
1614 pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1615 CPPUNIT_ASSERT( pTableObj
);
1618 uno::Reference
< table::XCellRange
> xTable
;
1619 uno::Reference
< beans::XPropertySet
> xCell
;
1620 xTable
.set(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1621 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1622 aAny
= xCell
->getPropertyValue("FillStyle");
1624 if (aAny
.hasValue())
1626 drawing::FillStyle aFillStyle
;
1627 aAny
>>= aFillStyle
;
1628 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, aFillStyle
);
1631 xDocShRef
->DoClose();
1634 void SdImportTest::testTdf113163()
1636 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf113163.pptx"), PPTX
);
1637 uno::Reference
< uno::XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
1638 uno::Reference
< drawing::XGraphicExportFilter
> xGraphicExporter
= drawing::GraphicExportFilter::create(xContext
);
1640 uno::Sequence
< beans::PropertyValue
> aFilterData(2);
1641 aFilterData
[0].Name
= "PixelWidth";
1642 aFilterData
[0].Value
<<= sal_Int32(100);
1643 aFilterData
[1].Name
= "PixelHeight";
1644 aFilterData
[1].Value
<<= sal_Int32(100);
1646 utl::TempFile aTempFile
;
1647 aTempFile
.EnableKillingFile();
1649 uno::Sequence
< beans::PropertyValue
> aDescriptor(3);
1650 aDescriptor
[0].Name
= "URL";
1651 aDescriptor
[0].Value
<<= aTempFile
.GetURL();
1652 aDescriptor
[1].Name
= "FilterName";
1653 aDescriptor
[1].Value
<<= OUString("PNG");
1654 aDescriptor
[2].Name
= "FilterData";
1655 aDescriptor
[2].Value
<<= aFilterData
;
1657 uno::Reference
< lang::XComponent
> xPage(getPage(0, xDocShRef
), uno::UNO_QUERY
);
1658 xGraphicExporter
->setSourceDocument(xPage
);
1659 xGraphicExporter
->filter(aDescriptor
);
1661 SvFileStream
aFileStream(aTempFile
.GetURL(), StreamMode::READ
);
1662 vcl::PNGReader
aPNGReader(aFileStream
);
1663 BitmapEx aBMPEx
= aPNGReader
.Read();
1665 // make sure the bitmap is not empty and correct size (PNG export->import was successful)
1666 CPPUNIT_ASSERT_EQUAL(Size(100, 100), aBMPEx
.GetSizePixel());
1667 Bitmap aBMP
= aBMPEx
.GetBitmap();
1669 Bitmap::ScopedReadAccess
pReadAccess(aBMP
);
1670 int nNonBlackCount
= 0;
1671 for (tools::Long nY
= 1; nY
< 99; ++nY
)
1673 for (tools::Long nX
= 1; nX
< 99; ++nX
)
1675 const Color aColor
= pReadAccess
->GetColor(nY
, nX
);
1676 if ((aColor
.GetRed() != 0x00) || (aColor
.GetGreen() != 0x00) || (aColor
.GetBlue() != 0x00))
1680 CPPUNIT_ASSERT_EQUAL_MESSAGE("Tdf113163: EMF image is not transparent", 0, nNonBlackCount
);
1682 xDocShRef
->DoClose();
1685 void SdImportTest::testTdf93124()
1687 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/ppt/tdf93124.ppt"), PPT
);
1688 uno::Reference
< uno::XComponentContext
> xContext
= ::comphelper::getProcessComponentContext();
1689 uno::Reference
< drawing::XGraphicExportFilter
> xGraphicExporter
= drawing::GraphicExportFilter::create(xContext
);
1691 uno::Sequence
< beans::PropertyValue
> aFilterData(2);
1692 aFilterData
[0].Name
= "PixelWidth";
1693 aFilterData
[0].Value
<<= sal_Int32(320);
1694 aFilterData
[1].Name
= "PixelHeight";
1695 aFilterData
[1].Value
<<= sal_Int32(180);
1697 utl::TempFile aTempFile
;
1698 aTempFile
.EnableKillingFile();
1700 uno::Sequence
< beans::PropertyValue
> aDescriptor(3);
1701 aDescriptor
[0].Name
= "URL";
1702 aDescriptor
[0].Value
<<= aTempFile
.GetURL();
1703 aDescriptor
[1].Name
= "FilterName";
1704 aDescriptor
[1].Value
<<= OUString("PNG");
1705 aDescriptor
[2].Name
= "FilterData";
1706 aDescriptor
[2].Value
<<= aFilterData
;
1708 uno::Reference
< lang::XComponent
> xPage(getPage(0, xDocShRef
), uno::UNO_QUERY
);
1709 xGraphicExporter
->setSourceDocument(xPage
);
1710 xGraphicExporter
->filter(aDescriptor
);
1712 SvFileStream
aFileStream(aTempFile
.GetURL(), StreamMode::READ
);
1713 vcl::PNGReader
aPNGReader(aFileStream
);
1714 BitmapEx aBMPEx
= aPNGReader
.Read();
1716 // make sure the bitmap is not empty and correct size (PNG export->import was successful)
1717 CPPUNIT_ASSERT_EQUAL(Size(320, 180), aBMPEx
.GetSizePixel());
1718 Bitmap aBMP
= aBMPEx
.GetBitmap();
1720 Bitmap::ScopedReadAccess
pReadAccess(aBMP
);
1721 int nNonWhiteCount
= 0;
1722 // The word "Top" should be in rectangle 34,4 - 76,30. If text alignment is wrong, the rectangle will be white.
1723 for (tools::Long nY
= 4; nY
< (4 + 26); ++nY
)
1725 for (tools::Long nX
= 34; nX
< (34 + 43); ++nX
)
1727 const Color aColor
= pReadAccess
->GetColor(nY
, nX
);
1728 if ((aColor
.GetRed() != 0xff) || (aColor
.GetGreen() != 0xff) || (aColor
.GetBlue() != 0xff))
1732 CPPUNIT_ASSERT_MESSAGE("Tdf93124: vertical alignment of text is incorrect!", nNonWhiteCount
>50);
1734 xDocShRef
->DoClose();
1737 void SdImportTest::testTdf99729()
1739 const OUString filenames
[] = { "/sd/qa/unit/data/odp/tdf99729-new.odp", "/sd/qa/unit/data/odp/tdf99729-legacy.odp" };
1740 int nonwhitecounts
[] = { 0, 0 };
1741 for (size_t i
= 0; i
< SAL_N_ELEMENTS(filenames
); ++i
)
1743 // 1st check for new behaviour - having AnchoredTextOverflowLegacy compatibility flag set to false in settings.xml
1744 uno::Reference
<lang::XComponent
> xComponent
1745 = loadFromDesktop(m_directories
.getURLFromSrc(filenames
[i
]),
1746 "com.sun.star.presentation.PresentationDocument");
1748 uno::Reference
<uno::XComponentContext
> xContext
= getComponentContext();
1749 CPPUNIT_ASSERT(xContext
.is());
1750 uno::Reference
< drawing::XGraphicExportFilter
> xGraphicExporter
= drawing::GraphicExportFilter::create(xContext
);
1751 CPPUNIT_ASSERT(xGraphicExporter
.is());
1753 uno::Sequence
< beans::PropertyValue
> aFilterData(2);
1754 aFilterData
[0].Name
= "PixelWidth";
1755 aFilterData
[0].Value
<<= sal_Int32(320);
1756 aFilterData
[1].Name
= "PixelHeight";
1757 aFilterData
[1].Value
<<= sal_Int32(240);
1759 utl::TempFile aTempFile
;
1760 aTempFile
.EnableKillingFile();
1762 uno::Sequence
< beans::PropertyValue
> aDescriptor(3);
1763 aDescriptor
[0].Name
= "URL";
1764 aDescriptor
[0].Value
<<= aTempFile
.GetURL();
1765 aDescriptor
[1].Name
= "FilterName";
1766 aDescriptor
[1].Value
<<= OUString("PNG");
1767 aDescriptor
[2].Name
= "FilterData";
1768 aDescriptor
[2].Value
<<= aFilterData
;
1770 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(xComponent
, uno::UNO_QUERY
);
1771 uno::Reference
<lang::XComponent
> xPage(xDrawPagesSupplier
->getDrawPages()->getByIndex(0),
1773 CPPUNIT_ASSERT(xPage
.is());
1774 xGraphicExporter
->setSourceDocument(xPage
);
1775 xGraphicExporter
->filter(aDescriptor
);
1777 SvFileStream
aFileStream(aTempFile
.GetURL(), StreamMode::READ
);
1778 vcl::PNGReader
aPNGReader(aFileStream
);
1779 BitmapEx aBMPEx
= aPNGReader
.Read();
1780 Bitmap aBMP
= aBMPEx
.GetBitmap();
1781 Bitmap::ScopedReadAccess
pRead(aBMP
);
1782 for (tools::Long nX
= 154; nX
< (154 + 12); ++nX
)
1784 for (tools::Long nY
= 16; nY
< (16 + 96); ++nY
)
1786 const Color aColor
= pRead
->GetColor(nY
, nX
);
1787 if ((aColor
.GetRed() != 0xff) || (aColor
.GetGreen() != 0xff) || (aColor
.GetBlue() != 0xff))
1788 ++nonwhitecounts
[i
];
1791 xComponent
->dispose();
1793 // The numbers 1-9 should be above the Text Box in rectangle 154,16 - 170,112.
1794 // If text alignment is wrong, the rectangle will be white.
1795 CPPUNIT_ASSERT_MESSAGE("Tdf99729: vertical alignment of text is incorrect!", nonwhitecounts
[0]>100); // it is 134 with cleartype disabled
1796 // The numbers 1-9 should be below the Text Box -> rectangle 154,16 - 170,112 should be white.
1797 CPPUNIT_ASSERT_EQUAL_MESSAGE("Tdf99729: legacy vertical alignment of text is incorrect!", 0, nonwhitecounts
[1]);
1800 void SdImportTest::testTdf89927()
1802 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf89927.pptx"), PPTX
);
1803 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
1804 uno::Reference
< text::XTextRange
> xParagraph( getParagraphFromShape( 0, xShape
) );
1805 uno::Reference
< text::XTextRange
> xRun( getRunFromParagraph( 0, xParagraph
) );
1806 uno::Reference
< beans::XPropertySet
> xPropSet( xRun
, uno::UNO_QUERY_THROW
);
1808 sal_Int32 nCharColor
;
1809 xPropSet
->getPropertyValue( "CharColor" ) >>= nCharColor
;
1810 CPPUNIT_ASSERT_EQUAL( sal_Int32(0xFFFFFF), nCharColor
);
1812 xDocShRef
->DoClose();
1815 void SdImportTest::testTdf93868()
1817 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf93868.pptx"), PPTX
);
1819 const SdrPage
*pPage
= &(GetPage( 1, xDocShRef
)->TRG_GetMasterPage());
1820 CPPUNIT_ASSERT_EQUAL(size_t(5), pPage
->GetObjCount());
1821 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, dynamic_cast<const XFillStyleItem
&>(pPage
->GetObj(0)->GetMergedItem(XATTR_FILLSTYLE
)).GetValue());
1822 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT
, dynamic_cast<const XFillStyleItem
&>(pPage
->GetObj(1)->GetMergedItem(XATTR_FILLSTYLE
)).GetValue());
1824 xDocShRef
->DoClose();
1827 void SdImportTest::testTdf95932()
1829 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf95932.pptx"), PPTX
);
1831 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
1832 SdrObject
*const pObj
= pPage
->GetObj(2);
1833 CPPUNIT_ASSERT(pObj
);
1835 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
1836 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
1837 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
1838 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
1839 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
1840 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x76bf3d), sal_uInt32(rColorItem
.GetColorValue()));
1842 xDocShRef
->DoClose();
1845 void SdImportTest::testTdf99030()
1847 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf99030.pptx"), PPTX
);
1849 uno::Reference
< drawing::XMasterPagesSupplier
> xDoc(
1850 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
1851 uno::Reference
< drawing::XDrawPage
> xPage(
1852 xDoc
->getMasterPages()->getByIndex( 0 ), uno::UNO_QUERY_THROW
);
1853 uno::Reference
< beans::XPropertySet
> xPropSet( xPage
, uno::UNO_QUERY
);
1855 sal_Int32
nFillColor(0);
1856 uno::Any aAny
= xPropSet
->getPropertyValue( "Background" );
1857 if (aAny
.hasValue())
1859 uno::Reference
< beans::XPropertySet
> xBackgroundPropSet
;
1860 aAny
>>= xBackgroundPropSet
;
1861 xBackgroundPropSet
->getPropertyValue( "FillColor" ) >>= nFillColor
;
1863 CPPUNIT_ASSERT_EQUAL( sal_Int32(0x676A55), nFillColor
);
1865 xDocShRef
->DoClose();
1868 void SdImportTest::testTdf49561()
1870 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/ppt/tdf49561.ppt"), PPT
);
1872 uno::Reference
< drawing::XMasterPagesSupplier
> xDoc(
1873 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
1874 uno::Reference
< drawing::XDrawPage
> xPage(
1875 xDoc
->getMasterPages()->getByIndex( 0 ), uno::UNO_QUERY_THROW
);
1876 CPPUNIT_ASSERT_EQUAL( sal_Int32(5), xPage
->getCount() );
1878 uno::Reference
< beans::XPropertySet
> xShape( getShape( 3, xPage
) );
1879 uno::Reference
<text::XTextRange
> xParagraph( getParagraphFromShape( 0, xShape
) );
1880 uno::Reference
<text::XTextRange
> xRun( getRunFromParagraph (0, xParagraph
) );
1881 uno::Reference
< beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
1883 float fCharHeight
= 0;
1884 CPPUNIT_ASSERT(xPropSet
->getPropertyValue("CharHeight") >>= fCharHeight
);
1885 CPPUNIT_ASSERT_EQUAL(12.f
, fCharHeight
);
1887 OUString aCharFontName
;
1888 CPPUNIT_ASSERT(xPropSet
->getPropertyValue("CharFontName") >>= aCharFontName
);
1889 CPPUNIT_ASSERT_EQUAL(OUString("Stencil"), aCharFontName
);
1891 xDocShRef
->DoClose();
1894 void SdImportTest::testTdf103473()
1896 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf103473.pptx"), PPTX
);
1898 const SdrPage
*pPage
= GetPage(1, xDocShRef
);
1899 SdrTextObj
*const pObj
= dynamic_cast<SdrTextObj
*const>(pPage
->GetObj(0));
1900 CPPUNIT_ASSERT(pObj
);
1901 ::tools::Rectangle aRect
= pObj
->GetGeoRect();
1902 CPPUNIT_ASSERT_EQUAL(tools::Long(3629), aRect
.Left());
1903 CPPUNIT_ASSERT_EQUAL(tools::Long(4431), aRect
.Top());
1904 CPPUNIT_ASSERT_EQUAL(tools::Long(8353), aRect
.Right());
1905 CPPUNIT_ASSERT_EQUAL(tools::Long(9155), aRect
.Bottom());
1907 xDocShRef
->DoClose();
1910 void SdImportTest::testAoo124143()
1912 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/odg/ooo124143-1.odg"), ODG
);
1914 uno::Reference
<beans::XPropertySet
> const xImage(getShapeFromPage(0, 0, xDocShRef
));
1915 uno::Reference
<drawing::XGluePointsSupplier
> const xGPS(xImage
, uno::UNO_QUERY
);
1916 uno::Reference
<container::XIdentifierAccess
> const xGluePoints(xGPS
->getGluePoints(), uno::UNO_QUERY
);
1918 uno::Sequence
<sal_Int32
> const ids(xGluePoints
->getIdentifiers());
1919 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), ids
.getLength());
1920 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ids
[0]);
1921 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), ids
[1]);
1922 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), ids
[2]);
1923 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), ids
[3]);
1924 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), ids
[4]);
1925 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ids
[5]);
1927 // interesting ones are custom 4, 5
1928 drawing::GluePoint2 glue4
;
1929 xGluePoints
->getByIdentifier(4) >>= glue4
;
1930 CPPUNIT_ASSERT_EQUAL(sal_Int32( 2470), glue4
.Position
.X
);
1931 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1810), glue4
.Position
.Y
);
1933 drawing::GluePoint2 glue5
;
1934 xGluePoints
->getByIdentifier(5) >>= glue5
;
1935 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2975), glue5
.Position
.X
);
1936 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2165), glue5
.Position
.Y
);
1938 // now check connectors
1939 uno::Reference
<beans::XPropertySet
> const xEllipse(getShapeFromPage(1, 0, xDocShRef
));
1940 uno::Reference
<beans::XPropertySet
> const xConn1(getShapeFromPage(2, 0, xDocShRef
));
1941 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xConn1
->getPropertyValue("StartGluePointIndex").get
<sal_Int32
>());
1942 CPPUNIT_ASSERT_EQUAL(xEllipse
, xConn1
->getPropertyValue("StartShape").get
<uno::Reference
<beans::XPropertySet
>>());
1943 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xConn1
->getPropertyValue("EndGluePointIndex").get
<sal_Int32
>());
1944 CPPUNIT_ASSERT_EQUAL(xImage
, xConn1
->getPropertyValue("EndShape").get
<uno::Reference
<beans::XPropertySet
>>());
1945 uno::Reference
<beans::XPropertySet
> const xConn2(getShapeFromPage(3, 0, xDocShRef
));
1946 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xConn2
->getPropertyValue("StartGluePointIndex").get
<sal_Int32
>());
1947 CPPUNIT_ASSERT_EQUAL(xEllipse
, xConn2
->getPropertyValue("StartShape").get
<uno::Reference
<beans::XPropertySet
>>());
1948 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xConn2
->getPropertyValue("EndGluePointIndex").get
<sal_Int32
>());
1949 CPPUNIT_ASSERT_EQUAL(xImage
, xConn2
->getPropertyValue("EndShape").get
<uno::Reference
<beans::XPropertySet
>>());
1951 xDocShRef
->DoClose();
1954 void SdImportTest::testTdf103567()
1956 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/odp/tdf103567.odp"), ODP
);
1957 for (int i
= 0; i
< 4; ++i
)
1959 uno::Reference
<beans::XPropertySet
> const xShape(getShapeFromPage(i
, 0, xDocShRef
));
1960 uno::Reference
<document::XEventsSupplier
> const xEventsSupplier(xShape
, uno::UNO_QUERY
);
1961 uno::Reference
<container::XNameAccess
> const xEvents(xEventsSupplier
->getEvents());
1962 OString
const msg("shape " + OString::number(i
) + ": ");
1964 CPPUNIT_ASSERT(xEvents
->hasByName("OnClick"));
1965 uno::Sequence
<beans::PropertyValue
> props
;
1966 xEvents
->getByName("OnClick") >>= props
;
1967 comphelper::SequenceAsHashMap
const map(props
);
1969 auto iter(map
.find("EventType"));
1970 CPPUNIT_ASSERT_MESSAGE(OString(msg
+ "no EventType").getStr(), iter
!= map
.end());
1971 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg
.getStr(), OUString("Presentation"), iter
->second
.get
<OUString
>());
1974 auto iter(map
.find("ClickAction"));
1975 CPPUNIT_ASSERT_MESSAGE(OString(msg
+ "no ClickAction").getStr(), iter
!= map
.end());
1978 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg
.getStr(), css::presentation::ClickAction_DOCUMENT
, iter
->second
.get
<css::presentation::ClickAction
>());
1982 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg
.getStr(), css::presentation::ClickAction_NEXTPAGE
, iter
->second
.get
<css::presentation::ClickAction
>());
1987 auto iter(map
.find("Bookmark"));
1988 CPPUNIT_ASSERT_MESSAGE(OString(msg
+ "no Bookmark").getStr(), iter
!= map
.end());
1989 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg
.getStr(), OUString("http://example.com/"), iter
->second
.get
<OUString
>());
1993 xDocShRef
->DoClose();
1996 void SdImportTest::testTdf103792()
1998 // Title text shape on the actual slide contained no text neither a placeholder text.
1999 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf103792.pptx"), PPTX
);
2001 const SdrPage
*pPage
= GetPage(1, xDocShRef
);
2002 CPPUNIT_ASSERT_MESSAGE("No page found", pPage
!= nullptr);
2003 SdrObject
*pObj
= pPage
->GetObj(0);
2004 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj
!= nullptr);
2005 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>(pObj
);
2006 CPPUNIT_ASSERT_MESSAGE("Not a text object", pTxtObj
!= nullptr);
2008 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
2009 CPPUNIT_ASSERT_EQUAL(OUString("Click to add Title"), aEdit
.GetText(0));
2011 xDocShRef
->DoClose();
2014 void SdImportTest::testTdf103876()
2016 // Title text shape's placeholder text did not inherit the corresponding text properties
2017 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf103876.pptx"), PPTX
);
2018 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
2020 // Check paragraph alignment
2021 sal_Int16 nParaAdjust
= 0;
2022 xShape
->getPropertyValue( "ParaAdjust" ) >>= nParaAdjust
;
2023 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(nParaAdjust
));
2025 // Check character color
2026 sal_Int32 nCharColor
;
2027 xShape
->getPropertyValue( "CharColor" ) >>= nCharColor
;
2028 CPPUNIT_ASSERT_EQUAL( sal_Int32(0xFF0000), nCharColor
);
2030 xDocShRef
->DoClose();
2033 void SdImportTest::testTdf79007()
2035 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf79007.pptx"), PPTX
);
2037 uno::Reference
<beans::XPropertySet
> xShape1(getShapeFromPage(0, 0, xDocShRef
));
2038 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape1
.is());
2040 // Check we map mso washout to our watermark
2041 drawing::ColorMode aColorMode1
;
2042 xShape1
->getPropertyValue("GraphicColorMode") >>= aColorMode1
;
2043 CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_WATERMARK
, aColorMode1
);
2045 sal_Int16 nContrast1
;
2046 xShape1
->getPropertyValue("AdjustContrast") >>= nContrast1
;
2047 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nContrast1
);
2049 sal_Int16 nLuminance1
;
2050 xShape1
->getPropertyValue("AdjustLuminance") >>= nLuminance1
;
2051 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nLuminance1
);
2053 uno::Reference
<beans::XPropertySet
> xShape2(getShapeFromPage(1, 0, xDocShRef
));
2054 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape2
.is());
2056 // Check we map mso grayscale to our grayscale
2057 drawing::ColorMode aColorMode2
;
2058 xShape2
->getPropertyValue("GraphicColorMode") >>= aColorMode2
;
2059 CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_GREYS
, aColorMode2
);
2061 sal_Int16 nContrast2
;
2062 xShape2
->getPropertyValue("AdjustContrast") >>= nContrast2
;
2063 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nContrast2
);
2065 sal_Int16 nLuminance2
;
2066 xShape2
->getPropertyValue("AdjustLuminance") >>= nLuminance2
;
2067 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nLuminance2
);
2069 uno::Reference
<beans::XPropertySet
> xShape3(getShapeFromPage(2, 0, xDocShRef
));
2070 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape3
.is());
2072 // Check we map mso black/white to our black/white
2073 drawing::ColorMode aColorMode3
;
2074 xShape3
->getPropertyValue("GraphicColorMode") >>= aColorMode3
;
2075 CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_MONO
, aColorMode3
);
2077 sal_Int16 nContrast3
;
2078 xShape3
->getPropertyValue("AdjustContrast") >>= nContrast3
;
2079 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nContrast3
);
2081 sal_Int16 nLuminance3
;
2082 xShape3
->getPropertyValue("AdjustLuminance") >>= nLuminance3
;
2083 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nLuminance3
);
2085 xDocShRef
->DoClose();
2088 void SdImportTest::testTdf129686()
2090 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf129686.pptx"), PPTX
);
2091 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
2093 // Get first paragraph of the text
2094 uno::Reference
<text::XTextRange
> const xParagraph( getParagraphFromShape( 0, xShape
) );
2096 // Get first run of the paragraph
2097 uno::Reference
<text::XTextRange
> xRun( getRunFromParagraph (0, xParagraph
) );
2098 uno::Reference
< beans::XPropertySet
> xPropSet( xRun
, uno::UNO_QUERY_THROW
);
2099 sal_Int16 nTransparency
= 0;
2100 xPropSet
->getPropertyValue("CharTransparence") >>= nTransparency
;
2102 // 100 = no transparency
2103 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(100), nTransparency
);
2105 xDocShRef
->DoClose();
2108 void SdImportTest::testTdf104015()
2110 // Shape fill, line and effect properties were not inherited from master slide shape
2111 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf104015.pptx"), PPTX
);
2113 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
2114 CPPUNIT_ASSERT_MESSAGE("No page found", pPage
!= nullptr);
2115 SdrObject
*const pObj
= pPage
->GetObj(0);
2116 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj
!= nullptr);
2117 // Should have a red fill color
2119 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
2120 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
2121 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
2122 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
2123 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
2124 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), sal_uInt32(rColorItem
.GetColorValue()));
2126 // Should have a blue line
2128 const XLineStyleItem
& rStyleItem
= dynamic_cast<const XLineStyleItem
&>(
2129 pObj
->GetMergedItem(XATTR_LINESTYLE
));
2130 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, rStyleItem
.GetValue());
2132 const XLineColorItem
& rColorItem
= dynamic_cast<const XLineColorItem
&>(
2133 pObj
->GetMergedItem(XATTR_LINECOLOR
));
2134 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x0000FF), sal_uInt32(rColorItem
.GetColorValue()));
2136 // Should have some shadow
2138 const SdrOnOffItem
& rShadowItem
= dynamic_cast<const SdrOnOffItem
&>(
2139 pObj
->GetMergedItem(SDRATTR_SHADOW
));
2140 CPPUNIT_ASSERT(rShadowItem
.GetValue());
2143 xDocShRef
->DoClose();
2146 void SdImportTest::testTdf104201()
2148 // Group shape properties did not overwrite the child shapes' fill
2149 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf104201.pptx"), PPTX
);
2151 const SdrPage
*pPage
= GetPage(1, xDocShRef
);
2152 CPPUNIT_ASSERT_MESSAGE("No page found", pPage
!= nullptr);
2154 // First shape has red fill, but this should be overwritten by green group fill
2156 SdrObject
*const pObj
= pPage
->GetObj(0);
2157 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj
!= nullptr);
2158 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
2159 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
2160 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
2161 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
2162 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
2163 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FF00), sal_uInt32(rColorItem
.GetColorValue()));
2165 // Second shape has blue fill, but this should be overwritten by green group fill
2167 SdrObject
*const pObj
= pPage
->GetObj(0);
2168 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj
!= nullptr);
2169 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
2170 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
2171 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
2172 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
2173 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
2174 CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FF00), sal_uInt32(rColorItem
.GetColorValue()));
2177 xDocShRef
->DoClose();
2180 void SdImportTest::testTdf103477()
2182 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf103477.pptx"), PPTX
);
2184 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
2186 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj(6) );
2187 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr );
2189 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
2190 const SvxNumBulletItem
*pNumFmt
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
2191 CPPUNIT_ASSERT(pNumFmt
);
2192 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", Color(0x000000), pNumFmt
->GetNumRule()->GetLevel(1).GetBulletColor());
2194 xDocShRef
->DoClose();
2197 void SdImportTest::testTdf105150()
2199 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf105150.pptx"), PPTX
);
2200 const SdrPage
* pPage
= GetPage(1, xDocShRef
);
2201 const SdrObject
* pObj
= pPage
->GetObj(1);
2202 auto& rFillStyleItem
= dynamic_cast<const XFillStyleItem
&>(pObj
->GetMergedItem(XATTR_FILLSTYLE
));
2203 // This was drawing::FillStyle_NONE, <p:sp useBgFill="1"> was ignored when
2204 // the slide didn't have an explicit background fill.
2205 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rFillStyleItem
.GetValue());
2206 xDocShRef
->DoClose();
2209 void SdImportTest::testTdf123684()
2211 sd::DrawDocShellRef xDocShRef
2212 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf123684.pptx"), PPTX
);
2213 const SdrPage
* pPage
= GetPage(1, xDocShRef
);
2214 const SdrObject
* pObj
= pPage
->GetObj(0);
2215 auto& rFillStyleItem
2216 = dynamic_cast<const XFillStyleItem
&>(pObj
->GetMergedItem(XATTR_FILLSTYLE
));
2217 // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual:
2218 // 1', i.e. the shape's fill was FillStyle_SOLID, making the text of the shape unreadable.
2219 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rFillStyleItem
.GetValue());
2220 xDocShRef
->DoClose();
2223 void SdImportTest::testTdf105150PPT()
2225 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/ppt/tdf105150.ppt"), PPT
);
2226 const SdrPage
* pPage
= GetPage(1, xDocShRef
);
2227 const SdrObject
* pObj
= pPage
->GetObj(1);
2228 // This was drawing::FillStyle_NONE, the shape's mso_fillBackground was
2229 // ignored when the slide didn't have an explicit background fill.
2230 auto& rFillStyleItem
= dynamic_cast<const XFillStyleItem
&>(pObj
->GetMergedItem(XATTR_FILLSTYLE
));
2231 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rFillStyleItem
.GetValue());
2232 xDocShRef
->DoClose();
2235 void SdImportTest::testTdf104445()
2237 // Extra bullets were added to the first shape
2238 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf104445.pptx"), PPTX
);
2240 // First shape should not have bullet
2242 uno::Reference
< beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
));
2243 uno::Reference
< text::XText
> xText
= uno::Reference
< text::XTextRange
>(xShape
, uno::UNO_QUERY_THROW
)->getText();
2244 CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText
.is());
2245 uno::Reference
< beans::XPropertySet
> xPropSet(xText
, uno::UNO_QUERY_THROW
);
2247 uno::Reference
< container::XIndexAccess
> xNumRule
;
2248 xPropSet
->getPropertyValue("NumberingRules") >>= xNumRule
;
2249 uno::Sequence
<beans::PropertyValue
> aBulletProps
;
2250 xNumRule
->getByIndex(0) >>= aBulletProps
;
2252 for (beans::PropertyValue
const & rProp
: std::as_const(aBulletProps
))
2254 if(rProp
.Name
== "NumberingType")
2255 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::NUMBER_NONE
), rProp
.Value
.get
<sal_Int16
>());
2256 if(rProp
.Name
== "LeftMargin")
2257 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp
.Value
.get
<sal_Int32
>());
2260 // Second shape should have bullet set
2262 uno::Reference
< beans::XPropertySet
> xShape(getShapeFromPage(1, 0, xDocShRef
));
2263 uno::Reference
< text::XText
> xText
= uno::Reference
< text::XTextRange
>(xShape
, uno::UNO_QUERY_THROW
)->getText();
2264 CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText
.is());
2265 uno::Reference
< beans::XPropertySet
> xPropSet(xText
, uno::UNO_QUERY_THROW
);
2267 uno::Reference
< container::XIndexAccess
> xNumRule
;
2268 xPropSet
->getPropertyValue("NumberingRules") >>= xNumRule
;
2269 uno::Sequence
<beans::PropertyValue
> aBulletProps
;
2270 xNumRule
->getByIndex(0) >>= aBulletProps
;
2272 for(beans::PropertyValue
const & rProp
: std::as_const(aBulletProps
))
2274 if(rProp
.Name
== "NumberingType")
2275 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::CHAR_SPECIAL
), rProp
.Value
.get
<sal_Int16
>());
2276 if(rProp
.Name
== "LeftMargin")
2277 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), rProp
.Value
.get
<sal_Int32
>());
2280 xDocShRef
->DoClose();
2286 bool checkPatternValues(std::vector
<sal_uInt8
>& rExpected
, Bitmap
& rBitmap
)
2288 bool bResult
= true;
2290 const Color
aFGColor(0xFF0000);
2291 const Color
aBGColor(0xFFFFFF);
2293 Bitmap::ScopedReadAccess
pAccess(rBitmap
);
2294 for (tools::Long y
= 0; y
< pAccess
->Height(); ++y
)
2296 Scanline pScanline
= pAccess
->GetScanline( y
);
2297 for (tools::Long x
= 0; x
< pAccess
->Width(); ++x
)
2299 Color aColor
= pAccess
->GetPixelFromData(pScanline
, x
);
2300 sal_uInt8 aValue
= rExpected
[y
*8+x
];
2302 if (aValue
== 1 && aColor
!= aFGColor
)
2304 else if (aValue
== 0 && aColor
!= aBGColor
)
2312 } // end anonymous namespace
2314 bool SdImportTest::checkPattern(sd::DrawDocShellRef
const & rDocRef
, int nShapeNumber
, std::vector
<sal_uInt8
>& rExpected
)
2316 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(nShapeNumber
, 0, rDocRef
));
2317 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape
.is());
2322 uno::Any aBitmapAny
= xShape
->getPropertyValue("FillBitmap");
2323 uno::Reference
<awt::XBitmap
> xBitmap
;
2324 if (aBitmapAny
>>= xBitmap
)
2326 uno::Sequence
<sal_Int8
> aBitmapSequence(xBitmap
->getDIB());
2327 SvMemoryStream
aBitmapStream(aBitmapSequence
.getArray(),
2328 aBitmapSequence
.getLength(),
2330 ReadDIB(aBitmap
, aBitmapStream
, true);
2333 CPPUNIT_ASSERT_EQUAL(tools::Long(8), aBitmap
.GetSizePixel().Width());
2334 CPPUNIT_ASSERT_EQUAL(tools::Long(8), aBitmap
.GetSizePixel().Height());
2335 return checkPatternValues(rExpected
, aBitmap
);
2338 /* Test checks that importing a PPT file with all supported fill patterns is
2339 * correctly imported as a tiled fill bitmap with the expected pattern.
2341 void SdImportTest::testPatternImport()
2343 sd::DrawDocShellRef xDocRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/ppt/FillPatterns.ppt"), PPT
);
2345 std::vector
<sal_uInt8
> aExpectedPattern1
= {
2355 std::vector
<sal_uInt8
> aExpectedPattern2
= {
2365 std::vector
<sal_uInt8
> aExpectedPattern3
= {
2375 std::vector
<sal_uInt8
> aExpectedPattern4
= {
2385 std::vector
<sal_uInt8
> aExpectedPattern5
= {
2395 std::vector
<sal_uInt8
> aExpectedPattern6
= {
2405 std::vector
<sal_uInt8
> aExpectedPattern7
= {
2415 std::vector
<sal_uInt8
> aExpectedPattern8
= {
2425 std::vector
<sal_uInt8
> aExpectedPattern9
= {
2435 std::vector
<sal_uInt8
> aExpectedPattern10
= {
2445 std::vector
<sal_uInt8
> aExpectedPattern11
= {
2455 std::vector
<sal_uInt8
> aExpectedPattern12
= {
2465 std::vector
<sal_uInt8
> aExpectedPatternLine1
= {
2475 std::vector
<sal_uInt8
> aExpectedPatternLine2
= {
2485 std::vector
<sal_uInt8
> aExpectedPatternLine3
= {
2495 std::vector
<sal_uInt8
> aExpectedPatternLine4
= {
2505 std::vector
<sal_uInt8
> aExpectedPatternLine5
= {
2515 std::vector
<sal_uInt8
> aExpectedPatternLine6
= {
2525 std::vector
<sal_uInt8
> aExpectedPatternLine7
= {
2535 std::vector
<sal_uInt8
> aExpectedPatternLine8
= {
2545 std::vector
<sal_uInt8
> aExpectedPatternLine9
= {
2555 std::vector
<sal_uInt8
> aExpectedPatternLine10
= {
2565 std::vector
<sal_uInt8
> aExpectedPatternLine11
= {
2575 std::vector
<sal_uInt8
> aExpectedPatternLine12
= {
2586 CPPUNIT_ASSERT_MESSAGE("Pattern1 - 5%" , checkPattern(xDocRef
, 0, aExpectedPattern1
));
2587 CPPUNIT_ASSERT_MESSAGE("Pattern2 - 10%", checkPattern(xDocRef
, 1, aExpectedPattern2
));
2588 CPPUNIT_ASSERT_MESSAGE("Pattern3 - 20%", checkPattern(xDocRef
, 2, aExpectedPattern3
));
2589 CPPUNIT_ASSERT_MESSAGE("Pattern4 - 25%", checkPattern(xDocRef
, 3, aExpectedPattern4
));
2590 CPPUNIT_ASSERT_MESSAGE("Pattern5 - 30%", checkPattern(xDocRef
, 4, aExpectedPattern5
));
2591 CPPUNIT_ASSERT_MESSAGE("Pattern6 - 40%", checkPattern(xDocRef
, 5, aExpectedPattern6
));
2592 CPPUNIT_ASSERT_MESSAGE("Pattern7 - 50%", checkPattern(xDocRef
, 6, aExpectedPattern7
));
2593 CPPUNIT_ASSERT_MESSAGE("Pattern8 - 60%", checkPattern(xDocRef
, 7, aExpectedPattern8
));
2594 CPPUNIT_ASSERT_MESSAGE("Pattern9 - 70%", checkPattern(xDocRef
, 8, aExpectedPattern9
));
2595 CPPUNIT_ASSERT_MESSAGE("Pattern10 - 75%", checkPattern(xDocRef
, 9, aExpectedPattern10
));
2596 CPPUNIT_ASSERT_MESSAGE("Pattern11 - 80%", checkPattern(xDocRef
, 10, aExpectedPattern11
));
2597 CPPUNIT_ASSERT_MESSAGE("Pattern12 - 90%", checkPattern(xDocRef
, 11, aExpectedPattern12
));
2599 CPPUNIT_ASSERT_MESSAGE("Pattern13 - Light downward diagonal", checkPattern(xDocRef
, 12, aExpectedPatternLine1
));
2600 CPPUNIT_ASSERT_MESSAGE("Pattern14 - Light upward diagonal", checkPattern(xDocRef
, 13, aExpectedPatternLine2
));
2601 CPPUNIT_ASSERT_MESSAGE("Pattern15 - Dark downward diagonal", checkPattern(xDocRef
, 14, aExpectedPatternLine3
));
2602 CPPUNIT_ASSERT_MESSAGE("Pattern16 - Dark upward diagonal", checkPattern(xDocRef
, 15, aExpectedPatternLine4
));
2603 CPPUNIT_ASSERT_MESSAGE("Pattern17 - Wide downward diagonal", checkPattern(xDocRef
, 16, aExpectedPatternLine5
));
2604 CPPUNIT_ASSERT_MESSAGE("Pattern18 - Wide upward diagonal", checkPattern(xDocRef
, 17, aExpectedPatternLine6
));
2606 CPPUNIT_ASSERT_MESSAGE("Pattern19 - Light vertical", checkPattern(xDocRef
, 18, aExpectedPatternLine7
));
2607 CPPUNIT_ASSERT_MESSAGE("Pattern20 - Light horizontal", checkPattern(xDocRef
, 19, aExpectedPatternLine8
));
2608 CPPUNIT_ASSERT_MESSAGE("Pattern21 - Narrow vertical", checkPattern(xDocRef
, 20, aExpectedPatternLine9
));
2609 CPPUNIT_ASSERT_MESSAGE("Pattern22 - Narrow horizontal", checkPattern(xDocRef
, 21, aExpectedPatternLine10
));
2610 CPPUNIT_ASSERT_MESSAGE("Pattern23 - Dark vertical", checkPattern(xDocRef
, 22, aExpectedPatternLine11
));
2611 CPPUNIT_ASSERT_MESSAGE("Pattern24 - Dark horizontal", checkPattern(xDocRef
, 23, aExpectedPatternLine12
));
2613 // TODO: other patterns in the test document
2618 void SdImportTest::testTdf100926()
2620 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf100926.pptx"), PPTX
);
2621 const SdrPage
* pPage
= GetPage(1, xDocShRef
);
2622 CPPUNIT_ASSERT(pPage
!= nullptr);
2624 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
2625 CPPUNIT_ASSERT(pTableObj
!= nullptr);
2626 uno::Reference
< table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
2628 sal_Int32 nRotation
= 0;
2629 uno::Reference
< beans::XPropertySet
> xCell(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
2630 xCell
->getPropertyValue("RotateAngle") >>= nRotation
;
2631 CPPUNIT_ASSERT_EQUAL(sal_Int32(27000), nRotation
);
2633 xCell
.set(xTable
->getCellByPosition(1, 0), uno::UNO_QUERY_THROW
);
2634 xCell
->getPropertyValue("RotateAngle") >>= nRotation
;
2635 CPPUNIT_ASSERT_EQUAL(sal_Int32(9000), nRotation
);
2637 xCell
.set(xTable
->getCellByPosition(2, 0), uno::UNO_QUERY_THROW
);
2638 xCell
->getPropertyValue("RotateAngle") >>= nRotation
;
2639 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRotation
);
2641 xDocShRef
->DoClose();
2644 void SdImportTest::testTdf89064()
2646 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf89064.pptx"), PPTX
);
2647 uno::Reference
< presentation::XPresentationPage
> xPage (getPage(0, xDocShRef
), uno::UNO_QUERY_THROW
);
2648 uno::Reference
< drawing::XDrawPage
> xNotesPage (xPage
->getNotesPage(), uno::UNO_SET_THROW
);
2649 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), xNotesPage
->getCount());
2651 xDocShRef
->DoClose();
2654 void SdImportTest::testTdf108925()
2656 // Test document contains bulleting with too small bullet size (1%) which breaks the lower constraint
2657 // So it should be converted to the lowest allowed value (25%).
2658 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/tdf108925.odp"), ODP
);
2659 const SdrPage
*pPage
= GetPage(1, xDocShRef
);
2660 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>(pPage
->GetObj(0));
2661 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
2662 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
2664 const SvxNumBulletItem
*pNumFmt
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
2665 CPPUNIT_ASSERT(pNumFmt
);
2666 CPPUNIT_ASSERT_EQUAL(sal_uInt16(25), pNumFmt
->GetNumRule()->GetLevel(0).GetBulletRelSize());
2668 xDocShRef
->DoClose();
2671 void SdImportTest::testTdf109067()
2673 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf109067.pptx"), PPTX
);
2674 uno::Reference
< beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_SET_THROW
);
2675 awt::Gradient gradient
;
2676 CPPUNIT_ASSERT(xShape
->getPropertyValue("FillGradient") >>= gradient
);
2677 CPPUNIT_ASSERT_EQUAL(sal_Int16(450), gradient
.Angle
);
2679 xDocShRef
->DoClose();
2682 void SdImportTest::testTdf109187()
2684 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf109187.pptx"), PPTX
);
2685 uno::Reference
< beans::XPropertySet
> xArrow1(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_SET_THROW
);
2686 awt::Gradient aGradient1
;
2687 CPPUNIT_ASSERT(xArrow1
->getPropertyValue("FillGradient") >>= aGradient1
);
2688 CPPUNIT_ASSERT_EQUAL(sal_Int16(2250), aGradient1
.Angle
);
2689 uno::Reference
< beans::XPropertySet
> xArrow2(getShapeFromPage(1, 0, xDocShRef
), uno::UNO_SET_THROW
);
2690 awt::Gradient aGradient2
;
2691 CPPUNIT_ASSERT(xArrow2
->getPropertyValue("FillGradient") >>= aGradient2
);
2692 CPPUNIT_ASSERT_EQUAL(sal_Int16(1350), aGradient2
.Angle
);
2694 xDocShRef
->DoClose();
2697 void SdImportTest::testTdf108926()
2699 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf108926.ppt"), PPT
);
2700 uno::Reference
< presentation::XPresentationPage
> xPage (getPage(0, xDocShRef
), uno::UNO_QUERY_THROW
);
2701 uno::Reference
< drawing::XDrawPage
> xNotesPage (xPage
->getNotesPage(), uno::UNO_SET_THROW
);
2702 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xNotesPage
->getCount());
2704 // Second object should be imported as an empty presentation shape
2705 uno::Reference
< beans::XPropertySet
> xPresentationShape(xNotesPage
->getByIndex(1), uno::UNO_QUERY
);
2706 CPPUNIT_ASSERT(xPresentationShape
.is());
2707 bool bIsEmptyPresObject
= false;
2708 xPresentationShape
->getPropertyValue( "IsEmptyPresentationObject" ) >>= bIsEmptyPresObject
;
2709 CPPUNIT_ASSERT(bIsEmptyPresObject
);
2711 xDocShRef
->DoClose();
2714 void SdImportTest::testTdf100065()
2716 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf100065.pptx"), PPTX
);
2718 uno::Reference
< container::XIndexAccess
> xGroupShape1(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
2719 uno::Reference
< beans::XPropertySet
> xShape1(xGroupShape1
->getByIndex(1), uno::UNO_QUERY_THROW
);
2721 CPPUNIT_ASSERT(xShape1
->getPropertyValue("RotateAngle") >>= nAngle1
);
2722 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), nAngle1
);
2724 uno::Reference
< container::XIndexAccess
> xGroupShape2(getShapeFromPage(1, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
2725 uno::Reference
< beans::XPropertySet
> xShape2(xGroupShape2
->getByIndex(0), uno::UNO_QUERY_THROW
);
2727 CPPUNIT_ASSERT(xShape2
->getPropertyValue("RotateAngle") >>= nAngle2
);
2728 CPPUNIT_ASSERT_EQUAL(sal_Int32(18000), nAngle2
);
2730 xDocShRef
->DoClose();
2733 void SdImportTest::testTdf90626()
2735 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf90626.pptx"), PPTX
);
2736 const SdrPage
*pPage
= GetPage(1, xDocShRef
);
2737 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>(pPage
->GetObj(1));
2738 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
2739 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
2740 for(int i
= 0; i
< 4; i
++)
2742 const SvxNumBulletItem
*pNumFmt
= aEdit
.GetParaAttribs(i
).GetItem(EE_PARA_NUMBULLET
);
2743 CPPUNIT_ASSERT(pNumFmt
);
2744 CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(371), pNumFmt
->GetNumRule()->GetLevel(0).GetGraphicSize().getHeight(), tools::Long(1));
2747 xDocShRef
->DoClose();
2750 void SdImportTest::testTdf138148()
2752 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf138148.pptx"), PPTX
);
2753 const SdrPage
*pPage
= GetPage(1, xDocShRef
);
2754 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>(pPage
->GetObj(0));
2755 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
2756 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
2757 for(int i
= 0; i
< 2; i
++)
2759 const SvxNumBulletItem
*pNumFmt
= aEdit
.GetParaAttribs(i
).GetItem(EE_PARA_NUMBULLET
);
2760 CPPUNIT_ASSERT(pNumFmt
);
2761 CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(444), pNumFmt
->GetNumRule()->GetLevel(0).GetGraphicSize().getHeight(), tools::Long(1));
2763 // Without the fix in place, this test would have failed with
2766 CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(148), pNumFmt
->GetNumRule()->GetLevel(0).GetGraphicSize().getWidth(), tools::Long(1));
2769 xDocShRef
->DoClose();
2772 void SdImportTest::testTdf114488()
2774 // This doc has two images - one WMF and the other PNG (fallback image).
2775 // When loading this doc, the WMF image should be preferred over the PNG image.
2776 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odg/tdf114488.fodg"), FODG
);
2777 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_SET_THROW
);
2778 uno::Reference
<graphic::XGraphic
> xGraphic
;
2779 xShape
->getPropertyValue("Graphic") >>= xGraphic
;
2780 CPPUNIT_ASSERT(xGraphic
.is());
2781 OUString
sMimeType(comphelper::GraphicMimeTypeHelper::GetMimeTypeForXGraphic(xGraphic
));
2782 CPPUNIT_ASSERT_EQUAL(OUString("image/x-wmf"), sMimeType
);
2784 xDocShRef
->DoClose();
2787 void SdImportTest::testTdf134174()
2789 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf134174.pptx"), PPTX
);
2790 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_SET_THROW
);
2791 CPPUNIT_ASSERT(xShape
.is());
2793 uno::Reference
<graphic::XGraphic
> xGraphic
;
2794 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
2795 CPPUNIT_ASSERT(xGraphic
.is());
2797 Graphic
aGraphic(xGraphic
);
2798 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
2799 CPPUNIT_ASSERT_EQUAL( Color(9118171), aBitmap
.GetPixelColor( 0, 0 ));
2801 xDocShRef
->DoClose();
2804 void SdImportTest::testTdf134210()
2806 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc(u
"sd/qa/unit/data/pptx/tdf134210.pptx"), PPTX
);
2807 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_SET_THROW
);
2808 CPPUNIT_ASSERT(xShape
.is());
2810 uno::Reference
<graphic::XGraphic
> xGraphic
;
2811 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
2812 CPPUNIT_ASSERT(xGraphic
.is());
2814 Graphic
aGraphic(xGraphic
);
2815 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
2816 CPPUNIT_ASSERT_EQUAL( Color(6708292), aBitmap
.GetPixelColor( 0, 0 ));
2818 xDocShRef
->DoClose();
2821 void SdImportTest::testTdf114913()
2823 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf114913.pptx"), PPTX
);
2824 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>(GetPage(1, xDocShRef
)->GetObj(1));
2825 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
2826 const SvxNumBulletItem
*pItem
= pTxtObj
->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
2827 CPPUNIT_ASSERT(pItem
);
2828 CPPUNIT_ASSERT_EQUAL(tools::Long(691), pItem
->GetNumRule()->GetLevel(0).GetGraphicSize().getHeight());
2830 xDocShRef
->DoClose();
2833 void SdImportTest::testTdf114821()
2836 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc( "/sd/qa/unit/data/pptx/tdf114821.pptx" ), PPTX
);
2838 uno::Reference
< beans::XPropertySet
> xPropSet( getShapeFromPage( 0, 0, xDocShRef
) );
2839 aAny
= xPropSet
->getPropertyValue( "Model" );
2840 CPPUNIT_ASSERT_MESSAGE( "The shape doesn't have the property", aAny
.hasValue() );
2842 uno::Reference
< chart::XChartDocument
> xChartDoc
;
2844 CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc
.is() );
2845 uno::Reference
< chart2::XChartDocument
> xChart2Doc( xChartDoc
, uno::UNO_QUERY
);
2846 CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc
.is() );
2848 uno::Reference
< chart2::XCoordinateSystemContainer
> xBCooSysCnt( xChart2Doc
->getFirstDiagram(), uno::UNO_QUERY
);
2849 uno::Sequence
< uno::Reference
< chart2::XCoordinateSystem
> > aCooSysSeq( xBCooSysCnt
->getCoordinateSystems() );
2850 uno::Reference
< chart2::XChartTypeContainer
> xCTCnt( aCooSysSeq
[0], uno::UNO_QUERY
);
2852 uno::Reference
< chart2::XDataSeriesContainer
> xDSCnt( xCTCnt
->getChartTypes()[0], uno::UNO_QUERY
);
2853 CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt
.is() );
2854 uno::Sequence
< uno::Reference
< chart2::XDataSeries
> > aSeriesSeq( xDSCnt
->getDataSeries() );
2855 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Invalid Series count", static_cast<sal_Int32
>( 1 ), aSeriesSeq
.getLength() );
2857 // These Labels have custom position, so the exported LabelPlacement (reference point) by MSO is OUTSIDE/OUTEND
2858 // Check the first label
2859 const css::uno::Reference
< css::beans::XPropertySet
>& rPropSet0( aSeriesSeq
[0]->getDataPointByIndex( 0 ) );
2860 CPPUNIT_ASSERT( rPropSet0
.is() );
2861 sal_Int32 aPlacement
;
2862 rPropSet0
->getPropertyValue( "LabelPlacement" ) >>= aPlacement
;
2863 CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::OUTSIDE
, aPlacement
);
2865 // Check the second label
2866 const css::uno::Reference
< css::beans::XPropertySet
>& rPropSet1( aSeriesSeq
[0]->getDataPointByIndex( 1 ) );
2867 CPPUNIT_ASSERT( rPropSet1
.is() );
2868 rPropSet1
->getPropertyValue( "LabelPlacement" ) >>= aPlacement
;
2869 CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::OUTSIDE
, aPlacement
);
2871 // Check the third label
2872 const css::uno::Reference
< css::beans::XPropertySet
>& rPropSet2( aSeriesSeq
[0]->getDataPointByIndex( 2 ) );
2873 CPPUNIT_ASSERT( rPropSet2
.is() );
2874 rPropSet2
->getPropertyValue( "LabelPlacement") >>= aPlacement
;
2875 CPPUNIT_ASSERT_EQUAL( css::chart::DataLabelPlacement::OUTSIDE
, aPlacement
);
2877 xDocShRef
->DoClose();
2880 void SdImportTest::testTdf115394()
2882 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf115394.pptx"), PPTX
);
2883 double fTransitionDuration
;
2885 // Slow in MS formats
2886 SdPage
* pPage1
= xDocShRef
->GetDoc()->GetSdPage(0, PageKind::Standard
);
2887 fTransitionDuration
= pPage1
->getTransitionDuration();
2888 CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration
);
2890 // Medium in MS formats
2891 SdPage
* pPage2
= xDocShRef
->GetDoc()->GetSdPage(1, PageKind::Standard
);
2892 fTransitionDuration
= pPage2
->getTransitionDuration();
2893 CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration
);
2895 // Fast in MS formats
2896 SdPage
* pPage3
= xDocShRef
->GetDoc()->GetSdPage(2, PageKind::Standard
);
2897 fTransitionDuration
= pPage3
->getTransitionDuration();
2898 CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration
);
2901 SdPage
* pPage4
= xDocShRef
->GetDoc()->GetSdPage(3, PageKind::Standard
);
2902 fTransitionDuration
= pPage4
->getTransitionDuration();
2903 CPPUNIT_ASSERT_EQUAL(0.25, fTransitionDuration
);
2905 SdPage
* pPage5
= xDocShRef
->GetDoc()->GetSdPage(4, PageKind::Standard
);
2906 fTransitionDuration
= pPage5
->getTransitionDuration();
2907 CPPUNIT_ASSERT_EQUAL(4.25, fTransitionDuration
);
2909 xDocShRef
->DoClose();
2912 void SdImportTest::testTdf115394PPT()
2914 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/ppt/tdf115394.ppt"), PPT
);
2915 double fTransitionDuration
;
2918 SdPage
* pPage1
= xDocShRef
->GetDoc()->GetSdPage(0, PageKind::Standard
);
2919 fTransitionDuration
= pPage1
->getTransitionDuration();
2920 CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration
);
2923 SdPage
* pPage2
= xDocShRef
->GetDoc()->GetSdPage(1, PageKind::Standard
);
2924 fTransitionDuration
= pPage2
->getTransitionDuration();
2925 CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration
);
2928 SdPage
* pPage3
= xDocShRef
->GetDoc()->GetSdPage(2, PageKind::Standard
);
2929 fTransitionDuration
= pPage3
->getTransitionDuration();
2930 CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration
);
2932 xDocShRef
->DoClose();
2935 void SdImportTest::testTdf51340()
2937 // Line spacing was not inherited from upper levels (slide layout, master slide)
2938 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf51340.pptx"), PPTX
);
2939 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 1, 0, xDocShRef
) );
2941 // First paragraph has a 90% line spacing set on master slide
2942 uno::Reference
<text::XTextRange
> xParagraph( getParagraphFromShape( 0, xShape
) );
2943 uno::Reference
< beans::XPropertySet
> xPropSet( xParagraph
, uno::UNO_QUERY_THROW
);
2944 css::style::LineSpacing aSpacing
;
2945 xPropSet
->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing
;
2946 CPPUNIT_ASSERT_EQUAL( css::style::LineSpacingMode::PROP
, aSpacing
.Mode
);
2947 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16
>(90), aSpacing
.Height
);
2949 // Second paragraph has a 125% line spacing set on slide layout
2950 xParagraph
.set( getParagraphFromShape( 1, xShape
) );
2951 xPropSet
.set( xParagraph
, uno::UNO_QUERY_THROW
);
2952 xPropSet
->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing
;
2953 CPPUNIT_ASSERT_EQUAL( css::style::LineSpacingMode::PROP
, aSpacing
.Mode
);
2954 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16
>(125), aSpacing
.Height
);
2956 // Third paragraph has a 70% line spacing set directly on normal slide (master slide property is overridden)
2957 xParagraph
.set( getParagraphFromShape( 2, xShape
) );
2958 xPropSet
.set( xParagraph
, uno::UNO_QUERY_THROW
);
2959 xPropSet
->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing
;
2960 CPPUNIT_ASSERT_EQUAL( css::style::LineSpacingMode::PROP
, aSpacing
.Mode
);
2961 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16
>(70), aSpacing
.Height
);
2963 // Fourth paragraph has a 190% line spacing set directly on normal slide (slide layout property is overridden)
2964 xParagraph
.set( getParagraphFromShape( 3, xShape
) );
2965 xPropSet
.set( xParagraph
, uno::UNO_QUERY_THROW
);
2966 xPropSet
->getPropertyValue( "ParaLineSpacing" ) >>= aSpacing
;
2967 CPPUNIT_ASSERT_EQUAL( css::style::LineSpacingMode::PROP
, aSpacing
.Mode
);
2968 CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int16
>(190), aSpacing
.Height
);
2970 xDocShRef
->DoClose();
2973 void SdImportTest::testTdf116899()
2975 // This is a PPT created in Impress and roundtripped in PP, the key times become [1, -1] in PP,
2976 // a time of -1 (-1000) in PPT means key times have to be distributed evenly between 0 and 1
2977 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/ppt/tdf116899.ppt"), PPT
);
2979 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(
2980 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
2981 uno::Reference
< drawing::XDrawPage
> xPage(
2982 xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
2983 uno::Reference
< animations::XAnimationNodeSupplier
> xAnimNodeSupplier(
2984 xPage
, uno::UNO_QUERY_THROW
);
2985 uno::Reference
< animations::XAnimationNode
> xRootNode(
2986 xAnimNodeSupplier
->getAnimationNode() );
2987 std::vector
< uno::Reference
< animations::XAnimationNode
> > aAnimVector
;
2988 anim::create_deep_vector(xRootNode
, aAnimVector
);
2989 uno::Reference
< animations::XAnimate
> xNode(
2990 aAnimVector
[8], uno::UNO_QUERY_THROW
);
2991 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of key times in the animation node isn't 2.", static_cast<sal_Int32
>(2), xNode
->getKeyTimes().getLength() );
2992 CPPUNIT_ASSERT_EQUAL_MESSAGE( "First key time in the animation node isn't 0, key times aren't normalized.", 0., xNode
->getKeyTimes()[0] );
2993 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Second key time in the animation node isn't 1, key times aren't normalized.", 1., xNode
->getKeyTimes()[1] );
2995 xDocShRef
->DoClose();
2998 void SdImportTest::testTdf77747()
3000 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/ppt/tdf77747.ppt"), PPT
);
3001 CPPUNIT_ASSERT(xDocShRef
.is());
3002 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>(GetPage(1, xDocShRef
)->GetObj(0));
3003 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
3004 const SvxNumBulletItem
*pNumFmt
= pTxtObj
->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
3005 CPPUNIT_ASSERT(pNumFmt
);
3006 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", OUString("-"), pNumFmt
->GetNumRule()->GetLevel(0).GetSuffix() );
3007 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's numbering type is wrong!", SVX_NUM_NUMBER_HEBREW
,
3008 pNumFmt
->GetNumRule()->GetLevel(0).GetNumberingType());
3010 xDocShRef
->DoClose();
3013 void SdImportTest::testTdf116266()
3015 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/odp/tdf116266.odp"), ODP
);
3016 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
3017 sfx2::LinkManager
* rLinkManager
= pDoc
->GetLinkManager();
3018 // The document contains one SVG stored as a link.
3019 CPPUNIT_ASSERT_EQUAL(size_t(1), rLinkManager
->GetLinks().size());
3021 xDocShRef
->DoClose();
3024 void SdImportTest::testTdf120028()
3026 // Check that the table shape has 4 columns.
3027 ::sd::DrawDocShellRef xDocShRef
3028 = loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf120028.pptx"), PPTX
);
3029 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(),
3031 CPPUNIT_ASSERT(xDoc
.is());
3033 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
3034 CPPUNIT_ASSERT(xPage
.is());
3036 // This failed, shape was not a table, all text was rendered in a single
3038 uno::Reference
<beans::XPropertySet
> xShape(getShape(0, xPage
));
3039 uno::Reference
<table::XColumnRowRange
> xModel(xShape
->getPropertyValue("Model"),
3041 CPPUNIT_ASSERT(xModel
.is());
3043 uno::Reference
<table::XTableColumns
> xColumns
= xModel
->getColumns();
3044 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xColumns
->getCount());
3046 // Check font size in the A1 cell.
3047 uno::Reference
<table::XCellRange
> xCells(xModel
, uno::UNO_QUERY
);
3048 uno::Reference
<beans::XPropertySet
> xCell(xCells
->getCellByPosition(0, 0), uno::UNO_QUERY
);
3049 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xCell
));
3050 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
3051 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY
);
3052 double fCharHeight
= 0;
3053 xPropSet
->getPropertyValue("CharHeight") >>= fCharHeight
;
3054 // This failed, non-scaled height was 13.5.
3055 CPPUNIT_ASSERT_DOUBLES_EQUAL(11.5, fCharHeight
, 1E-12);
3057 xDocShRef
->DoClose();
3060 void SdImportTest::testTdf120028b()
3062 // Check that the table shape has 4 columns.
3063 ::sd::DrawDocShellRef xDocShRef
3064 = loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf120028b.pptx"), PPTX
);
3065 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(),
3067 CPPUNIT_ASSERT(xDoc
.is());
3069 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
3070 CPPUNIT_ASSERT(xPage
.is());
3072 uno::Reference
<beans::XPropertySet
> xShape(getShape(0, xPage
));
3073 CPPUNIT_ASSERT(xShape
.is());
3075 uno::Reference
<table::XColumnRowRange
> xModel(xShape
->getPropertyValue("Model"),
3077 CPPUNIT_ASSERT(xModel
.is());
3079 uno::Reference
<table::XTableColumns
> xColumns
= xModel
->getColumns();
3080 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xColumns
->getCount());
3082 // Check font color in the A1 cell.
3083 uno::Reference
<table::XCellRange
> xCells(xModel
, uno::UNO_QUERY
);
3084 uno::Reference
<beans::XPropertySet
> xCell(xCells
->getCellByPosition(0, 0), uno::UNO_QUERY
);
3085 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xCell
));
3086 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
3087 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY
);
3088 sal_Int32 nCharColor
= 0;
3089 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
3090 // This was 0x1f497d, not white: text list style from placeholder shape
3091 // from slide layout was ignored.
3092 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0xffffff), nCharColor
);
3094 xDocShRef
->DoClose();
3097 void SdImportTest::testDescriptionImport()
3099 sd::DrawDocShellRef xDocShRef
3100 = loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/altdescription.pptx"), PPTX
);
3102 uno::Reference
<beans::XPropertySet
> xPropertySet(
3103 getShapeFromPage(/*nShape=*/2, /*nPage=*/0, xDocShRef
));
3106 xPropertySet
->getPropertyValue("Description") >>= sDesc
;
3108 CPPUNIT_ASSERT_EQUAL(OUString("We Can Do It!"), sDesc
);
3110 xDocShRef
->DoClose();
3113 void SdImportTest::testTdf83247()
3115 auto GetPause
= [this](const OUString
& sSrc
, sal_Int32 nFormat
) {
3116 sd::DrawDocShellRef xDocShRef
3117 = loadURL(m_directories
.getURLFromSrc(sSrc
), nFormat
);
3118 uno::Reference
<presentation::XPresentationSupplier
> xPresentationSupplier(
3119 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY
);
3120 uno::Reference
<beans::XPropertySet
> xPresentationProps(
3121 xPresentationSupplier
->getPresentation(), uno::UNO_QUERY_THROW
);
3123 auto retVal
= xPresentationProps
->getPropertyValue("Pause");
3124 xDocShRef
->DoClose();
3125 return retVal
.get
<sal_Int32
>();
3128 // 1. Check that presentation:pause attribute is imported correctly
3129 CPPUNIT_ASSERT_EQUAL(sal_Int32(10), GetPause("/sd/qa/unit/data/odp/loopPause10.odp", ODP
));
3131 // 2. ODF compliance: if presentation:pause attribute is absent, it must be treated as 0
3132 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause("/sd/qa/unit/data/odp/loopNoPause.odp", ODP
));
3134 // 3. Import PPT: pause should be 0
3135 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause("/sd/qa/unit/data/ppt/loopNoPause.ppt", PPT
));
3138 void SdImportTest::testTdf47365()
3140 sd::DrawDocShellRef xDocShRef
3141 = loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/loopNoPause.pptx"), PPTX
);
3142 uno::Reference
<presentation::XPresentationSupplier
> xPresentationSupplier(
3143 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
3144 uno::Reference
<beans::XPropertySet
> xPresentationProps(xPresentationSupplier
->getPresentation(),
3145 uno::UNO_QUERY_THROW
);
3147 const bool bEndlessVal
= xPresentationProps
->getPropertyValue("IsEndless").get
<bool>();
3148 const sal_Int32 nPauseVal
= xPresentationProps
->getPropertyValue("Pause").get
<sal_Int32
>();
3150 // Check that we import "loop" attribute of the presentation, and don't introduce any pauses
3151 CPPUNIT_ASSERT(bEndlessVal
);
3152 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPauseVal
);
3154 xDocShRef
->DoClose();
3157 void SdImportTest::testTdf122899()
3159 // tdf122899 FILEOPEN: ppt: old kind arc from MS Office 97 is broken
3160 // Error was, that the path coordinates of a mso_sptArc shape were read as sal_Int16
3161 // although they are unsigned 16 bit. This leads to wrong positions of start and end
3162 // point and results to a huge shape width in the test document.
3163 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/ppt/tdf122899_Arc_90_to_91_clockwise.ppt"), PPT
);
3164 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(
3165 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
3166 CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier
.is());
3167 uno::Reference
<drawing::XDrawPages
> xDrawPages(xDrawPagesSupplier
->getDrawPages());
3168 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPages
->getByIndex(0), uno::UNO_QUERY_THROW
);
3169 CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage
.is());
3170 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
3171 CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape
.is());
3172 awt::Rectangle aFrameRect
;
3173 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
3174 CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps
.is());
3175 xShapeProps
->getPropertyValue(UNO_NAME_MISC_OBJ_FRAMERECT
) >>= aFrameRect
;
3176 // original width is 9cm, add some tolerance
3177 CPPUNIT_ASSERT_LESS(static_cast<sal_Int32
>(9020), aFrameRect
.Width
);
3179 xDocShRef
->DoClose();
3182 void SdImportTest::testOOXTheme()
3184 sd::DrawDocShellRef xDocShRef
3185 = loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/ooxtheme.pptx"), PPTX
);
3187 uno::Reference
<beans::XPropertySet
> xPropSet(xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
3188 uno::Sequence
<beans::PropertyValue
> aGrabBag
;
3189 xPropSet
->getPropertyValue("InteropGrabBag") >>= aGrabBag
;
3191 bool bTheme
= false;
3192 for (beans::PropertyValue
const & prop
: std::as_const(aGrabBag
))
3194 if (prop
.Name
== "OOXTheme")
3197 uno::Reference
<xml::dom::XDocument
> aThemeDom
;
3198 CPPUNIT_ASSERT(prop
.Value
>>= aThemeDom
); // PropertyValue of proper type
3199 CPPUNIT_ASSERT(aThemeDom
); // Reference not empty
3202 CPPUNIT_ASSERT(bTheme
); // Grab Bag has all the expected elements
3204 xDocShRef
->DoClose();
3207 void SdImportTest::testCropToShape()
3209 sd::DrawDocShellRef xDocShRef
3210 = loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/crop-to-shape.pptx"), PPTX
);
3211 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(
3212 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
3213 CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier
.is());
3214 uno::Reference
<drawing::XDrawPages
> xDrawPages(xDrawPagesSupplier
->getDrawPages());
3215 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPages
->getByIndex(0), uno::UNO_QUERY_THROW
);
3216 CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage
.is());
3217 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
3218 CPPUNIT_ASSERT_EQUAL(OUString
{"com.sun.star.drawing.CustomShape"}, xShape
->getShapeType());
3219 CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape
.is());
3220 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
3221 css::drawing::FillStyle fillStyle
;
3222 xShapeProps
->getPropertyValue("FillStyle") >>= fillStyle
;
3223 CPPUNIT_ASSERT_EQUAL(css::drawing::FillStyle_BITMAP
, fillStyle
);
3224 css::drawing::BitmapMode bitmapmode
;
3225 xShapeProps
->getPropertyValue("FillBitmapMode") >>= bitmapmode
;
3226 CPPUNIT_ASSERT_EQUAL(css::drawing::BitmapMode_STRETCH
, bitmapmode
);
3229 void SdImportTest::testTdf127964()
3231 sd::DrawDocShellRef xDocShRef
3232 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf127964.pptx"), PPTX
);
3233 const SdrPage
* pPage
= GetPage(1, xDocShRef
);
3234 const SdrObject
* pObj
= pPage
->GetObj(0);
3235 auto& rFillStyleItem
3236 = dynamic_cast<const XFillStyleItem
&>(pObj
->GetMergedItem(XATTR_FILLSTYLE
));
3237 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rFillStyleItem
.GetValue());
3239 auto& rFillColorItem
3240 = dynamic_cast<const XFillColorItem
&>(pObj
->GetMergedItem(XATTR_FILLCOLOR
));
3241 // Without the accompanying fix in place, this test would have failed with:
3242 // - Expected: 4294967295
3243 // - Actual : 5210557
3244 // i.e. instead of transparent (which then got rendered as white), the shape fill color was
3246 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT
, rFillColorItem
.GetColorValue());
3247 xDocShRef
->DoClose();
3250 void SdImportTest::testTdf106638()
3252 sd::DrawDocShellRef xDocShRef
3253 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf106638.pptx"), PPTX
);
3254 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
));
3255 uno::Reference
<text::XTextRange
> const xPara(getParagraphFromShape(1, xShape
));
3256 uno::Reference
<text::XText
> xText
= xPara
->getText();
3257 uno::Reference
<text::XTextCursor
> xTextCursor
= xText
->createTextCursorByRange(xPara
->getStart());
3258 uno::Reference
<beans::XPropertySet
> xPropSet(xTextCursor
, uno::UNO_QUERY_THROW
);
3259 OUString aCharFontName
;
3260 CPPUNIT_ASSERT(xTextCursor
->goRight(1, true));
3261 // First character U+f0fe that uses Wingding
3262 xPropSet
->getPropertyValue("CharFontName") >>= aCharFontName
;
3263 CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), aCharFontName
);
3265 // The rest characters that do not use Wingding.
3266 CPPUNIT_ASSERT(xTextCursor
->goRight(45, true));
3267 xPropSet
->getPropertyValue("CharFontName") >>= aCharFontName
;
3268 CPPUNIT_ASSERT(aCharFontName
!= "Wingdings");
3271 void SdImportTest::testTdf128684()
3273 sd::DrawDocShellRef xDocShRef
3274 = loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf128684.pptx"), PPTX
);
3275 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(),
3277 CPPUNIT_ASSERT(xDoc
.is());
3278 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
3279 CPPUNIT_ASSERT(xPage
.is());
3280 uno::Reference
<beans::XPropertySet
> xShape(getShape(0, xPage
));
3281 CPPUNIT_ASSERT(xShape
.is());
3282 uno::Any aAny
= xShape
->getPropertyValue("CustomShapeGeometry");
3283 CPPUNIT_ASSERT(aAny
.hasValue());
3284 uno::Sequence
<beans::PropertyValue
> aProps
;
3285 CPPUNIT_ASSERT(aAny
>>= aProps
);
3286 sal_Int32 nRotateAngle
= 0;
3287 for( const auto& rProp
: std::as_const(aProps
) )
3289 if( rProp
.Name
== "TextPreRotateAngle")
3291 rProp
.Value
>>= nRotateAngle
;
3294 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-90), nRotateAngle
);
3297 void SdImportTest::testTdf113198()
3299 sd::DrawDocShellRef xDocShRef
3300 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf113198.pptx"), PPTX
);
3302 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
));
3303 sal_Int16 nParaAdjust
= -1;
3304 xShape
->getPropertyValue("ParaAdjust") >>= nParaAdjust
;
3305 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(nParaAdjust
));
3309 void SdImportTest::testTdf49856()
3311 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/ppt/tdf49856.ppt"), PPT
);
3312 const SdrPage
*pPage
= GetPage(1, xDocShRef
);
3313 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>(pPage
->GetObj(1));
3314 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
3315 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
3316 const SvxNumBulletItem
*pNumFmt
= aEdit
.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET
);
3317 CPPUNIT_ASSERT(pNumFmt
);
3318 const sal_UCS4 aBullet
= pNumFmt
->GetNumRule()->GetLevel(0).GetBulletChar();
3319 CPPUNIT_ASSERT_EQUAL(OUString("More level 2"), aEdit
.GetText(2));
3320 CPPUNIT_ASSERT_EQUAL(sal_UCS4(0x2022), aBullet
);
3322 xDocShRef
->DoClose();
3325 void SdImportTest::testShapeGlowEffectPPTXImpoer()
3327 sd::DrawDocShellRef xDocShRef
3328 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/shape-glow-effect.pptx"), PPTX
);
3330 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
));
3331 sal_Int32 nRadius
= -1;
3332 xShape
->getPropertyValue("GlowEffectRadius") >>= nRadius
;
3333 CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRadius
); // 139700 EMU = 388.0556 mm/100
3335 xShape
->getPropertyValue("GlowEffectColor") >>= nColor
;
3336 CPPUNIT_ASSERT_EQUAL(Color(0xFFC000), nColor
);
3337 sal_Int16 nTransparency
;
3338 xShape
->getPropertyValue("GlowEffectTransparency") >>= nTransparency
;
3339 CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nTransparency
);
3342 void SdImportTest::testShapeBlurPPTXImport()
3344 sd::DrawDocShellRef xDocShRef
3345 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/shape-blur-effect.pptx"), PPTX
);
3347 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
));
3348 bool bHasShadow
= false;
3349 xShape
->getPropertyValue("Shadow") >>= bHasShadow
;
3350 CPPUNIT_ASSERT(bHasShadow
);
3352 sal_Int32 nRadius
= -1;
3353 xShape
->getPropertyValue("ShadowBlur") >>= nRadius
;
3354 CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRadius
); // 584200EMU=46pt - 139700EMU = 388Hmm = 11pt
3358 void SdImportTest::testMirroredGraphic()
3360 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc(u
"sd/qa/unit/data/pptx/mirrored-graphic.pptx"), PPTX
);
3361 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_SET_THROW
);
3362 CPPUNIT_ASSERT(xShape
.is());
3363 uno::Reference
<graphic::XGraphic
> xGraphic
;
3364 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
3365 CPPUNIT_ASSERT(xGraphic
.is());
3366 Graphic
aGraphic(xGraphic
);
3367 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
3368 CPPUNIT_ASSERT_EQUAL( Color(5196117), aBitmap
.GetPixelColor( 0, 0 ));
3369 xDocShRef
->DoClose();
3372 void SdImportTest::testTdf134210CropPosition()
3374 // We are testing crop position of bitmap in custom shapes. We should see only green with proper fix.
3375 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc(u
"sd/qa/unit/data/pptx/crop-position.pptx"), PPTX
);
3376 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_SET_THROW
);
3377 CPPUNIT_ASSERT(xShape
.is());
3378 uno::Reference
<graphic::XGraphic
> xGraphic
;
3379 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
3380 CPPUNIT_ASSERT(xGraphic
.is());
3381 Graphic
aGraphic(xGraphic
);
3382 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
3383 CPPUNIT_ASSERT_EQUAL( Color(8508442), aBitmap
.GetPixelColor( 0, 0 ));
3384 xDocShRef
->DoClose();
3387 void SdImportTest::testGreysScaleGraphic()
3389 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc(u
"sd/qa/unit/data/pptx/greysscale-graphic.pptx"), PPTX
);
3390 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_SET_THROW
);
3391 CPPUNIT_ASSERT(xShape
.is());
3392 uno::Reference
<graphic::XGraphic
> xGraphic
;
3393 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
3394 CPPUNIT_ASSERT(xGraphic
.is());
3395 Graphic
aGraphic(xGraphic
);
3396 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
3397 CPPUNIT_ASSERT_EQUAL( Color(3947580), aBitmap
.GetPixelColor( 0, 0 ));
3398 xDocShRef
->DoClose();
3401 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest
);
3403 CPPUNIT_PLUGIN_IMPLEMENT();
3405 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */