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 <config_poppler.h>
12 #include "sdmodeltestbase.hxx"
14 #include <editeng/eeitem.hxx>
15 #include <editeng/editobj.hxx>
16 #include <editeng/ulspitem.hxx>
17 #include <editeng/fhgtitem.hxx>
18 #include <editeng/escapementitem.hxx>
19 #include <editeng/colritem.hxx>
20 #include <editeng/numitem.hxx>
22 #include <svx/svdoashp.hxx>
23 #include <svx/svdogrp.hxx>
24 #include <svx/svdoole2.hxx>
25 #include <svx/svdotable.hxx>
26 #include <svx/xfillit0.hxx>
27 #include <svx/xflclit.hxx>
28 #include <svx/xlineit0.hxx>
29 #include <svx/xlnclit.hxx>
30 #include <svx/xlnwtit.hxx>
31 #include <svx/sdasitm.hxx>
32 #include <svx/sdmetitm.hxx>
33 #include <animations/animationnodehelper.hxx>
34 #include <sax/tools/converter.hxx>
36 #include <com/sun/star/awt/Gradient.hpp>
37 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
38 #include <com/sun/star/document/XEventsSupplier.hpp>
39 #include <com/sun/star/presentation/ClickAction.hpp>
40 #include <com/sun/star/presentation/XPresentationSupplier.hpp>
41 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
42 #include <com/sun/star/animations/XAnimate.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/chart2/data/XNumericalDataSequence.hpp>
49 #include <com/sun/star/table/BorderLineStyle.hpp>
50 #include <com/sun/star/table/BorderLine2.hpp>
51 #include <com/sun/star/style/ParagraphAdjust.hpp>
52 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
53 #include <com/sun/star/presentation/XCustomPresentationSupplier.hpp>
54 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
55 #include <com/sun/star/drawing/ConnectorType.hpp>
56 #include <com/sun/star/drawing/RectanglePoint.hpp>
58 #include <stlpool.hxx>
59 #include <unotools/syslocaleoptions.hxx>
60 #include <comphelper/scopeguard.hxx>
61 #include <comphelper/sequenceashashmap.hxx>
62 #include <comphelper/lok.hxx>
63 #include <svx/svdograf.hxx>
64 #include <vcl/filter/PDFiumLibrary.hxx>
66 using namespace ::com::sun::star
;
68 namespace com::sun::star::uno
71 static std::ostream
& operator<<(std::ostream
& rStrm
, const uno::Reference
<T
>& xRef
)
78 /// Impress import filters tests.
79 class SdImportTest
: public SdModelTestBase
83 : SdModelTestBase("/sd/qa/unit/data/")
88 /** Test document against a reference XML dump of shapes.
90 If you want to update one of these tests, or add a new one, set the nUpdateMe
91 to the index of the test, and the dump XML's will be created (or rewritten)
92 instead of checking. Use with care - when the test is failing, first find out
93 why, instead of just updating .xml's blindly.
95 Example: Let's say you are adding a test called fdoABCD.pptx. You'll place it
96 to the data/ subdirectory, and will add an entry to aFilesToCompare below,
97 the 3rd parameter is for export test - can be -1 (don't export), "impress8", "MS PowerPoint 97" or "Impress Office Open XML"
100 { "fdoABCD.pptx", "xml/fdoABCD_", "Impress Office Open XML" },
102 and will count the index in the aFilesToCompare structure (1st is 0, 2nd is 1,
103 etc.) Temporarily you'll set nUpdateMe to this index (instead of -1), and run
107 This will generate the sd/qa/unit/data/xml/fdoABCD_*.xml for you. Now you
108 will change nUpdateMe back to -1, and commit your fdoABCD.pptx test, the
109 xml/fdoABCD_*.xml dumps, and the aFilesToCompare addition in one commit.
111 As the last step, you will revert your fix and do 'make sd' again, to check
112 that without your fix, the unit test breaks. Then clean up, and push :-)
114 NOTE: This approach is suitable only for tests of fixes that actually change
115 the layout - best to check by reverting your fix locally after having added
116 the test, and re-running; it should break.
118 CPPUNIT_TEST_FIXTURE(SdImportTest
, testDocumentLayout
)
122 std::u16string_view sInput
, sDump
;
123 OUString sExportType
;
125 = { { u
"odp/shapes-test.odp", u
"xml/shapes-test_page", u
"" },
126 { u
"fdo47434.pptx", u
"xml/fdo47434_", u
"" },
127 { u
"n758621.ppt", u
"xml/n758621_", u
"" },
128 { u
"fdo64586.ppt", u
"xml/fdo64586_", u
"" },
130 // needed to adapt this, the border parameter is no longer
131 // exported with MCGRs due to oox neither needing nor
132 // supporting it with now freely definable gradients
133 { u
"n819614.pptx", u
"xml/n819614_", u
"" },
135 { u
"n820786.pptx", u
"xml/n820786_", u
"" },
136 { u
"n762695.pptx", u
"xml/n762695_", u
"" },
137 { u
"n593612.pptx", u
"xml/n593612_", u
"" },
138 { u
"fdo71434.pptx", u
"xml/fdo71434_", u
"" },
139 { u
"n902652.pptx", u
"xml/n902652_", u
"" },
140 { u
"tdf90403.pptx", u
"xml/tdf90403_", u
"" },
141 { u
"tdf90338.odp", u
"xml/tdf90338_", u
"Impress Office Open XML" },
142 { u
"tdf92001.odp", u
"xml/tdf92001_", u
"Impress Office Open XML" },
143 // GCC -mfpmath=387 rounding issues in lclPushMarkerProperties
144 // (oox/source/drawingml/lineproperties.cxx); see mail sub-thread starting at
145 // <https://lists.freedesktop.org/archives/libreoffice/2016-September/
146 // 075211.html> "Re: Test File: sc/qa/unit/data/functions/fods/chiinv.fods:
147 // fails with Assertion" for how "-mfpmath=sse -msse2" would fix that:
148 #if !(defined LINUX && defined X86)
149 { u
"tdf100491.pptx", u
"xml/tdf100491_", u
"" },
151 { u
"tdf109317.pptx", u
"xml/tdf109317_", u
"impress8" },
152 // { u"pptx/n828390.pptx", u"pptx/xml/n828390_", "Impress Office Open XML" }, // Example
155 for (int i
= 0; i
< static_cast<int>(SAL_N_ELEMENTS(aFilesToCompare
)); ++i
)
158 = -1; // index of test we want to update; supposedly only when the test is created
160 loadFromURL(aFilesToCompare
[i
].sInput
);
161 if (!aFilesToCompare
[i
].sExportType
.isEmpty())
162 saveAndReload(aFilesToCompare
[i
].sExportType
);
163 uno::Reference
<drawing::XDrawPagesSupplier
> xDrawPagesSupplier(mxComponent
,
164 uno::UNO_QUERY_THROW
);
165 uno::Reference
<drawing::XDrawPages
> xDrawPages
= xDrawPagesSupplier
->getDrawPages();
166 CPPUNIT_ASSERT(xDrawPages
.is());
168 sal_Int32 nLength
= xDrawPages
->getCount();
169 for (sal_Int32 j
= 0; j
< nLength
; ++j
)
171 uno::Reference
<drawing::XDrawPage
> xDrawPage
;
172 uno::Any aAny
= xDrawPages
->getByIndex(j
);
174 uno::Reference
<drawing::XShapes
> xShapes(xDrawPage
, uno::UNO_QUERY_THROW
);
175 OUString aString
= XShapeDumper::dump(xShapes
);
178 = OUStringToOString(createFileURL(aFilesToCompare
[i
].sDump
), RTL_TEXTENCODING_UTF8
)
179 + OString::number(j
) + ".xml";
181 if (nUpdateMe
== i
) // index was wrong here
183 // had to adapt this, std::ofstream annot write to an URL but needs a
184 // filesystem path. Seems as if no one had to adapt any of the cases
185 // for some years :-/
186 OUString sTempFilePath
;
187 osl::FileBase::getSystemPathFromFileURL(OUString::fromUtf8(aFileName
),
189 std::ofstream
aStream(sTempFilePath
.toUtf8().getStr(),
190 std::ofstream::out
| std::ofstream::binary
);
196 doXMLDiff(aFileName
.getStr(),
197 OUStringToOString(aString
, RTL_TEXTENCODING_UTF8
).getStr(),
198 static_cast<int>(aString
.getLength()),
199 OUStringToOString(createFileURL(u
"tolerance.xml"), RTL_TEXTENCODING_UTF8
)
206 CPPUNIT_TEST_FIXTURE(SdImportTest
, testFreeformShapeGluePoints
)
208 createSdImpressDoc("pptx/tdf156829.pptx");
209 uno::Reference
<beans::XPropertySet
> xFreeformShape(getShapeFromPage(0, 0));
210 uno::Sequence
<beans::PropertyValue
> aProps
;
211 xFreeformShape
->getPropertyValue("CustomShapeGeometry") >>= aProps
;
213 uno::Sequence
<beans::PropertyValue
> aPathProps
;
214 for (beans::PropertyValue
const& rProp
: std::as_const(aProps
))
216 if (rProp
.Name
== "Path")
217 aPathProps
= rProp
.Value
.get
<uno::Sequence
<beans::PropertyValue
>>();
220 uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> seqGluePoints
;
221 for (beans::PropertyValue
const& rProp
: std::as_const(aPathProps
))
223 if (rProp
.Name
== "GluePoints")
226 = rProp
.Value
.get
<uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
>>();
230 sal_Int32 nCountGluePoints
= seqGluePoints
.getLength();
231 CPPUNIT_ASSERT_EQUAL(sal_Int32(5), nCountGluePoints
);
234 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf154363
)
237 createSdImpressDoc("pptx/tdf154363.pptx");
239 uno::Reference
<beans::XPropertySet
> xConnector1(getShapeFromPage(1, 0), uno::UNO_SET_THROW
);
240 uno::Reference
<beans::XPropertySet
> xConnector2(getShapeFromPage(3, 0), uno::UNO_SET_THROW
);
241 nGlueId
= xConnector1
->getPropertyValue("StartGluePointIndex").get
<sal_Int32
>();
242 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nGlueId
);
243 nGlueId
= xConnector2
->getPropertyValue("EndGluePointIndex").get
<sal_Int32
>();
244 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nGlueId
);
247 saveAndReload("Impress MS PowerPoint 2007 XML");
249 uno::Reference
<beans::XPropertySet
> xConnector1(getShapeFromPage(1, 0), uno::UNO_SET_THROW
);
250 uno::Reference
<beans::XPropertySet
> xConnector2(getShapeFromPage(3, 0), uno::UNO_SET_THROW
);
251 nGlueId
= xConnector1
->getPropertyValue("StartGluePointIndex").get
<sal_Int32
>();
252 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nGlueId
);
253 nGlueId
= xConnector2
->getPropertyValue("EndGluePointIndex").get
<sal_Int32
>();
254 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nGlueId
);
258 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf153466
)
260 createSdImpressDoc("pptx/tdf153466.pptx");
262 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
263 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
264 uno::Reference
<beans::XPropertySet
> xPageSet(xPage
, uno::UNO_QUERY_THROW
);
265 uno::Reference
<beans::XPropertySet
> xBackground(
266 xPageSet
->getPropertyValue("Background").get
<uno::Reference
<beans::XPropertySet
>>());
268 com::sun::star::drawing::RectanglePoint aRectanglePoint
;
269 xBackground
->getPropertyValue("FillBitmapRectanglePoint") >>= aRectanglePoint
;
270 CPPUNIT_ASSERT_EQUAL(drawing::RectanglePoint::RectanglePoint_RIGHT_BOTTOM
, aRectanglePoint
);
272 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW
);
273 xShape
->getPropertyValue("FillBitmapRectanglePoint") >>= aRectanglePoint
;
274 CPPUNIT_ASSERT_EQUAL(drawing::RectanglePoint::RectanglePoint_LEFT_MIDDLE
, aRectanglePoint
);
277 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf152434
)
279 createSdImpressDoc("pptx/tdf152434.pptx");
281 SdXImpressDocument
* pXImpressDocument
= dynamic_cast<SdXImpressDocument
*>(mxComponent
.get());
282 CPPUNIT_ASSERT(pXImpressDocument
);
283 SdDrawDocument
* pDoc
= pXImpressDocument
->GetDoc();
284 const SdrPage
* pPage
= pDoc
->GetPage(1);
285 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage
->GetObjCount());
288 CPPUNIT_TEST_FIXTURE(SdImportTest
, testStandardConnectors
)
290 createSdImpressDoc("pptx/standardConnectors.pptx");
292 sal_Int32 aEdgeValue
[] = { -1352, -2457, 3977, -2900, -1261, 4611, -1431, -2643, 3830, 3438 };
294 sal_Int32 nCount
= 0;
295 sal_Int32 nEdgeLine
= 0;
296 for (size_t i
= 0; i
< 10; i
++)
298 uno::Reference
<beans::XPropertySet
> xConnector(getShapeFromPage(i
, 0));
299 bool bConnector
= xConnector
->getPropertySetInfo()->hasPropertyByName("EdgeKind");
302 nEdgeLine
= xConnector
->getPropertyValue("EdgeLine1Delta").get
<sal_Int32
>();
303 CPPUNIT_ASSERT_EQUAL(aEdgeValue
[nCount
], nEdgeLine
);
306 nEdgeLine
= xConnector
->getPropertyValue("EdgeLine2Delta").get
<sal_Int32
>();
309 CPPUNIT_ASSERT_EQUAL(aEdgeValue
[nCount
], nEdgeLine
);
316 CPPUNIT_TEST_FIXTURE(SdImportTest
, testConnectors
)
318 createSdImpressDoc("pptx/connectors.pptx");
320 sal_Int32 aEdgeValue
[] = { -1167, -1167, -1591, 1476, 1356, -1357, 1604, -1540,
321 607, 1296, -1638, -1060, -522, 1578, -1291, 333 };
323 sal_Int32 nCount
= 0;
324 for (size_t i
= 0; i
< 18; i
++)
326 uno::Reference
<beans::XPropertySet
> xConnector(getShapeFromPage(i
, 0));
327 bool bConnector
= xConnector
->getPropertySetInfo()->hasPropertyByName("EdgeLine1Delta");
330 sal_Int32 nEdgeLine
= xConnector
->getPropertyValue("EdgeLine1Delta").get
<sal_Int32
>();
331 CPPUNIT_ASSERT_EQUAL(aEdgeValue
[nCount
], nEdgeLine
);
337 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf153036_resizedConnectorL
)
339 createSdImpressDoc("pptx/tdf153036_resizedConnectorL.pptx");
341 // TODO: If you are working on improvement related to connectors import, then
342 // expect this unit test to fail.
343 // This is a "L" shape, imported as a special "Z" shape that looks like a "L" shape.
344 uno::Reference
<beans::XPropertySet
> xConnector(getShapeFromPage(1, 0));
345 CPPUNIT_ASSERT(xConnector
->getPropertySetInfo()->hasPropertyByName("EdgeLine1Delta"));
347 sal_Int32 nEdgeLine
= xConnector
->getPropertyValue("EdgeLine1Delta").get
<sal_Int32
>();
348 CPPUNIT_ASSERT_EQUAL(sal_Int32(-3243), nEdgeLine
);
351 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf150719
)
353 createSdImpressDoc("pptx/tdf150719.pptx");
355 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
356 uno::Reference
<text::XTextRange
> const xParagraph(getParagraphFromShape(0, xShape
));
357 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(1, xParagraph
));
358 uno::Reference
<beans::XPropertySet
> xPropSet1(xRun
, uno::UNO_QUERY_THROW
);
359 sal_Int16 nUnderline
;
360 xPropSet1
->getPropertyValue("CharUnderline") >>= nUnderline
;
361 CPPUNIT_ASSERT_EQUAL_MESSAGE("The underline is missing!", sal_Int16(1), nUnderline
);
364 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf149314
)
366 createSdImpressDoc("pptx/tdf149314.pptx");
369 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 1));
371 uno::Reference
<text::XTextRange
> const xParagraph1(getParagraphFromShape(0, xShape
));
372 uno::Reference
<text::XTextRange
> xRun1(getRunFromParagraph(0, xParagraph1
));
373 uno::Reference
<beans::XPropertySet
> xPropSet1(xRun1
, uno::UNO_QUERY_THROW
);
374 uno::Reference
<text::XTextField
> xField1
;
375 xPropSet1
->getPropertyValue("TextField") >>= xField1
;
376 xPropSet1
.set(xField1
, uno::UNO_QUERY
);
377 xPropSet1
->getPropertyValue("URL") >>= aURL
;
378 CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("#Slide 1"), aURL
);
380 uno::Reference
<text::XTextRange
> const xParagraph2(getParagraphFromShape(1, xShape
));
381 uno::Reference
<text::XTextRange
> xRun2(getRunFromParagraph(0, xParagraph2
));
382 uno::Reference
<beans::XPropertySet
> xPropSet2(xRun2
, uno::UNO_QUERY_THROW
);
383 uno::Reference
<text::XTextField
> xField2
;
384 xPropSet2
->getPropertyValue("TextField") >>= xField2
;
385 xPropSet2
.set(xField2
, uno::UNO_QUERY
);
386 xPropSet2
->getPropertyValue("URL") >>= aURL
;
387 CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("#Slide 3"), aURL
);
390 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf149124
)
392 createSdImpressDoc("pptx/tdf149124.pptx");
394 uno::Reference
<container::XIndexAccess
> xGroupShape(getShapeFromPage(0, 0),
395 uno::UNO_QUERY_THROW
);
396 uno::Reference
<beans::XPropertySet
> xStandardConnector(xGroupShape
->getByIndex(2),
397 uno::UNO_QUERY_THROW
);
399 sal_Int32 nStartGlueId
400 = xStandardConnector
->getPropertyValue("StartGluePointIndex").get
<sal_Int32
>();
401 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nStartGlueId
);
403 = xStandardConnector
->getPropertyValue("EndGluePointIndex").get
<sal_Int32
>();
404 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nEndGlueId
);
407 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf148965
)
409 // Set the system user interface to Hungarian
410 SvtSysLocaleOptions aOptions
;
411 OUString sUIConfigString
= aOptions
.GetLanguageTag().getBcp47();
412 aOptions
.SetUILocaleConfigString("hu-HU");
414 comphelper::ScopeGuard
g([&aOptions
, &sUIConfigString
] {
415 aOptions
.SetUILocaleConfigString(sUIConfigString
);
419 createSdImpressDoc("pptx/tdf148965.pptx");
421 uno::Reference
<beans::XPropertySet
> xShape1(getShapeFromPage(0, 1));
422 uno::Reference
<document::XEventsSupplier
> xEventsSupplier1(xShape1
, uno::UNO_QUERY
);
423 uno::Reference
<container::XNameAccess
> xEvents1(xEventsSupplier1
->getEvents());
424 uno::Sequence
<beans::PropertyValue
> props1
;
425 xEvents1
->getByName("OnClick") >>= props1
;
426 comphelper::SequenceAsHashMap
map1(props1
);
427 auto iter1(map1
.find("Bookmark"));
428 CPPUNIT_ASSERT_EQUAL(OUString("page1"), iter1
->second
.get
<OUString
>());
430 uno::Reference
<beans::XPropertySet
> xShape2(getShapeFromPage(1, 1));
431 uno::Reference
<document::XEventsSupplier
> xEventsSupplier2(xShape2
, uno::UNO_QUERY
);
432 uno::Reference
<container::XNameAccess
> xEvents2(xEventsSupplier2
->getEvents());
433 uno::Sequence
<beans::PropertyValue
> props2
;
434 xEvents2
->getByName("OnClick") >>= props2
;
435 comphelper::SequenceAsHashMap
map2(props2
);
436 auto iter2(map2
.find("Bookmark"));
437 CPPUNIT_ASSERT_EQUAL(OUString("page3"), iter2
->second
.get
<OUString
>());
440 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf89449
)
442 createSdImpressDoc("pptx/tdf89449.pptx");
444 sal_Int32 nStartGlueId
;
445 sal_Int32 nEndGlueId
;
446 css::drawing::ConnectorType aConnectorType
;
448 uno::Reference
<beans::XPropertySet
> xCurvedConnector(getShapeFromPage(3, 0));
449 xCurvedConnector
->getPropertyValue("EdgeKind") >>= aConnectorType
;
450 CPPUNIT_ASSERT_EQUAL(drawing::ConnectorType::ConnectorType_CURVE
, aConnectorType
);
451 nStartGlueId
= xCurvedConnector
->getPropertyValue("StartGluePointIndex").get
<sal_Int32
>();
452 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nStartGlueId
);
453 nEndGlueId
= xCurvedConnector
->getPropertyValue("EndGluePointIndex").get
<sal_Int32
>();
454 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nEndGlueId
);
456 uno::Reference
<beans::XPropertySet
> xStraightConnector(getShapeFromPage(4, 0));
457 xStraightConnector
->getPropertyValue("EdgeKind") >>= aConnectorType
;
458 CPPUNIT_ASSERT_EQUAL(drawing::ConnectorType::ConnectorType_LINE
, aConnectorType
);
459 nStartGlueId
= xStraightConnector
->getPropertyValue("StartGluePointIndex").get
<sal_Int32
>();
460 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), nStartGlueId
);
461 nEndGlueId
= xStraightConnector
->getPropertyValue("EndGluePointIndex").get
<sal_Int32
>();
462 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nEndGlueId
);
464 uno::Reference
<beans::XPropertySet
> xStandardConnector(getShapeFromPage(5, 0));
465 xStandardConnector
->getPropertyValue("EdgeKind") >>= aConnectorType
;
466 CPPUNIT_ASSERT_EQUAL(drawing::ConnectorType::ConnectorType_STANDARD
, aConnectorType
);
467 nStartGlueId
= xStandardConnector
->getPropertyValue("StartGluePointIndex").get
<sal_Int32
>();
468 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nStartGlueId
);
469 nEndGlueId
= xStandardConnector
->getPropertyValue("EndGluePointIndex").get
<sal_Int32
>();
470 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), nEndGlueId
);
473 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf147459
)
475 createSdImpressDoc("pptx/tdf147459.pptx");
476 uno::Reference
<beans::XPropertySet
> xTriangleShape(getShapeFromPage(0, 0));
477 uno::Sequence
<beans::PropertyValue
> aProps
;
478 xTriangleShape
->getPropertyValue("CustomShapeGeometry") >>= aProps
;
480 uno::Sequence
<beans::PropertyValue
> aPathProps
;
481 for (beans::PropertyValue
const& rProp
: std::as_const(aProps
))
483 if (rProp
.Name
== "Path")
484 aPathProps
= rProp
.Value
.get
<uno::Sequence
<beans::PropertyValue
>>();
487 uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
> seqGluePoints
;
488 for (beans::PropertyValue
const& rProp
: std::as_const(aPathProps
))
490 if (rProp
.Name
== "GluePoints")
493 = rProp
.Value
.get
<uno::Sequence
<drawing::EnhancedCustomShapeParameterPair
>>();
497 sal_Int32 nCountGluePoints
= seqGluePoints
.getLength();
498 // The triangle has 6 glue points.
499 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), nCountGluePoints
);
502 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf146223
)
504 createSdImpressDoc("pptx/tdf146223.pptx");
506 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
508 uno::Reference
<drawing::XDrawPage
> xPage1(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
509 uno::Reference
<beans::XPropertySet
> xSet(xPage1
, uno::UNO_QUERY_THROW
);
511 bool bBackgroundObjectsVisible
;
512 xSet
->getPropertyValue("IsBackgroundObjectsVisible") >>= bBackgroundObjectsVisible
;
513 CPPUNIT_ASSERT_EQUAL(false, bBackgroundObjectsVisible
);
516 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf144918
)
518 createSdImpressDoc("pptx/tdf144918.pptx");
520 uno::Reference
<beans::XPropertySet
> xShape1(getShapeFromPage(0, 1));
521 uno::Reference
<document::XEventsSupplier
> xEventsSupplier1(xShape1
, uno::UNO_QUERY
);
522 uno::Reference
<container::XNameAccess
> xEvents1(xEventsSupplier1
->getEvents());
523 uno::Sequence
<beans::PropertyValue
> props1
;
524 xEvents1
->getByName("OnClick") >>= props1
;
525 comphelper::SequenceAsHashMap
map1(props1
);
526 auto iter1(map1
.find("Bookmark"));
527 CPPUNIT_ASSERT_EQUAL(OUString("First slide"), iter1
->second
.get
<OUString
>());
529 uno::Reference
<beans::XPropertySet
> xShape2(getShapeFromPage(1, 1));
530 uno::Reference
<document::XEventsSupplier
> xEventsSupplier2(xShape2
, uno::UNO_QUERY
);
531 uno::Reference
<container::XNameAccess
> xEvents2(xEventsSupplier2
->getEvents());
532 uno::Sequence
<beans::PropertyValue
> props2
;
533 xEvents2
->getByName("OnClick") >>= props2
;
534 comphelper::SequenceAsHashMap
map2(props2
);
535 auto iter2(map2
.find("Bookmark"));
536 CPPUNIT_ASSERT_EQUAL(OUString("Third slide"), iter2
->second
.get
<OUString
>());
539 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf144917
)
541 createSdImpressDoc("pptx/tdf144917.pptx");
543 uno::Reference
<container::XIndexAccess
> xGroupShape(getShapeFromPage(0, 0),
544 uno::UNO_QUERY_THROW
);
545 uno::Reference
<beans::XPropertySet
> xShape(xGroupShape
->getByIndex(1), uno::UNO_QUERY_THROW
);
546 uno::Reference
<document::XEventsSupplier
> xEventsSupplier(xShape
, uno::UNO_QUERY
);
547 uno::Reference
<container::XNameAccess
> xEvents(xEventsSupplier
->getEvents());
548 uno::Sequence
<beans::PropertyValue
> props
;
549 xEvents
->getByName("OnClick") >>= props
;
550 comphelper::SequenceAsHashMap
map(props
);
551 auto iter(map
.find("Bookmark"));
552 CPPUNIT_ASSERT_EQUAL(OUString("http://www.example.com/"), iter
->second
.get
<OUString
>());
555 CPPUNIT_TEST_FIXTURE(SdImportTest
, testHyperlinkOnImage
)
557 createSdImpressDoc("pptx/hyperlinkOnImage.pptx");
559 uno::Reference
<beans::XPropertySet
> xShape1(getShapeFromPage(1, 0));
560 uno::Reference
<document::XEventsSupplier
> xEventsSupplier1(xShape1
, uno::UNO_QUERY
);
561 uno::Reference
<container::XNameAccess
> xEvents1(xEventsSupplier1
->getEvents());
562 uno::Sequence
<beans::PropertyValue
> props1
;
563 xEvents1
->getByName("OnClick") >>= props1
;
564 comphelper::SequenceAsHashMap
map1(props1
);
565 auto iter1(map1
.find("ClickAction"));
566 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_LASTPAGE
,
567 iter1
->second
.get
<css::presentation::ClickAction
>());
569 uno::Reference
<beans::XPropertySet
> xShape2(getShapeFromPage(1, 1));
570 uno::Reference
<document::XEventsSupplier
> xEventsSupplier2(xShape2
, uno::UNO_QUERY
);
571 uno::Reference
<container::XNameAccess
> xEvents2(xEventsSupplier2
->getEvents());
572 uno::Sequence
<beans::PropertyValue
> props2
;
573 xEvents2
->getByName("OnClick") >>= props2
;
574 comphelper::SequenceAsHashMap
map2(props2
);
575 auto iter2(map2
.find("ClickAction"));
576 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_NONE
,
577 iter2
->second
.get
<css::presentation::ClickAction
>());
580 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf142645
)
582 createSdImpressDoc("pptx/tdf142645.pptx");
583 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
585 uno::Reference
<drawing::XDrawPage
> xPage1(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
586 uno::Reference
<container::XNamed
> xNamed1(xPage1
, uno::UNO_QUERY_THROW
);
587 CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xNamed1
->getName());
590 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf141704
)
592 createSdImpressDoc("pptx/tdf141704.pptx");
594 for (sal_Int32 i
= 0; i
< 7; i
++)
596 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(1, i
));
597 uno::Reference
<document::XEventsSupplier
> xEventsSupplier(xShape
, uno::UNO_QUERY
);
598 uno::Reference
<container::XNameAccess
> xEvents(xEventsSupplier
->getEvents());
600 uno::Sequence
<beans::PropertyValue
> props
;
601 xEvents
->getByName("OnClick") >>= props
;
602 comphelper::SequenceAsHashMap
map(props
);
603 auto iter(map
.find("ClickAction"));
607 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_LASTPAGE
,
608 iter
->second
.get
<css::presentation::ClickAction
>());
611 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_NEXTPAGE
,
612 iter
->second
.get
<css::presentation::ClickAction
>());
615 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_PREVPAGE
,
616 iter
->second
.get
<css::presentation::ClickAction
>());
620 auto iter1(map
.find("Bookmark"));
621 CPPUNIT_ASSERT_EQUAL(OUString("http://www.example.com/"),
622 iter1
->second
.get
<OUString
>());
627 auto iter2(map
.find("Bookmark"));
628 CPPUNIT_ASSERT_EQUAL(OUString("End Show"), iter2
->second
.get
<OUString
>());
632 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_STOPPRESENTATION
,
633 iter
->second
.get
<css::presentation::ClickAction
>());
636 CPPUNIT_ASSERT_EQUAL(css::presentation::ClickAction_FIRSTPAGE
,
637 iter
->second
.get
<css::presentation::ClickAction
>());
645 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf142915
)
647 createSdImpressDoc("pptx/tdf142915.pptx");
649 uno::Reference
<presentation::XPresentationSupplier
> xPresentationSupplier(mxComponent
,
650 uno::UNO_QUERY_THROW
);
651 uno::Reference
<beans::XPropertySet
> xPresentationProps(xPresentationSupplier
->getPresentation(),
652 uno::UNO_QUERY_THROW
);
654 bool bChangeManually
= xPresentationProps
->getPropertyValue("IsAutomatic").get
<bool>();
656 CPPUNIT_ASSERT_EQUAL(true, bChangeManually
);
659 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf142913
)
661 createSdImpressDoc("pptx/tdf142913.pptx");
663 uno::Reference
<presentation::XPresentationSupplier
> xPresentationSupplier(mxComponent
,
664 uno::UNO_QUERY_THROW
);
665 uno::Reference
<beans::XPropertySet
> xPresentationProps(xPresentationSupplier
->getPresentation(),
666 uno::UNO_QUERY_THROW
);
668 OUString sFirstPage
= xPresentationProps
->getPropertyValue("FirstPage").get
<OUString
>();
670 CPPUNIT_ASSERT_EQUAL(OUString("Second"), sFirstPage
);
673 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf142590
)
675 createSdImpressDoc("pptx/tdf142590.pptx");
677 uno::Reference
<presentation::XPresentationSupplier
> xPresentationSupplier(mxComponent
,
678 uno::UNO_QUERY_THROW
);
679 uno::Reference
<beans::XPropertySet
> xPresentationProps(xPresentationSupplier
->getPresentation(),
680 uno::UNO_QUERY_THROW
);
681 const OUString sCustomShowId
682 = xPresentationProps
->getPropertyValue("CustomShow").get
<OUString
>();
684 CPPUNIT_ASSERT(!sCustomShowId
.isEmpty());
687 CPPUNIT_TEST_FIXTURE(SdImportTest
, testCustomSlideShow
)
689 createSdImpressDoc("pptx/tdf131390.pptx");
691 css::uno::Reference
<css::presentation::XCustomPresentationSupplier
> aXCPSup(
692 mxComponent
, css::uno::UNO_QUERY
);
693 css::uno::Reference
<css::container::XNameContainer
> aXCont(aXCPSup
->getCustomPresentations());
694 const css::uno::Sequence
<OUString
> aNameSeq(aXCont
->getElementNames());
696 // In the document, there are two custom presentations.
697 CPPUNIT_ASSERT_EQUAL(sal_uInt32(2), aNameSeq
.size());
700 CPPUNIT_TEST_FIXTURE(SdImportTest
, testInternalHyperlink
)
702 createSdImpressDoc("pptx/tdf65724.pptx");
704 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(1, 0));
706 // Get first paragraph
707 uno::Reference
<text::XTextRange
> const xParagraph(getParagraphFromShape(0, xShape
));
709 // first chunk of text
710 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
711 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
713 uno::Reference
<text::XTextField
> xField
;
714 xPropSet
->getPropertyValue("TextField") >>= xField
;
715 CPPUNIT_ASSERT_MESSAGE("The text field is missing!", xField
.is());
717 xPropSet
.set(xField
, uno::UNO_QUERY
);
719 xPropSet
->getPropertyValue("URL") >>= aURL
;
720 CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("#Slide2"), aURL
);
723 CPPUNIT_TEST_FIXTURE(SdImportTest
, testHyperlinkColor
)
725 createSdImpressDoc("pptx/tdf137367.pptx");
727 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
729 // Get first paragraph of the text
730 uno::Reference
<text::XTextRange
> const xParagraph1(getParagraphFromShape(0, xShape
));
731 // Get second paragraph of the text
732 uno::Reference
<text::XTextRange
> const xParagraph2(getParagraphFromShape(1, xShape
));
733 // Get third paragraph of the text
734 uno::Reference
<text::XTextRange
> const xParagraph3(getParagraphFromShape(2, xShape
));
736 // Get run of the first paragraph
737 uno::Reference
<text::XTextRange
> xRun1(getRunFromParagraph(0, xParagraph1
));
738 uno::Reference
<beans::XPropertySet
> xPropSet1(xRun1
, uno::UNO_QUERY_THROW
);
739 Color nCharColorBlue
;
740 xPropSet1
->getPropertyValue("CharColor") >>= nCharColorBlue
;
742 // Get run of the second paragraph
743 uno::Reference
<text::XTextRange
> xRun2(getRunFromParagraph(1, xParagraph2
));
744 uno::Reference
<beans::XPropertySet
> xPropSet2(xRun2
, uno::UNO_QUERY_THROW
);
746 xPropSet2
->getPropertyValue("CharColor") >>= nCharColorRed
;
748 // Get run of the third paragraph
749 uno::Reference
<text::XTextRange
> xRun3(getRunFromParagraph(2, xParagraph3
));
750 uno::Reference
<beans::XPropertySet
> xPropSet3(xRun3
, uno::UNO_QUERY_THROW
);
751 Color nCharColorGreen
;
752 xPropSet3
->getPropertyValue("CharColor") >>= nCharColorGreen
;
754 // Hyperlink colors should be blue, red, green.
755 CPPUNIT_ASSERT_EQUAL(Color(0x4472c4), nCharColorBlue
);
756 CPPUNIT_ASSERT_EQUAL(Color(0xff0000), nCharColorRed
);
757 CPPUNIT_ASSERT_EQUAL(Color(0x548235), nCharColorGreen
);
760 CPPUNIT_TEST_FIXTURE(SdImportTest
, testSmoketest
)
762 createSdImpressDoc("smoketest.pptx");
764 SdXImpressDocument
* pXImpressDocument
= dynamic_cast<SdXImpressDocument
*>(mxComponent
.get());
765 CPPUNIT_ASSERT(pXImpressDocument
);
766 SdDrawDocument
* pDoc
= pXImpressDocument
->GetDoc();
768 // cf. SdrModel svx/svdmodel.hxx ...
770 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong page count", static_cast<sal_uInt16
>(3),
771 pDoc
->GetPageCount());
773 const SdrPage
* pPage
= pDoc
->GetPage(1);
774 CPPUNIT_ASSERT_MESSAGE("no page", pPage
!= nullptr);
776 CPPUNIT_ASSERT_MESSAGE("changed", !pDoc
->IsChanged());
779 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf131269
)
781 createSdImpressDoc("tdf131269.ppt");
783 SdXImpressDocument
* pXImpressDocument
= dynamic_cast<SdXImpressDocument
*>(mxComponent
.get());
784 CPPUNIT_ASSERT(pXImpressDocument
);
785 SdDrawDocument
* pDoc
= pXImpressDocument
->GetDoc();
787 // Without the fix in place, this test would have failed with
790 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16
>(115), pDoc
->GetPageCount());
793 CPPUNIT_TEST_FIXTURE(SdImportTest
, testN759180
)
795 createSdImpressDoc("n759180.pptx");
797 const SdrPage
* pPage
= GetPage(1);
800 SdrObject
* pObj
= pPage
->GetObj(0);
801 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pObj
);
802 CPPUNIT_ASSERT(pTxtObj
);
803 std::vector
<EECharAttrib
> rLst
;
804 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
805 const SvxULSpaceItem
* pULSpace
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_ULSPACE
);
806 CPPUNIT_ASSERT(pULSpace
);
807 CPPUNIT_ASSERT_EQUAL_MESSAGE("Para bottom spacing is wrong!", static_cast<sal_uInt16
>(0),
808 pULSpace
->GetLower());
809 aEdit
.GetCharAttribs(1, rLst
);
810 auto it
= std::find_if(rLst
.rbegin(), rLst
.rend(), [](const EECharAttrib
& rCharAttr
) {
811 return dynamic_cast<const SvxFontHeightItem
*>(rCharAttr
.pAttr
) != nullptr;
813 if (it
!= rLst
.rend())
815 const SvxFontHeightItem
* pFontHeight
= dynamic_cast<const SvxFontHeightItem
*>((*it
).pAttr
);
817 // font height = 5 => 5*2540/72
818 CPPUNIT_ASSERT_EQUAL_MESSAGE("Font height is wrong", static_cast<sal_uInt32
>(176),
819 pFontHeight
->GetHeight());
823 CPPUNIT_TEST_FIXTURE(SdImportTest
, testN862510_1
)
825 createSdImpressDoc("pptx/n862510_1.pptx");
827 const SdrPage
* pPage
= GetPage(1);
829 std::vector
<EECharAttrib
> rLst
;
830 SdrObject
* pObj
= pPage
->GetObj(0);
831 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pObj
);
832 CPPUNIT_ASSERT(pTxtObj
);
833 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
834 aEdit
.GetCharAttribs(0, rLst
);
835 for (std::vector
<EECharAttrib
>::reverse_iterator it
= rLst
.rbegin(); it
!= rLst
.rend();
838 const SvxEscapementItem
* pFontEscapement
839 = dynamic_cast<const SvxEscapementItem
*>((*it
).pAttr
);
840 CPPUNIT_ASSERT_MESSAGE(
841 "Baseline attribute not handled properly",
842 !(pFontEscapement
&& pFontEscapement
->GetProportionalHeight() != 100));
847 CPPUNIT_TEST_FIXTURE(SdImportTest
, testN862510_2
)
849 createSdImpressDoc("pptx/n862510_2.pptx");
851 const SdrPage
* pPage
= GetPage(1);
853 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage
->GetObjCount());
854 SdrObjGroup
* pGrpObj
= dynamic_cast<SdrObjGroup
*>(pPage
->GetObj(0));
855 CPPUNIT_ASSERT(pGrpObj
);
856 SdrObjCustomShape
* pObj
857 = dynamic_cast<SdrObjCustomShape
*>(pGrpObj
->GetSubList()->GetObj(1));
858 CPPUNIT_ASSERT(pObj
);
859 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong Text Rotation!", 90.0,
860 pObj
->GetExtraTextRotation(false));
864 CPPUNIT_TEST_FIXTURE(SdImportTest
, testN862510_4
)
866 createSdImpressDoc("pptx/n862510_4.pptx");
868 const SdrPage
* pPage
= GetPage(1);
870 std::vector
<EECharAttrib
> rLst
;
871 SdrObject
* pObj
= pPage
->GetObj(0);
872 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pObj
);
873 CPPUNIT_ASSERT(pTxtObj
);
874 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
875 aEdit
.GetCharAttribs(0, rLst
);
876 for (std::vector
<EECharAttrib
>::reverse_iterator it
= rLst
.rbegin(); it
!= rLst
.rend();
879 const SvxColorItem
* pC
= dynamic_cast<const SvxColorItem
*>((*it
).pAttr
);
880 CPPUNIT_ASSERT_MESSAGE("gradfill for text color not handled!",
881 !(pC
&& pC
->GetValue() == Color(0)));
886 CPPUNIT_TEST_FIXTURE(SdImportTest
, testN828390_2
)
888 createSdImpressDoc("pptx/n828390_2.pptx");
889 const SdrPage
* pPage
= GetPage(1);
891 SdrObject
* pObj
= pPage
->GetObj(0);
892 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pObj
);
893 CPPUNIT_ASSERT(pTxtObj
);
894 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
895 CPPUNIT_ASSERT_EQUAL(OUString("Linux "), aEdit
.GetText(0));
896 CPPUNIT_ASSERT_EQUAL(OUString("Standard Platform"), aEdit
.GetText(1));
899 CPPUNIT_TEST_FIXTURE(SdImportTest
, testN828390_3
)
901 createSdImpressDoc("pptx/n828390_3.pptx");
902 const SdrPage
* pPage
= GetPage(1);
904 SdrObject
* pObj
= pPage
->GetObj(0);
905 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pObj
);
906 CPPUNIT_ASSERT(pTxtObj
);
907 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
908 std::vector
<EECharAttrib
> rLst
;
909 aEdit
.GetCharAttribs(1, rLst
);
910 bool bPassed
= std::none_of(rLst
.rbegin(), rLst
.rend(), [](const EECharAttrib
& rCharAttr
) {
911 const SvxEscapementItem
* pFontEscapement
912 = dynamic_cast<const SvxEscapementItem
*>(rCharAttr
.pAttr
);
913 return pFontEscapement
&& (pFontEscapement
->GetEsc() != 0);
915 CPPUNIT_ASSERT_MESSAGE("CharEscapment not imported properly", bPassed
);
918 CPPUNIT_TEST_FIXTURE(SdImportTest
, testMasterPageStyleParent
)
920 createSdImpressDoc("odp/masterpage_style_parent.odp");
921 SdXImpressDocument
* pXImpressDocument
= dynamic_cast<SdXImpressDocument
*>(mxComponent
.get());
922 CPPUNIT_ASSERT(pXImpressDocument
);
923 SdDrawDocument
* pDoc
= pXImpressDocument
->GetDoc();
925 SdStyleSheetPool
* const pPool(pDoc
->GetSdStyleSheetPool());
928 SfxStyleSheetIterator
iter(pPool
, SfxStyleFamily::Page
);
929 for (SfxStyleSheetBase
* pStyle
= iter
.First(); pStyle
; pStyle
= iter
.Next())
931 OUString
const name(pStyle
->GetName());
932 OUString
const parent(pStyle
->GetParent());
933 if (!parent
.isEmpty())
936 // check that parent exists
937 SfxStyleSheetBase
* const pParentStyle(pPool
->Find(parent
, SfxStyleFamily::Page
));
938 CPPUNIT_ASSERT(pParentStyle
);
939 CPPUNIT_ASSERT_EQUAL(pParentStyle
->GetName(), parent
);
940 // check that parent has the same master page as pStyle
941 CPPUNIT_ASSERT(parent
.indexOf(SD_LT_SEPARATOR
) != -1);
942 CPPUNIT_ASSERT(name
.indexOf(SD_LT_SEPARATOR
) != -1);
943 CPPUNIT_ASSERT_EQUAL(parent
.copy(0, parent
.indexOf(SD_LT_SEPARATOR
)),
944 name
.copy(0, name
.indexOf(SD_LT_SEPARATOR
)));
947 // check that there are actually parents...
948 CPPUNIT_ASSERT_EQUAL(16, parents
);
951 CPPUNIT_TEST_FIXTURE(SdImportTest
, testGradientAngle
)
953 createSdDrawDoc("odg/gradient-angle.fodg");
955 uno::Reference
<lang::XMultiServiceFactory
> const xDoc(mxComponent
, uno::UNO_QUERY
);
957 awt::Gradient gradient
;
958 uno::Reference
<container::XNameAccess
> const xGradients(
959 xDoc
->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY
);
961 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 38") >>= gradient
);
962 CPPUNIT_ASSERT_EQUAL(sal_Int16(0), gradient
.Angle
); // was: 3600
964 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 10") >>= gradient
);
965 CPPUNIT_ASSERT_EQUAL(sal_Int16(270), gradient
.Angle
); // 27deg
967 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 11") >>= gradient
);
968 CPPUNIT_ASSERT_EQUAL(sal_Int16(1145), gradient
.Angle
); // 2rad
970 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 12") >>= gradient
);
971 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), gradient
.Angle
); // 100grad
973 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 13") >>= gradient
);
974 CPPUNIT_ASSERT_EQUAL(sal_Int16(3599), gradient
.Angle
); // -1
976 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 14") >>= gradient
);
977 CPPUNIT_ASSERT_EQUAL(sal_Int16(3028), gradient
.Angle
); // -1rad
979 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 15") >>= gradient
);
980 CPPUNIT_ASSERT_EQUAL(sal_Int16(300), gradient
.Angle
); // 3900
982 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 16") >>= gradient
);
983 CPPUNIT_ASSERT_EQUAL(sal_Int16(105), gradient
.Angle
); // 10.5deg
985 CPPUNIT_ASSERT(xGradients
->getByName("Gradient 17") >>= gradient
);
986 CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), gradient
.Angle
); // \pi rad
988 uno::Reference
<container::XNameAccess
> const xTranspGradients(
989 xDoc
->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY
);
991 CPPUNIT_ASSERT(xTranspGradients
->getByName("Transparency 2") >>= gradient
);
992 CPPUNIT_ASSERT_EQUAL(sal_Int16(10), gradient
.Angle
); // 1
994 CPPUNIT_ASSERT(xTranspGradients
->getByName("Transparency 1") >>= gradient
);
995 CPPUNIT_ASSERT_EQUAL(sal_Int16(900), gradient
.Angle
); // 90deg
997 CPPUNIT_ASSERT(xTranspGradients
->getByName("Transparency 3") >>= gradient
);
998 CPPUNIT_ASSERT_EQUAL(sal_Int16(572), gradient
.Angle
); // 1.0rad
1000 CPPUNIT_ASSERT(xTranspGradients
->getByName("Transparency 4") >>= gradient
);
1001 CPPUNIT_ASSERT_EQUAL(sal_Int16(1800), gradient
.Angle
); // 1000grad
1004 CPPUNIT_TEST_FIXTURE(SdImportTest
, testN778859
)
1006 createSdImpressDoc("pptx/n778859.pptx");
1008 const SdrPage
* pPage
= GetPage(1);
1011 SdrObject
* pObj
= pPage
->GetObj(1);
1012 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pObj
);
1013 CPPUNIT_ASSERT_MESSAGE("no text object", pTxtObj
!= nullptr);
1014 CPPUNIT_ASSERT(!pTxtObj
->IsAutoFit());
1018 CPPUNIT_TEST_FIXTURE(SdImportTest
, testFdo68594
)
1020 createSdImpressDoc("ppt/fdo68594.ppt");
1022 const SdrPage
* pPage
= &(GetPage(1)->TRG_GetMasterPage());
1023 SdrObject
* pObj
= pPage
->GetObj(1);
1024 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pObj
);
1025 CPPUNIT_ASSERT_MESSAGE("no text object", pTxtObj
!= nullptr);
1026 const SvxColorItem
* pC
= &pTxtObj
->GetMergedItem(EE_CHAR_COLOR
);
1027 CPPUNIT_ASSERT_MESSAGE("no color item", pC
!= nullptr);
1028 // Color should be black
1029 CPPUNIT_ASSERT_EQUAL_MESSAGE("Placeholder color mismatch", COL_BLACK
, pC
->GetValue());
1032 CPPUNIT_TEST_FIXTURE(SdImportTest
, testPlaceholderPriority
)
1034 createSdImpressDoc("ppt/placeholder-priority.pptx");
1036 const SdrPage
* pPage
= GetPage(1);
1037 CPPUNIT_ASSERT_EQUAL_MESSAGE("Missing placeholder", sal_uInt32(2),
1038 sal_uInt32(pPage
->GetObjCount()));
1040 tools::Rectangle
pObj1Rect(9100, 3500, 29619, 4038);
1041 SdrObject
* pObj1
= pPage
->GetObj(0);
1042 CPPUNIT_ASSERT_EQUAL_MESSAGE("Placeholder position is wrong, check the placeholder priority",
1043 pObj1Rect
, pObj1
->GetCurrentBoundRect());
1045 tools::Rectangle
pObj2Rect(9102, 8643, 29619, 12642);
1046 SdrObject
* pObj2
= pPage
->GetObj(1);
1047 CPPUNIT_ASSERT_EQUAL_MESSAGE("Placeholder position is wrong, check the placeholder priority",
1048 pObj2Rect
, pObj2
->GetCurrentBoundRect());
1050 // If the placeholder positions are wrong, please check placeholder priority in Placeholders class.
1053 CPPUNIT_TEST_FIXTURE(SdImportTest
, testFdo72998
)
1055 createSdImpressDoc("pptx/cshapes.pptx");
1057 const SdrPage
* pPage
= GetPage(1);
1059 SdrObjCustomShape
* pObj
= dynamic_cast<SdrObjCustomShape
*>(pPage
->GetObj(2));
1060 CPPUNIT_ASSERT(pObj
);
1061 const SdrCustomShapeGeometryItem
& rGeometryItem
1062 = pObj
->GetMergedItem(SDRATTR_CUSTOMSHAPE_GEOMETRY
);
1063 const css::uno::Any
* pViewBox
= const_cast<SdrCustomShapeGeometryItem
&>(rGeometryItem
)
1064 .GetPropertyValueByName(OUString("ViewBox"));
1065 CPPUNIT_ASSERT_MESSAGE("Missing ViewBox", pViewBox
);
1066 css::awt::Rectangle aViewBox
;
1067 CPPUNIT_ASSERT((*pViewBox
>>= aViewBox
));
1068 CPPUNIT_ASSERT_MESSAGE("Width should be zero - for forcing scale to 1", !aViewBox
.Width
);
1069 CPPUNIT_ASSERT_MESSAGE("Height should be zero - for forcing scale to 1", !aViewBox
.Height
);
1073 CPPUNIT_TEST_FIXTURE(SdImportTest
, testFdo77027
)
1075 createSdImpressDoc("odp/fdo77027.odp");
1077 const SdrPage
* pPage
= GetPage(1);
1079 SdrOle2Obj
* const pObj
= dynamic_cast<SdrOle2Obj
*>(pPage
->GetObj(0));
1080 CPPUNIT_ASSERT(pObj
);
1082 // check that the fill style/color was actually imported
1083 const XFillStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
1084 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
1085 const XFillColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_FILLCOLOR
);
1086 CPPUNIT_ASSERT_EQUAL(Color(0xff6600), rColorItem
.GetColorValue());
1090 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf97808
)
1092 createSdImpressDoc("tdf97808.fodp");
1094 uno::Reference
<style::XStyleFamiliesSupplier
> xStyleFamiliesSupplier(mxComponent
,
1096 uno::Reference
<container::XNameAccess
> xStyleFamilies
1097 = xStyleFamiliesSupplier
->getStyleFamilies();
1098 uno::Reference
<container::XNameAccess
> xStyleFamily(xStyleFamilies
->getByName("graphics"),
1100 uno::Reference
<beans::XPropertySet
> xStyle(xStyleFamily
->getByName("objectwithoutfill"),
1103 CPPUNIT_ASSERT(xStyle
->getPropertyValue("LineEndName") >>= lineend
);
1104 CPPUNIT_ASSERT_EQUAL(OUString("Arrow"), lineend
);
1106 // the draw:marker-end="" did not override the style
1107 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
1108 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0),
1109 uno::UNO_QUERY_THROW
);
1110 uno::Reference
<beans::XPropertySet
> xLine(xPage
->getByIndex(0), uno::UNO_QUERY_THROW
);
1111 //uno::Reference<style::XStyle> xParent;
1112 uno::Reference
<beans::XPropertySet
> xParent
;
1113 CPPUNIT_ASSERT(xLine
->getPropertyValue("Style") >>= xParent
);
1114 CPPUNIT_ASSERT_EQUAL(xStyle
, xParent
);
1115 CPPUNIT_ASSERT(xLine
->getPropertyValue("LineEndName") >>= lineend
);
1116 CPPUNIT_ASSERT_EQUAL(OUString(), lineend
);
1118 CPPUNIT_TEST_FIXTURE(SdImportTest
, testFillStyleNone
)
1120 createSdDrawDoc("tdf123841.odg");
1122 const SdrPage
* pPage
= GetPage(1);
1123 const SdrObject
* pObj
= pPage
->GetObj(0);
1124 auto& rFillStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
1125 // Without the accompanying fix in place, this test would have failed with 'Expected: 0; Actual:
1126 // 1', i.e. the shape's fill was FillStyle_SOLID, making the text of the shape unreadable.
1127 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, rFillStyleItem
.GetValue());
1130 CPPUNIT_TEST_FIXTURE(SdImportTest
, testFdo64512
)
1132 createSdImpressDoc("fdo64512.odp");
1134 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
1135 CPPUNIT_ASSERT_EQUAL_MESSAGE("not exactly one page", static_cast<sal_Int32
>(1),
1136 xDoc
->getDrawPages()->getCount());
1138 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0),
1139 uno::UNO_QUERY_THROW
);
1140 CPPUNIT_ASSERT_EQUAL_MESSAGE("not exactly three shapes", static_cast<sal_Int32
>(3),
1143 uno::Reference
<beans::XPropertySet
> xConnectorShape(xPage
->getByIndex(2), uno::UNO_QUERY
);
1144 CPPUNIT_ASSERT_MESSAGE("no connector shape", xConnectorShape
.is());
1146 uno::Reference
<beans::XPropertySet
> xSvgShape(xConnectorShape
->getPropertyValue("StartShape"),
1148 CPPUNIT_ASSERT_MESSAGE("no start shape", xSvgShape
.is());
1150 uno::Reference
<beans::XPropertySet
> xCustomShape(xConnectorShape
->getPropertyValue("EndShape"),
1152 CPPUNIT_ASSERT_MESSAGE("no end shape", xCustomShape
.is());
1154 uno::Reference
<animations::XAnimationNodeSupplier
> xAnimNodeSupplier(xPage
,
1155 uno::UNO_QUERY_THROW
);
1156 uno::Reference
<animations::XAnimationNode
> xRootNode(xAnimNodeSupplier
->getAnimationNode());
1157 std::vector
<uno::Reference
<animations::XAnimationNode
>> aAnimVector
;
1158 anim::create_deep_vector(xRootNode
, aAnimVector
);
1159 CPPUNIT_ASSERT_EQUAL_MESSAGE("not 8 animation nodes", static_cast<std::size_t>(8),
1160 aAnimVector
.size());
1162 uno::Reference
<animations::XAnimate
> xNode(aAnimVector
[7], uno::UNO_QUERY_THROW
);
1163 uno::Reference
<drawing::XShape
> xTargetShape(xNode
->getTarget(), uno::UNO_QUERY_THROW
);
1164 CPPUNIT_ASSERT_MESSAGE("inner node not referencing svg shape", xTargetShape
!= xSvgShape
);
1167 // Unit test for importing charts
1168 CPPUNIT_TEST_FIXTURE(SdImportTest
, testFdo71075
)
1170 double values
[] = { 12.0, 13.0, 14.0 };
1173 createSdImpressDoc("fdo71075.odp");
1175 uno::Reference
<beans::XPropertySet
> xPropSet(getShapeFromPage(0, 0));
1176 aAny
= xPropSet
->getPropertyValue("Model");
1177 CPPUNIT_ASSERT_MESSAGE("The shape doesn't have the property", aAny
.hasValue());
1179 uno::Reference
<chart::XChartDocument
> xChartDoc
;
1181 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChartDoc
.is());
1182 uno::Reference
<chart2::XChartDocument
> xChart2Doc(xChartDoc
, uno::UNO_QUERY
);
1183 CPPUNIT_ASSERT_MESSAGE("failed to load chart", xChart2Doc
.is());
1185 uno::Reference
<chart2::XCoordinateSystemContainer
> xBCooSysCnt(xChart2Doc
->getFirstDiagram(),
1187 uno::Sequence
<uno::Reference
<chart2::XCoordinateSystem
>> aCooSysSeq(
1188 xBCooSysCnt
->getCoordinateSystems());
1189 uno::Reference
<chart2::XChartTypeContainer
> xCTCnt(aCooSysSeq
[0], uno::UNO_QUERY
);
1191 uno::Reference
<chart2::XDataSeriesContainer
> xDSCnt(xCTCnt
->getChartTypes()[0], uno::UNO_QUERY
);
1192 CPPUNIT_ASSERT_MESSAGE("failed to load data series", xDSCnt
.is());
1193 uno::Sequence
<uno::Reference
<chart2::XDataSeries
>> aSeriesSeq(xDSCnt
->getDataSeries());
1194 CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Series count", static_cast<sal_Int32
>(1),
1195 aSeriesSeq
.getLength());
1196 uno::Reference
<chart2::data::XDataSource
> xSource(aSeriesSeq
[0], uno::UNO_QUERY
);
1197 uno::Sequence
<uno::Reference
<chart2::data::XLabeledDataSequence
>> aSeqCnt(
1198 xSource
->getDataSequences());
1199 CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Series count", static_cast<sal_Int32
>(1),
1200 aSeqCnt
.getLength());
1201 uno::Reference
<chart2::data::XDataSequence
> xValueSeq(aSeqCnt
[0]->getValues());
1202 CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Data count",
1203 static_cast<sal_Int32
>(SAL_N_ELEMENTS(values
)),
1204 xValueSeq
->getData().getLength());
1205 uno::Reference
<chart2::data::XNumericalDataSequence
> xNumSeq(xValueSeq
, uno::UNO_QUERY
);
1206 uno::Sequence
<double> aValues(xNumSeq
->getNumericalData());
1207 for (sal_Int32 i
= 0; i
< xValueSeq
->getData().getLength(); i
++)
1208 CPPUNIT_ASSERT_EQUAL_MESSAGE("Invalid Series count", values
[i
], aValues
.getConstArray()[i
]);
1211 CPPUNIT_TEST_FIXTURE(SdImportTest
, testStrictOOXML
)
1213 createSdImpressDoc("strict_ooxml.pptx");
1215 SdXImpressDocument
* pXImpressDocument
= dynamic_cast<SdXImpressDocument
*>(mxComponent
.get());
1216 CPPUNIT_ASSERT(pXImpressDocument
);
1217 SdDrawDocument
* pDoc
= pXImpressDocument
->GetDoc();
1218 CPPUNIT_ASSERT_MESSAGE("no document", pDoc
!= nullptr);
1219 getShapeFromPage(0, 0);
1222 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBnc870237
)
1224 createSdImpressDoc("pptx/bnc870237.pptx");
1225 const SdrPage
* pPage
= GetPage(1);
1227 // Simulate a:ext inside dsp:txXfrm with changing the lower distance
1228 const SdrObjGroup
* pGroupObj
= dynamic_cast<SdrObjGroup
*>(pPage
->GetObj(0));
1229 const SdrObject
* pObj
= pGroupObj
->GetSubList()->GetObj(1);
1230 CPPUNIT_ASSERT_MESSAGE("no object", pObj
!= nullptr);
1231 CPPUNIT_ASSERT_EQUAL(sal_Int32(-158), pObj
->GetMergedItem(SDRATTR_TEXT_UPPERDIST
).GetValue());
1232 CPPUNIT_ASSERT_EQUAL(sal_Int32(9760), pObj
->GetMergedItem(SDRATTR_TEXT_LOWERDIST
).GetValue());
1233 CPPUNIT_ASSERT_EQUAL(sal_Int32(-158), pObj
->GetMergedItem(SDRATTR_TEXT_RIGHTDIST
).GetValue());
1234 CPPUNIT_ASSERT_EQUAL(sal_Int32(-158), pObj
->GetMergedItem(SDRATTR_TEXT_LEFTDIST
).GetValue());
1237 CPPUNIT_TEST_FIXTURE(SdImportTest
, testCreationDate
)
1239 createSdImpressDoc("fdo71434.pptx");
1240 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(
1241 mxComponent
, uno::UNO_QUERY
);
1242 uno::Reference
<document::XDocumentProperties
> xDocumentProperties
1243 = xDocumentPropertiesSupplier
->getDocumentProperties();
1244 util::DateTime aDate
= xDocumentProperties
->getCreationDate();
1245 OUStringBuffer aBuffer
;
1246 sax::Converter::convertDateTime(aBuffer
, aDate
, nullptr);
1247 // Metadata wasn't imported, this was 0000-00-00.
1248 CPPUNIT_ASSERT_EQUAL(OUString("2013-11-09T10:37:56"), aBuffer
.makeStringAndClear());
1251 CPPUNIT_TEST_FIXTURE(SdImportTest
, testMultiColTexts
)
1253 createSdImpressDoc("pptx/multicol.pptx");
1254 const SdrPage
* pPage
= GetPage(1);
1256 auto pTextObj
= DynCastSdrTextObj(pPage
->GetObj(0));
1257 CPPUNIT_ASSERT(pTextObj
);
1259 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pTextObj
->GetTextColumnsNumber());
1260 CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), pTextObj
->GetTextColumnsSpacing());
1262 auto pMasterTextObj
= DynCastSdrTextObj(pPage
->TRG_GetMasterPage().GetObj(0));
1263 CPPUNIT_ASSERT(pMasterTextObj
);
1265 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pMasterTextObj
->GetTextColumnsNumber());
1266 CPPUNIT_ASSERT_EQUAL(sal_Int32(1000), pMasterTextObj
->GetTextColumnsSpacing());
1268 uno::Reference
<text::XTextRange
> xText(pMasterTextObj
->getUnoShape(), uno::UNO_QUERY_THROW
);
1269 CPPUNIT_ASSERT_EQUAL(OUString("mastershape1\nmastershape2"), xText
->getString());
1272 CPPUNIT_TEST_FIXTURE(SdImportTest
, testPredefinedTableStyle
)
1274 // 073A0DAA-6AF3-43AB-8588-CEC1D06C72B9 (Medium Style 2)
1275 createSdImpressDoc("pptx/predefined-table-style.pptx");
1276 const SdrPage
* pPage
= GetPage(1);
1278 sdr::table::SdrTableObj
* pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1279 CPPUNIT_ASSERT(pTableObj
);
1281 uno::Reference
<table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1282 uno::Reference
<beans::XPropertySet
> xCell
;
1285 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1286 xCell
->getPropertyValue("FillColor") >>= nColor
;
1287 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nColor
);
1289 xCell
.set(xTable
->getCellByPosition(0, 1), uno::UNO_QUERY_THROW
);
1290 xCell
->getPropertyValue("FillColor") >>= nColor
;
1291 CPPUNIT_ASSERT_EQUAL(Color(0xcccccc), nColor
);
1293 xCell
.set(xTable
->getCellByPosition(0, 2), uno::UNO_QUERY_THROW
);
1294 xCell
->getPropertyValue("FillColor") >>= nColor
;
1295 CPPUNIT_ASSERT_EQUAL(Color(0xe7e7e7), nColor
);
1298 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBnc887225
)
1300 createSdImpressDoc("pptx/bnc887225.pptx");
1301 // In the document, lastRow and lastCol table properties are used.
1302 // Make sure styles are set properly for individual cells.
1304 const SdrPage
* pPage
= GetPage(1);
1306 sdr::table::SdrTableObj
* pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(2));
1307 CPPUNIT_ASSERT(pTableObj
);
1308 uno::Reference
<table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1309 uno::Reference
<beans::XPropertySet
> xCell
;
1312 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1313 xCell
->getPropertyValue("FillColor") >>= nColor
;
1314 CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nColor
);
1316 xCell
.set(xTable
->getCellByPosition(0, 1), uno::UNO_QUERY_THROW
);
1317 xCell
->getPropertyValue("FillColor") >>= nColor
;
1318 CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nColor
);
1320 xCell
.set(xTable
->getCellByPosition(1, 1), uno::UNO_QUERY_THROW
);
1321 xCell
->getPropertyValue("FillColor") >>= nColor
;
1322 CPPUNIT_ASSERT_EQUAL(Color(0xd1deef), nColor
);
1324 xCell
.set(xTable
->getCellByPosition(1, 2), uno::UNO_QUERY_THROW
);
1325 xCell
->getPropertyValue("FillColor") >>= nColor
;
1326 CPPUNIT_ASSERT_EQUAL(Color(0xe9eff7), nColor
);
1328 xCell
.set(xTable
->getCellByPosition(1, 4), uno::UNO_QUERY_THROW
);
1329 xCell
->getPropertyValue("FillColor") >>= nColor
;
1330 CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nColor
);
1332 xCell
.set(xTable
->getCellByPosition(3, 2), uno::UNO_QUERY_THROW
);
1333 xCell
->getPropertyValue("FillColor") >>= nColor
;
1334 CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nColor
);
1336 xCell
.set(xTable
->getCellByPosition(3, 4), uno::UNO_QUERY_THROW
);
1337 xCell
->getPropertyValue("FillColor") >>= nColor
;
1338 CPPUNIT_ASSERT_EQUAL(Color(0x5b9bd5), nColor
);
1341 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBnc584721_1
)
1343 // Title text shape on the master page contained wrong text.
1345 createSdImpressDoc("pptx/bnc584721_1_2.pptx");
1347 const SdrPage
* pPage
= &(GetPage(1)->TRG_GetMasterPage());
1348 SdrObject
* pObj
= pPage
->GetObj(0);
1349 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pObj
);
1350 CPPUNIT_ASSERT_MESSAGE("no text object", pTxtObj
!= nullptr);
1351 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
1352 CPPUNIT_ASSERT_EQUAL(OUString("Click to edit Master title style"), aEdit
.GetText(0));
1355 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBnc584721_2
)
1357 // Import created an extra/unneeded outliner shape on the master slide next to the imported title shape.
1359 createSdImpressDoc("pptx/bnc584721_1_2.pptx");
1361 const SdrPage
* pPage
= &(GetPage(1)->TRG_GetMasterPage());
1362 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage
->GetObjCount());
1365 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBnc591147
)
1367 createSdImpressDoc("pptx/bnc591147.pptx");
1369 // In the document, there are two slides with media files.
1370 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
1371 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDoc
->getDrawPages()->getCount());
1373 // First page has video file inserted
1374 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0),
1375 uno::UNO_QUERY_THROW
);
1376 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage
->getCount());
1378 //uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
1379 uno::Reference
<beans::XPropertySet
> xPropSet(getShape(0, xPage
));
1380 OUString
sVideoURL("emptyURL");
1381 bool bSuccess
= xPropSet
->getPropertyValue("MediaURL") >>= sVideoURL
;
1382 CPPUNIT_ASSERT_MESSAGE("MediaURL property is not set", bSuccess
);
1383 CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sVideoURL
.isEmpty());
1385 // Second page has audio file inserted
1386 xPage
.set(xDoc
->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW
);
1387 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage
->getCount());
1389 xPropSet
.set(getShape(0, xPage
));
1390 OUString
sAudioURL("emptyURL");
1391 bSuccess
= xPropSet
->getPropertyValue("MediaURL") >>= sAudioURL
;
1392 CPPUNIT_ASSERT_MESSAGE("MediaURL property is not set", bSuccess
);
1393 CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sAudioURL
.isEmpty());
1395 CPPUNIT_ASSERT_MESSAGE("sAudioURL and sVideoURL should not be equal", sAudioURL
!= sVideoURL
);
1398 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBnc584721_4
)
1400 // Black text was imported as white because of wrong caching mechanism
1402 createSdImpressDoc("pptx/bnc584721_4.pptx");
1403 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(1, 1));
1405 // Get first paragraph of the text
1406 uno::Reference
<text::XTextRange
> const xParagraph(getParagraphFromShape(0, xShape
));
1408 // Get first run of the paragraph
1409 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
1410 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
1412 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
1414 // Color should be black
1415 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nCharColor
);
1418 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBnc904423
)
1420 // Here the problem was that different fill properties were applied in wrong order on the shape
1421 // Right order: 1) master slide fill style, 2) theme, 3) direct formatting
1423 createSdImpressDoc("pptx/bnc904423.pptx");
1425 const SdrPage
* pPage
= GetPage(1);
1426 // First shape's background color is defined on master slide
1428 SdrObject
* const pObj
= pPage
->GetObj(0);
1429 CPPUNIT_ASSERT(pObj
);
1431 const XFillStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
1432 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
1433 const XFillColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_FILLCOLOR
);
1434 CPPUNIT_ASSERT_EQUAL(Color(0x00CC99), rColorItem
.GetColorValue());
1437 // Second shape's background color is defined by theme
1439 SdrObject
* const pObj
= pPage
->GetObj(1);
1440 CPPUNIT_ASSERT(pObj
);
1442 const XFillStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
1443 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
1444 const XFillColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_FILLCOLOR
);
1445 CPPUNIT_ASSERT_EQUAL(Color(0x3333CC), rColorItem
.GetColorValue());
1448 // Third shape's background color is defined by direct formatting
1450 SdrObject
* const pObj
= pPage
->GetObj(2);
1451 CPPUNIT_ASSERT(pObj
);
1453 const XFillStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_FILLSTYLE
);
1454 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
1455 const XFillColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_FILLCOLOR
);
1456 CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), rColorItem
.GetColorValue());
1460 CPPUNIT_TEST_FIXTURE(SdImportTest
, testShapeLineStyle
)
1462 // Here the problem was that different line properties were applied in wrong order on the shape
1463 // Right order: 1) master slide line style, 2) theme, 3) direct formatting
1464 createSdImpressDoc("pptx/ShapeLineProperties.pptx");
1466 const SdrPage
* pPage
= GetPage(1);
1467 // First shape's line style is defined on master slide
1469 SdrObject
* const pObj
= pPage
->GetObj(0);
1470 CPPUNIT_ASSERT(pObj
);
1472 const XLineStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_LINESTYLE
);
1473 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_DASH
, rStyleItem
.GetValue());
1475 const XLineColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_LINECOLOR
);
1476 CPPUNIT_ASSERT_EQUAL(Color(0xFF0000), rColorItem
.GetColorValue());
1478 const XLineWidthItem
& rWidthItem
= pObj
->GetMergedItem(XATTR_LINEWIDTH
);
1479 CPPUNIT_ASSERT_EQUAL(sal_Int32(132), rWidthItem
.GetValue());
1482 // Second shape's line style is defined by theme
1484 SdrObject
* const pObj
= pPage
->GetObj(1);
1485 CPPUNIT_ASSERT(pObj
);
1487 const XLineStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_LINESTYLE
);
1488 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, rStyleItem
.GetValue());
1490 const XLineColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_LINECOLOR
);
1491 CPPUNIT_ASSERT_EQUAL(Color(0x3333CC), rColorItem
.GetColorValue());
1493 const XLineWidthItem
& rWidthItem
= pObj
->GetMergedItem(XATTR_LINEWIDTH
);
1494 CPPUNIT_ASSERT_EQUAL(sal_Int32(35), rWidthItem
.GetValue());
1497 // Third shape's line style is defined by direct formatting
1499 SdrObject
* const pObj
= pPage
->GetObj(2);
1500 CPPUNIT_ASSERT(pObj
);
1502 const XLineStyleItem
& rStyleItem
= pObj
->GetMergedItem(XATTR_LINESTYLE
);
1503 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, rStyleItem
.GetValue());
1505 const XLineColorItem
& rColorItem
= pObj
->GetMergedItem(XATTR_LINECOLOR
);
1506 CPPUNIT_ASSERT_EQUAL(Color(0x7030A0), rColorItem
.GetColorValue());
1508 const XLineWidthItem
& rWidthItem
= pObj
->GetMergedItem(XATTR_LINEWIDTH
);
1509 CPPUNIT_ASSERT_EQUAL(sal_Int32(176), rWidthItem
.GetValue());
1513 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTableBorderLineStyle
)
1515 createSdImpressDoc("pptx/tableBorderLineStyle.pptx");
1517 // TODO: If you are working on improvement of table border line style
1518 // support, then expect this unit test to fail.
1520 const sal_Int16 nObjBorderLineStyles
[]
1521 = { ::table::BorderLineStyle::DASHED
, ::table::BorderLineStyle::DASH_DOT_DOT
,
1522 ::table::BorderLineStyle::DASH_DOT
, ::table::BorderLineStyle::DOTTED
,
1523 ::table::BorderLineStyle::DASHED
, ::table::BorderLineStyle::DOTTED
,
1524 ::table::BorderLineStyle::DASHED
, ::table::BorderLineStyle::DASH_DOT
,
1525 ::table::BorderLineStyle::DASH_DOT
, ::table::BorderLineStyle::SOLID
,
1526 ::table::BorderLineStyle::NONE
};
1528 const SdrPage
* pPage
= GetPage(1);
1529 CPPUNIT_ASSERT_EQUAL(SAL_N_ELEMENTS(nObjBorderLineStyles
), pPage
->GetObjCount());
1531 sdr::table::SdrTableObj
* pTableObj
;
1532 uno::Reference
<table::XCellRange
> xTable
;
1533 uno::Reference
<beans::XPropertySet
> xCell
;
1534 table::BorderLine2 aBorderLine
;
1536 for (size_t i
= 0; i
< SAL_N_ELEMENTS(nObjBorderLineStyles
); i
++)
1538 pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(i
));
1539 CPPUNIT_ASSERT(pTableObj
);
1540 xTable
.set(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1541 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1542 xCell
->getPropertyValue("TopBorder") >>= aBorderLine
;
1543 if (aBorderLine
.LineWidth
> 0)
1545 CPPUNIT_ASSERT_EQUAL(nObjBorderLineStyles
[i
], aBorderLine
.LineStyle
);
1550 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBnc862510_6
)
1552 // Black text was imported instead of gray
1554 createSdImpressDoc("pptx/bnc862510_6.pptx");
1555 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
1557 // Get first paragraph of the text
1558 uno::Reference
<text::XTextRange
> const xParagraph(getParagraphFromShape(0, xShape
));
1560 // Get first run of the paragraph
1561 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
1562 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
1564 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
1566 // Color should be gray
1567 CPPUNIT_ASSERT_EQUAL(Color(0x8B8B8B), nCharColor
);
1570 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBnc862510_7
)
1572 // Title shape's text was aligned to left instead of center.
1574 createSdImpressDoc("pptx/bnc862510_7.pptx");
1575 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
1577 // Get first paragraph
1578 uno::Reference
<text::XTextRange
> const xParagraph(getParagraphFromShape(0, xShape
));
1579 uno::Reference
<beans::XPropertySet
> xPropSet(xParagraph
, uno::UNO_QUERY_THROW
);
1581 sal_Int16 nParaAdjust
= 0;
1582 xPropSet
->getPropertyValue("ParaAdjust") >>= nParaAdjust
;
1583 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
,
1584 static_cast<style::ParagraphAdjust
>(nParaAdjust
));
1587 #if ENABLE_PDFIMPORT
1588 // These tests use the old PDF-importing logic, which imports PDF elements as
1589 // SD elements. This suffered many issues, and therefore wasn't ideal.
1590 // The old PDF importer relied on an open-source project (xpdf) with an
1591 // incompatible license (gpl), which has to be interfaced via an out-of-process
1592 // library wrapper process. The resulting imported document was inaccurate
1593 // and often very slow and with large memory footprint.
1594 // Instead, PDFium offers state-of-the-art PDF importing logic,
1595 // which is well-maintained and renders PDFs into images with high accuracy.
1596 // So, the idea is to import PDFs as images using PDFium, which has a very
1597 // high quality (and is much faster) than importing individual editable elements.
1598 // So that's the "new" way of importing.
1599 // The user then breaks the image to editable elements (which is not perfect,
1600 // but very close to the old way), only if they need editing ability.
1601 // PDFium should overall be better, and where it isn't, we just need to improve it.
1602 // So these tests aren't really useful anymore. They should be modified to do
1603 // import+break and then check the results. But that isn't straight-forward and
1604 // currently await volunteering time to implement.
1606 CPPUNIT_TEST_FIXTURE(SdImportTest
, testPDFImportShared
)
1608 auto pPdfium
= vcl::pdf::PDFiumLibrary::get();
1614 comphelper::LibreOfficeKit::setActive();
1616 createSdDrawDoc("pdf/multipage.pdf");
1617 SdXImpressDocument
* pXImpressDocument
= dynamic_cast<SdXImpressDocument
*>(mxComponent
.get());
1618 CPPUNIT_ASSERT(pXImpressDocument
);
1619 SdDrawDocument
* pDoc
= pXImpressDocument
->GetDoc();
1621 // This test is to verify that we share the PDF stream linked to each
1622 // Graphic instance in the imported document.
1623 // Since we import PDFs as images, we support attaching the original
1624 // PDF with each image to allow for advanced editing.
1625 // Here we iterate over all Graphic instances embedded in the pages
1626 // and verify that they all point to the same object in memory.
1627 std::vector
<Graphic
> aGraphics
;
1629 for (int nPageIndex
= 0; nPageIndex
< pDoc
->GetPageCount(); ++nPageIndex
)
1631 const SdrPage
* pPage
= GetPage(nPageIndex
);
1632 if (pPage
== nullptr)
1635 for (size_t nObjIndex
= 0; nObjIndex
< pPage
->GetObjCount(); ++nObjIndex
)
1637 SdrObject
* pObject
= pPage
->GetObj(nObjIndex
);
1638 if (pObject
== nullptr)
1641 SdrGrafObj
* pSdrGrafObj
= dynamic_cast<SdrGrafObj
*>(pObject
);
1642 if (pSdrGrafObj
== nullptr)
1645 const GraphicObject
& rGraphicObject
= pSdrGrafObj
->GetGraphicObject().GetGraphic();
1646 const Graphic
& rGraphic
= rGraphicObject
.GetGraphic();
1647 CPPUNIT_ASSERT_MESSAGE(
1648 "After loading, the PDF shouldn't have the primitive sequence created yet",
1649 !rGraphic
.getVectorGraphicData()->isPrimitiveSequenceCreated());
1650 aGraphics
.push_back(rGraphic
);
1654 CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected more than one page.", size_t(9), aGraphics
.size());
1656 Graphic
const& rFirstGraphic
= aGraphics
[0];
1658 for (size_t i
= 0; i
< aGraphics
.size(); ++i
)
1660 Graphic
const& rGraphic
= aGraphics
[i
];
1661 CPPUNIT_ASSERT_EQUAL_MESSAGE(
1662 "Expected all PDF streams to be identical.",
1663 rFirstGraphic
.getVectorGraphicData()->getBinaryDataContainer().getData(),
1664 rGraphic
.getVectorGraphicData()->getBinaryDataContainer().getData());
1666 CPPUNIT_ASSERT_EQUAL_MESSAGE("Expected all GfxLinks to be identical.",
1667 rFirstGraphic
.GetSharedGfxLink().get(),
1668 rGraphic
.GetSharedGfxLink().get());
1670 CPPUNIT_ASSERT_EQUAL_MESSAGE("Page number doesn't match expected", sal_Int32(i
),
1671 rGraphic
.getPageNumber());
1674 mxComponent
->dispose();
1675 mxComponent
.clear();
1677 comphelper::LibreOfficeKit::setActive(false);
1680 #if defined(IMPORT_PDF_ELEMENTS)
1682 CPPUNIT_TEST_FIXTURE(SdImportTest
, testPDFImport
)
1684 createSdDrawDoc("pdf/txtpic.pdf");
1685 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
1686 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0),
1687 uno::UNO_QUERY_THROW
);
1688 CPPUNIT_ASSERT_EQUAL_MESSAGE("no exactly two shapes", static_cast<sal_Int32
>(2),
1691 uno::Reference
<beans::XPropertySet
> xShape(getShape(0, xPage
));
1692 uno::Reference
<text::XText
> xText
1693 = uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY_THROW
)->getText();
1694 CPPUNIT_ASSERT_MESSAGE("not a text shape", xText
.is());
1697 CPPUNIT_TEST_FIXTURE(SdImportTest
, testPDFImportSkipImages
)
1699 auto pParams
= std::make_shared
<SfxAllItemSet
>(SfxGetpApp()->GetPool());
1700 pParams
->Put(SfxStringItem(SID_FILE_FILTEROPTIONS
, "SkipImages"));
1702 createSdDrawDoc("pdf/txtpic.pdf"), PDF
, pParams
);
1703 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
1704 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0),
1705 uno::UNO_QUERY_THROW
);
1706 CPPUNIT_ASSERT_EQUAL_MESSAGE("no exactly one shape", static_cast<sal_Int32
>(1),
1709 uno::Reference
<drawing::XShape
> xShape(xPage
->getByIndex(0), uno::UNO_QUERY_THROW
);
1710 uno::Reference
<text::XText
> xText
1711 = uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY_THROW
)->getText();
1712 CPPUNIT_ASSERT_MESSAGE("not a text shape", xText
.is());
1718 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBulletSuffix
)
1720 createSdImpressDoc("pptx/n83889.pptx");
1722 // check suffix of the char bullet
1723 const SdrPage
* pPage
= GetPage(1);
1724 SdrTextObj
* pTxtObj
= DynCastSdrTextObj(pPage
->GetObj(0));
1725 CPPUNIT_ASSERT_MESSAGE("no text object", pTxtObj
!= nullptr);
1726 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
1727 const SvxNumBulletItem
* pNumFmt
= aEdit
.GetParaAttribs(1).GetItem(EE_PARA_NUMBULLET
);
1728 CPPUNIT_ASSERT(pNumFmt
);
1729 CPPUNIT_ASSERT_EQUAL_MESSAGE("Bullet's suffix is wrong!",
1730 pNumFmt
->GetNumRule().GetLevel(0).GetSuffix(), OUString());
1733 CPPUNIT_TEST_FIXTURE(SdImportTest
, testBnc910045
)
1735 // Problem with table style which defines cell color with fill style
1737 createSdImpressDoc("pptx/bnc910045.pptx");
1738 const SdrPage
* pPage
= GetPage(1);
1740 sdr::table::SdrTableObj
* pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1741 CPPUNIT_ASSERT(pTableObj
);
1742 uno::Reference
<table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1743 uno::Reference
<beans::XPropertySet
> xCell
;
1746 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1747 xCell
->getPropertyValue("FillColor") >>= nColor
;
1748 CPPUNIT_ASSERT_EQUAL(Color(0x4f81bd), nColor
);
1751 CPPUNIT_TEST_FIXTURE(SdImportTest
, testRowHeight
)
1753 createSdImpressDoc("pptx/n80340.pptx");
1754 const SdrPage
* pPage
= GetPage(1);
1756 sdr::table::SdrTableObj
* pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1757 CPPUNIT_ASSERT(pTableObj
);
1760 uno::Reference
<css::table::XTable
> xTable(pTableObj
->getTable(), uno::UNO_SET_THROW
);
1761 uno::Reference
<css::table::XTableRows
> xRows(xTable
->getRows(), uno::UNO_SET_THROW
);
1762 uno::Reference
<beans::XPropertySet
> xRefRow(xRows
->getByIndex(0), uno::UNO_QUERY_THROW
);
1763 xRefRow
->getPropertyValue("Height") >>= nHeight
;
1764 CPPUNIT_ASSERT_EQUAL(sal_Int32(508), nHeight
);
1766 createSdImpressDoc("pptx/tablescale.pptx");
1767 const SdrPage
* pPage2
= GetPage(1);
1769 sdr::table::SdrTableObj
* pTableObj2
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage2
->GetObj(0));
1770 CPPUNIT_ASSERT(pTableObj2
);
1772 uno::Reference
<css::table::XTable
> xTable2(pTableObj2
->getTable(), uno::UNO_SET_THROW
);
1773 uno::Reference
<css::table::XTableRows
> xRows2(xTable2
->getRows(), uno::UNO_SET_THROW
);
1775 for (sal_Int32 nRow
= 0; nRow
< 7; ++nRow
)
1777 uno::Reference
<beans::XPropertySet
> xRefRow2(xRows2
->getByIndex(nRow
),
1778 uno::UNO_QUERY_THROW
);
1779 xRefRow2
->getPropertyValue("Height") >>= nHeight
;
1780 CPPUNIT_ASSERT_EQUAL(sal_Int32(800), nHeight
);
1784 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf93830
)
1786 // Text shape offset was ignored
1788 createSdImpressDoc("pptx/tdf93830.pptx");
1789 uno::Reference
<drawing::XDrawPage
> xPage(getPage(0));
1791 // Get the first text box from group shape
1792 uno::Reference
<container::XIndexAccess
> xShape(xPage
->getByIndex(0), uno::UNO_QUERY
);
1793 uno::Reference
<beans::XPropertySet
> xPropSet(xShape
->getByIndex(3), uno::UNO_QUERY
);
1794 CPPUNIT_ASSERT_MESSAGE("no textbox shape", xPropSet
.is());
1796 sal_Int32 nTextLeftDistance
= 0;
1797 xPropSet
->getPropertyValue("TextLeftDistance") >>= nTextLeftDistance
;
1798 CPPUNIT_ASSERT_EQUAL(sal_Int32(4024), nTextLeftDistance
);
1801 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf127129
)
1803 createSdImpressDoc("pptx/tdf127129.pptx");
1804 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
1805 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
1806 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
1807 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
1810 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
1811 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, nCharColor
);
1813 // Without the accompanying fix in place, the highlight would be -1
1814 Color nCharBackColor
;
1815 xPropSet
->getPropertyValue("CharBackColor") >>= nCharBackColor
;
1816 CPPUNIT_ASSERT_EQUAL(Color(0xFF00), nCharBackColor
);
1818 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf93097
)
1820 // Throwing metadata import aborted the filter, check that metadata is now imported.
1822 createSdImpressDoc("pptx/tdf93097.pptx");
1823 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(
1824 mxComponent
, uno::UNO_QUERY
);
1825 uno::Reference
<document::XDocumentProperties
> xDocumentProperties
1826 = xDocumentPropertiesSupplier
->getDocumentProperties();
1827 CPPUNIT_ASSERT_EQUAL(OUString("ss"), xDocumentProperties
->getTitle());
1830 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf62255
)
1832 createSdImpressDoc("pptx/tdf62255.pptx");
1833 const SdrPage
* pPage
= GetPage(1);
1835 sdr::table::SdrTableObj
* pTableObj
;
1836 pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1837 CPPUNIT_ASSERT(pTableObj
);
1840 uno::Reference
<table::XCellRange
> xTable
;
1841 uno::Reference
<beans::XPropertySet
> xCell
;
1842 xTable
.set(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1843 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1844 aAny
= xCell
->getPropertyValue("FillStyle");
1846 if (aAny
.hasValue())
1848 drawing::FillStyle aFillStyle
;
1849 aAny
>>= aFillStyle
;
1850 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE
, aFillStyle
);
1854 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf89927
)
1856 createSdImpressDoc("pptx/tdf89927.pptx");
1857 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
1858 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
1859 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
1860 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
1863 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
1864 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nCharColor
);
1867 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf103800
)
1869 createSdImpressDoc("pptx/tdf103800.pptx");
1870 uno::Reference
<beans::XPropertySet
> xShape(getShapeFromPage(0, 0));
1871 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
1872 uno::Reference
<text::XTextRange
> xRun(getRunFromParagraph(0, xParagraph
));
1873 uno::Reference
<beans::XPropertySet
> xPropSet(xRun
, uno::UNO_QUERY_THROW
);
1876 xPropSet
->getPropertyValue("CharColor") >>= nCharColor
;
1877 CPPUNIT_ASSERT_EQUAL(Color(0xC00000), nCharColor
);
1880 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf151767
)
1882 createSdImpressDoc("pptx/tdf151767.pptx");
1884 const SdrPage
* pPage
= GetPage(1);
1885 sdr::table::SdrTableObj
* pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1886 uno::Reference
<table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1887 uno::Reference
<beans::XPropertySet
> xCell(xTable
->getCellByPosition(0, 0),
1888 uno::UNO_QUERY_THROW
);
1890 table::BorderLine2 aLeft
;
1891 xCell
->getPropertyValue("LeftBorder") >>= aLeft
;
1892 CPPUNIT_ASSERT_EQUAL_MESSAGE("The left border is missing!", true, aLeft
.LineWidth
> 0);
1894 table::BorderLine2 aRight
;
1895 xCell
->getPropertyValue("RightBorder") >>= aRight
;
1896 CPPUNIT_ASSERT_EQUAL_MESSAGE("The right border is missing!", true, aRight
.LineWidth
> 0);
1898 table::BorderLine2 aTop
;
1899 xCell
->getPropertyValue("TopBorder") >>= aTop
;
1900 CPPUNIT_ASSERT_EQUAL_MESSAGE("The top border is missing!", true, aTop
.LineWidth
> 0);
1902 table::BorderLine2 aBottom
;
1903 xCell
->getPropertyValue("BottomBorder") >>= aBottom
;
1904 CPPUNIT_ASSERT_EQUAL_MESSAGE("The bottom border is missing!", true, aBottom
.LineWidth
> 0);
1907 CPPUNIT_TEST_FIXTURE(SdImportTest
, testTdf152070
)
1909 createSdImpressDoc("pptx/tdf152070.pptx");
1911 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(mxComponent
, uno::UNO_QUERY_THROW
);
1912 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
1913 uno::Reference
<beans::XPropertySet
> xPropSet(xPage
, uno::UNO_QUERY_THROW
);
1914 uno::Reference
<beans::XPropertySet
> xBackgroundProps(
1915 xPropSet
->getPropertyValue("Background").get
<uno::Reference
<beans::XPropertySet
>>());
1917 CPPUNIT_ASSERT_EQUAL(
1918 sal_Int32(50), // 50%
1919 xBackgroundProps
->getPropertyValue("FillBitmapPositionOffsetX").get
<sal_Int32
>());
1920 CPPUNIT_ASSERT_EQUAL(
1921 sal_Int32(83), // 83%
1922 xBackgroundProps
->getPropertyValue("FillBitmapPositionOffsetY").get
<sal_Int32
>());
1925 CPPUNIT_PLUGIN_IMPLEMENT();
1927 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */