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/.
12 #include "sdmodeltestbase.hxx"
14 #include <editeng/eeitem.hxx>
15 #include <editeng/editobj.hxx>
16 #include <editeng/numitem.hxx>
17 #include <editeng/unoprnms.hxx>
19 #include <svx/svdotable.hxx>
20 #include <svx/xfillit0.hxx>
21 #include <svx/xfilluseslidebackgrounditem.hxx>
22 #include <svx/xflclit.hxx>
23 #include <svx/xlineit0.hxx>
24 #include <svx/xlnclit.hxx>
25 #include <svx/sdooitm.hxx>
26 #include <animations/animationnodehelper.hxx>
28 #include <com/sun/star/awt/XBitmap.hpp>
29 #include <com/sun/star/awt/Gradient.hpp>
30 #include <com/sun/star/document/XEventsSupplier.hpp>
31 #include <com/sun/star/presentation/ClickAction.hpp>
32 #include <com/sun/star/presentation/XPresentationPage.hpp>
33 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
34 #include <com/sun/star/drawing/BitmapMode.hpp>
35 #include <com/sun/star/drawing/ColorMode.hpp>
36 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
37 #include <com/sun/star/drawing/XGluePointsSupplier.hpp>
38 #include <com/sun/star/drawing/GluePoint2.hpp>
39 #include <com/sun/star/container/XIdentifierAccess.hpp>
40 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
41 #include <com/sun/star/animations/XAnimate.hpp>
42 #include <com/sun/star/chart/DataLabelPlacement.hpp>
43 #include <com/sun/star/chart/XChartDocument.hpp>
44 #include <com/sun/star/chart2/XChartDocument.hpp>
45 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
46 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
47 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
48 #include <com/sun/star/style/ParagraphAdjust.hpp>
49 #include <com/sun/star/style/LineSpacing.hpp>
50 #include <com/sun/star/style/LineSpacingMode.hpp>
51 #include <com/sun/star/text/GraphicCrop.hpp>
52 #include <com/sun/star/text/WritingMode2.hpp>
53 #include <com/sun/star/text/XTextColumns.hpp>
54 #include <com/sun/star/xml/dom/XDocument.hpp>
56 #include <comphelper/sequenceashashmap.hxx>
57 #include <comphelper/graphicmimetype.hxx>
58 #include <sfx2/linkmgr.hxx>
59 #include <vcl/BitmapReadAccess.hxx>
60 #include <vcl/dibtools.hxx>
62 using namespace ::com::sun::star
;
64 class SdImportTest2
: public SdModelTestBase
68 : SdModelTestBase("/sd/qa/unit/data/")
73 bool checkPattern(int nShapeNumber
, std::vector
<sal_uInt8
>& rExpected
);
76 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf152186
)
78 createSdImpressDoc("pptx/tdf152186.pptx");
79 saveAndReload("Impress MS PowerPoint 2007 XML");
81 bool bHasShadow
= bool();
82 const SdrPage
* pPage
= GetPage(1);
83 for (size_t i
= 0; i
< pPage
->GetObjCount(); ++i
)
85 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(i
, 0));
86 CPPUNIT_ASSERT(xShape
->getPropertyValue("Shadow") >>= bHasShadow
);
87 CPPUNIT_ASSERT(!bHasShadow
);
91 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf93868
)
93 createSdImpressDoc("pptx/tdf93868.pptx");
95 const SdrPage
* pPage
= &(GetPage(1)->TRG_GetMasterPage());
96 CPPUNIT_ASSERT_EQUAL(size_t(5), pPage
->GetObjCount());
97 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
,
98 pPage
->GetObj(0)->GetMergedItem(XATTR_FILLSTYLE
).GetValue());
100 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
,
101 pPage
->GetObj(1)->GetMergedItem(XATTR_FILLSTYLE
).GetValue());
102 CPPUNIT_ASSERT_EQUAL(true,
103 pPage
->GetObj(1)->GetMergedItem(XATTR_FILLUSESLIDEBACKGROUND
).GetValue());
106 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf95932
)
108 createSdImpressDoc("pptx/tdf95932.pptx");
110 const SdrPage
* pPage
= GetPage(1);
111 SdrObject
* const pObj
= pPage
->GetObj(1);
112 CPPUNIT_ASSERT(pObj
);
114 const XFillStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
115 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
116 const XFillColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_FILLCOLOR
);
117 CPPUNIT_ASSERT_EQUAL(Color(0x76bf3d), rColorItem
.GetColorValue());
120 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf99030
)
122 createSdImpressDoc("pptx/tdf99030.pptx");
124 uno::Reference
<drawing::XMasterPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
125 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getMasterPages()->getByIndex(0),
126 uno::UNO_QUERY_THROW
);
127 uno::Reference
<beans::XPropertySet
> xPropSet(xPage
, uno::UNO_QUERY
);
130 uno::Any aAny
= xPropSet
->getPropertyValue("Background");
133 uno::Reference
<beans::XPropertySet
> xBackgroundPropSet
;
134 aAny
>>= xBackgroundPropSet
;
135 xBackgroundPropSet
->getPropertyValue("FillColor") >>= nFillColor
;
137 CPPUNIT_ASSERT_EQUAL(Color(0x676A55), nFillColor
);
140 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf49561
)
142 createSdImpressDoc("ppt/tdf49561.ppt");
144 uno::Reference
<drawing::XMasterPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
145 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getMasterPages()->getByIndex(0),
146 uno::UNO_QUERY_THROW
);
147 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), xPage
->getCount());
149 uno::Reference
<beans::XPropertySet
> xShape(getShape(3, xPage
));
150 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
151 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
152 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
154 float fCharHeight
= 0;
155 CPPUNIT_ASSERT(xPropSet
->getPropertyValue("CharHeight") >>= fCharHeight
);
156 CPPUNIT_ASSERT_EQUAL(12.f
, fCharHeight
);
158 OUString aCharFontName
;
159 CPPUNIT_ASSERT(xPropSet
->getPropertyValue("CharFontName") >>= aCharFontName
);
160 CPPUNIT_ASSERT_EQUAL(OUString("Stencil"), aCharFontName
);
163 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf103473
)
165 createSdImpressDoc("pptx/tdf103473.pptx");
167 const SdrPage
* pPage
= GetPage(1);
168 SdrTextObj
* const pObj
= dynamic_cast<SdrTextObj
* const>(pPage
->GetObj(0));
169 CPPUNIT_ASSERT(pObj
);
170 ::tools::Rectangle aRect
= pObj
->GetGeoRect();
171 CPPUNIT_ASSERT_EQUAL(tools::Long(3629), aRect
.Left());
172 CPPUNIT_ASSERT_EQUAL(tools::Long(4431), aRect
.Top());
173 CPPUNIT_ASSERT_EQUAL(tools::Long(8353), aRect
.Right());
174 CPPUNIT_ASSERT_EQUAL(tools::Long(9155), aRect
.Bottom());
177 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testAoo124143
)
179 createSdDrawDoc("odg/ooo124143-1.odg");
181 uno::Reference
<beans::XPropertySet
> const xImage(getShapeFromPage(0, 0));
182 uno::Reference
<drawing::XGluePointsSupplier
> const xGPS(xImage
, uno::UNO_QUERY
);
183 uno::Reference
<container::XIdentifierAccess
> const xGluePoints(xGPS
->getGluePoints(),
186 uno::Sequence
<sal_Int32
> const ids(xGluePoints
->getIdentifiers());
187 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), ids
.getLength());
188 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), ids
[0]);
189 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), ids
[1]);
190 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), ids
[2]);
191 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), ids
[3]);
192 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), ids
[4]);
193 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), ids
[5]);
195 // interesting ones are custom 4, 5
196 drawing::GluePoint2 glue4
;
197 xGluePoints
->getByIdentifier(4) >>= glue4
;
198 CPPUNIT_ASSERT_EQUAL(sal_Int32(2470), glue4
.Position
.X
);
199 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1810), glue4
.Position
.Y
);
201 drawing::GluePoint2 glue5
;
202 xGluePoints
->getByIdentifier(5) >>= glue5
;
203 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2975), glue5
.Position
.X
);
204 CPPUNIT_ASSERT_EQUAL(sal_Int32(-2165), glue5
.Position
.Y
);
206 // now check connectors
207 uno::Reference
<beans::XPropertySet
> const xEllipse(getShapeFromPage(1, 0));
208 uno::Reference
<beans::XPropertySet
> const xConn1(getShapeFromPage(2, 0));
209 CPPUNIT_ASSERT_EQUAL(sal_Int32(1),
210 xConn1
->getPropertyValue("StartGluePointIndex").get
<sal_Int32
>());
211 CPPUNIT_ASSERT_EQUAL(
213 xConn1
->getPropertyValue("StartShape").get
<uno::Reference
<beans::XPropertySet
>>());
214 CPPUNIT_ASSERT_EQUAL(sal_Int32(4),
215 xConn1
->getPropertyValue("EndGluePointIndex").get
<sal_Int32
>());
216 CPPUNIT_ASSERT_EQUAL(
217 xImage
, xConn1
->getPropertyValue("EndShape").get
<uno::Reference
<beans::XPropertySet
>>());
218 uno::Reference
<beans::XPropertySet
> const xConn2(getShapeFromPage(3, 0));
219 CPPUNIT_ASSERT_EQUAL(sal_Int32(3),
220 xConn2
->getPropertyValue("StartGluePointIndex").get
<sal_Int32
>());
221 CPPUNIT_ASSERT_EQUAL(
223 xConn2
->getPropertyValue("StartShape").get
<uno::Reference
<beans::XPropertySet
>>());
224 CPPUNIT_ASSERT_EQUAL(sal_Int32(5),
225 xConn2
->getPropertyValue("EndGluePointIndex").get
<sal_Int32
>());
226 CPPUNIT_ASSERT_EQUAL(
227 xImage
, xConn2
->getPropertyValue("EndShape").get
<uno::Reference
<beans::XPropertySet
>>());
230 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf103567
)
232 createSdImpressDoc("odp/tdf103567.odp");
233 for (int i
= 0; i
< 4; ++i
)
235 uno::Reference
<beans::XPropertySet
> const xShape(getShapeFromPage(i
, 0));
236 uno::Reference
<document::XEventsSupplier
> const xEventsSupplier(xShape
, uno::UNO_QUERY
);
237 uno::Reference
<container::XNameAccess
> const xEvents(xEventsSupplier
->getEvents());
238 OString
const msg("shape " + OString::number(i
) + ": ");
240 CPPUNIT_ASSERT(xEvents
->hasByName("OnClick"));
241 uno::Sequence
<beans::PropertyValue
> props
;
242 xEvents
->getByName("OnClick") >>= props
;
243 comphelper::SequenceAsHashMap
const map(props
);
245 auto iter(map
.find("EventType"));
246 CPPUNIT_ASSERT_MESSAGE(OString(msg
+ "no EventType").getStr(), iter
!= map
.end());
247 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg
.getStr(), OUString("Presentation"),
248 iter
->second
.get
<OUString
>());
251 auto iter(map
.find("ClickAction"));
252 CPPUNIT_ASSERT_MESSAGE(OString(msg
+ "no ClickAction").getStr(), iter
!= map
.end());
255 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg
.getStr(), css::presentation::ClickAction_DOCUMENT
,
256 iter
->second
.get
<css::presentation::ClickAction
>());
260 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg
.getStr(), css::presentation::ClickAction_NEXTPAGE
,
261 iter
->second
.get
<css::presentation::ClickAction
>());
266 auto iter(map
.find("Bookmark"));
267 CPPUNIT_ASSERT_MESSAGE(OString(msg
+ "no Bookmark").getStr(), iter
!= map
.end());
268 CPPUNIT_ASSERT_EQUAL_MESSAGE(msg
.getStr(), OUString("http://example.com/"),
269 iter
->second
.get
<OUString
>());
274 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf103792
)
276 // Title text shape on the actual slide contained no text neither a placeholder text.
278 createSdImpressDoc("pptx/tdf103792.pptx");
280 const SdrPage
* pPage
= GetPage(1);
281 CPPUNIT_ASSERT_MESSAGE("No page found", pPage
!= nullptr);
282 SdrObject
* pObj
= pPage
->GetObj(0);
283 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj
!= nullptr);
284 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pObj
);
285 CPPUNIT_ASSERT_MESSAGE("Not a text object", pTxtObj
!= nullptr);
287 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
288 CPPUNIT_ASSERT_EQUAL(OUString("Click to add Title"), aEdit
.GetText(0));
291 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf148685
)
293 createSdImpressDoc("pptx/tdf148685.pptx");
294 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(1, 0));
296 uno::Reference
<text::XTextRange
> const xParagraph(getParagraphFromShape(0, xShape
));
298 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
299 CPPUNIT_ASSERT_EQUAL(OUString("TEXT "), xRun
->getString());
301 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
303 Color nCharUnderlineColor
;
304 xPropSet
->getPropertyValue("CharUnderlineColor") >>= nCharUnderlineColor
;
305 CPPUNIT_ASSERT_EQUAL(Color(0xA1467E), nCharUnderlineColor
);
307 xRun
.set(getRunFromParagraph(1, xParagraph
));
309 CPPUNIT_ASSERT_EQUAL(OUString("TE"), xRun
->getString());
311 xPropSet
.set(xRun
, uno::UNO_QUERY_THROW
);
313 xPropSet
->getPropertyValue("CharUnderlineColor") >>= nCharUnderlineColor
;
315 // Without the fix in place, this test would have failed with
316 // - Expected: Color: R:255 G:255 B:255 A:255
317 // - Actual : Color: R:161 G:70 B:126 A:0
318 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, nCharUnderlineColor
);
320 xRun
.set(getRunFromParagraph(2, xParagraph
));
321 CPPUNIT_ASSERT_EQUAL(OUString("XT"), xRun
->getString());
323 xPropSet
.set(xRun
, uno::UNO_QUERY_THROW
);
325 xPropSet
->getPropertyValue("CharUnderlineColor") >>= nCharUnderlineColor
;
326 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, nCharUnderlineColor
);
329 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf103876
)
331 // Title text shape's placeholder text did not inherit the corresponding text properties
333 createSdImpressDoc("pptx/tdf103876.pptx");
334 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
336 // Check paragraph alignment
337 sal_Int16 nParaAdjust
= 0;
338 xShape
->getPropertyValue("ParaAdjust") >>= nParaAdjust
;
339 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
,
340 static_cast<style::ParagraphAdjust
>(nParaAdjust
));
342 // Check character color
344 xShape
->getPropertyValue("CharColor") >>= nCharColor
;
345 CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), nCharColor
);
348 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf79007
)
350 createSdImpressDoc("pptx/tdf79007.pptx");
352 uno::Reference
<beans::XPropertySet
> xShape1(getShapeFromPage(0, 0));
353 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape1
.is());
355 // Check we map mso washout to our watermark
356 drawing::ColorMode aColorMode1
;
357 xShape1
->getPropertyValue("GraphicColorMode") >>= aColorMode1
;
358 CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_WATERMARK
, aColorMode1
);
360 sal_Int16 nContrast1
;
361 xShape1
->getPropertyValue("AdjustContrast") >>= nContrast1
;
362 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nContrast1
);
364 sal_Int16 nLuminance1
;
365 xShape1
->getPropertyValue("AdjustLuminance") >>= nLuminance1
;
366 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nLuminance1
);
368 uno::Reference
<beans::XPropertySet
> xShape2(getShapeFromPage(1, 0));
369 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape2
.is());
371 // Check we map mso grayscale to our grayscale
372 drawing::ColorMode aColorMode2
;
373 xShape2
->getPropertyValue("GraphicColorMode") >>= aColorMode2
;
374 CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_GREYS
, aColorMode2
);
376 sal_Int16 nContrast2
;
377 xShape2
->getPropertyValue("AdjustContrast") >>= nContrast2
;
378 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nContrast2
);
380 sal_Int16 nLuminance2
;
381 xShape2
->getPropertyValue("AdjustLuminance") >>= nLuminance2
;
382 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nLuminance2
);
384 uno::Reference
<beans::XPropertySet
> xShape3(getShapeFromPage(2, 0));
385 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape3
.is());
387 // Check we map mso black/white to our black/white
388 drawing::ColorMode aColorMode3
;
389 xShape3
->getPropertyValue("GraphicColorMode") >>= aColorMode3
;
390 CPPUNIT_ASSERT_EQUAL(drawing::ColorMode_MONO
, aColorMode3
);
392 sal_Int16 nContrast3
;
393 xShape3
->getPropertyValue("AdjustContrast") >>= nContrast3
;
394 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nContrast3
);
396 sal_Int16 nLuminance3
;
397 xShape3
->getPropertyValue("AdjustLuminance") >>= nLuminance3
;
398 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nLuminance3
);
401 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf119649
)
403 createSdImpressDoc("pptx/tdf119649.pptx");
404 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(1, 0));
406 // Get first paragraph of the text
407 uno::Reference
<text::XTextRange
> const xParagraph(getParagraphFromShape(0, xShape
));
409 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
410 CPPUNIT_ASSERT_EQUAL(OUString("default_color("), xRun
->getString());
412 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
415 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
416 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, nCharColor
);
418 xRun
.set(getRunFromParagraph(1, xParagraph
));
420 // Without the fix in place, this test would have failed with
421 // - Expected: colored_text
422 // - Actual : colored_text)
423 CPPUNIT_ASSERT_EQUAL(OUString("colored_text"), xRun
->getString());
425 xPropSet
.set(xRun
, uno::UNO_QUERY_THROW
);
427 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
428 CPPUNIT_ASSERT_EQUAL(Color(0xCE181E), nCharColor
);
430 xRun
.set(getRunFromParagraph(2, xParagraph
));
431 CPPUNIT_ASSERT_EQUAL(OUString(")"), xRun
->getString());
433 xPropSet
.set(xRun
, uno::UNO_QUERY_THROW
);
435 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
436 CPPUNIT_ASSERT_EQUAL(COL_AUTO
, nCharColor
);
439 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf118776
)
441 createSdImpressDoc("pptx/tdf118776.pptx");
442 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
444 // Get first paragraph of the text
445 uno::Reference
<text::XTextRange
> const xParagraph(getParagraphFromShape(0, xShape
));
447 // Get first run of the paragraph
448 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
449 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
450 sal_Int16 nTransparency
= 0;
451 xPropSet
->getPropertyValue("CharTransparence") >>= nTransparency
;
453 // Import noFill color as 99% transparency
454 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(99), nTransparency
);
457 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf129686
)
459 createSdImpressDoc("pptx/tdf129686.pptx");
460 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
462 // Get first paragraph of the text
463 uno::Reference
<text::XTextRange
> const xParagraph(getParagraphFromShape(0, xShape
));
465 // Get first run of the paragraph
466 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
467 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
468 sal_Int16 nTransparency
= 0;
469 xPropSet
->getPropertyValue("CharTransparence") >>= nTransparency
;
471 // 0 = no transparency, 100 (default) = completely transparent (unless COL_AUTO)
472 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(0), nTransparency
);
475 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf104015
)
477 // Shape fill, line and effect properties were not inherited from master slide shape
479 createSdImpressDoc("pptx/tdf104015.pptx");
481 const SdrPage
* pPage
= GetPage(1);
482 CPPUNIT_ASSERT_MESSAGE("No page found", pPage
!= nullptr);
483 SdrObject
* const pObj
= pPage
->GetObj(0);
484 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj
!= nullptr);
485 // Should have a red fill color
487 const XFillStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
488 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
489 const XFillColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_FILLCOLOR
);
490 CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), rColorItem
.GetColorValue());
492 // Should have a blue line
494 const XLineStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_LINESTYLE
);
495 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, rStyleItem
.GetValue());
497 const XLineColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_LINECOLOR
);
498 CPPUNIT_ASSERT_EQUAL(Color(0x0000FF), rColorItem
.GetColorValue());
500 // Should have some shadow
502 const SdrOnOffItem
& rShadowItem
= pObj
->GetMergedItem(SDRATTR_SHADOW
);
503 CPPUNIT_ASSERT(rShadowItem
.GetValue());
507 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf104201
)
509 // Group shape properties did not overwrite the child shapes' fill
511 createSdImpressDoc("pptx/tdf104201.pptx");
513 const SdrPage
* pPage
= GetPage(1);
514 CPPUNIT_ASSERT_MESSAGE("No page found", pPage
!= nullptr);
516 // First shape has red fill, but this should be overwritten by green group fill
518 SdrObject
* const pObj
= pPage
->GetObj(0);
519 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj
!= nullptr);
520 const XFillStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
521 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
522 const XFillColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_FILLCOLOR
);
523 CPPUNIT_ASSERT_EQUAL(Color(0x00FF00), rColorItem
.GetColorValue());
525 // Second shape has blue fill, but this should be overwritten by green group fill
527 SdrObject
* const pObj
= pPage
->GetObj(0);
528 CPPUNIT_ASSERT_MESSAGE("Wrong object", pObj
!= nullptr);
529 const XFillStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
530 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
531 const XFillColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_FILLCOLOR
);
532 CPPUNIT_ASSERT_EQUAL(Color(0x00FF00), rColorItem
.GetColorValue());
536 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf103477
)
538 createSdImpressDoc("pptx/tdf103477.pptx");
540 const SdrPage
* pPage
= GetPage(1);
542 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pPage
->GetObj(6));
543 CPPUNIT_ASSERT_MESSAGE("no text object", pTxtObj
!= nullptr);
545 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
546 const SvxNumBulletItem
* pNumFmt
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
547 CPPUNIT_ASSERT(pNumFmt
);
548 CPPUNIT_ASSERT_EQUAL_MESSAGE("Bullet's color is wrong!", Color(0x000000),
549 pNumFmt
->GetNumRule().GetLevel(1).GetBulletColor());
552 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf105150
)
554 createSdImpressDoc("pptx/tdf105150.pptx");
555 const SdrPage
* pPage
= GetPage(1);
556 const SdrObject
* pObj
= pPage
->GetObj(1);
557 auto& rFillStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
558 // This was drawing::FillStyle_NONE, <p:sp useBgFill="1"> was ignored when
559 // the slide didn't have an explicit background fill.
560 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rFillStyleItem
.GetValue());
561 auto& rFillBackgroundItem
= pObj
->GetMergedItem(XATTR_FILLUSESLIDEBACKGROUND
);
562 CPPUNIT_ASSERT_EQUAL(true, rFillBackgroundItem
.GetValue());
565 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf123684
)
567 createSdImpressDoc("pptx/tdf123684.pptx");
568 const SdrPage
* pPage
= GetPage(1);
569 const SdrObject
* pObj
= pPage
->GetObj(0);
570 auto& rFillStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
571 // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual:
572 // 1', i.e. the shape's fill was FillStyle_SOLID, making the text of the shape unreadable.
573 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rFillStyleItem
.GetValue());
576 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf105150PPT
)
578 createSdImpressDoc("ppt/tdf105150.ppt");
579 const SdrPage
* pPage
= GetPage(1);
580 const SdrObject
* pObj
= pPage
->GetObj(1);
581 // This was drawing::FillStyle_NONE, the shape's mso_fillBackground was
582 // ignored when the slide didn't have an explicit background fill.
583 auto& rFillStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
584 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rFillStyleItem
.GetValue());
585 auto& rFillBackgroundItem
= pObj
->GetMergedItem(XATTR_FILLUSESLIDEBACKGROUND
);
586 CPPUNIT_ASSERT_EQUAL(true, rFillBackgroundItem
.GetValue());
589 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf104445
)
591 // Extra bullets were added to the first shape
593 createSdImpressDoc("pptx/tdf104445.pptx");
595 // First shape should not have bullet
597 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
598 uno::Reference
<text::XText
> xText
599 = uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY_THROW
)->getText();
600 CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText
.is());
601 uno::Reference
<beans::XPropertySet
> xPropSet(xText
, uno::UNO_QUERY_THROW
);
603 uno::Reference
<container::XIndexAccess
> xNumRule
;
604 xPropSet
->getPropertyValue("NumberingRules") >>= xNumRule
;
605 uno::Sequence
<beans::PropertyValue
> aBulletProps
;
606 xNumRule
->getByIndex(0) >>= aBulletProps
;
608 for (beans::PropertyValue
const& rProp
: std::as_const(aBulletProps
))
610 if (rProp
.Name
== "NumberingType")
611 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::NUMBER_NONE
),
612 rProp
.Value
.get
<sal_Int16
>());
613 if (rProp
.Name
== "LeftMargin")
614 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), rProp
.Value
.get
<sal_Int32
>());
617 // Second shape should have bullet set
619 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(1, 0));
620 uno::Reference
<text::XText
> xText
621 = uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY_THROW
)->getText();
622 CPPUNIT_ASSERT_MESSAGE("Not a text shape", xText
.is());
623 uno::Reference
<beans::XPropertySet
> xPropSet(xText
, uno::UNO_QUERY_THROW
);
625 uno::Reference
<container::XIndexAccess
> xNumRule
;
626 xPropSet
->getPropertyValue("NumberingRules") >>= xNumRule
;
627 uno::Sequence
<beans::PropertyValue
> aBulletProps
;
628 xNumRule
->getByIndex(0) >>= aBulletProps
;
630 for (beans::PropertyValue
const& rProp
: std::as_const(aBulletProps
))
632 if (rProp
.Name
== "NumberingType")
633 CPPUNIT_ASSERT_EQUAL(sal_Int16(style::NumberingType::CHAR_SPECIAL
),
634 rProp
.Value
.get
<sal_Int16
>());
635 if (rProp
.Name
== "LeftMargin")
636 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), rProp
.Value
.get
<sal_Int32
>());
643 bool checkPatternValues(std::vector
<sal_uInt8
>& rExpected
, Bitmap
& rBitmap
)
647 const Color
aFGColor(0xFF0000);
648 const Color
aBGColor(0xFFFFFF);
650 Bitmap::ScopedReadAccess
pAccess(rBitmap
);
651 for (tools::Long y
= 0; y
< pAccess
->Height(); ++y
)
653 Scanline pScanline
= pAccess
->GetScanline(y
);
654 for (tools::Long x
= 0; x
< pAccess
->Width(); ++x
)
656 Color aColor
= pAccess
->GetPixelFromData(pScanline
, x
);
657 sal_uInt8 aValue
= rExpected
[y
* 8 + x
];
659 if (aValue
== 1 && aColor
!= aFGColor
)
661 else if (aValue
== 0 && aColor
!= aBGColor
)
669 } // end anonymous namespace
671 bool SdImportTest2::checkPattern(int nShapeNumber
, std::vector
<sal_uInt8
>& rExpected
)
673 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(nShapeNumber
, 0));
674 CPPUNIT_ASSERT_MESSAGE("Not a shape", xShape
.is());
679 uno::Any aBitmapAny
= xShape
->getPropertyValue("FillBitmap");
680 uno::Reference
<awt::XBitmap
> xBitmap
;
681 if (aBitmapAny
>>= xBitmap
)
683 uno::Sequence
<sal_Int8
> aBitmapSequence(xBitmap
->getDIB());
684 SvMemoryStream
aBitmapStream(aBitmapSequence
.getArray(), aBitmapSequence
.getLength(),
686 ReadDIB(aBitmap
, aBitmapStream
, true);
689 CPPUNIT_ASSERT_EQUAL(tools::Long(8), aBitmap
.GetSizePixel().Width());
690 CPPUNIT_ASSERT_EQUAL(tools::Long(8), aBitmap
.GetSizePixel().Height());
691 return checkPatternValues(rExpected
, aBitmap
);
694 /* Test checks that importing a PPT file with all supported fill patterns is
695 * correctly imported as a tiled fill bitmap with the expected pattern.
697 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testPatternImport
)
699 createSdImpressDoc("ppt/FillPatterns.ppt");
701 std::vector
<sal_uInt8
> aExpectedPattern1
= {
702 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
703 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
704 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
706 std::vector
<sal_uInt8
> aExpectedPattern2
= {
707 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
708 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
709 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
711 std::vector
<sal_uInt8
> aExpectedPattern3
= {
712 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
713 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
714 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
716 std::vector
<sal_uInt8
> aExpectedPattern4
= {
717 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0,
718 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0,
719 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0,
721 std::vector
<sal_uInt8
> aExpectedPattern5
= {
722 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0,
723 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0,
724 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1,
726 std::vector
<sal_uInt8
> aExpectedPattern6
= {
727 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0,
728 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1,
729 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1,
731 std::vector
<sal_uInt8
> aExpectedPattern7
= {
732 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0,
733 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1,
734 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1,
736 std::vector
<sal_uInt8
> aExpectedPattern8
= {
737 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0,
738 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1,
739 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1,
741 std::vector
<sal_uInt8
> aExpectedPattern9
= {
742 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1,
743 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1,
744 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1,
746 std::vector
<sal_uInt8
> aExpectedPattern10
= {
747 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
748 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1,
749 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
751 std::vector
<sal_uInt8
> aExpectedPattern11
= {
752 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
753 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
754 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
756 std::vector
<sal_uInt8
> aExpectedPattern12
= {
757 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
758 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
759 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1,
761 std::vector
<sal_uInt8
> aExpectedPatternLine1
= {
762 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,
763 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
764 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1,
766 std::vector
<sal_uInt8
> aExpectedPatternLine2
= {
767 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1,
768 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0,
769 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
771 std::vector
<sal_uInt8
> aExpectedPatternLine3
= {
772 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0,
773 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0,
774 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1,
776 std::vector
<sal_uInt8
> aExpectedPatternLine4
= {
777 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 1,
778 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0,
779 0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1,
781 std::vector
<sal_uInt8
> aExpectedPatternLine5
= {
782 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0,
783 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0,
784 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1,
786 std::vector
<sal_uInt8
> aExpectedPatternLine6
= {
787 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1,
788 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1,
789 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1,
791 std::vector
<sal_uInt8
> aExpectedPatternLine7
= {
792 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0,
793 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
794 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
796 std::vector
<sal_uInt8
> aExpectedPatternLine8
= {
797 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
798 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
799 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
801 std::vector
<sal_uInt8
> aExpectedPatternLine9
= {
802 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
803 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
804 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
806 std::vector
<sal_uInt8
> aExpectedPatternLine10
= {
807 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1,
808 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0,
809 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
811 std::vector
<sal_uInt8
> aExpectedPatternLine11
= {
812 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1,
813 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0,
814 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0,
816 std::vector
<sal_uInt8
> aExpectedPatternLine12
= {
817 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
818 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
819 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
822 CPPUNIT_ASSERT_MESSAGE("Pattern1 - 5%", checkPattern(0, aExpectedPattern1
));
823 CPPUNIT_ASSERT_MESSAGE("Pattern2 - 10%", checkPattern(1, aExpectedPattern2
));
824 CPPUNIT_ASSERT_MESSAGE("Pattern3 - 20%", checkPattern(2, aExpectedPattern3
));
825 CPPUNIT_ASSERT_MESSAGE("Pattern4 - 25%", checkPattern(3, aExpectedPattern4
));
826 CPPUNIT_ASSERT_MESSAGE("Pattern5 - 30%", checkPattern(4, aExpectedPattern5
));
827 CPPUNIT_ASSERT_MESSAGE("Pattern6 - 40%", checkPattern(5, aExpectedPattern6
));
828 CPPUNIT_ASSERT_MESSAGE("Pattern7 - 50%", checkPattern(6, aExpectedPattern7
));
829 CPPUNIT_ASSERT_MESSAGE("Pattern8 - 60%", checkPattern(7, aExpectedPattern8
));
830 CPPUNIT_ASSERT_MESSAGE("Pattern9 - 70%", checkPattern(8, aExpectedPattern9
));
831 CPPUNIT_ASSERT_MESSAGE("Pattern10 - 75%", checkPattern(9, aExpectedPattern10
));
832 CPPUNIT_ASSERT_MESSAGE("Pattern11 - 80%", checkPattern(10, aExpectedPattern11
));
833 CPPUNIT_ASSERT_MESSAGE("Pattern12 - 90%", checkPattern(11, aExpectedPattern12
));
835 CPPUNIT_ASSERT_MESSAGE("Pattern13 - Light downward diagonal",
836 checkPattern(12, aExpectedPatternLine1
));
837 CPPUNIT_ASSERT_MESSAGE("Pattern14 - Light upward diagonal",
838 checkPattern(13, aExpectedPatternLine2
));
839 CPPUNIT_ASSERT_MESSAGE("Pattern15 - Dark downward diagonal",
840 checkPattern(14, aExpectedPatternLine3
));
841 CPPUNIT_ASSERT_MESSAGE("Pattern16 - Dark upward diagonal",
842 checkPattern(15, aExpectedPatternLine4
));
843 CPPUNIT_ASSERT_MESSAGE("Pattern17 - Wide downward diagonal",
844 checkPattern(16, aExpectedPatternLine5
));
845 CPPUNIT_ASSERT_MESSAGE("Pattern18 - Wide upward diagonal",
846 checkPattern(17, aExpectedPatternLine6
));
848 CPPUNIT_ASSERT_MESSAGE("Pattern19 - Light vertical", checkPattern(18, aExpectedPatternLine7
));
849 CPPUNIT_ASSERT_MESSAGE("Pattern20 - Light horizontal", checkPattern(19, aExpectedPatternLine8
));
850 CPPUNIT_ASSERT_MESSAGE("Pattern21 - Narrow vertical", checkPattern(20, aExpectedPatternLine9
));
851 CPPUNIT_ASSERT_MESSAGE("Pattern22 - Narrow horizontal",
852 checkPattern(21, aExpectedPatternLine10
));
853 CPPUNIT_ASSERT_MESSAGE("Pattern23 - Dark vertical", checkPattern(22, aExpectedPatternLine11
));
854 CPPUNIT_ASSERT_MESSAGE("Pattern24 - Dark horizontal", checkPattern(23, aExpectedPatternLine12
));
856 // TODO: other patterns in the test document
859 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf100926
)
861 createSdImpressDoc("pptx/tdf100926.pptx");
862 const SdrPage
* pPage
= GetPage(1);
863 CPPUNIT_ASSERT(pPage
!= nullptr);
865 sdr::table::SdrTableObj
* pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
866 CPPUNIT_ASSERT(pTableObj
!= nullptr);
867 uno::Reference
<table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
869 sal_Int32 nRotation
= 0;
870 uno::Reference
<beans::XPropertySet
> xCell(xTable
->getCellByPosition(0, 0),
871 uno::UNO_QUERY_THROW
);
872 xCell
->getPropertyValue("RotateAngle") >>= nRotation
;
873 CPPUNIT_ASSERT_EQUAL(sal_Int32(27000), nRotation
);
875 xCell
.set(xTable
->getCellByPosition(1, 0), uno::UNO_QUERY_THROW
);
876 xCell
->getPropertyValue("RotateAngle") >>= nRotation
;
877 CPPUNIT_ASSERT_EQUAL(sal_Int32(9000), nRotation
);
879 xCell
.set(xTable
->getCellByPosition(2, 0), uno::UNO_QUERY_THROW
);
880 xCell
->getPropertyValue("RotateAngle") >>= nRotation
;
881 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRotation
);
884 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf89064
)
886 createSdImpressDoc("pptx/tdf89064.pptx");
887 uno::Reference
<presentation::XPresentationPage
> xPage(getPage(0), uno::UNO_QUERY_THROW
);
888 uno::Reference
<drawing::XDrawPage
> xNotesPage(xPage
->getNotesPage(), uno::UNO_SET_THROW
);
889 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), xNotesPage
->getCount());
892 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf108925
)
894 // Test document contains bulleting with too small bullet size (1%) which breaks the lower constraint
895 // So it should be converted to the lowest allowed value (25%).
897 createSdImpressDoc("odp/tdf108925.odp");
898 const SdrPage
* pPage
= GetPage(1);
899 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pPage
->GetObj(0));
900 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
901 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
903 const SvxNumBulletItem
* pNumFmt
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
904 CPPUNIT_ASSERT(pNumFmt
);
905 CPPUNIT_ASSERT_EQUAL(sal_uInt16(25), pNumFmt
->GetNumRule().GetLevel(0).GetBulletRelSize());
908 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf109067
)
910 createSdImpressDoc("pptx/tdf109067.pptx");
911 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
912 awt::Gradient gradient
;
913 CPPUNIT_ASSERT(xShape
->getPropertyValue("FillGradient") >>= gradient
);
914 CPPUNIT_ASSERT_EQUAL(sal_Int16(450), gradient
.Angle
);
917 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf109187
)
919 createSdImpressDoc("pptx/tdf109187.pptx");
920 uno::Reference
<beans::XPropertySet
> xArrow1(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
921 awt::Gradient aGradient1
;
922 CPPUNIT_ASSERT(xArrow1
->getPropertyValue("FillGradient") >>= aGradient1
);
923 CPPUNIT_ASSERT_EQUAL(sal_Int16(2250), aGradient1
.Angle
);
924 uno::Reference
<beans::XPropertySet
> xArrow2(getShapeFromPage(1, 0), uno::UNO_SET_THROW
);
925 awt::Gradient aGradient2
;
926 CPPUNIT_ASSERT(xArrow2
->getPropertyValue("FillGradient") >>= aGradient2
);
927 CPPUNIT_ASSERT_EQUAL(sal_Int16(1350), aGradient2
.Angle
);
930 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf108926
)
932 createSdImpressDoc("pptx/tdf108926.ppt");
933 uno::Reference
<presentation::XPresentationPage
> xPage(getPage(0), uno::UNO_QUERY_THROW
);
934 uno::Reference
<drawing::XDrawPage
> xNotesPage(xPage
->getNotesPage(), uno::UNO_SET_THROW
);
935 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xNotesPage
->getCount());
937 // Second object should be imported as an empty presentation shape
938 uno::Reference
<beans::XPropertySet
> xPresentationShape(xNotesPage
->getByIndex(1),
940 CPPUNIT_ASSERT(xPresentationShape
.is());
941 bool bIsEmptyPresObject
= false;
942 xPresentationShape
->getPropertyValue("IsEmptyPresentationObject") >>= bIsEmptyPresObject
;
943 CPPUNIT_ASSERT(bIsEmptyPresObject
);
946 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf100065
)
948 createSdImpressDoc("pptx/tdf100065.pptx");
950 uno::Reference
<container::XIndexAccess
> xGroupShape1(getShapeFromPage(0, 0),
951 uno::UNO_QUERY_THROW
);
952 uno::Reference
<beans::XPropertySet
> xShape1(xGroupShape1
->getByIndex(1), uno::UNO_QUERY_THROW
);
954 CPPUNIT_ASSERT(xShape1
->getPropertyValue("RotateAngle") >>= nAngle1
);
955 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), nAngle1
);
957 uno::Reference
<container::XIndexAccess
> xGroupShape2(getShapeFromPage(1, 0),
958 uno::UNO_QUERY_THROW
);
959 uno::Reference
<beans::XPropertySet
> xShape2(xGroupShape2
->getByIndex(0), uno::UNO_QUERY_THROW
);
961 CPPUNIT_ASSERT(xShape2
->getPropertyValue("RotateAngle") >>= nAngle2
);
962 CPPUNIT_ASSERT_EQUAL(sal_Int32(18000), nAngle2
);
965 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf90626
)
967 createSdImpressDoc("pptx/tdf90626.pptx");
968 const SdrPage
* pPage
= GetPage(1);
969 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pPage
->GetObj(1));
970 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
971 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
972 for (int i
= 0; i
< 4; i
++)
974 const SvxNumBulletItem
* pNumFmt
= aEdit
.GetParaAttribs(i
).GetItem(EE_PARA_NUMBULLET
);
975 CPPUNIT_ASSERT(pNumFmt
);
976 CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(372),
977 pNumFmt
->GetNumRule().GetLevel(0).GetGraphicSize().getHeight(),
982 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf138148
)
984 createSdImpressDoc("pptx/tdf138148.pptx");
985 const SdrPage
* pPage
= GetPage(1);
986 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pPage
->GetObj(0));
987 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
988 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
989 for (int i
= 0; i
< 2; i
++)
991 const SvxNumBulletItem
* pNumFmt
= aEdit
.GetParaAttribs(i
).GetItem(EE_PARA_NUMBULLET
);
992 CPPUNIT_ASSERT(pNumFmt
);
993 CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(444),
994 pNumFmt
->GetNumRule().GetLevel(0).GetGraphicSize().getHeight(),
997 // Without the fix in place, this test would have failed with
1000 CPPUNIT_ASSERT_DOUBLES_EQUAL(tools::Long(148),
1001 pNumFmt
->GetNumRule().GetLevel(0).GetGraphicSize().getWidth(),
1006 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf114488
)
1008 // This doc has two images - one WMF and the other PNG (fallback image).
1009 // When loading this doc, the WMF image should be preferred over the PNG image.
1011 createSdDrawDoc("odg/tdf114488.fodg");
1012 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
1013 uno::Reference
<graphic::XGraphic
> xGraphic
;
1014 xShape
->getPropertyValue("Graphic") >>= xGraphic
;
1015 CPPUNIT_ASSERT(xGraphic
.is());
1016 OUString
sMimeType(comphelper::GraphicMimeTypeHelper::GetMimeTypeForXGraphic(xGraphic
));
1017 CPPUNIT_ASSERT_EQUAL(OUString("image/x-wmf"), sMimeType
);
1020 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf134174
)
1022 createSdImpressDoc("pptx/tdf134174.pptx");
1023 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
1024 CPPUNIT_ASSERT(xShape
.is());
1026 uno::Reference
<graphic::XGraphic
> xGraphic
;
1027 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
1028 CPPUNIT_ASSERT(xGraphic
.is());
1030 Graphic
aGraphic(xGraphic
);
1031 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
1032 CPPUNIT_ASSERT_EQUAL(Color(0x8b21db), aBitmap
.GetPixelColor(0, 0));
1035 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf134210
)
1037 createSdImpressDoc("pptx/tdf134210.pptx");
1038 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
1039 CPPUNIT_ASSERT(xShape
.is());
1041 uno::Reference
<graphic::XGraphic
> xGraphic
;
1042 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
1043 CPPUNIT_ASSERT(xGraphic
.is());
1045 Graphic
aGraphic(xGraphic
);
1046 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
1047 CPPUNIT_ASSERT_EQUAL(Color(0x605741), aBitmap
.GetPixelColor(0, 0));
1050 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf114913
)
1052 createSdImpressDoc("pptx/tdf114913.pptx");
1053 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(GetPage(1)->GetObj(1));
1054 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
1055 const SvxNumBulletItem
* pItem
1056 = pTxtObj
->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(
1058 CPPUNIT_ASSERT(pItem
);
1059 CPPUNIT_ASSERT_EQUAL(tools::Long(692),
1060 pItem
->GetNumRule().GetLevel(0).GetGraphicSize().getHeight());
1063 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf114821
)
1067 createSdImpressDoc("pptx/tdf114821.pptx");
1069 uno::Reference
<beans::XPropertySet
> xPropSet(getShapeFromPage(0, 0));
1070 aAny
= xPropSet
->getPropertyValue("Model");
1071 CPPUNIT_ASSERT_MESSAGE("The shape doesn't have the property", aAny
.hasValue());
1073 uno::Reference
<chart::XChartDocument
> xChartDoc
;
1075 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1076 uno::Reference
<chart2::XChartDocument
> xChart2Doc(xChartDoc
, uno::UNO_QUERY
);
1077 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChart2Doc
.is());
1079 uno::Reference
<chart2::XCoordinateSystemContainer
> xBCooSysCnt(xChart2Doc
->getFirstDiagram(),
1081 uno::Sequence
<uno::Reference
<chart2::XCoordinateSystem
>> aCooSysSeq(
1082 xBCooSysCnt
->getCoordinateSystems());
1083 uno::Reference
<chart2::XChartTypeContainer
> xCTCnt(aCooSysSeq
[0], uno::UNO_QUERY
);
1085 uno::Reference
<chart2::XDataSeriesContainer
> xDSCnt(xCTCnt
->getChartTypes()[0], uno::UNO_QUERY
);
1086 CPPUNIT_ASSERT_MESSAGE("failed to load data series", xDSCnt
.is());
1087 uno::Sequence
<uno::Reference
<chart2::XDataSeries
>> aSeriesSeq(xDSCnt
->getDataSeries());
1088 CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Series count", static_cast<sal_Int32
>(1),
1089 aSeriesSeq
.getLength());
1091 // These Labels have custom position, so the exported LabelPlacement (reference point) by MSO is OUTSIDE/OUTEND
1092 // Check the first label
1093 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet0(
1094 aSeriesSeq
[0]->getDataPointByIndex(0));
1095 CPPUNIT_ASSERT(rPropSet0
.is());
1096 sal_Int32 aPlacement
;
1097 rPropSet0
->getPropertyValue("LabelPlacement") >>= aPlacement
;
1098 CPPUNIT_ASSERT_EQUAL(css::chart::DataLabelPlacement::OUTSIDE
, aPlacement
);
1100 // Check the second label
1101 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet1(
1102 aSeriesSeq
[0]->getDataPointByIndex(1));
1103 CPPUNIT_ASSERT(rPropSet1
.is());
1104 rPropSet1
->getPropertyValue("LabelPlacement") >>= aPlacement
;
1105 CPPUNIT_ASSERT_EQUAL(css::chart::DataLabelPlacement::OUTSIDE
, aPlacement
);
1107 // Check the third label
1108 const css::uno::Reference
<css::beans::XPropertySet
>& rPropSet2(
1109 aSeriesSeq
[0]->getDataPointByIndex(2));
1110 CPPUNIT_ASSERT(rPropSet2
.is());
1111 rPropSet2
->getPropertyValue("LabelPlacement") >>= aPlacement
;
1112 CPPUNIT_ASSERT_EQUAL(css::chart::DataLabelPlacement::OUTSIDE
, aPlacement
);
1115 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf115394
)
1117 createSdImpressDoc("pptx/tdf115394.pptx");
1118 double fTransitionDuration
;
1120 SdXImpressDocument
* pXImpressDocument
= dynamic_cast<SdXImpressDocument
*>(mxComponent
.get());
1121 CPPUNIT_ASSERT(pXImpressDocument
);
1122 SdDrawDocument
* pDoc
= pXImpressDocument
->GetDoc();
1124 // Slow in MS formats
1125 SdPage
* pPage1
= pDoc
->GetSdPage(0, PageKind::Standard
);
1126 fTransitionDuration
= pPage1
->getTransitionDuration();
1127 CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration
);
1129 // Medium in MS formats
1130 SdPage
* pPage2
= pDoc
->GetSdPage(1, PageKind::Standard
);
1131 fTransitionDuration
= pPage2
->getTransitionDuration();
1132 CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration
);
1134 // Fast in MS formats
1135 SdPage
* pPage3
= pDoc
->GetSdPage(2, PageKind::Standard
);
1136 fTransitionDuration
= pPage3
->getTransitionDuration();
1137 CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration
);
1140 SdPage
* pPage4
= pDoc
->GetSdPage(3, PageKind::Standard
);
1141 fTransitionDuration
= pPage4
->getTransitionDuration();
1142 CPPUNIT_ASSERT_EQUAL(0.25, fTransitionDuration
);
1144 SdPage
* pPage5
= pDoc
->GetSdPage(4, PageKind::Standard
);
1145 fTransitionDuration
= pPage5
->getTransitionDuration();
1146 CPPUNIT_ASSERT_EQUAL(4.25, fTransitionDuration
);
1149 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf115394PPT
)
1151 createSdImpressDoc("ppt/tdf115394.ppt");
1152 double fTransitionDuration
;
1154 SdXImpressDocument
* pXImpressDocument
= dynamic_cast<SdXImpressDocument
*>(mxComponent
.get());
1155 CPPUNIT_ASSERT(pXImpressDocument
);
1156 SdDrawDocument
* pDoc
= pXImpressDocument
->GetDoc();
1159 SdPage
* pPage1
= pDoc
->GetSdPage(0, PageKind::Standard
);
1160 fTransitionDuration
= pPage1
->getTransitionDuration();
1161 CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration
);
1164 SdPage
* pPage2
= pDoc
->GetSdPage(1, PageKind::Standard
);
1165 fTransitionDuration
= pPage2
->getTransitionDuration();
1166 CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration
);
1169 SdPage
* pPage3
= pDoc
->GetSdPage(2, PageKind::Standard
);
1170 fTransitionDuration
= pPage3
->getTransitionDuration();
1171 CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration
);
1174 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf51340
)
1176 // Line spacing was not inherited from upper levels (slide layout, master slide)
1178 createSdImpressDoc("pptx/tdf51340.pptx");
1179 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(1, 0));
1181 // First paragraph has a 90% line spacing set on master slide
1182 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
1183 uno::Reference
<beans::XPropertySet
> xPropSet(xParagraph
, uno::UNO_QUERY_THROW
);
1184 css::style::LineSpacing aSpacing
;
1185 xPropSet
->getPropertyValue("ParaLineSpacing") >>= aSpacing
;
1186 CPPUNIT_ASSERT_EQUAL(css::style::LineSpacingMode::PROP
, aSpacing
.Mode
);
1187 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(90), aSpacing
.Height
);
1189 // Second paragraph has a 125% line spacing set on slide layout
1190 xParagraph
.set(getParagraphFromShape(1, xShape
));
1191 xPropSet
.set(xParagraph
, uno::UNO_QUERY_THROW
);
1192 xPropSet
->getPropertyValue("ParaLineSpacing") >>= aSpacing
;
1193 CPPUNIT_ASSERT_EQUAL(css::style::LineSpacingMode::PROP
, aSpacing
.Mode
);
1194 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(125), aSpacing
.Height
);
1196 // Third paragraph has a 70% line spacing set directly on normal slide (master slide property is overridden)
1197 xParagraph
.set(getParagraphFromShape(2, xShape
));
1198 xPropSet
.set(xParagraph
, uno::UNO_QUERY_THROW
);
1199 xPropSet
->getPropertyValue("ParaLineSpacing") >>= aSpacing
;
1200 CPPUNIT_ASSERT_EQUAL(css::style::LineSpacingMode::PROP
, aSpacing
.Mode
);
1201 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(70), aSpacing
.Height
);
1203 // Fourth paragraph has a 190% line spacing set directly on normal slide (slide layout property is overridden)
1204 xParagraph
.set(getParagraphFromShape(3, xShape
));
1205 xPropSet
.set(xParagraph
, uno::UNO_QUERY_THROW
);
1206 xPropSet
->getPropertyValue("ParaLineSpacing") >>= aSpacing
;
1207 CPPUNIT_ASSERT_EQUAL(css::style::LineSpacingMode::PROP
, aSpacing
.Mode
);
1208 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(190), aSpacing
.Height
);
1211 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf116899
)
1213 // This is a PPT created in Impress and roundtripped in PP, the key times become [1, -1] in PP,
1214 // a time of -1 (-1000) in PPT means key times have to be distributed evenly between 0 and 1
1216 createSdImpressDoc("ppt/tdf116899.ppt");
1218 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
1219 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0),
1220 uno::UNO_QUERY_THROW
);
1221 uno::Reference
<animations::XAnimationNodeSupplier
> xAnimNodeSupplier(xPage
,
1222 uno::UNO_QUERY_THROW
);
1223 uno::Reference
<animations::XAnimationNode
> xRootNode(xAnimNodeSupplier
->getAnimationNode());
1224 std::vector
<uno::Reference
<animations::XAnimationNode
>> aAnimVector
;
1225 anim::create_deep_vector(xRootNode
, aAnimVector
);
1226 uno::Reference
<animations::XAnimate
> xNode(aAnimVector
[8], uno::UNO_QUERY_THROW
);
1227 CPPUNIT_ASSERT_EQUAL_MESSAGE("Number of key times in the animation node isn't 2.",
1228 static_cast<sal_Int32
>(2), xNode
->getKeyTimes().getLength());
1229 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1230 "First key time in the animation node isn't 0, key times aren't normalized.", 0.,
1231 xNode
->getKeyTimes()[0]);
1232 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1233 "Second key time in the animation node isn't 1, key times aren't normalized.", 1.,
1234 xNode
->getKeyTimes()[1]);
1237 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf77747
)
1239 createSdImpressDoc("ppt/tdf77747.ppt");
1240 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(GetPage(1)->GetObj(0));
1241 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
1242 const SvxNumBulletItem
* pNumFmt
1243 = pTxtObj
->GetOutlinerParaObject()->GetTextObject().GetParaAttribs(0).GetItem(
1245 CPPUNIT_ASSERT(pNumFmt
);
1246 CPPUNIT_ASSERT_EQUAL_MESSAGE("Bullet's suffix is wrong!", OUString("-"),
1247 pNumFmt
->GetNumRule().GetLevel(0).GetSuffix());
1248 CPPUNIT_ASSERT_EQUAL_MESSAGE("Bullet's numbering type is wrong!", SVX_NUM_NUMBER_HEBREW
,
1249 pNumFmt
->GetNumRule().GetLevel(0).GetNumberingType());
1252 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf116266
)
1254 createSdImpressDoc("odp/tdf116266.odp");
1255 SdXImpressDocument
* pXImpressDocument
= dynamic_cast<SdXImpressDocument
*>(mxComponent
.get());
1256 CPPUNIT_ASSERT(pXImpressDocument
);
1257 SdDrawDocument
* pDoc
= pXImpressDocument
->GetDoc();
1258 sfx2::LinkManager
* rLinkManager
= pDoc
->GetLinkManager();
1259 // The document contains one SVG stored as a link.
1260 CPPUNIT_ASSERT_EQUAL(size_t(1), rLinkManager
->GetLinks().size());
1263 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testPptCrop
)
1265 createSdImpressDoc("ppt/crop.ppt");
1267 uno::Reference
<beans::XPropertySet
> xPropertySet(getShapeFromPage(/*nShape=*/1, /*nPage=*/0));
1268 text::GraphicCrop aCrop
;
1269 xPropertySet
->getPropertyValue("GraphicCrop") >>= aCrop
;
1270 // These were all 0, lazy-loading broke cropping.
1271 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(0), aCrop
.Top
);
1272 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(0), aCrop
.Bottom
);
1273 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(0), aCrop
.Left
);
1274 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(0), aCrop
.Right
);
1277 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf149206
)
1279 // Check that the image is cropped
1280 createSdImpressDoc("pptx/tdf149206.pptx");
1282 uno::Reference
<beans::XPropertySet
> xPropertySet(getShapeFromPage(/*nShape=*/0, /*nPage=*/0));
1283 text::GraphicCrop aCrop
;
1284 xPropertySet
->getPropertyValue("GraphicCrop") >>= aCrop
;
1286 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0), aCrop
.Top
);
1288 // Without the fix in place, this test would have failed with
1291 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(5937), aCrop
.Bottom
);
1292 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0), aCrop
.Left
);
1293 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0), aCrop
.Right
);
1296 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf149785
)
1298 // Without the fix in place, this test would have failed to load the file
1299 createSdImpressDoc("pptx/tdf149785.pptx");
1301 const SdrPage
* pPage
= GetPage(1);
1302 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage
->GetObjCount());
1305 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf149985
)
1307 // Without the fix in place, this test would have failed to load the file
1308 createSdImpressDoc("pptx/tdf149985.pptx");
1310 const SdrPage
* pPage
= GetPage(1);
1311 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage
->GetObjCount());
1314 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf150770
)
1316 // Without the fix in place, this test would have failed to load the file
1317 createSdImpressDoc("pptx/tdf150770.pptx");
1318 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY
);
1319 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xDoc
->getDrawPages()->getCount());
1322 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf120028
)
1324 // Check that the text shape has 4 columns.
1325 createSdImpressDoc("pptx/tdf120028.pptx");
1326 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY
);
1327 CPPUNIT_ASSERT(xDoc
.is());
1329 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
1330 CPPUNIT_ASSERT(xPage
.is());
1332 uno::Reference
<beans::XPropertySet
> xShape(getShape(0, xPage
));
1333 uno::Reference
<text::XTextColumns
> xCols(xShape
->getPropertyValue("TextColumns"),
1334 uno::UNO_QUERY_THROW
);
1335 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(4), xCols
->getColumnCount());
1336 uno::Reference
<beans::XPropertySet
> xColProps(xCols
, uno::UNO_QUERY_THROW
);
1337 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(0)), xColProps
->getPropertyValue("AutomaticDistance"));
1339 // Check font size in the shape.
1340 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
1341 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
1342 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
1343 double fCharHeight
= 0;
1344 xPropSet
->getPropertyValue("CharHeight") >>= fCharHeight
;
1345 CPPUNIT_ASSERT_DOUBLES_EQUAL(13.5, fCharHeight
, 1E-12);
1347 double fTextSclale
= 0.0;
1348 xShape
->getPropertyValue("TextFitToSizeScale") >>= fTextSclale
;
1349 CPPUNIT_ASSERT_DOUBLES_EQUAL(92.0, fTextSclale
, 1E1
);
1352 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testDescriptionImport
)
1354 createSdImpressDoc("pptx/altdescription.pptx");
1356 uno::Reference
<beans::XPropertySet
> xPropertySet(getShapeFromPage(/*nShape=*/2, /*nPage=*/0));
1359 xPropertySet
->getPropertyValue("Description") >>= sDesc
;
1361 CPPUNIT_ASSERT_EQUAL(OUString("We Can Do It!"), sDesc
);
1364 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf83247
)
1366 auto GetPause
= [this](const OUString
& sSrc
) {
1368 uno::Reference
<presentation::XPresentationSupplier
> xPresentationSupplier(mxComponent
,
1370 uno::Reference
<beans::XPropertySet
> xPresentationProps(
1371 xPresentationSupplier
->getPresentation(), uno::UNO_QUERY_THROW
);
1373 auto retVal
= xPresentationProps
->getPropertyValue("Pause");
1374 return retVal
.get
<sal_Int32
>();
1377 // 1. Check that presentation:pause attribute is imported correctly
1378 CPPUNIT_ASSERT_EQUAL(sal_Int32(10), GetPause("odp/loopPause10.odp"));
1380 // 2. ODF compliance: if presentation:pause attribute is absent, it must be treated as 0
1381 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause("odp/loopNoPause.odp"));
1383 // 3. Import PPT: pause should be 0
1384 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), GetPause("ppt/loopNoPause.ppt"));
1387 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf47365
)
1389 createSdImpressDoc("pptx/loopNoPause.pptx");
1390 uno::Reference
<presentation::XPresentationSupplier
> xPresentationSupplier(mxComponent
,
1391 uno::UNO_QUERY_THROW
);
1392 uno::Reference
<beans::XPropertySet
> xPresentationProps(xPresentationSupplier
->getPresentation(),
1393 uno::UNO_QUERY_THROW
);
1395 const bool bEndlessVal
= xPresentationProps
->getPropertyValue("IsEndless").get
<bool>();
1396 const sal_Int32 nPauseVal
= xPresentationProps
->getPropertyValue("Pause").get
<sal_Int32
>();
1398 // Check that we import "loop" attribute of the presentation, and don't introduce any pauses
1399 CPPUNIT_ASSERT(bEndlessVal
);
1400 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nPauseVal
);
1403 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf122899
)
1405 // tdf122899 FILEOPEN: ppt: old kind arc from MS Office 97 is broken
1406 // Error was, that the path coordinates of a mso_sptArc shape were read as sal_Int16
1407 // although they are unsigned 16 bit. This leads to wrong positions of start and end
1408 // point and results to a huge shape width in the test document.
1409 createSdImpressDoc("ppt/tdf122899_Arc_90_to_91_clockwise.ppt");
1410 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
,
1411 uno::UNO_QUERY_THROW
);
1412 CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier
.is());
1413 uno::Reference
<drawing::XDrawPages
> xDrawPages(xDrawPagesSupplier
->getDrawPages());
1414 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPages
->getByIndex(0), uno::UNO_QUERY_THROW
);
1415 CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage
.is());
1416 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
1417 CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape
.is());
1418 awt::Rectangle aFrameRect
;
1419 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
1420 CPPUNIT_ASSERT_MESSAGE("Could not get the shape properties", xShapeProps
.is());
1421 xShapeProps
->getPropertyValue(UNO_NAME_MISC_OBJ_FRAMERECT
) >>= aFrameRect
;
1422 // original width is 9cm, add some tolerance
1423 CPPUNIT_ASSERT_LESS(static_cast<sal_Int32
>(9020), aFrameRect
.Width
);
1426 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testOOXTheme
)
1428 createSdImpressDoc("pptx/ooxtheme.pptx");
1430 uno::Reference
<beans::XPropertySet
> xPropSet(mxComponent
, uno::UNO_QUERY_THROW
);
1431 uno::Sequence
<beans::PropertyValue
> aGrabBag
;
1432 xPropSet
->getPropertyValue("InteropGrabBag") >>= aGrabBag
;
1434 bool bTheme
= false;
1435 for (beans::PropertyValue
const& prop
: std::as_const(aGrabBag
))
1437 if (prop
.Name
== "OOXTheme")
1440 uno::Reference
<xml::dom::XDocument
> aThemeDom
;
1441 CPPUNIT_ASSERT(prop
.Value
>>= aThemeDom
); // PropertyValue of proper type
1442 CPPUNIT_ASSERT(aThemeDom
); // Reference not empty
1445 CPPUNIT_ASSERT(bTheme
); // Grab Bag has all the expected elements
1448 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testCropToShape
)
1450 createSdImpressDoc("pptx/crop-to-shape.pptx");
1451 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
,
1452 uno::UNO_QUERY_THROW
);
1453 CPPUNIT_ASSERT_MESSAGE("Could not get XDrawPagesSupplier", xDrawPagesSupplier
.is());
1454 uno::Reference
<drawing::XDrawPages
> xDrawPages(xDrawPagesSupplier
->getDrawPages());
1455 uno::Reference
<drawing::XDrawPage
> xDrawPage(xDrawPages
->getByIndex(0), uno::UNO_QUERY_THROW
);
1456 CPPUNIT_ASSERT_MESSAGE("Could not get xDrawPage", xDrawPage
.is());
1457 uno::Reference
<drawing::XShape
> xShape(xDrawPage
->getByIndex(0), uno::UNO_QUERY
);
1458 CPPUNIT_ASSERT_EQUAL(OUString
{ "com.sun.star.drawing.CustomShape" }, xShape
->getShapeType());
1459 CPPUNIT_ASSERT_MESSAGE("Could not get xShape", xShape
.is());
1460 uno::Reference
<beans::XPropertySet
> xShapeProps(xShape
, uno::UNO_QUERY
);
1461 css::drawing::FillStyle fillStyle
;
1462 xShapeProps
->getPropertyValue("FillStyle") >>= fillStyle
;
1463 CPPUNIT_ASSERT_EQUAL(css::drawing::FillStyle_BITMAP
, fillStyle
);
1464 css::drawing::BitmapMode bitmapmode
;
1465 xShapeProps
->getPropertyValue("FillBitmapMode") >>= bitmapmode
;
1466 CPPUNIT_ASSERT_EQUAL(css::drawing::BitmapMode_STRETCH
, bitmapmode
);
1469 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf127964
)
1471 createSdImpressDoc("pptx/tdf127964.pptx");
1473 const SdrPage
* pPage
= GetPage(1);
1474 const SdrObject
* pObj
= pPage
->GetObj(0);
1475 auto& rFillStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
1476 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rFillStyleItem
.GetValue());
1477 auto& rFillBackgroundItem
= pObj
->GetMergedItem(XATTR_FILLUSESLIDEBACKGROUND
);
1478 CPPUNIT_ASSERT_EQUAL(true, rFillBackgroundItem
.GetValue());
1481 saveAndReload("impress8");
1484 const SdrPage
* pPage
= GetPage(1);
1485 const SdrObject
* pObj
= pPage
->GetObj(0);
1486 auto& rFillStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
1487 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rFillStyleItem
.GetValue());
1488 auto& rFillBackgroundItem
= pObj
->GetMergedItem(XATTR_FILLUSESLIDEBACKGROUND
);
1489 CPPUNIT_ASSERT_EQUAL(true, rFillBackgroundItem
.GetValue());
1493 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf48083
)
1495 createSdImpressDoc("ppt/tdf48083.ppt");
1496 const SdrPage
* pPage
= GetPage(1);
1497 CPPUNIT_ASSERT_EQUAL(size_t(2), pPage
->GetObjCount());
1498 const SdrObject
* pObj
= pPage
->GetObj(1);
1499 auto& rFillStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
1500 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rFillStyleItem
.GetValue());
1501 auto& rFillBackgroundItem
= pObj
->GetMergedItem(XATTR_FILLUSESLIDEBACKGROUND
);
1502 CPPUNIT_ASSERT_EQUAL(true, rFillBackgroundItem
.GetValue());
1505 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf106638
)
1507 createSdImpressDoc("pptx/tdf106638.pptx");
1508 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
1509 uno::Reference
<text::XTextRange
> const xPara(getParagraphFromShape(1, xShape
));
1510 uno::Reference
<text::XText
> xText
= xPara
->getText();
1511 uno::Reference
<text::XTextCursor
> xTextCursor
1512 = xText
->createTextCursorByRange(xPara
->getStart());
1513 uno::Reference
<beans::XPropertySet
> xPropSet(xTextCursor
, uno::UNO_QUERY_THROW
);
1514 OUString aCharFontName
;
1515 CPPUNIT_ASSERT(xTextCursor
->goRight(1, true));
1516 // First character U+f0fe that uses Wingding
1517 xPropSet
->getPropertyValue("CharFontName") >>= aCharFontName
;
1518 CPPUNIT_ASSERT_EQUAL(OUString("Wingdings"), aCharFontName
);
1520 // The rest characters that do not use Wingding.
1521 CPPUNIT_ASSERT(xTextCursor
->goRight(45, true));
1522 xPropSet
->getPropertyValue("CharFontName") >>= aCharFontName
;
1523 CPPUNIT_ASSERT(aCharFontName
!= "Wingdings");
1526 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf128684
)
1528 createSdImpressDoc("pptx/tdf128684.pptx");
1529 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY
);
1530 CPPUNIT_ASSERT(xDoc
.is());
1531 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
1532 CPPUNIT_ASSERT(xPage
.is());
1533 uno::Reference
<beans::XPropertySet
> xShapeProperties(getShape(0, xPage
));
1534 CPPUNIT_ASSERT(xShapeProperties
.is());
1535 // Check text direction.
1536 sal_Int16
eWritingMode(text::WritingMode2::LR_TB
);
1537 if (xShapeProperties
->getPropertySetInfo()->hasPropertyByName("WritingMode"))
1538 xShapeProperties
->getPropertyValue("WritingMode") >>= eWritingMode
;
1539 CPPUNIT_ASSERT_EQUAL(sal_Int16(text::WritingMode2::TB_RL90
), eWritingMode
);
1540 // Check shape rotation
1541 sal_Int32 nRotateAngle
= 0;
1542 if (xShapeProperties
->getPropertySetInfo()->hasPropertyByName("RotateAngle"))
1543 xShapeProperties
->getPropertyValue("RotateAngle") >>= nRotateAngle
;
1544 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(9000), nRotateAngle
);
1547 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf113198
)
1549 createSdImpressDoc("pptx/tdf113198.pptx");
1551 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
1552 sal_Int16 nParaAdjust
= -1;
1553 xShape
->getPropertyValue("ParaAdjust") >>= nParaAdjust
;
1554 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
,
1555 static_cast<style::ParagraphAdjust
>(nParaAdjust
));
1558 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf49856
)
1560 createSdImpressDoc("ppt/tdf49856.ppt");
1561 const SdrPage
* pPage
= GetPage(1);
1562 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pPage
->GetObj(1));
1563 CPPUNIT_ASSERT_MESSAGE("No text object", pTxtObj
!= nullptr);
1564 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
1565 const SvxNumBulletItem
* pNumFmt
= aEdit
.GetParaAttribs(2).GetItem(EE_PARA_NUMBULLET
);
1566 CPPUNIT_ASSERT(pNumFmt
);
1567 const sal_UCS4 aBullet
= pNumFmt
->GetNumRule().GetLevel(0).GetBulletChar();
1568 CPPUNIT_ASSERT_EQUAL(OUString("More level 2"), aEdit
.GetText(2));
1569 CPPUNIT_ASSERT_EQUAL(sal_UCS4(0x2022), aBullet
);
1572 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testShapeGlowEffectPPTXImpoer
)
1574 createSdImpressDoc("pptx/shape-glow-effect.pptx");
1576 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
1577 sal_Int32 nRadius
= -1;
1578 xShape
->getPropertyValue("GlowEffectRadius") >>= nRadius
;
1579 CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRadius
); // 139700 EMU = 388.0556 mm/100
1581 xShape
->getPropertyValue("GlowEffectColor") >>= nColor
;
1582 CPPUNIT_ASSERT_EQUAL(Color(0xFFC000), nColor
);
1583 sal_Int16 nTransparency
;
1584 xShape
->getPropertyValue("GlowEffectTransparency") >>= nTransparency
;
1585 CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nTransparency
);
1588 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testShapeBlurPPTXImport
)
1590 createSdImpressDoc("pptx/shape-blur-effect.pptx");
1592 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
1593 bool bHasShadow
= false;
1594 xShape
->getPropertyValue("Shadow") >>= bHasShadow
;
1595 CPPUNIT_ASSERT(bHasShadow
);
1597 sal_Int32 nRadius
= -1;
1598 xShape
->getPropertyValue("ShadowBlur") >>= nRadius
;
1599 CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRadius
); // 584200EMU=46pt - 139700EMU = 388Hmm = 11pt
1602 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testMirroredGraphic
)
1604 createSdImpressDoc("pptx/mirrored-graphic.pptx");
1605 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
1606 CPPUNIT_ASSERT(xShape
.is());
1607 uno::Reference
<graphic::XGraphic
> xGraphic
;
1608 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
1609 CPPUNIT_ASSERT(xGraphic
.is());
1610 Graphic
aGraphic(xGraphic
);
1611 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
1612 CPPUNIT_ASSERT_EQUAL(Color(0x4f4955), aBitmap
.GetPixelColor(0, 0));
1615 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf134210CropPosition
)
1617 // We are testing crop position of bitmap in custom shapes. We should see only green with proper fix.
1619 createSdImpressDoc("pptx/crop-position.pptx");
1620 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
1621 CPPUNIT_ASSERT(xShape
.is());
1622 uno::Reference
<graphic::XGraphic
> xGraphic
;
1623 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
1624 CPPUNIT_ASSERT(xGraphic
.is());
1625 Graphic
aGraphic(xGraphic
);
1626 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
1627 CPPUNIT_ASSERT_EQUAL(Color(0x81d41a), aBitmap
.GetPixelColor(0, 0));
1630 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testGreysScaleGraphic
)
1632 createSdImpressDoc("pptx/greysscale-graphic.pptx");
1633 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
1634 CPPUNIT_ASSERT(xShape
.is());
1635 uno::Reference
<graphic::XGraphic
> xGraphic
;
1636 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
1637 CPPUNIT_ASSERT(xGraphic
.is());
1638 Graphic
aGraphic(xGraphic
);
1639 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
1640 CPPUNIT_ASSERT_EQUAL(Color(0x3c3c3c), aBitmap
.GetPixelColor(0, 0));
1643 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf103347
)
1645 createSdImpressDoc("pptx/tdf103347.pptx");
1646 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
1648 uno::Reference
<drawing::XDrawPage
> xPage1(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
1649 uno::Reference
<container::XNamed
> xNamed1(xPage1
, uno::UNO_QUERY_THROW
);
1650 CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xNamed1
->getName());
1652 uno::Reference
<drawing::XDrawPage
> xPage2(xDoc
->getDrawPages()->getByIndex(1), uno::UNO_QUERY
);
1653 uno::Reference
<container::XNamed
> xNamed2(xPage2
, uno::UNO_QUERY_THROW
);
1654 CPPUNIT_ASSERT_EQUAL(OUString("Hello (2)"), xNamed2
->getName());
1656 uno::Reference
<drawing::XDrawPage
> xPage3(xDoc
->getDrawPages()->getByIndex(2), uno::UNO_QUERY
);
1657 uno::Reference
<container::XNamed
> xNamed3(xPage3
, uno::UNO_QUERY_THROW
);
1658 CPPUNIT_ASSERT_EQUAL(OUString("Hello (3)"), xNamed3
->getName());
1661 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testHyperlinksOnShapes
)
1663 createSdImpressDoc("pptx/tdf144616.pptx");
1665 for (sal_Int32 i
= 0; i
< 7; i
++)
1667 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(i
, 0));
1668 uno::Reference
<document::XEventsSupplier
> xEventsSupplier(xShape
, uno::UNO_QUERY
);
1669 uno::Reference
<container::XNameAccess
> xEvents(xEventsSupplier
->getEvents());
1671 uno::Sequence
<beans::PropertyValue
> props
;
1672 xEvents
->getByName("OnClick") >>= props
;
1673 comphelper::SequenceAsHashMap
map(props
);
1674 auto iter(map
.find("ClickAction"));
1678 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_FIRSTPAGE
,
1679 iter
->second
.get
<css::presentation::ClickAction
>());
1682 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_LASTPAGE
,
1683 iter
->second
.get
<css::presentation::ClickAction
>());
1686 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_NEXTPAGE
,
1687 iter
->second
.get
<css::presentation::ClickAction
>());
1690 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_PREVPAGE
,
1691 iter
->second
.get
<css::presentation::ClickAction
>());
1695 auto iter2(map
.find("Bookmark"));
1696 CPPUNIT_ASSERT_EQUAL(OUString("Second slide"), iter2
->second
.get
<OUString
>());
1700 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_STOPPRESENTATION
,
1701 iter
->second
.get
<css::presentation::ClickAction
>());
1705 auto iter1(map
.find("Bookmark"));
1706 CPPUNIT_ASSERT_EQUAL(OUString("http://www.example.com/"),
1707 iter1
->second
.get
<OUString
>());
1716 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf112209
)
1718 createSdImpressDoc("pptx/tdf112209.pptx");
1719 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
1720 CPPUNIT_ASSERT(xShape
.is());
1722 uno::Reference
<graphic::XGraphic
> xGraphic
;
1723 xShape
->getPropertyValue("FillBitmap") >>= xGraphic
;
1724 CPPUNIT_ASSERT(xGraphic
.is());
1726 Graphic
aGraphic(xGraphic
);
1727 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
1729 // Without the accompanying fix in place, this test would have failed with:
1730 // - Expected: Color: R:132 G:132 B:132 A:0
1731 // - Actual : Color: R:21 G:170 B:236 A:0
1732 // i.e. the image color was blue instead of grey.
1733 CPPUNIT_ASSERT_EQUAL(Color(0x848484), aBitmap
.GetPixelColor(0, 0));
1736 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf128596
)
1738 createSdImpressDoc("pptx/tdf128596.pptx");
1739 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
1740 CPPUNIT_ASSERT(xShape
.is());
1742 css::drawing::BitmapMode bitmapmode
;
1743 xShape
->getPropertyValue("FillBitmapMode") >>= bitmapmode
;
1744 CPPUNIT_ASSERT_EQUAL(css::drawing::BitmapMode_REPEAT
, bitmapmode
);
1747 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testDefaultTabStop
)
1749 createSdImpressDoc("pptx/deftabstop.pptx");
1751 SdXImpressDocument
* pXImpressDocument
= dynamic_cast<SdXImpressDocument
*>(mxComponent
.get());
1752 CPPUNIT_ASSERT(pXImpressDocument
);
1753 SdDrawDocument
* pDoc
= pXImpressDocument
->GetDoc();
1755 sal_Int32 nDefTab
= pDoc
->GetDefaultTabulator();
1757 CPPUNIT_ASSERT_EQUAL(sal_Int32(2540), nDefTab
);
1760 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testCropToZero
)
1762 // Must not crash because of division by zero
1763 // Also must not fail assertions because of passing negative value to CropQuotientsFromSrcRect
1764 createSdImpressDoc("pptx/croppedTo0.pptx");
1767 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf144092TableHeight
)
1769 createSdImpressDoc("pptx/tdf144092-tableHeight.pptx");
1771 uno::Reference
<drawing::XShape
> xTableShape(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1773 // Without the accompanying fix in place, this test would have failed with:
1776 // i.e. the table height wasn't corrected by expanding less than minimum sized rows.
1777 CPPUNIT_ASSERT_EQUAL(sal_Int32(7606), xTableShape
->getSize().Height
);
1780 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf89928BlackWhiteThreshold
)
1782 // A slide with two graphics, one with color HSV{0,0,74%} and one with HSV{0,0,76%}
1783 // where both have an applied 75% Black/White Color Effect.
1785 createSdImpressDoc("pptx/tdf89928-blackWhiteEffectThreshold.pptx");
1787 // First graphic should appear black
1789 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
1790 uno::Reference
<graphic::XGraphic
> xGraphic
;
1791 xShape
->getPropertyValue("Graphic") >>= xGraphic
;
1792 CPPUNIT_ASSERT(xGraphic
.is());
1794 Graphic
aGraphic(xGraphic
);
1795 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
1797 // Without the accompanying fix in place, this test would have failed with:
1798 // - Expected: Color: R:0 G:0 B:0 A:0
1799 // - Actual : Color: R:189 G:189 B:189 A:0
1800 CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency
, 0x000000), aBitmap
.GetPixelColor(0, 0));
1803 // Second graphic should appear white
1805 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(1, 0), uno::UNO_SET_THROW
);
1806 uno::Reference
<graphic::XGraphic
> xGraphic
;
1807 xShape
->getPropertyValue("Graphic") >>= xGraphic
;
1808 CPPUNIT_ASSERT(xGraphic
.is());
1810 Graphic
aGraphic(xGraphic
);
1811 BitmapEx
aBitmap(aGraphic
.GetBitmapEx());
1813 CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency
, 0xFFFFFF), aBitmap
.GetPixelColor(0, 0));
1817 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf151547TransparentWhiteText
)
1819 createSdImpressDoc("pptx/tdf151547-transparent-white-text.pptx");
1821 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
1822 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
1823 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
1824 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
1827 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
1828 // Without the accompanying fix in place, this test would have failed with:
1829 // - Expected: Color: R:255 G:255 B:254 A:255
1830 // - Actual : Color: R:255 G:255 B:255 A:255
1831 // i.e. fully transparent white text color was interpreted as COL_AUTO
1832 CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency
, 0xFFFFFFFE), nCharColor
);
1835 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf149961AutofitIndentation
)
1837 createSdImpressDoc("pptx/tdf149961-autofitIndentation.pptx");
1839 const SdrPage
* pPage
= GetPage(1);
1842 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pPage
->GetObj(0));
1843 CPPUNIT_ASSERT_MESSAGE("no text object", pTxtObj
!= nullptr);
1845 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
1846 const SvxNumBulletItem
* pNumFmt
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
1847 CPPUNIT_ASSERT(pNumFmt
);
1849 CPPUNIT_ASSERT_EQUAL(sal_Int32(3175), pNumFmt
->GetNumRule().GetLevel(0).GetAbsLSpace());
1850 CPPUNIT_ASSERT_EQUAL(sal_Int32(-3175),
1851 pNumFmt
->GetNumRule().GetLevel(0).GetFirstLineOffset());
1855 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pPage
->GetObj(1));
1856 CPPUNIT_ASSERT_MESSAGE("no text object", pTxtObj
!= nullptr);
1858 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
1859 const SvxNumBulletItem
* pNumFmt
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
1860 CPPUNIT_ASSERT(pNumFmt
);
1862 // Spacing doesn't change when it is scaled
1863 CPPUNIT_ASSERT_EQUAL(sal_Int32(3175), pNumFmt
->GetNumRule().GetLevel(0).GetAbsLSpace());
1864 CPPUNIT_ASSERT_EQUAL(sal_Int32(-3175),
1865 pNumFmt
->GetNumRule().GetLevel(0).GetFirstLineOffset());
1869 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf149588TransparentSolidFill
)
1871 createSdImpressDoc("pptx/tdf149588_transparentSolidFill.pptx");
1872 saveAndReload("Impress MS PowerPoint 2007 XML");
1874 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(6, 0));
1875 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
1876 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
1877 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
1880 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
1881 // Without the accompanying fix in place, this test would have failed with:
1882 // - Expected: Color: R:99 G:99 B:99 A 51 (T:204)
1883 // - Actual : Color: R:99 G:99 B:99 A: 255 (T: 0)
1884 CPPUNIT_ASSERT_EQUAL(Color(ColorTransparency
, 0xCC636363), nCharColor
);
1887 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testOverflowBehaviorClip
)
1889 createSdImpressDoc("odp/style-overflow-behavior-clip.fodp");
1891 uno::Reference
<beans::XPropertySet
> xPropSet(getShapeFromPage(0, 0));
1892 // Without the accompanying fix in place, this test would have failed with:
1895 CPPUNIT_ASSERT_EQUAL(true,
1896 xPropSet
->getPropertyValue("TextClipVerticalOverflow").get
<bool>());
1899 saveAndReload("impress8");
1901 uno::Reference
<beans::XPropertySet
> xPropSet(getShapeFromPage(0, 0));
1902 CPPUNIT_ASSERT_EQUAL(true,
1903 xPropSet
->getPropertyValue("TextClipVerticalOverflow").get
<bool>());
1907 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testIndentDuplication
)
1909 createSdImpressDoc("pptx/formatting-bullet-indent.pptx");
1910 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(2, 0));
1912 uno::Reference
<beans::XPropertySet
> const xParagraph1(getParagraphFromShape(0, xShape
),
1913 uno::UNO_QUERY_THROW
);
1915 xParagraph1
->getPropertyValue("ParaFirstLineIndent") >>= nIndent1
;
1916 CPPUNIT_ASSERT_EQUAL(sal_Int32(2500), nIndent1
);
1918 uno::Reference
<beans::XPropertySet
> const xParagraph2(getParagraphFromShape(1, xShape
),
1919 uno::UNO_QUERY_THROW
);
1921 xParagraph2
->getPropertyValue("ParaFirstLineIndent") >>= nIndent2
;
1922 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nIndent2
);
1925 CPPUNIT_TEST_FIXTURE(SdImportTest2
, test_srcRect_smallNegBound
)
1927 // Given a cropped custom shape, with a srcRect having a small negative value in one of bounds
1928 createSdImpressDoc("pptx/tdf153008-srcRect-smallNegBound.pptx");
1930 uno::Reference
<graphic::XGraphic
> xGraphic(
1931 getShapeFromPage(0, 0)->getPropertyValue("FillBitmap"), uno::UNO_QUERY_THROW
);
1933 BitmapEx
aBitmap(Graphic(xGraphic
).GetBitmapEx());
1935 // Properly cropped bitmap should have black pixels close to left edge, near vertical center.
1936 // Before the fix, the gear was distorted, and this area was white.
1937 auto yMiddle
= aBitmap
.GetSizePixel().Height() / 2;
1938 auto x5Percent
= aBitmap
.GetSizePixel().Width() / 20;
1939 CPPUNIT_ASSERT(aBitmap
.GetPixelColor(x5Percent
, yMiddle
).IsDark());
1940 // Just in case, check that the corner is bright (it is in fact yellow)
1941 CPPUNIT_ASSERT(aBitmap
.GetPixelColor(0, 0).IsBright());
1944 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testTdf153012
)
1946 // Given a chart with a data point with solid fill of "Background 1, Darker 15%" color,
1947 // where the 'bg1' is mapped in the slide to "dk1", but in the chart to "lt1":
1948 createSdImpressDoc("pptx/chart_pt_color_bg1.pptx");
1950 uno::Reference
<chart2::XChartDocument
> xChart2Doc(
1951 getShapeFromPage(0, 0)->getPropertyValue("Model"), uno::UNO_QUERY_THROW
);
1953 uno::Reference
<chart2::XCoordinateSystemContainer
> xCooSysCnt(xChart2Doc
->getFirstDiagram(),
1954 uno::UNO_QUERY_THROW
);
1956 uno::Reference
<chart2::XChartTypeContainer
> xCTCnt(xCooSysCnt
->getCoordinateSystems()[0],
1957 uno::UNO_QUERY_THROW
);
1959 uno::Reference
<chart2::XDataSeriesContainer
> xDSCnt(xCTCnt
->getChartTypes()[0],
1960 uno::UNO_QUERY_THROW
);
1962 uno::Sequence
<uno::Reference
<chart2::XDataSeries
>> aSeriesSeq(xDSCnt
->getDataSeries());
1963 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeriesSeq
.getLength());
1965 css::uno::Reference
<css::beans::XPropertySet
> xPropSet1(aSeriesSeq
[0]->getDataPointByIndex(1),
1966 uno::UNO_SET_THROW
);
1968 xPropSet1
->getPropertyValue("FillColor") >>= aFillColor
;
1969 // The color must arrive correctly. Without the fix, it would fail:
1970 // - Expected: rgba[d9d9d9ff]
1971 // - Actual : rgba[000000ff]
1972 CPPUNIT_ASSERT_EQUAL(Color(0xd9d9d9), aFillColor
);
1975 CPPUNIT_TEST_FIXTURE(SdImportTest2
, testMasterSlides
)
1977 createSdImpressDoc("pptx/master-slides.pptx");
1978 uno::Reference
<drawing::XMasterPagesSupplier
> xMasterPagesSupplier(mxComponent
,
1979 uno::UNO_QUERY_THROW
);
1980 uno::Reference
<drawing::XDrawPages
> xMasterPages(xMasterPagesSupplier
->getMasterPages());
1981 CPPUNIT_ASSERT(xMasterPages
.is());
1982 CPPUNIT_ASSERT_EQUAL(sal_Int32(7), xMasterPages
->getCount());
1985 CPPUNIT_PLUGIN_IMPLEMENT();
1987 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */