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 "sdmodeltestbase.hxx"
12 #include <com/sun/star/beans/XPropertySet.hpp>
13 #include <com/sun/star/drawing/FillStyle.hpp>
14 #include <com/sun/star/drawing/TextFitToSizeType.hpp>
15 #include <com/sun/star/drawing/XShape.hpp>
16 #include <com/sun/star/style/ParagraphAdjust.hpp>
17 #include <com/sun/star/text/XText.hpp>
18 #include <com/sun/star/graphic/XGraphic.hpp>
20 #include <svx/svdoashp.hxx>
21 #include <svx/svdpage.hxx>
22 #include <svx/svdogrp.hxx>
23 #include <comphelper/sequenceashashmap.hxx>
24 #include <oox/drawingml/drawingmltypes.hxx>
26 using namespace ::com::sun::star
;
30 /// Gets one child of xShape, which one is specified by nIndex.
31 uno::Reference
<drawing::XShape
> getChildShape(const uno::Reference
<drawing::XShape
>& xShape
,
34 uno::Reference
<container::XIndexAccess
> xGroup(xShape
, uno::UNO_QUERY
);
35 CPPUNIT_ASSERT(xGroup
.is());
37 CPPUNIT_ASSERT(xGroup
->getCount() > nIndex
);
39 uno::Reference
<drawing::XShape
> xRet(xGroup
->getByIndex(nIndex
), uno::UNO_QUERY
);
40 CPPUNIT_ASSERT(xRet
.is());
45 uno::Reference
<drawing::XShape
> findChildShapeByText(const uno::Reference
<drawing::XShape
>& xShape
,
46 const OUString
& sText
)
48 uno::Reference
<text::XText
> xText(xShape
, uno::UNO_QUERY
);
49 if (xText
.is() && xText
->getString() == sText
)
52 uno::Reference
<container::XIndexAccess
> xGroup(xShape
, uno::UNO_QUERY
);
54 return uno::Reference
<drawing::XShape
>();
56 for (sal_Int32 i
= 0; i
< xGroup
->getCount(); i
++)
58 uno::Reference
<drawing::XShape
> xChildShape(xGroup
->getByIndex(i
), uno::UNO_QUERY
);
59 uno::Reference
<drawing::XShape
> xReturnShape
= findChildShapeByText(xChildShape
, sText
);
60 if (xReturnShape
.is())
64 return uno::Reference
<drawing::XShape
>();
68 class SdImportTestSmartArt
: public SdModelTestBase
71 SdImportTestSmartArt()
72 : SdModelTestBase("/sd/qa/unit/data/")
77 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBase
)
79 createSdImpressDoc("pptx/smartart1.pptx");
80 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
81 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xShapeGroup
->getCount());
83 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
84 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0
->getString());
85 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
86 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1
->getString());
87 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
88 CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2
->getString());
89 uno::Reference
<text::XText
> xText3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
90 CPPUNIT_ASSERT_EQUAL(OUString("d"), xText3
->getString());
91 uno::Reference
<text::XText
> xText4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
92 CPPUNIT_ASSERT_EQUAL(OUString("e"), xText4
->getString());
94 uno::Reference
<beans::XPropertySet
> xShape(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
97 xShape
->getPropertyValue("FillColor") >>= nFillColor
;
98 CPPUNIT_ASSERT_EQUAL(Color(0x4F81BD), nFillColor
);
100 sal_Int16 nParaAdjust
= 0;
101 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
102 uno::Reference
<beans::XPropertySet
> xPropSet(xParagraph
, uno::UNO_QUERY_THROW
);
103 xPropSet
->getPropertyValue("ParaAdjust") >>= nParaAdjust
;
104 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
,
105 static_cast<style::ParagraphAdjust
>(nParaAdjust
));
107 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
108 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
109 uno::Reference
<drawing::XShape
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
110 uno::Reference
<drawing::XShape
> xShape3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
111 uno::Reference
<drawing::XShape
> xShape4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
122 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().Y
, xShape1
->getPosition().Y
);
123 CPPUNIT_ASSERT_EQUAL(xShape2
->getPosition().Y
, xShape3
->getPosition().Y
);
125 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().X
, xShape2
->getPosition().X
);
126 CPPUNIT_ASSERT_EQUAL(xShape1
->getPosition().X
, xShape3
->getPosition().X
);
128 CPPUNIT_ASSERT_EQUAL(xShape2
->getPosition().Y
- xShape0
->getPosition().Y
,
129 xShape4
->getPosition().Y
- xShape2
->getPosition().Y
);
130 CPPUNIT_ASSERT_EQUAL(xShape1
->getPosition().X
- xShape0
->getPosition().X
,
131 xShape3
->getPosition().X
- xShape2
->getPosition().X
);
132 CPPUNIT_ASSERT_DOUBLES_EQUAL(xShape2
->getPosition().X
+ xShape3
->getPosition().X
,
133 2 * xShape4
->getPosition().X
, 1);
135 CPPUNIT_ASSERT(xShape2
->getPosition().Y
> xShape0
->getPosition().Y
);
136 CPPUNIT_ASSERT(xShape4
->getPosition().Y
> xShape2
->getPosition().Y
);
137 CPPUNIT_ASSERT(xShape0
->getPosition().X
< xShape1
->getPosition().X
);
138 CPPUNIT_ASSERT(xShape2
->getPosition().X
< xShape3
->getPosition().X
);
139 CPPUNIT_ASSERT((xShape2
->getPosition().X
< xShape4
->getPosition().X
));
140 CPPUNIT_ASSERT((xShape3
->getPosition().X
> xShape4
->getPosition().X
));
143 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testChildren
)
145 createSdImpressDoc("pptx/smartart-children.pptx");
146 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
147 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup
->getCount());
149 uno::Reference
<drawing::XShapes
> xShapeGroup0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
150 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup0
->getCount());
151 uno::Reference
<text::XText
> xTextA(xShapeGroup0
->getByIndex(0), uno::UNO_QUERY_THROW
);
152 CPPUNIT_ASSERT_EQUAL(OUString("a"), xTextA
->getString());
154 uno::Reference
<drawing::XShapes
> xChildren0(xShapeGroup0
->getByIndex(1), uno::UNO_QUERY_THROW
);
155 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xChildren0
->getCount());
156 uno::Reference
<drawing::XShapes
> xChildB(xChildren0
->getByIndex(0), uno::UNO_QUERY_THROW
);
157 uno::Reference
<text::XText
> xTextB(xChildB
->getByIndex(0), uno::UNO_QUERY_THROW
);
158 CPPUNIT_ASSERT_EQUAL(OUString("b"), xTextB
->getString());
159 uno::Reference
<drawing::XShapes
> xChildC(xChildren0
->getByIndex(1), uno::UNO_QUERY_THROW
);
160 uno::Reference
<text::XText
> xTextC(xChildC
->getByIndex(0), uno::UNO_QUERY_THROW
);
161 CPPUNIT_ASSERT_EQUAL(OUString("c"), xTextC
->getString());
163 uno::Reference
<drawing::XShapes
> xShapeGroup1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
164 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup1
->getCount());
165 uno::Reference
<text::XText
> xTextX(xShapeGroup1
->getByIndex(0), uno::UNO_QUERY_THROW
);
166 CPPUNIT_ASSERT_EQUAL(OUString("x"), xTextX
->getString());
168 uno::Reference
<drawing::XShapes
> xChildren1(xShapeGroup1
->getByIndex(1), uno::UNO_QUERY_THROW
);
169 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xChildren1
->getCount());
170 uno::Reference
<drawing::XShapes
> xChildY(xChildren1
->getByIndex(0), uno::UNO_QUERY_THROW
);
171 uno::Reference
<text::XText
> xTextY(xChildY
->getByIndex(0), uno::UNO_QUERY_THROW
);
172 CPPUNIT_ASSERT_EQUAL(OUString("y"), xTextY
->getString());
173 uno::Reference
<drawing::XShapes
> xChildZ(xChildren1
->getByIndex(1), uno::UNO_QUERY_THROW
);
174 uno::Reference
<text::XText
> xTextZ(xChildZ
->getByIndex(0), uno::UNO_QUERY_THROW
);
175 CPPUNIT_ASSERT_EQUAL(OUString("z"), xTextZ
->getString());
178 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testText
)
180 createSdImpressDoc("pptx/smartart-text.pptx");
181 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
182 uno::Reference
<drawing::XShapes
> xShapeGroup2(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
184 uno::Reference
<text::XText
> xText0(xShapeGroup2
->getByIndex(0), uno::UNO_QUERY_THROW
);
185 CPPUNIT_ASSERT(xText0
->getString().isEmpty());
187 uno::Reference
<text::XText
> xText1(xShapeGroup2
->getByIndex(1), uno::UNO_QUERY_THROW
);
188 CPPUNIT_ASSERT_EQUAL(OUString("test"), xText1
->getString());
191 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testCnt
)
193 createSdImpressDoc("pptx/smartart-cnt.pptx");
194 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
195 sal_Int32 nCount
= xShapeGroup
->getCount();
196 sal_Int32 nCorrect
= 0;
197 for (sal_Int32 i
= 0; i
< nCount
; i
++)
199 uno::Reference
<text::XText
> xText(xShapeGroup
->getByIndex(i
), uno::UNO_QUERY
);
200 if (xText
.is() && !xText
->getString().isEmpty())
203 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nCorrect
);
206 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testDir
)
208 createSdImpressDoc("pptx/smartart-dir.pptx");
209 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
210 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup
->getCount());
212 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
213 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
214 CPPUNIT_ASSERT(xShape0
->getPosition().X
> xShape1
->getPosition().X
);
217 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf148665
)
219 // Without the fix in place, this test would have crashed at import time
220 createSdImpressDoc("pptx/tdf148665.pptx");
221 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
222 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xShapeGroup
->getCount());
224 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
225 CPPUNIT_ASSERT_EQUAL(OUString("\nFufufu"), xText0
->getString());
226 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
227 CPPUNIT_ASSERT_EQUAL(OUString("Susu"), xText1
->getString());
228 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
229 CPPUNIT_ASSERT_EQUAL(OUString("Sasa Haha"), xText2
->getString());
232 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf148921
)
234 createSdImpressDoc("pptx/tdf148921.pptx");
235 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
236 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup
->getCount());
238 uno::Reference
<drawing::XShapes
> xShapeGroup2(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
240 // Without the fix in place, this test would have failed with
243 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup2
->getCount());
245 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup2
->getByIndex(0), uno::UNO_QUERY_THROW
);
246 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup2
->getByIndex(1), uno::UNO_QUERY_THROW
);
248 CPPUNIT_ASSERT(xShape0
->getPosition().X
< xShape1
->getPosition().X
);
249 CPPUNIT_ASSERT(xShape0
->getPosition().Y
< xShape1
->getPosition().Y
);
250 CPPUNIT_ASSERT(xShape0
->getSize().Height
> xShape1
->getSize().Height
);
251 CPPUNIT_ASSERT(xShape0
->getSize().Width
> xShape1
->getSize().Width
);
254 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testMaxDepth
)
256 createSdImpressDoc("pptx/smartart-maxdepth.pptx");
257 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
258 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup
->getCount());
260 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
261 CPPUNIT_ASSERT_EQUAL(OUString("first"), xText0
->getString());
262 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
263 CPPUNIT_ASSERT_EQUAL(OUString("second"), xText1
->getString());
265 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
266 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
267 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().Y
,
268 xShape1
->getPosition().Y
); // Confirms shapes are in same Y axis-level.
271 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testRotation
)
273 createSdImpressDoc("pptx/smartart-rotation.pptx");
274 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
276 uno::Reference
<beans::XPropertySet
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
277 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape0
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
279 uno::Reference
<beans::XPropertySet
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
280 CPPUNIT_ASSERT_EQUAL(sal_Int32(24000),
281 xShape1
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
283 uno::Reference
<beans::XPropertySet
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
284 CPPUNIT_ASSERT_EQUAL(sal_Int32(12000),
285 xShape2
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
288 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTextAutoRotation
)
290 createSdImpressDoc("pptx/smartart-autoTxRot.pptx");
292 auto testText
= [&](int pageNo
, sal_Int32 txtNo
, const OUString
& expTx
, sal_Int32 expShRot
,
293 sal_Int32 expTxRot
) {
294 OString msgText
= "Page: " + OString::number(pageNo
) + " text: " + OString::number(txtNo
);
295 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, pageNo
),
296 uno::UNO_QUERY_THROW
);
298 txtNo
++; //skip background
299 uno::Reference
<text::XText
> xTxt(xShapeGroup
->getByIndex(txtNo
), uno::UNO_QUERY_THROW
);
300 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), expTx
, xTxt
->getString());
301 uno::Reference
<beans::XPropertySet
> xTxtProps(xTxt
, uno::UNO_QUERY_THROW
);
302 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), expShRot
,
303 xTxtProps
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
305 auto aGeomPropSeq
= xTxtProps
->getPropertyValue("CustomShapeGeometry")
306 .get
<uno::Sequence
<beans::PropertyValue
>>();
307 comphelper::SequenceAsHashMap
aCustomShapeGeometry(aGeomPropSeq
);
309 auto it
= aCustomShapeGeometry
.find("TextPreRotateAngle");
310 if (it
== aCustomShapeGeometry
.end())
312 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), sal_Int32(0), expTxRot
);
316 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), expTxRot
, it
->second
.get
<sal_Int32
>());
320 // Slide 1: absent autoTxRot => defaults to "upr"
321 testText(0, 0, "a", 0, 0);
322 testText(0, 1, "b", 33750, 0);
323 testText(0, 2, "c", 31500, 0);
324 testText(0, 3, "d", 29250, 90);
325 testText(0, 4, "e", 27000, 90);
326 testText(0, 5, "f", 24750, 90);
327 testText(0, 6, "g", 22500, 180);
328 testText(0, 7, "h", 20250, 180);
329 testText(0, 8, "i", 18000, 180);
330 testText(0, 9, "j", 15750, 180);
331 testText(0, 10, "k", 13500, 180);
332 testText(0, 11, "l", 11250, 270);
333 testText(0, 12, "m", 9000, 270);
334 testText(0, 13, "n", 6750, 270);
335 testText(0, 14, "o", 4500, 0);
336 testText(0, 15, "p", 2250, 0);
338 // Slide 2: autoTxRot == "none"
339 testText(1, 0, "a", 0, 0);
340 testText(1, 1, "b", 33750, 0);
341 testText(1, 2, "c", 31500, 0);
342 testText(1, 3, "d", 29250, 0);
343 testText(1, 4, "e", 27000, 0);
344 testText(1, 5, "f", 24750, 0);
345 testText(1, 6, "g", 22500, 0);
346 testText(1, 7, "h", 20250, 0);
347 testText(1, 8, "i", 18000, 0);
348 testText(1, 9, "j", 15750, 0);
349 testText(1, 10, "k", 13500, 0);
350 testText(1, 11, "l", 11250, 0);
351 testText(1, 12, "m", 9000, 0);
352 testText(1, 13, "n", 6750, 0);
353 testText(1, 14, "o", 4500, 0);
354 testText(1, 15, "p", 2250, 0);
356 // Slide 3: autoTxRot == "grav"
357 testText(2, 0, "a", 0, 0);
358 testText(2, 1, "b", 33750, 0);
359 testText(2, 2, "c", 31500, 0);
360 testText(2, 3, "d", 29250, 0);
361 testText(2, 4, "e", 27000, 0);
362 testText(2, 5, "f", 24750, 180);
363 testText(2, 6, "g", 22500, 180);
364 testText(2, 7, "h", 20250, 180);
365 testText(2, 8, "i", 18000, 180);
366 testText(2, 9, "j", 15750, 180);
367 testText(2, 10, "k", 13500, 180);
368 testText(2, 11, "l", 11250, 180);
369 testText(2, 12, "m", 9000, 0);
370 testText(2, 13, "n", 6750, 0);
371 testText(2, 14, "o", 4500, 0);
372 testText(2, 15, "p", 2250, 0);
375 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBasicProcess
)
377 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
380 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testPyramid
)
382 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
385 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testPyramidOneChild
)
387 // Load a document with a pyra algorithm in it.
388 // Without the accompanying fix in place, this test would have crashed.
389 createSdImpressDoc("pptx/smartart-pyramid-1child.pptx");
390 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
391 uno::Reference
<text::XTextRange
> xText(getChildShape(getChildShape(xGroup
, 1), 1),
393 // Verify that the text of the only child is imported correctly.
394 CPPUNIT_ASSERT_EQUAL(OUString("A"), xText
->getString());
397 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testChevron
)
399 createSdImpressDoc("pptx/smartart-chevron.pptx");
400 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
401 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xShapeGroup
->getCount());
403 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
404 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0
->getString());
405 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
406 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1
->getString());
407 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
408 CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2
->getString());
410 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
411 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
412 uno::Reference
<drawing::XShape
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
414 CPPUNIT_ASSERT(xShape0
->getPosition().X
< xShape1
->getPosition().X
);
415 CPPUNIT_ASSERT(xShape1
->getPosition().X
< xShape2
->getPosition().X
);
416 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().Y
, xShape1
->getPosition().Y
);
417 CPPUNIT_ASSERT_EQUAL(xShape1
->getPosition().Y
, xShape2
->getPosition().Y
);
420 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testCycle
)
422 createSdImpressDoc("pptx/smartart-cycle.pptx");
423 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
424 CPPUNIT_ASSERT(xGroup
.is());
426 // 11 children: background, 5 shapes, 5 connectors
427 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(11), xGroup
->getCount());
429 uno::Reference
<drawing::XShape
> xShape0(xGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
430 uno::Reference
<drawing::XShape
> xShapeConn(xGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
431 uno::Reference
<drawing::XShape
> xShape2(xGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
433 uno::Reference
<text::XText
> xText0(xShape0
, uno::UNO_QUERY_THROW
);
434 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0
->getString());
435 uno::Reference
<text::XText
> xText2(xShape2
, uno::UNO_QUERY_THROW
);
436 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText2
->getString());
438 // xShapeConn is connector between shapes 0 and 2
439 // it should lay between them and be rotated 0 -> 2
440 CPPUNIT_ASSERT(xShape0
->getPosition().X
< xShapeConn
->getPosition().X
);
441 CPPUNIT_ASSERT(xShape0
->getPosition().Y
< xShapeConn
->getPosition().Y
);
442 CPPUNIT_ASSERT(xShapeConn
->getPosition().Y
< xShape2
->getPosition().Y
);
443 uno::Reference
<beans::XPropertySet
> xPropSetConn(xShapeConn
, uno::UNO_QUERY_THROW
);
444 CPPUNIT_ASSERT_EQUAL(sal_Int32(32400),
445 xPropSetConn
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
447 // Make sure that we have an arrow shape between the two shapes
448 comphelper::SequenceAsHashMap
aCustomShapeGeometry(
449 xPropSetConn
->getPropertyValue("CustomShapeGeometry"));
450 CPPUNIT_ASSERT(aCustomShapeGeometry
["Type"].has
<OUString
>());
451 OUString aType
= aCustomShapeGeometry
["Type"].get
<OUString
>();
452 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-rightArrow"), aType
);
455 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testHierarchy
)
457 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
460 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testmatrix
)
462 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
465 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testvenndiagram
)
467 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
470 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testInvertedPyramid
)
472 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
475 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testMultidirectional
)
477 // similar document as cycle, but arrows are pointing in both directions
478 createSdImpressDoc("pptx/smartart-multidirectional.pptx");
479 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
480 CPPUNIT_ASSERT(xGroup
.is());
482 // 7 children: background, 3 shapes, 3 connectors
483 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(7), xGroup
->getCount());
485 uno::Reference
<drawing::XShape
> xShapeConn(xGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
486 uno::Reference
<beans::XPropertySet
> xPropSetConn(xShapeConn
, uno::UNO_QUERY_THROW
);
487 comphelper::SequenceAsHashMap
aCustomShapeGeometry(
488 xPropSetConn
->getPropertyValue("CustomShapeGeometry"));
489 CPPUNIT_ASSERT(aCustomShapeGeometry
["Type"].has
<OUString
>());
490 OUString aType
= aCustomShapeGeometry
["Type"].get
<OUString
>();
491 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-leftRightArrow"), aType
);
494 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testHorizontalBulletList
)
496 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
499 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testEquation
)
501 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
504 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBasicRadicals
)
506 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
509 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testSegmentedCycle
)
511 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
514 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBaseRtoL
)
516 createSdImpressDoc("pptx/smartart-rightoleftblockdiagram.pptx");
517 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
518 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xShapeGroup
->getCount());
520 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
521 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0
->getString());
522 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
523 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1
->getString());
524 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
525 CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2
->getString());
526 uno::Reference
<text::XText
> xText3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
527 CPPUNIT_ASSERT_EQUAL(OUString("d"), xText3
->getString());
528 uno::Reference
<text::XText
> xText4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
529 CPPUNIT_ASSERT_EQUAL(OUString("e"), xText4
->getString());
531 uno::Reference
<beans::XPropertySet
> xShape(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
534 xShape
->getPropertyValue("FillColor") >>= nFillColor
;
535 CPPUNIT_ASSERT_EQUAL(Color(0x4F81BD), nFillColor
);
537 sal_Int16 nParaAdjust
= 0;
538 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
539 uno::Reference
<beans::XPropertySet
> xPropSet(xParagraph
, uno::UNO_QUERY_THROW
);
540 xPropSet
->getPropertyValue("ParaAdjust") >>= nParaAdjust
;
541 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
,
542 static_cast<style::ParagraphAdjust
>(nParaAdjust
));
544 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
545 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
546 uno::Reference
<drawing::XShape
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
547 uno::Reference
<drawing::XShape
> xShape3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
548 uno::Reference
<drawing::XShape
> xShape4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
559 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().Y
, xShape1
->getPosition().Y
);
560 CPPUNIT_ASSERT_EQUAL(xShape2
->getPosition().Y
, xShape3
->getPosition().Y
);
562 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().X
, xShape2
->getPosition().X
);
563 CPPUNIT_ASSERT_EQUAL(xShape1
->getPosition().X
, xShape3
->getPosition().X
);
565 CPPUNIT_ASSERT_EQUAL(xShape2
->getPosition().Y
- xShape0
->getPosition().Y
,
566 xShape4
->getPosition().Y
- xShape2
->getPosition().Y
);
567 CPPUNIT_ASSERT_EQUAL(xShape1
->getPosition().X
- xShape0
->getPosition().X
,
568 xShape3
->getPosition().X
- xShape2
->getPosition().X
);
569 CPPUNIT_ASSERT_DOUBLES_EQUAL(xShape2
->getPosition().X
+ xShape3
->getPosition().X
,
570 2 * xShape4
->getPosition().X
, 1);
572 CPPUNIT_ASSERT(xShape2
->getPosition().Y
> xShape0
->getPosition().Y
);
573 CPPUNIT_ASSERT(xShape4
->getPosition().Y
> xShape2
->getPosition().Y
);
574 CPPUNIT_ASSERT(xShape0
->getPosition().X
> xShape1
->getPosition().X
);
575 CPPUNIT_ASSERT(xShape2
->getPosition().X
> xShape3
->getPosition().X
);
576 CPPUNIT_ASSERT((xShape2
->getPosition().X
> xShape4
->getPosition().X
));
577 CPPUNIT_ASSERT((xShape3
->getPosition().X
< xShape4
->getPosition().X
));
580 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testVerticalBoxList
)
582 createSdImpressDoc("pptx/smartart-vertical-box-list.pptx");
583 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
584 // Without the accompanying fix in place, this test would have failed with
586 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xShapeGroup
->getCount());
588 uno::Reference
<drawing::XShapes
> xFirstChild(xShapeGroup
->getByIndex(1), uno::UNO_QUERY
);
589 CPPUNIT_ASSERT(xFirstChild
.is());
590 uno::Reference
<drawing::XShape
> xParentText(xFirstChild
->getByIndex(1), uno::UNO_QUERY
);
591 CPPUNIT_ASSERT(xParentText
.is());
592 // Without the accompanying fix in place, this test would have failed with
593 // 'actual: 7361', i.e. the width was not the 70% of the parent as the
594 // constraint wanted.
595 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(11852), xParentText
->getSize().Width
);
597 uno::Reference
<drawing::XShape
> xChildText(xShapeGroup
->getByIndex(2), uno::UNO_QUERY
);
598 CPPUNIT_ASSERT(xChildText
.is());
599 // Without the accompanying fix in place, this test would have failed with
600 // 'actual: 7361' (and with the fix: 'actual: 16932', i.e. the width of the
602 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(10000), xChildText
->getSize().Width
);
604 // Assert that the right edge of the parent text is closer to the slide
605 // boundary than the right edge of the parent text.
606 // Without the accompanying fix in place, this test would have failed with
607 // 'Expected greater than: 25656, Actual : 21165'.
608 CPPUNIT_ASSERT_GREATER(xParentText
->getPosition().X
+ xParentText
->getSize().Width
,
609 xChildText
->getPosition().X
+ xChildText
->getSize().Width
);
612 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testVerticalBracketList
)
614 createSdImpressDoc("pptx/vertical-bracket-list.pptx");
615 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
616 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xShapeGroup
->getCount());
618 uno::Reference
<drawing::XShapes
> xFirstChild(xShapeGroup
->getByIndex(1), uno::UNO_QUERY
);
619 CPPUNIT_ASSERT(xFirstChild
.is());
620 // Without the accompanying fix in place, this test would have failed with
621 // 'actual: 2', i.e. one child shape (with its "A" text) was missing.
622 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xFirstChild
->getCount());
625 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTableList
)
627 createSdImpressDoc("pptx/table-list.pptx");
628 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
629 CPPUNIT_ASSERT(xShapeGroup
.is());
630 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xShapeGroup
->getCount());
632 uno::Reference
<text::XText
> xParentText(xShapeGroup
->getByIndex(1), uno::UNO_QUERY
);
633 CPPUNIT_ASSERT(xParentText
.is());
634 CPPUNIT_ASSERT_EQUAL(OUString("Parent"), xParentText
->getString());
635 uno::Reference
<drawing::XShape
> xParent(xParentText
, uno::UNO_QUERY
);
636 CPPUNIT_ASSERT(xParent
.is());
637 int nParentRight
= xParent
->getPosition().X
+ xParent
->getSize().Width
;
639 uno::Reference
<drawing::XShapes
> xChildren(xShapeGroup
->getByIndex(2), uno::UNO_QUERY
);
640 CPPUNIT_ASSERT(xChildren
.is());
641 uno::Reference
<text::XText
> xChild2Text(xChildren
->getByIndex(1), uno::UNO_QUERY
);
642 CPPUNIT_ASSERT(xChild2Text
.is());
643 CPPUNIT_ASSERT_EQUAL(OUString("Child 2"), xChild2Text
->getString());
644 uno::Reference
<drawing::XShape
> xChild2(xChild2Text
, uno::UNO_QUERY
);
645 CPPUNIT_ASSERT(xChild2
.is());
646 int nChild2Right
= xChild2
->getPosition().X
+ xChild2
->getSize().Width
;
648 // Without the accompanying fix in place, this test would have failed with
649 // 'Expected less than: 100, Actual : 22014', i.e. the second child was
650 // shifted to the right too much.
651 CPPUNIT_ASSERT_LESS(100, abs(nChild2Right
- nParentRight
));
654 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testAccentProcess
)
656 createSdImpressDoc("pptx/smartart-accent-process.pptx");
657 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
658 CPPUNIT_ASSERT(xGroup
.is());
659 // 3 children: first pair, connector, second pair.
660 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xGroup
->getCount());
661 uno::Reference
<drawing::XShape
> xGroupShape(xGroup
, uno::UNO_QUERY
);
662 CPPUNIT_ASSERT(xGroupShape
.is());
664 // The pair is a parent (shape + text) and a child, so 3 shapes in total.
665 // The order is important, first is at the back, last is at the front.
666 uno::Reference
<drawing::XShapes
> xFirstPair(xGroup
->getByIndex(1), uno::UNO_QUERY
);
667 CPPUNIT_ASSERT(xFirstPair
.is());
668 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xFirstPair
->getCount());
670 uno::Reference
<text::XText
> xFirstParentText(xFirstPair
->getByIndex(1), uno::UNO_QUERY
);
671 CPPUNIT_ASSERT(xFirstParentText
.is());
672 CPPUNIT_ASSERT_EQUAL(OUString("a"), xFirstParentText
->getString());
673 uno::Reference
<drawing::XShape
> xFirstParent(xFirstParentText
, uno::UNO_QUERY
);
674 CPPUNIT_ASSERT(xFirstParent
.is());
675 int nFirstParentTop
= xFirstParent
->getPosition().Y
;
677 uno::Reference
<text::XText
> xFirstChildText(xFirstPair
->getByIndex(2), uno::UNO_QUERY
);
678 CPPUNIT_ASSERT(xFirstChildText
.is());
679 CPPUNIT_ASSERT_EQUAL(OUString("b"), xFirstChildText
->getString());
680 uno::Reference
<drawing::XShape
> xFirstChild(xFirstChildText
, uno::UNO_QUERY
);
681 CPPUNIT_ASSERT(xFirstChildText
.is());
684 uno::Reference
<container::XEnumerationAccess
> xParasAccess(xFirstChildText
, uno::UNO_QUERY
);
685 uno::Reference
<container::XEnumeration
> xParas
= xParasAccess
->createEnumeration();
686 uno::Reference
<beans::XPropertySet
> xPara(xParas
->nextElement(), uno::UNO_QUERY
);
687 // Without the accompanying fix in place, this test would have failed
688 // with 'Expected: 0; Actual : 1270', i.e. there was a large
689 // unexpected left margin.
690 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0),
691 xPara
->getPropertyValue("ParaLeftMargin").get
<sal_Int32
>());
693 uno::Reference
<container::XIndexAccess
> xRules(xPara
->getPropertyValue("NumberingRules"),
695 comphelper::SequenceAsHashMap
aRule(xRules
->getByIndex(0));
696 CPPUNIT_ASSERT_EQUAL(OUString(u
"•"), aRule
["BulletChar"].get
<OUString
>());
699 int nFirstChildTop
= xFirstChild
->getPosition().Y
;
700 int nFirstChildRight
= xFirstChild
->getPosition().X
+ xFirstChild
->getSize().Width
;
702 // First child is below the first parent.
703 // Without the accompanying fix in place, this test would have failed with
704 // 'Expected less than: 3881, Actual : 3881', i.e. xFirstChild was not
705 // below xFirstParent (a good position is 9081).
706 CPPUNIT_ASSERT_LESS(nFirstChildTop
, nFirstParentTop
);
708 // Make sure that we have an arrow shape between the two pairs.
709 uno::Reference
<beans::XPropertySet
> xArrow(xGroup
->getByIndex(2), uno::UNO_QUERY
);
710 CPPUNIT_ASSERT(xArrow
.is());
711 comphelper::SequenceAsHashMap
aCustomShapeGeometry(
712 xArrow
->getPropertyValue("CustomShapeGeometry"));
713 // Without the accompanying fix in place, this test would have failed, i.e.
714 // the custom shape lacked a type -> arrow was not visible.
715 CPPUNIT_ASSERT(aCustomShapeGeometry
["Type"].has
<OUString
>());
716 OUString aType
= aCustomShapeGeometry
["Type"].get
<OUString
>();
717 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-rightArrow"), aType
);
719 // Make sure that height of the arrow is less than its width.
720 uno::Reference
<drawing::XShape
> xArrowShape(xArrow
, uno::UNO_QUERY
);
721 CPPUNIT_ASSERT(xArrowShape
.is());
722 awt::Size aArrowSize
= xArrowShape
->getSize();
723 CPPUNIT_ASSERT_LESS(aArrowSize
.Width
, aArrowSize
.Height
);
725 uno::Reference
<drawing::XShapes
> xSecondPair(xGroup
->getByIndex(3), uno::UNO_QUERY
);
726 CPPUNIT_ASSERT(xSecondPair
.is());
727 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xSecondPair
->getCount());
728 uno::Reference
<text::XText
> xSecondParentText(xSecondPair
->getByIndex(1), uno::UNO_QUERY
);
729 CPPUNIT_ASSERT(xFirstParentText
.is());
730 // Without the accompanying fix in place, this test would have failed with
731 // 'Expected: cc; Actual : c', i.e. non-first runs on data points were ignored.
732 CPPUNIT_ASSERT_EQUAL(OUString("cc"), xSecondParentText
->getString());
733 uno::Reference
<drawing::XShape
> xSecondParent(xSecondParentText
, uno::UNO_QUERY
);
734 CPPUNIT_ASSERT(xSecondParent
.is());
735 int nSecondParentLeft
= xSecondParent
->getPosition().X
;
736 // Without the accompanying fix in place, this test would have failed with
737 // 'Expected less than: 12700; Actual : 18540', i.e. the "b" and "c"
738 // shapes overlapped.
739 CPPUNIT_ASSERT_LESS(nSecondParentLeft
, nFirstChildRight
);
742 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testContinuousBlockProcess
)
744 createSdImpressDoc("pptx/smartart-continuous-block-process.pptx");
745 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
746 CPPUNIT_ASSERT(xGroup
.is());
747 // 3 children: diagram background, background arrow, foreground.
748 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xGroup
->getCount());
750 uno::Reference
<drawing::XShapes
> xLinear(xGroup
->getByIndex(2), uno::UNO_QUERY
);
751 CPPUNIT_ASSERT(xLinear
.is());
752 // 3 children: A, B and C.
753 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xLinear
->getCount());
755 uno::Reference
<text::XText
> xA(xLinear
->getByIndex(0), uno::UNO_QUERY
);
756 CPPUNIT_ASSERT(xA
.is());
757 CPPUNIT_ASSERT_EQUAL(OUString("A"), xA
->getString());
758 uno::Reference
<drawing::XShape
> xAShape(xA
, uno::UNO_QUERY
);
759 CPPUNIT_ASSERT(xAShape
.is());
760 // Without the accompanying fix in place, this test would have failed: the
761 // theoretically correct value is 5462 mm100 (16933 is the total width, and
762 // need to divide that to 1, 0.5, 1, 0.5 and 1 units), while the old value
763 // was 4703 and the new one is 5461.
764 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(5000), xAShape
->getSize().Width
);
767 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testOrgChart
)
769 // Simple org chart with 1 manager and 1 employee only.
770 createSdImpressDoc("pptx/smartart-org-chart.pptx");
771 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
772 CPPUNIT_ASSERT(xGroup
.is());
774 uno::Reference
<text::XText
> xManager(
775 getChildShape(getChildShape(getChildShape(xGroup
, 1), 0), 0), uno::UNO_QUERY
);
776 CPPUNIT_ASSERT(xManager
.is());
777 // Without the accompanying fix in place, this test would have failed: this
778 // was just "Manager", and the second paragraph was lost.
779 CPPUNIT_ASSERT_EQUAL(OUString("Manager\nSecond para"), xManager
->getString());
781 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xManager
, uno::UNO_QUERY
);
782 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
783 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
784 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xPara
, uno::UNO_QUERY
);
785 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
786 uno::Reference
<beans::XPropertySet
> xRun(xRunEnum
->nextElement(), uno::UNO_QUERY
);
788 xRun
->getPropertyValue("CharColor") >>= nActualColor
;
789 // Without the accompanying fix in place, this test would have failed: the
790 // "Manager" font color was black, not white.
791 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nActualColor
);
793 uno::Reference
<drawing::XShape
> xManagerShape(xManager
, uno::UNO_QUERY
);
794 CPPUNIT_ASSERT(xManagerShape
.is());
796 awt::Point aManagerPos
= xManagerShape
->getPosition();
797 awt::Size aManagerSize
= xManagerShape
->getSize();
799 // Make sure that the manager has 2 employees.
800 uno::Reference
<drawing::XShapes
> xEmployees(getChildShape(getChildShape(xGroup
, 1), 2),
802 CPPUNIT_ASSERT(xEmployees
.is());
803 // 4 children: connector, 1st employee, connector, 2nd employee.
804 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xEmployees
->getCount());
806 uno::Reference
<text::XText
> xEmployee(
808 getChildShape(getChildShape(getChildShape(getChildShape(xGroup
, 1), 2), 1), 0), 0),
810 CPPUNIT_ASSERT(xEmployee
.is());
811 CPPUNIT_ASSERT_EQUAL(OUString("Employee"), xEmployee
->getString());
813 uno::Reference
<drawing::XShape
> xEmployeeShape(xEmployee
, uno::UNO_QUERY
);
814 CPPUNIT_ASSERT(xEmployeeShape
.is());
816 awt::Point aEmployeePos
= xEmployeeShape
->getPosition();
817 awt::Size aEmployeeSize
= xEmployeeShape
->getSize();
819 CPPUNIT_ASSERT_EQUAL(aManagerPos
.X
, aEmployeePos
.X
);
821 // Without the accompanying fix in place, this test would have failed: the
822 // two shapes were overlapping, i.e. "manager" was not above "employee".
823 CPPUNIT_ASSERT_GREATER(aManagerPos
.Y
, aEmployeePos
.Y
);
825 // Make sure that the second employee is on the right of the first one.
826 // Without the accompanying fix in place, this test would have failed, as
827 // the second employee was below the first one.
828 uno::Reference
<text::XText
> xEmployee2(
830 getChildShape(getChildShape(getChildShape(getChildShape(xGroup
, 1), 2), 3), 0), 0),
832 CPPUNIT_ASSERT(xEmployee2
.is());
833 CPPUNIT_ASSERT_EQUAL(OUString("Employee2"), xEmployee2
->getString());
835 uno::Reference
<drawing::XShape
> xEmployee2Shape(xEmployee2
, uno::UNO_QUERY
);
836 CPPUNIT_ASSERT(xEmployee2Shape
.is());
838 awt::Point aEmployee2Pos
= xEmployee2Shape
->getPosition();
839 //awt::Size aEmployee2Size = xEmployee2Shape->getSize();
840 CPPUNIT_ASSERT_GREATER(aEmployeePos
.X
, aEmployee2Pos
.X
);
842 // Make sure that assistant is above employees.
843 uno::Reference
<text::XText
> xAssistant(
845 getChildShape(getChildShape(getChildShape(getChildShape(xGroup
, 1), 1), 1), 0), 0),
847 CPPUNIT_ASSERT_EQUAL(OUString("Assistant"), xAssistant
->getString());
849 uno::Reference
<drawing::XShape
> xAssistantShape(xAssistant
, uno::UNO_QUERY
);
850 CPPUNIT_ASSERT(xAssistantShape
.is());
852 awt::Point aAssistantPos
= xAssistantShape
->getPosition();
853 // Without the accompanying fix in place, this test would have failed: the
854 // assistant shape was below the employee shape.
855 CPPUNIT_ASSERT_GREATER(aAssistantPos
.Y
, aEmployeePos
.Y
);
857 // Make sure the connector of the assistant is above the shape.
858 uno::Reference
<drawing::XShape
> xAssistantConnector
859 = getChildShape(getChildShape(getChildShape(xGroup
, 1), 1), 0);
860 CPPUNIT_ASSERT(xAssistantConnector
.is());
861 //awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition();
862 // This failed, the vertical positions of the connector and the shape of
863 // the assistant were the same.
864 //CPPUNIT_ASSERT_LESS(aAssistantPos.Y, aAssistantConnectorPos.Y);
865 // connectors are hidden as they don't work correctly
867 // Make sure the height of xManager and xManager2 is the same.
868 uno::Reference
<text::XText
> xManager2(
869 getChildShape(getChildShape(getChildShape(xGroup
, 2), 0), 0), uno::UNO_QUERY
);
870 CPPUNIT_ASSERT(xManager2
.is());
871 CPPUNIT_ASSERT_EQUAL(OUString("Manager2"), xManager2
->getString());
873 uno::Reference
<drawing::XShape
> xManager2Shape(xManager2
, uno::UNO_QUERY
);
874 CPPUNIT_ASSERT(xManager2Shape
.is());
876 awt::Size aManager2Size
= xManager2Shape
->getSize();
877 // Without the accompanying fix in place, this test would have failed:
878 // xManager2's height was 3 times larger than xManager's height.
879 CPPUNIT_ASSERT_EQUAL(aManagerSize
.Height
, aManager2Size
.Height
);
881 // Make sure the employee nodes use the free space on the right, since
882 // manager2 has no assistants / employees.
883 //CPPUNIT_ASSERT_GREATER(aManagerSize.Width, aEmployeeSize.Width + aEmployee2Size.Width);
884 // currently disabled as causes problems in complex charts
886 // Without the accompanying fix in place, this test would have failed: an
887 // employee was exactly the third of the total height, without any spacing.
888 CPPUNIT_ASSERT_LESS(xGroup
->getSize().Height
/ 3, aEmployeeSize
.Height
);
891 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testCycleMatrix
)
893 createSdImpressDoc("pptx/smartart-cycle-matrix.pptx");
894 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
895 CPPUNIT_ASSERT(xGroup
.is());
897 // Without the accompanying fix in place, this test would have failed: the height was 12162,
898 // which is not the mm100 equivalent of the 4064000 EMU in the input file.
899 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(11288), xGroup
->getSize().Height
);
901 uno::Reference
<text::XText
> xA1(getChildShape(getChildShape(xGroup
, 2), 0), uno::UNO_QUERY
);
902 CPPUNIT_ASSERT(xA1
.is());
903 CPPUNIT_ASSERT_EQUAL(OUString("A1"), xA1
->getString());
905 // Test fill color of B1, should be orange.
906 uno::Reference
<text::XText
> xB1(getChildShape(getChildShape(xGroup
, 2), 1), uno::UNO_QUERY
);
907 CPPUNIT_ASSERT(xB1
.is());
908 CPPUNIT_ASSERT_EQUAL(OUString("B1"), xB1
->getString());
910 uno::Reference
<beans::XPropertySet
> xB1Props(xB1
, uno::UNO_QUERY
);
911 CPPUNIT_ASSERT(xB1Props
.is());
913 xB1Props
->getPropertyValue("FillColor") >>= nFillColor
;
914 // Without the accompanying fix in place, this test would have failed: the background color was
915 // 0x4f81bd, i.e. blue, not orange.
916 CPPUNIT_ASSERT_EQUAL(Color(0xf79646), nFillColor
);
918 // Without the accompanying fix in place, this test would have failed: the
919 // content of the "A2" shape was lost.
920 uno::Reference
<text::XText
> xA2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 0), 1),
922 CPPUNIT_ASSERT(xA2
.is());
923 CPPUNIT_ASSERT_EQUAL(OUString("A2"), xA2
->getString());
925 // Test that the layout of shapes is like this:
929 uno::Reference
<drawing::XShape
> xA2Shape(xA2
, uno::UNO_QUERY
);
930 CPPUNIT_ASSERT(xA2Shape
.is());
932 uno::Reference
<text::XText
> xB2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 1), 1),
934 CPPUNIT_ASSERT(xB2
.is());
935 CPPUNIT_ASSERT_EQUAL(OUString("B2"), xB2
->getString());
936 uno::Reference
<drawing::XShape
> xB2Shape(xB2
, uno::UNO_QUERY
);
937 CPPUNIT_ASSERT(xB2Shape
.is());
939 // Test line color of B2, should be orange.
940 uno::Reference
<beans::XPropertySet
> xB2Props(xB2
, uno::UNO_QUERY
);
941 CPPUNIT_ASSERT(xB2Props
.is());
942 Color nLineColor
= 0;
943 xB2Props
->getPropertyValue("LineColor") >>= nLineColor
;
944 CPPUNIT_ASSERT_EQUAL(Color(0xf79646), nLineColor
);
946 uno::Reference
<text::XText
> xC2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 2), 1),
948 CPPUNIT_ASSERT(xC2
.is());
949 // Without the accompanying fix in place, this test would have failed, i.e. the order of the
950 // lines in the shape were wrong: C2-1\nC2-4\nC2-3\nC2-2.
951 CPPUNIT_ASSERT_EQUAL(OUString("C2-1\nC2-2\nC2-3\nC2-4"), xC2
->getString());
952 uno::Reference
<drawing::XShape
> xC2Shape(xC2
, uno::UNO_QUERY
);
953 CPPUNIT_ASSERT(xC2Shape
.is());
955 uno::Reference
<text::XText
> xD2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 3), 1),
957 CPPUNIT_ASSERT(xD2
.is());
958 CPPUNIT_ASSERT_EQUAL(OUString("D2"), xD2
->getString());
959 uno::Reference
<drawing::XShape
> xD2Shape(xD2
, uno::UNO_QUERY
);
960 CPPUNIT_ASSERT(xD2Shape
.is());
962 // Without the accompanying fix in place, this test would have failed, i.e.
963 // the A2 and B2 shapes had the same horizontal position, while B2 should
964 // be on the right of A2.
965 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().X
, xB2Shape
->getPosition().X
);
966 CPPUNIT_ASSERT_EQUAL(xA2Shape
->getPosition().Y
, xB2Shape
->getPosition().Y
);
967 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().X
, xC2Shape
->getPosition().X
);
968 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().Y
, xC2Shape
->getPosition().Y
);
969 CPPUNIT_ASSERT_EQUAL(xA2Shape
->getPosition().X
, xD2Shape
->getPosition().X
);
970 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().Y
, xD2Shape
->getPosition().Y
);
972 // Without the accompanying fix in place, this test would have failed: width was expected to be
973 // 4887, was actually 7331.
974 uno::Reference
<drawing::XShape
> xA1Shape(xA1
, uno::UNO_QUERY
);
975 CPPUNIT_ASSERT(xA1Shape
.is());
976 CPPUNIT_ASSERT_EQUAL(xA1Shape
->getSize().Height
, xA1Shape
->getSize().Width
);
979 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testPictureStrip
)
981 createSdImpressDoc("pptx/smartart-picture-strip.pptx");
982 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
983 CPPUNIT_ASSERT(xGroup
.is());
985 uno::Reference
<beans::XPropertySet
> xFirstImage(getChildShape(getChildShape(xGroup
, 1), 1),
987 CPPUNIT_ASSERT(xFirstImage
.is());
988 drawing::FillStyle eFillStyle
= drawing::FillStyle_NONE
;
989 xFirstImage
->getPropertyValue("FillStyle") >>= eFillStyle
;
990 // Without the accompanying fix in place, this test would have failed: fill style was solid, not
992 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, eFillStyle
);
994 uno::Reference
<graphic::XGraphic
> xGraphic
;
995 xFirstImage
->getPropertyValue("FillBitmap") >>= xGraphic
;
996 Graphic
aFirstGraphic(xGraphic
);
998 uno::Reference
<beans::XPropertySet
> xSecondImage(getChildShape(getChildShape(xGroup
, 2), 1),
1000 CPPUNIT_ASSERT(xSecondImage
.is());
1001 eFillStyle
= drawing::FillStyle_NONE
;
1002 xSecondImage
->getPropertyValue("FillStyle") >>= eFillStyle
;
1003 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, eFillStyle
);
1005 xSecondImage
->getPropertyValue("FillBitmap") >>= xGraphic
;
1006 Graphic
aSecondGraphic(xGraphic
);
1007 // Without the accompanying fix in place, this test would have failed: both xFirstImage and
1008 // xSecondImage had the bitmap fill from the second shape.
1009 CPPUNIT_ASSERT(aFirstGraphic
.GetChecksum() != aSecondGraphic
.GetChecksum());
1011 // Test that the 3 images are in a single column, in 3 rows.
1012 uno::Reference
<drawing::XShape
> xFirstImageShape(xFirstImage
, uno::UNO_QUERY
);
1013 CPPUNIT_ASSERT(xFirstImage
.is());
1014 uno::Reference
<drawing::XShape
> xSecondImageShape(xSecondImage
, uno::UNO_QUERY
);
1015 CPPUNIT_ASSERT(xSecondImage
.is());
1016 uno::Reference
<drawing::XShape
> xThirdImageShape
= getChildShape(getChildShape(xGroup
, 3), 1);
1017 CPPUNIT_ASSERT(xThirdImageShape
.is());
1018 // Without the accompanying fix in place, this test would have failed: the first and the second
1019 // image were in the same row.
1020 CPPUNIT_ASSERT_EQUAL(xFirstImageShape
->getPosition().X
, xSecondImageShape
->getPosition().X
);
1021 CPPUNIT_ASSERT_EQUAL(xSecondImageShape
->getPosition().X
, xThirdImageShape
->getPosition().X
);
1022 CPPUNIT_ASSERT_GREATER(xFirstImageShape
->getPosition().Y
, xSecondImageShape
->getPosition().Y
);
1023 CPPUNIT_ASSERT_GREATER(xSecondImageShape
->getPosition().Y
, xThirdImageShape
->getPosition().Y
);
1025 // Make sure that the title shape doesn't overlap with the diagram.
1026 // Note that real "no overlap" is asserted here, though in fact what we want is a less strict
1027 // condition: that no text part of the title shape and the diagram overlaps.
1028 uno::Reference
<drawing::XShape
> xTitle(getShapeFromPage(1, 0), uno::UNO_QUERY
);
1029 CPPUNIT_ASSERT(xTitle
.is());
1030 // Without the accompanying fix in place, this test would have failed with 'Expected greater
1031 // than: 2873; Actual : 2320', i.e. the title shape and the diagram overlapped.
1032 uno::Reference
<drawing::XShape
> xFirstPair
= getChildShape(xGroup
, 1);
1033 CPPUNIT_ASSERT_GREATER(xTitle
->getPosition().Y
+ xTitle
->getSize().Height
,
1034 xFirstPair
->getPosition().Y
);
1036 // Make sure that left margin is 60% of width (if you count width in points and margin in mms).
1037 uno::Reference
<beans::XPropertySet
> xFirstText(getChildShape(getChildShape(xGroup
, 1), 0),
1039 CPPUNIT_ASSERT(xFirstText
.is());
1040 sal_Int32 nTextLeftDistance
= 0;
1041 xFirstText
->getPropertyValue("TextLeftDistance") >>= nTextLeftDistance
;
1042 uno::Reference
<drawing::XShape
> xFirstTextShape(xFirstText
, uno::UNO_QUERY
);
1043 CPPUNIT_ASSERT(xFirstTextShape
.is());
1044 sal_Int32 nWidth
= xFirstTextShape
->getSize().Width
;
1045 double fFactor
= oox::drawingml::convertPointToMms(0.6);
1046 // Without the accompanying fix in place, this test would have failed with 'Expected: 3440,
1047 // Actual : 263', i.e. the left margin was too small.
1048 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(nWidth
* fFactor
), nTextLeftDistance
);
1050 // Make sure that aspect ratio is not ignored, i.e. width is not larger than height 3 times.
1051 awt::Size aFirstPairSize
= xFirstPair
->getSize();
1052 // Without the accompanying fix in place, this test would have failed: bad width was 16932, good
1053 // width is 12540, but let's accept 12541 as well.
1054 CPPUNIT_ASSERT_LESSEQUAL(aFirstPairSize
.Height
* 3 + 1, aFirstPairSize
.Width
);
1057 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testInteropGrabBag
)
1059 createSdImpressDoc("pptx/smartart-interopgrabbag.pptx");
1060 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1061 CPPUNIT_ASSERT(xGroup
.is());
1063 uno::Reference
<beans::XPropertySet
> xPropertySet(xGroup
, uno::UNO_QUERY_THROW
);
1064 uno::Sequence
<beans::PropertyValue
> aGrabBagSeq
;
1065 xPropertySet
->getPropertyValue("InteropGrabBag") >>= aGrabBagSeq
;
1066 comphelper::SequenceAsHashMap
aGrabBag(aGrabBagSeq
);
1067 CPPUNIT_ASSERT(aGrabBag
.find("OOXData") != aGrabBag
.end());
1068 CPPUNIT_ASSERT(aGrabBag
.find("OOXLayout") != aGrabBag
.end());
1069 CPPUNIT_ASSERT(aGrabBag
.find("OOXStyle") != aGrabBag
.end());
1070 CPPUNIT_ASSERT(aGrabBag
.find("OOXColor") != aGrabBag
.end());
1071 CPPUNIT_ASSERT(aGrabBag
.find("OOXDrawing") != aGrabBag
.end());
1074 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBackground
)
1076 createSdImpressDoc("pptx/smartart-background.pptx");
1077 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1078 CPPUNIT_ASSERT(xGroup
.is());
1080 // background should fill whole diagram
1081 uno::Reference
<drawing::XShape
> xShapeGroup(xGroup
, uno::UNO_QUERY
);
1082 uno::Reference
<drawing::XShape
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
1083 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().X
, xShapeGroup
->getPosition().X
);
1084 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().Y
, xShapeGroup
->getPosition().Y
);
1085 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Width
, xShapeGroup
->getSize().Width
);
1086 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Height
, xShapeGroup
->getSize().Height
);
1088 uno::Reference
<beans::XPropertySet
> xPropertySet(xShape
, uno::UNO_QUERY_THROW
);
1089 drawing::FillStyle eFillStyle
= drawing::FillStyle_NONE
;
1090 xPropertySet
->getPropertyValue("FillStyle") >>= eFillStyle
;
1091 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, eFillStyle
);
1094 xPropertySet
->getPropertyValue("FillColor") >>= nFillColor
;
1095 CPPUNIT_ASSERT_EQUAL(Color(0x339933), nFillColor
);
1097 bool bMoveProtect
= false;
1098 xPropertySet
->getPropertyValue("MoveProtect") >>= bMoveProtect
;
1099 CPPUNIT_ASSERT_EQUAL(true, bMoveProtect
);
1101 bool bSizeProtect
= false;
1102 xPropertySet
->getPropertyValue("SizeProtect") >>= bSizeProtect
;
1103 CPPUNIT_ASSERT_EQUAL(true, bSizeProtect
);
1106 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBackgroundDrawingmlFallback
)
1108 // same as testBackground, but test file contains drawingML fallback
1110 createSdImpressDoc("pptx/smartart-background-drawingml-fallback.pptx");
1111 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1112 CPPUNIT_ASSERT(xGroup
.is());
1114 // background should fill whole diagram
1115 uno::Reference
<drawing::XShape
> xShapeGroup(xGroup
, uno::UNO_QUERY
);
1116 uno::Reference
<drawing::XShape
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
1117 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().X
, xShapeGroup
->getPosition().X
);
1118 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().Y
, xShapeGroup
->getPosition().Y
);
1119 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Width
, xShapeGroup
->getSize().Width
);
1120 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Height
, xShapeGroup
->getSize().Height
);
1122 uno::Reference
<beans::XPropertySet
> xPropertySet(xShape
, uno::UNO_QUERY_THROW
);
1123 drawing::FillStyle eFillStyle
= drawing::FillStyle_NONE
;
1124 xPropertySet
->getPropertyValue("FillStyle") >>= eFillStyle
;
1125 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, eFillStyle
);
1128 xPropertySet
->getPropertyValue("FillColor") >>= nFillColor
;
1129 CPPUNIT_ASSERT_EQUAL(Color(0x339933), nFillColor
);
1131 bool bMoveProtect
= false;
1132 xPropertySet
->getPropertyValue("MoveProtect") >>= bMoveProtect
;
1133 CPPUNIT_ASSERT_EQUAL(true, bMoveProtect
);
1135 bool bSizeProtect
= false;
1136 xPropertySet
->getPropertyValue("SizeProtect") >>= bSizeProtect
;
1137 CPPUNIT_ASSERT_EQUAL(true, bSizeProtect
);
1140 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testCenterCycle
)
1142 createSdImpressDoc("pptx/smartart-center-cycle.pptx");
1143 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1144 CPPUNIT_ASSERT(xGroup
.is());
1146 uno::Reference
<drawing::XShapes
> xGroupNested(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1147 CPPUNIT_ASSERT(xGroupNested
.is());
1149 uno::Reference
<drawing::XShape
> xShapeCenter(xGroupNested
->getByIndex(0), uno::UNO_QUERY
);
1150 uno::Reference
<drawing::XShape
> xShapeA(xGroupNested
->getByIndex(1), uno::UNO_QUERY
);
1151 uno::Reference
<drawing::XShape
> xShapeB(xGroupNested
->getByIndex(2), uno::UNO_QUERY
);
1152 uno::Reference
<drawing::XShape
> xShapeC(xGroupNested
->getByIndex(3), uno::UNO_QUERY
);
1154 uno::Reference
<text::XText
> xTextCenter(xShapeCenter
, uno::UNO_QUERY
);
1155 CPPUNIT_ASSERT(xTextCenter
.is());
1156 CPPUNIT_ASSERT_EQUAL(OUString("center"), xTextCenter
->getString());
1158 CPPUNIT_ASSERT_LESS(xShapeCenter
->getPosition().Y
, xShapeA
->getPosition().Y
);
1159 CPPUNIT_ASSERT_GREATER(xShapeCenter
->getPosition().X
, xShapeB
->getPosition().X
);
1160 CPPUNIT_ASSERT_GREATER(xShapeCenter
->getPosition().Y
, xShapeB
->getPosition().Y
);
1161 CPPUNIT_ASSERT_LESS(xShapeCenter
->getPosition().X
, xShapeC
->getPosition().X
);
1162 CPPUNIT_ASSERT_GREATER(xShapeCenter
->getPosition().Y
, xShapeC
->getPosition().Y
);
1165 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testFontSize
)
1167 createSdImpressDoc("pptx/smartart-font-size.pptx");
1169 uno::Reference
<drawing::XShapes
> xGroup1(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1170 uno::Reference
<beans::XPropertySet
> xShape1(xGroup1
->getByIndex(1), uno::UNO_QUERY
);
1171 uno::Reference
<text::XTextRange
> xParagraph1(getParagraphFromShape(0, xShape1
));
1172 uno::Reference
<text::XTextRange
> xRun1(getRunFromParagraph(0, xParagraph1
));
1173 uno::Reference
<beans::XPropertySet
> xPropSet1(xRun1
, uno::UNO_QUERY
);
1174 double fFontSize1
= xPropSet1
->getPropertyValue("CharHeight").get
<double>();
1175 CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, fFontSize1
, 0.01);
1177 uno::Reference
<drawing::XShapes
> xGroup2(getShapeFromPage(1, 0), uno::UNO_QUERY
);
1178 uno::Reference
<beans::XPropertySet
> xShape2(xGroup2
->getByIndex(1), uno::UNO_QUERY
);
1179 uno::Reference
<text::XTextRange
> xParagraph2(getParagraphFromShape(0, xShape2
));
1180 uno::Reference
<text::XTextRange
> xRun2(getRunFromParagraph(0, xParagraph2
));
1181 uno::Reference
<beans::XPropertySet
> xPropSet2(xRun2
, uno::UNO_QUERY
);
1182 double fFontSize2
= xPropSet2
->getPropertyValue("CharHeight").get
<double>();
1183 CPPUNIT_ASSERT_EQUAL(32.0, fFontSize2
);
1185 uno::Reference
<drawing::XShapes
> xGroup3(getShapeFromPage(2, 0), uno::UNO_QUERY
);
1186 uno::Reference
<beans::XPropertySet
> xShape3(xGroup3
->getByIndex(1), uno::UNO_QUERY
);
1187 drawing::TextFitToSizeType eTextFitToSize
= drawing::TextFitToSizeType_NONE
;
1188 xShape3
->getPropertyValue("TextFitToSize") >>= eTextFitToSize
;
1189 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_AUTOFIT
, eTextFitToSize
);
1192 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testVerticalBlockList
)
1194 createSdImpressDoc("pptx/smartart-vertical-block-list.pptx");
1195 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1196 CPPUNIT_ASSERT(xGroup
.is());
1198 uno::Reference
<drawing::XShapes
> xGroup1(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1199 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xGroup1
->getCount());
1200 uno::Reference
<drawing::XShape
> xShapeA(xGroup1
->getByIndex(1), uno::UNO_QUERY
);
1201 uno::Reference
<drawing::XShape
> xShapeBC(xGroup1
->getByIndex(0), uno::UNO_QUERY
);
1202 uno::Reference
<text::XText
> xTextA(xShapeA
, uno::UNO_QUERY
);
1203 uno::Reference
<text::XText
> xTextBC(xShapeBC
, uno::UNO_QUERY
);
1204 CPPUNIT_ASSERT_EQUAL(OUString("a"), xTextA
->getString());
1205 CPPUNIT_ASSERT_EQUAL(OUString("b\nc"), xTextBC
->getString());
1207 uno::Reference
<beans::XPropertySet
> xPropSetBC(xShapeBC
, uno::UNO_QUERY
);
1208 CPPUNIT_ASSERT_EQUAL(sal_Int32(27000),
1209 xPropSetBC
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
1211 // BC shape is rotated 90*, so width and height is swapped
1212 CPPUNIT_ASSERT_GREATER(xShapeA
->getSize().Width
, xShapeBC
->getSize().Height
);
1213 CPPUNIT_ASSERT_LESS(xShapeA
->getSize().Height
, xShapeBC
->getSize().Width
);
1214 CPPUNIT_ASSERT_GREATER(xShapeA
->getPosition().X
, xShapeBC
->getPosition().X
);
1215 CPPUNIT_ASSERT_GREATER(xShapeA
->getPosition().Y
, xShapeBC
->getPosition().Y
);
1217 uno::Reference
<drawing::XShapes
> xGroup3(xGroup
->getByIndex(3), uno::UNO_QUERY
);
1218 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), xGroup3
->getCount());
1219 uno::Reference
<drawing::XShape
> xShapeEmpty(xGroup3
->getByIndex(0), uno::UNO_QUERY
);
1220 uno::Reference
<text::XText
> xTextEmpty(xShapeEmpty
, uno::UNO_QUERY
);
1221 CPPUNIT_ASSERT_EQUAL(OUString("empty"), xTextEmpty
->getString());
1223 CPPUNIT_ASSERT_EQUAL(xShapeA
->getSize().Width
, xShapeEmpty
->getSize().Width
);
1224 CPPUNIT_ASSERT_EQUAL(xShapeA
->getSize().Height
, xShapeEmpty
->getSize().Height
);
1225 CPPUNIT_ASSERT_EQUAL(xShapeA
->getPosition().X
, xShapeEmpty
->getPosition().X
);
1226 CPPUNIT_ASSERT_GREATER(xShapeA
->getPosition().Y
+ 2 * xShapeA
->getSize().Height
,
1227 xShapeEmpty
->getPosition().Y
);
1229 uno::Reference
<drawing::XShape
> xGroupShape(xGroup
, uno::UNO_QUERY
);
1230 CPPUNIT_ASSERT_EQUAL(xGroupShape
->getPosition().Y
+ xGroupShape
->getSize().Height
,
1231 xShapeEmpty
->getPosition().Y
+ xShapeEmpty
->getSize().Height
);
1234 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testMissingBulletAndIndent
)
1236 createSdImpressDoc("pptx/smartart-missing-bullet.pptx");
1237 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1238 uno::Reference
<drawing::XShapes
> xGroup1(xGroup
->getByIndex(2), uno::UNO_QUERY
);
1239 uno::Reference
<drawing::XShapes
> xGroup2(xGroup1
->getByIndex(0), uno::UNO_QUERY
);
1240 uno::Reference
<text::XText
> xText(xGroup2
->getByIndex(0), uno::UNO_QUERY
);
1241 CPPUNIT_ASSERT(xText
.is());
1243 uno::Reference
<container::XEnumerationAccess
> xParasAccess(xText
, uno::UNO_QUERY
);
1244 uno::Reference
<container::XEnumeration
> xParas
= xParasAccess
->createEnumeration();
1245 xParas
->nextElement(); // skip parent
1247 uno::Reference
<beans::XPropertySet
> xPara1(xParas
->nextElement(), uno::UNO_QUERY
);
1248 CPPUNIT_ASSERT(xPara1
.is());
1250 sal_Int16 nNumberingLevel
= -1;
1251 xPara1
->getPropertyValue("NumberingLevel") >>= nNumberingLevel
;
1252 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nNumberingLevel
);
1254 uno::Reference
<container::XIndexAccess
> xNumRule
;
1255 xPara1
->getPropertyValue("NumberingRules") >>= xNumRule
;
1256 uno::Sequence
<beans::PropertyValue
> aBulletProps
;
1257 xNumRule
->getByIndex(1) >>= aBulletProps
;
1259 for (beans::PropertyValue
const& rProp
: std::as_const(aBulletProps
))
1261 if (rProp
.Name
== "LeftMargin")
1262 CPPUNIT_ASSERT_EQUAL(sal_Int32(309), rProp
.Value
.get
<sal_Int32
>());
1266 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBulletList
)
1268 createSdImpressDoc("pptx/smartart-bullet-list.pptx");
1269 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1270 CPPUNIT_ASSERT(xGroup
.is());
1272 uno::Reference
<text::XText
> xText(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1273 uno::Reference
<container::XEnumerationAccess
> xParasAccess(xText
, uno::UNO_QUERY
);
1274 uno::Reference
<container::XEnumeration
> xParas
= xParasAccess
->createEnumeration();
1275 xParas
->nextElement(); // skip parent
1277 // child levels should have bullets
1278 uno::Reference
<beans::XPropertySet
> xPara1(xParas
->nextElement(), uno::UNO_QUERY
);
1279 uno::Reference
<container::XIndexAccess
> xRules1(xPara1
->getPropertyValue("NumberingRules"),
1281 comphelper::SequenceAsHashMap
aRule1(xRules1
->getByIndex(1));
1282 CPPUNIT_ASSERT_EQUAL(OUString(u
"•"), aRule1
["BulletChar"].get
<OUString
>());
1284 uno::Reference
<beans::XPropertySet
> xPara2(xParas
->nextElement(), uno::UNO_QUERY
);
1285 uno::Reference
<container::XIndexAccess
> xRules2(xPara2
->getPropertyValue("NumberingRules"),
1287 comphelper::SequenceAsHashMap
aRule2(xRules2
->getByIndex(2));
1288 CPPUNIT_ASSERT_EQUAL(OUString(u
"•"), aRule2
["BulletChar"].get
<OUString
>());
1291 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testRecursion
)
1293 createSdImpressDoc("pptx/smartart-recursion.pptx");
1295 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1296 uno::Reference
<drawing::XShapes
> xGroup1(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1298 uno::Reference
<drawing::XShapes
> xGroupA(xGroup1
->getByIndex(0), uno::UNO_QUERY
);
1299 uno::Reference
<text::XText
> xTextA(xGroupA
->getByIndex(0), uno::UNO_QUERY
);
1300 CPPUNIT_ASSERT_EQUAL(OUString("A"), xTextA
->getString());
1302 uno::Reference
<drawing::XShapes
> xGroupB(xGroup1
->getByIndex(1), uno::UNO_QUERY
);
1303 // 5 connectors, B1 with children, B2 with children
1304 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(7), xGroupB
->getCount());
1306 uno::Reference
<drawing::XShapes
> xGroupB1(xGroupB
->getByIndex(1), uno::UNO_QUERY
);
1308 uno::Reference
<drawing::XShapes
> xGroupB1a(xGroupB1
->getByIndex(0), uno::UNO_QUERY
);
1309 uno::Reference
<text::XText
> xTextB1(xGroupB1a
->getByIndex(0), uno::UNO_QUERY
);
1310 CPPUNIT_ASSERT_EQUAL(OUString("B1"), xTextB1
->getString());
1312 uno::Reference
<drawing::XShape
> xGroupC12(xGroupB1
->getByIndex(1), uno::UNO_QUERY
);
1313 uno::Reference
<text::XText
> xTextC1(
1314 getChildShape(getChildShape(getChildShape(xGroupC12
, 0), 0), 0), uno::UNO_QUERY
);
1315 CPPUNIT_ASSERT_EQUAL(OUString("C1"), xTextC1
->getString());
1316 uno::Reference
<text::XText
> xTextC2(
1317 getChildShape(getChildShape(getChildShape(xGroupC12
, 1), 0), 0), uno::UNO_QUERY
);
1318 CPPUNIT_ASSERT_EQUAL(OUString("C2"), xTextC2
->getString());
1320 uno::Reference
<drawing::XShapes
> xGroupB2(xGroupB
->getByIndex(5), uno::UNO_QUERY
);
1322 uno::Reference
<drawing::XShapes
> xGroupB2a(xGroupB2
->getByIndex(0), uno::UNO_QUERY
);
1323 uno::Reference
<text::XText
> xTextB2(xGroupB2a
->getByIndex(0), uno::UNO_QUERY
);
1324 CPPUNIT_ASSERT_EQUAL(OUString("B2"), xTextB2
->getString());
1326 uno::Reference
<drawing::XShape
> xGroupC3(xGroupB2
->getByIndex(1), uno::UNO_QUERY
);
1327 uno::Reference
<text::XText
> xTextC3(
1328 getChildShape(getChildShape(getChildShape(xGroupC3
, 0), 0), 0), uno::UNO_QUERY
);
1329 CPPUNIT_ASSERT_EQUAL(OUString("C3"), xTextC3
->getString());
1332 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testDataFollow
)
1334 // checks if data nodes are followed correctly
1335 // different variables are set for two presentation points with the same name
1336 // they should be layouted differently - one horizontally and one vertically
1338 createSdImpressDoc("pptx/smartart-data-follow.pptx");
1340 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1342 uno::Reference
<drawing::XShapes
> xGroupLeft(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1343 uno::Reference
<drawing::XShape
> xGroupB(xGroupLeft
->getByIndex(1), uno::UNO_QUERY
);
1344 uno::Reference
<drawing::XShape
> xShapeB1
1345 = getChildShape(getChildShape(getChildShape(xGroupB
, 1), 0), 0);
1346 uno::Reference
<text::XText
> xTextB1(xShapeB1
, uno::UNO_QUERY
);
1347 CPPUNIT_ASSERT_EQUAL(OUString("B1"), xTextB1
->getString());
1348 uno::Reference
<drawing::XShape
> xShapeB2
1349 = getChildShape(getChildShape(getChildShape(xGroupB
, 3), 0), 0);
1350 uno::Reference
<text::XText
> xTextB2(xShapeB2
, uno::UNO_QUERY
);
1351 CPPUNIT_ASSERT_EQUAL(OUString("B2"), xTextB2
->getString());
1353 CPPUNIT_ASSERT_EQUAL(xShapeB1
->getPosition().Y
, xShapeB2
->getPosition().Y
);
1354 CPPUNIT_ASSERT_GREATEREQUAL(xShapeB1
->getPosition().X
+ xShapeB1
->getSize().Width
,
1355 xShapeB2
->getPosition().X
);
1357 uno::Reference
<drawing::XShapes
> xGroupRight(xGroup
->getByIndex(2), uno::UNO_QUERY
);
1358 uno::Reference
<drawing::XShape
> xGroupC(xGroupRight
->getByIndex(1), uno::UNO_QUERY
);
1359 uno::Reference
<drawing::XShape
> xShapeC1
1360 = getChildShape(getChildShape(getChildShape(xGroupC
, 3), 0), 0);
1361 uno::Reference
<text::XText
> xTextC1(xShapeC1
, uno::UNO_QUERY
);
1362 CPPUNIT_ASSERT_EQUAL(OUString("C1"), xTextC1
->getString());
1363 uno::Reference
<drawing::XShape
> xShapeC2
1364 = getChildShape(getChildShape(getChildShape(xGroupC
, 5), 0), 0);
1365 uno::Reference
<text::XText
> xTextC2(xShapeC2
, uno::UNO_QUERY
);
1366 CPPUNIT_ASSERT_EQUAL(OUString("C2"), xTextC2
->getString());
1368 CPPUNIT_ASSERT_EQUAL(xShapeC1
->getPosition().X
, xShapeC2
->getPosition().X
);
1369 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC1
->getPosition().Y
+ xShapeC1
->getSize().Height
,
1370 xShapeC2
->getPosition().Y
);
1373 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testOrgChart2
)
1375 createSdImpressDoc("pptx/smartart-org-chart2.pptx");
1376 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1378 uno::Reference
<drawing::XShape
> xShapeC1
= findChildShapeByText(xGroup
, "C1");
1379 uno::Reference
<drawing::XShape
> xShapeC2
= findChildShapeByText(xGroup
, "C2");
1380 uno::Reference
<drawing::XShape
> xShapeC3
= findChildShapeByText(xGroup
, "C3");
1381 uno::Reference
<drawing::XShape
> xShapeC4
= findChildShapeByText(xGroup
, "C4");
1382 uno::Reference
<drawing::XShape
> xShapeD1
= findChildShapeByText(xGroup
, "D1");
1383 uno::Reference
<drawing::XShape
> xShapeD2
= findChildShapeByText(xGroup
, "D2");
1385 CPPUNIT_ASSERT(xShapeC1
.is());
1386 CPPUNIT_ASSERT(xShapeC2
.is());
1387 CPPUNIT_ASSERT(xShapeC3
.is());
1388 CPPUNIT_ASSERT(xShapeC4
.is());
1389 CPPUNIT_ASSERT(xShapeD1
.is());
1390 CPPUNIT_ASSERT(xShapeD2
.is());
1392 CPPUNIT_ASSERT_EQUAL(xShapeC1
->getPosition().Y
, xShapeC2
->getPosition().Y
);
1393 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC1
->getPosition().X
+ xShapeC1
->getSize().Width
,
1394 xShapeC2
->getPosition().X
);
1396 CPPUNIT_ASSERT_EQUAL(xShapeC3
->getPosition().X
, xShapeC4
->getPosition().X
);
1397 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC3
->getPosition().Y
+ xShapeC3
->getSize().Height
,
1398 xShapeC4
->getPosition().Y
);
1400 CPPUNIT_ASSERT_EQUAL(xShapeD1
->getPosition().X
, xShapeD2
->getPosition().X
);
1401 CPPUNIT_ASSERT_GREATEREQUAL(xShapeD1
->getPosition().Y
+ xShapeD1
->getSize().Height
,
1402 xShapeD2
->getPosition().Y
);
1404 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC2
->getPosition().X
, xShapeD1
->getPosition().X
);
1405 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC2
->getPosition().Y
+ xShapeC2
->getSize().Height
,
1406 xShapeD1
->getPosition().Y
);
1408 CPPUNIT_ASSERT_GREATEREQUAL(xShapeD1
->getPosition().X
+ xShapeD1
->getSize().Width
,
1409 xShapeC4
->getPosition().X
);
1412 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf131553
)
1414 createSdImpressDoc("pptx/tdf131553.pptx");
1416 const SdrPage
* pPage
= GetPage(1);
1417 const SdrObjGroup
* pObjGroup
= dynamic_cast<SdrObjGroup
*>(pPage
->GetObj(0));
1418 CPPUNIT_ASSERT(pObjGroup
);
1419 const SdrObject
* pObj
= pObjGroup
->GetSubList()->GetObj(1);
1420 CPPUNIT_ASSERT_MESSAGE("no object", pObj
!= nullptr);
1421 CPPUNIT_ASSERT_EQUAL(SdrObjKind::OLE2
, pObj
->GetObjIdentifier());
1424 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testFillColorList
)
1426 createSdImpressDoc("pptx/fill-color-list.pptx");
1427 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1428 uno::Reference
<drawing::XShape
> xShape
= getChildShape(getChildShape(xGroup
, 1), 0);
1429 uno::Reference
<beans::XPropertySet
> xPropertySet(xShape
, uno::UNO_QUERY_THROW
);
1431 xPropertySet
->getPropertyValue("FillColor") >>= nFillColor
;
1432 // Without the accompanying fix in place, this test would have failed with:
1433 // - Expected: 12603469 (0xc0504d)
1434 // - Actual : 16225862 (0xf79646)
1435 // i.e. the background of the "A" shape was orange-ish, rather than red-ish.
1436 CPPUNIT_ASSERT_EQUAL(Color(0xC0504D), nFillColor
);
1438 // Without the accompanying fix in place, this test would have failed with:
1441 // i.e. the "A" shape's height/width aspect ratio was not 0.4 but rather close to 1.0, even if
1442 // ppt/diagrams/layout1.xml's <dgm:constr type="h" refType="w" op="lte" fact="0.4"/> requested
1444 awt::Size aActualSize
= xShape
->getSize();
1445 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2239), aActualSize
.Height
);
1447 // Without the accompanying fix in place, this test would have failed with:
1448 // - Expected greater than: 1738 (2766)
1450 // i.e. the columns were not centered vertically.
1451 sal_Int32 nGroupTop
= xGroup
->getPosition().Y
;
1452 sal_Int32 nShapeTop
= xShape
->getPosition().Y
;
1453 CPPUNIT_ASSERT_GREATER(nGroupTop
, nShapeTop
);
1456 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf134221
)
1458 createSdImpressDoc("pptx/smartart-tdf134221.pptx");
1459 saveAndReload("Impress Office Open XML");
1460 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1461 uno::Reference
<drawing::XShape
> xShapeB
= findChildShapeByText(xGroup
, "B");
1462 CPPUNIT_ASSERT(xShapeB
.is());
1463 uno::Reference
<beans::XPropertySet
> xTxtProps(xShapeB
, uno::UNO_QUERY_THROW
);
1465 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-248),
1466 xTxtProps
->getPropertyValue("TextUpperDistance").get
<sal_Int32
>());
1469 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testLinearRule
)
1471 createSdImpressDoc("pptx/smartart-linear-rule.pptx");
1473 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1474 // Last child, then first child inside that.
1475 // It is first as backgroundArrow is last, but chOrder="t" is set to reverse the order.
1476 uno::Reference
<drawing::XShape
> xShape
= getChildShape(getChildShape(xGroup
, 1), 0);
1478 // Without the accompanying fix in place, this test would have failed with:
1479 // - Expected greater than: 17500 (19867)
1481 // i.e. the width of the background arrow was too small.
1482 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(17500), xShape
->getSize().Width
);
1484 // Without the accompanying fix in place, this test would have failed with:
1487 // i.e. there was unexpected spacing on the left of the arrow.
1488 // Then the imported version of the test document failed with:
1491 // i.e. the spacing on the left of the arrow was so large that the shape was mostly outside the
1493 sal_Int32 nGroupLeft
= xGroup
->getPosition().X
;
1494 sal_Int32 nArrowLeft
= xShape
->getPosition().X
;
1495 CPPUNIT_ASSERT_EQUAL(nGroupLeft
, nArrowLeft
);
1497 // Without the accompanying fix in place, this test would have failed with:
1498 // - Expected less or equal than: 10092
1500 // i.e. the arrow height was larger than the canvas given to the smartart on slide 1.
1501 CPPUNIT_ASSERT_LESSEQUAL(static_cast<sal_Int32
>(10092), xShape
->getSize().Height
);
1504 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testLinearRuleVert
)
1506 createSdImpressDoc("pptx/smartart-linear-rule-vert.pptx");
1508 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1509 // Get the P1 shape.
1510 uno::Reference
<drawing::XShape
> xShape
= getChildShape(getChildShape(xGroup
, 1), 1);
1511 uno::Reference
<text::XTextRange
> xShapeText(xShape
, uno::UNO_QUERY
);
1512 CPPUNIT_ASSERT_EQUAL(OUString("P1"), xShapeText
->getString());
1514 // Without the accompanying fix in place, this test would have failed with:
1517 // i.e. the first item on the vertical linear layout used ~all space, the other items were not
1519 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2020), xShape
->getSize().Height
);
1522 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testAutofitSync
)
1524 createSdImpressDoc("pptx/smartart-autofit-sync.pptx");
1526 uno::Reference
<drawing::XShape
> xDiagram(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1527 uno::Reference
<drawing::XShape
> xMiddle
= getChildShape(xDiagram
, 2);
1528 uno::Reference
<beans::XPropertySet
> xFirstInner(getChildShape(getChildShape(xMiddle
, 0), 0),
1530 double nFirstScale
= 0;
1531 CPPUNIT_ASSERT(xFirstInner
->getPropertyValue("TextFitToSizeScale") >>= nFirstScale
);
1532 CPPUNIT_ASSERT_GREATER(0.0, nFirstScale
);
1533 CPPUNIT_ASSERT_LESS(100.0, nFirstScale
);
1534 uno::Reference
<beans::XPropertySet
> xSecondInner(getChildShape(getChildShape(xMiddle
, 2), 0),
1536 double nSecondScale
= 0;
1537 CPPUNIT_ASSERT(xSecondInner
->getPropertyValue("TextFitToSizeScale") >>= nSecondScale
);
1539 // Without the accompanying fix in place, this test would have failed with:
1542 // i.e. the left shape had no scale-down and the right shape was scaled down, even if it was
1543 // requested that their scaling matches.
1544 CPPUNIT_ASSERT_EQUAL(nSecondScale
, nFirstScale
);
1546 // Without the accompanying fix in place, this test would have failed with:
1547 // - Expected: 0 (drawing::TextFitToSizeType_NONE)
1548 // - Actual : 3 (TextFitToSizeType_AUTOFIT)
1549 // i.e. the 3rd shape had font size as direct formatting, but its automatic text scale was not
1551 uno::Reference
<beans::XPropertySet
> xThirdInner(getChildShape(getChildShape(xMiddle
, 4), 0),
1553 drawing::TextFitToSizeType eType
{};
1554 CPPUNIT_ASSERT(xThirdInner
->getPropertyValue("TextFitToSize") >>= eType
);
1555 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE
, eType
);
1558 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testSnakeRows
)
1560 // Load a smartart which contains a snake algorithm.
1561 // The expected layout of the 6 children is a 3x2 grid.
1562 createSdImpressDoc("pptx/smartart-snake-rows.pptx");
1564 uno::Reference
<drawing::XShapes
> xDiagram(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1565 // Collect position of the background and the real child shapes. First row and background has
1566 // the same top position, unless some unexpected spacing happens, since this is a
1567 // "left-to-right, then top-to-bottom" snake direction.
1568 std::set
<sal_Int32
> aYPositions
;
1569 for (sal_Int32 nChild
= 0; nChild
< xDiagram
->getCount(); ++nChild
)
1571 uno::Reference
<drawing::XShape
> xChild(xDiagram
->getByIndex(nChild
), uno::UNO_QUERY
);
1572 aYPositions
.insert(xChild
->getPosition().Y
);
1575 // Without the accompanying fix in place, this test would have failed with:
1578 // i.e. an unwanted row appeared.
1579 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aYPositions
.size());
1582 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testCompositeInferRight
)
1584 // Load a smartart which contains a composite algorithm.
1585 // One constraint says that the left of the text should be the right of the image.
1586 createSdImpressDoc("pptx/smartart-composite-infer-right.pptx");
1588 uno::Reference
<drawing::XShape
> xDiagram(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1589 uno::Reference
<drawing::XShape
> xMiddle
= getChildShape(xDiagram
, 1);
1590 uno::Reference
<drawing::XShape
> xImage
= getChildShape(xMiddle
, 1);
1591 uno::Reference
<drawing::XShape
> xText
= getChildShape(xMiddle
, 2);
1592 sal_Int32 nRightOfImage
= xImage
->getPosition().X
+ xImage
->getSize().Width
;
1593 sal_Int32 nLeftOfText
= xText
->getPosition().X
;
1595 // Without the accompanying fix in place, this test would have failed with:
1596 // - Expected greater than: 7925
1598 // i.e. the text was overlapping with the image.
1599 CPPUNIT_ASSERT_GREATER(nRightOfImage
, nLeftOfText
);
1602 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf149551Pie
)
1604 // The file contains a diagram of type "Basic Pie".
1605 createSdImpressDoc("pptx/tdf149551_SmartArt_Pie.pptx");
1606 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1607 // shape at index 0 is the background shape
1608 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1609 CPPUNIT_ASSERT(xShape
.is());
1610 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1611 CPPUNIT_ASSERT(pCustomShape
);
1612 tools::Rectangle aTextRect
;
1613 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1614 // without fix the text area rectangle had LT [7787,3420] and RB[16677,12312]. The values from
1615 // txXfrm were ignored.
1616 // The used tolerance is estimated.
1617 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(12658), sal_Int32(aTextRect
.Left()), 4);
1618 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5073), sal_Int32(aTextRect
.Top()), 4);
1619 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(15627), sal_Int32(aTextRect
.Right()), 4);
1620 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7990), sal_Int32(aTextRect
.Bottom()), 4);
1623 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf149551Pyramid
)
1625 // The file contains a diagram of type "Basic Pyramid".
1626 createSdImpressDoc("pptx/tdf149551_SmartArt_Pyramid.pptx");
1627 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1628 // shape at index 0 is the background shape
1629 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1630 CPPUNIT_ASSERT(xShape
.is());
1631 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1632 CPPUNIT_ASSERT(pCustomShape
);
1633 tools::Rectangle aTextRect
;
1634 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1635 // without fix the text area rectangle had LT [9369,2700] and RB[14632,6185]. The values from
1636 // txXfrm were ignored.
1637 // The used tolerance is estimated.
1638 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7591), sal_Int32(aTextRect
.Left()), 4);
1639 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1515), sal_Int32(aTextRect
.Top()), 4);
1640 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(16410), sal_Int32(aTextRect
.Right()), 4);
1641 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7370), sal_Int32(aTextRect
.Bottom()), 4);
1644 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf149551Venn
)
1646 // The file contains a diagram of type "Stacked Venn".
1647 createSdImpressDoc("pptx/tdf149551_SmartArt_Venn.pptx");
1648 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1649 // shape at index 0 is the background shape
1650 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1651 CPPUNIT_ASSERT(xShape
.is());
1652 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1653 CPPUNIT_ASSERT(pCustomShape
);
1654 tools::Rectangle aTextRect
;
1655 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1656 // without fix the text area rectangle had LT [6865,3396] and RB[17136,4600]. The values from
1657 // txXfrm were ignored.
1658 // The used tolerance is estimated.
1659 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(8772), sal_Int32(aTextRect
.Left()), 4);
1660 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1834), sal_Int32(aTextRect
.Top()), 4);
1661 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(15229), sal_Int32(aTextRect
.Right()), 4);
1662 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(6162), sal_Int32(aTextRect
.Bottom()), 4);
1665 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf149551Gear
)
1667 // The file contains a diagram of type "Gear".
1668 createSdImpressDoc("pptx/tdf149551_SmartArt_Gear.pptx");
1669 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1670 // shape at index 0 is the background shape
1671 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1672 CPPUNIT_ASSERT(xShape
.is());
1673 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1674 CPPUNIT_ASSERT(pCustomShape
);
1675 tools::Rectangle aTextRect
;
1676 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1677 // without fix the text area rectangle had LT [4101,1014] and RB[8019,4932]. The values from
1678 // txXfrm were ignored.
1679 // The used tolerance is estimated.
1680 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5501), sal_Int32(aTextRect
.Left()), 4);
1681 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4500), sal_Int32(aTextRect
.Top()), 4);
1682 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(11000), sal_Int32(aTextRect
.Right()), 4);
1683 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(9999), sal_Int32(aTextRect
.Bottom()), 4);
1686 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf145528Matrix
)
1688 // The file contains a diagram of type "Titled Matrix". Such is build from shapes of type
1690 createSdImpressDoc("pptx/tdf145528_SmartArt_Matrix.pptx");
1691 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1693 sal_Int32 nLeft
[]{ 4001, 12001, 12001, 18501 };
1694 sal_Int32 nTop
[]{ 9999, 1999, 12499, 5999 };
1695 // nWidth = 10292, nHeight = 4499
1696 // Without the fix in place the values were
1697 // nLeft {2001, 12001, 12001, 22001}
1698 // nTop {7999. 1999, 13999, 7999}
1699 // nWidth {6000, 10000, 10000, 6000}
1700 // nHeight {10000, 6000, 6000, 10000}
1701 tools::Rectangle aTextRect
;
1702 for (auto i
: { 1, 2, 3, 4 }) // shape at index 0 is the background shape
1704 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, i
);
1705 CPPUNIT_ASSERT(xShape
.is());
1707 = dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1708 CPPUNIT_ASSERT(pCustomShape
);
1709 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1710 CPPUNIT_ASSERT_DOUBLES_EQUAL(nLeft
[i
- 1], sal_Int32(aTextRect
.Left()), 4);
1711 CPPUNIT_ASSERT_DOUBLES_EQUAL(nTop
[i
- 1], sal_Int32(aTextRect
.Top()), 4);
1712 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(10293), sal_Int32(aTextRect
.GetWidth()), 4);
1713 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4500), sal_Int32(aTextRect
.GetHeight()), 4);
1717 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf135953TextPosition
)
1719 // The file contains a diagram of type "Detailed Process". There the text area rectangle
1720 // is at the left edge of the shape and rotated there.
1721 createSdImpressDoc("pptx/tdf135953_SmartArt_textposition.pptx");
1722 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1723 // shape at index 0 is the background shape
1724 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1725 CPPUNIT_ASSERT(xShape
.is());
1726 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1727 CPPUNIT_ASSERT(pCustomShape
);
1728 tools::Rectangle aTextRect
;
1729 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1730 // without fix the text area rectangle had LT[-2213,2336] and RB[4123,4575]. It was not
1731 // considered that the txXfrm and the preset text area rectangle have different centers in this
1732 // case and thus the text was far off.
1733 // The used tolerance is estimated.
1734 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(3223), sal_Int32(aTextRect
.Left()), 4);
1735 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(-1661), sal_Int32(aTextRect
.Top()), 4);
1736 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(9559), sal_Int32(aTextRect
.Right()), 4);
1737 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(578), sal_Int32(aTextRect
.Bottom()), 4);
1740 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf132302RightArrow
)
1742 // The file contains a diagram of type "Process Arrows". It uses shapes of type "rightArrow".
1743 // The text starts not at the left edge but in the middle to have space for a circle. Error was
1744 // that the text starts left and so was hidden by the circle.
1745 createSdImpressDoc("pptx/tdf132302_SmartArt_rightArrow.pptx");
1746 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1747 // shape at index 0 is the background shape
1748 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1749 CPPUNIT_ASSERT(xShape
.is());
1750 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1751 CPPUNIT_ASSERT(pCustomShape
);
1752 tools::Rectangle aTextRect
;
1753 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1754 // without fix the text area rectangle had LT[2790,59] and RB[11591,7940]. Position and size
1755 // given in txXfrm in drawing.xml were not considered.
1756 // The used tolerance is estimated.
1757 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5078), sal_Int32(aTextRect
.Left()), 4);
1758 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(58), sal_Int32(aTextRect
.Top()), 4);
1759 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(11989), sal_Int32(aTextRect
.Right()), 4);
1760 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7940), sal_Int32(aTextRect
.Bottom()), 4);
1763 CPPUNIT_PLUGIN_IMPLEMENT();
1765 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */