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(u
"/sd/qa/unit/data/"_ustr
)
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(u
"a"_ustr
, xText0
->getString());
85 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
86 CPPUNIT_ASSERT_EQUAL(u
"b"_ustr
, xText1
->getString());
87 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
88 CPPUNIT_ASSERT_EQUAL(u
"c"_ustr
, xText2
->getString());
89 uno::Reference
<text::XText
> xText3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
90 CPPUNIT_ASSERT_EQUAL(u
"d"_ustr
, xText3
->getString());
91 uno::Reference
<text::XText
> xText4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
92 CPPUNIT_ASSERT_EQUAL(u
"e"_ustr
, xText4
->getString());
94 uno::Reference
<beans::XPropertySet
> xShape(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
97 xShape
->getPropertyValue(u
"FillColor"_ustr
) >>= 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(u
"ParaAdjust"_ustr
) >>= 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(u
"a"_ustr
, 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(u
"b"_ustr
, 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(u
"c"_ustr
, 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(u
"x"_ustr
, 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(u
"y"_ustr
, 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(u
"z"_ustr
, 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(u
"test"_ustr
, 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(u
"\nFufufu"_ustr
, xText0
->getString());
226 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
227 CPPUNIT_ASSERT_EQUAL(u
"Susu"_ustr
, xText1
->getString());
228 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
229 CPPUNIT_ASSERT_EQUAL(u
"Sasa Haha"_ustr
, 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(u
"first"_ustr
, xText0
->getString());
262 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
263 CPPUNIT_ASSERT_EQUAL(u
"second"_ustr
, 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),
278 xShape0
->getPropertyValue(u
"RotateAngle"_ustr
).get
<sal_Int32
>());
280 uno::Reference
<beans::XPropertySet
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
281 CPPUNIT_ASSERT_EQUAL(sal_Int32(24000),
282 xShape1
->getPropertyValue(u
"RotateAngle"_ustr
).get
<sal_Int32
>());
284 uno::Reference
<beans::XPropertySet
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
285 CPPUNIT_ASSERT_EQUAL(sal_Int32(12000),
286 xShape2
->getPropertyValue(u
"RotateAngle"_ustr
).get
<sal_Int32
>());
289 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTextAutoRotation
)
291 createSdImpressDoc("pptx/smartart-autoTxRot.pptx");
293 auto testText
= [&](int pageNo
, sal_Int32 txtNo
, const OUString
& expTx
, sal_Int32 expShRot
,
294 sal_Int32 expTxRot
) {
295 OString msgText
= "Page: " + OString::number(pageNo
) + " text: " + OString::number(txtNo
);
296 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, pageNo
),
297 uno::UNO_QUERY_THROW
);
299 txtNo
++; //skip background
300 uno::Reference
<text::XText
> xTxt(xShapeGroup
->getByIndex(txtNo
), uno::UNO_QUERY_THROW
);
301 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), expTx
, xTxt
->getString());
302 uno::Reference
<beans::XPropertySet
> xTxtProps(xTxt
, uno::UNO_QUERY_THROW
);
303 CPPUNIT_ASSERT_EQUAL_MESSAGE(
304 msgText
.getStr(), expShRot
,
305 xTxtProps
->getPropertyValue(u
"RotateAngle"_ustr
).get
<sal_Int32
>());
307 auto aGeomPropSeq
= xTxtProps
->getPropertyValue(u
"CustomShapeGeometry"_ustr
)
308 .get
<uno::Sequence
<beans::PropertyValue
>>();
309 comphelper::SequenceAsHashMap
aCustomShapeGeometry(aGeomPropSeq
);
311 auto it
= aCustomShapeGeometry
.find(u
"TextPreRotateAngle"_ustr
);
312 if (it
== aCustomShapeGeometry
.end())
314 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), sal_Int32(0), expTxRot
);
318 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), expTxRot
, it
->second
.get
<sal_Int32
>());
322 // Slide 1: absent autoTxRot => defaults to "upr"
323 testText(0, 0, u
"a"_ustr
, 0, 0);
324 testText(0, 1, u
"b"_ustr
, 33750, 0);
325 testText(0, 2, u
"c"_ustr
, 31500, 0);
326 testText(0, 3, u
"d"_ustr
, 29250, 90);
327 testText(0, 4, u
"e"_ustr
, 27000, 90);
328 testText(0, 5, u
"f"_ustr
, 24750, 90);
329 testText(0, 6, u
"g"_ustr
, 22500, 180);
330 testText(0, 7, u
"h"_ustr
, 20250, 180);
331 testText(0, 8, u
"i"_ustr
, 18000, 180);
332 testText(0, 9, u
"j"_ustr
, 15750, 180);
333 testText(0, 10, u
"k"_ustr
, 13500, 180);
334 testText(0, 11, u
"l"_ustr
, 11250, 270);
335 testText(0, 12, u
"m"_ustr
, 9000, 270);
336 testText(0, 13, u
"n"_ustr
, 6750, 270);
337 testText(0, 14, u
"o"_ustr
, 4500, 0);
338 testText(0, 15, u
"p"_ustr
, 2250, 0);
340 // Slide 2: autoTxRot == "none"
341 testText(1, 0, u
"a"_ustr
, 0, 0);
342 testText(1, 1, u
"b"_ustr
, 33750, 0);
343 testText(1, 2, u
"c"_ustr
, 31500, 0);
344 testText(1, 3, u
"d"_ustr
, 29250, 0);
345 testText(1, 4, u
"e"_ustr
, 27000, 0);
346 testText(1, 5, u
"f"_ustr
, 24750, 0);
347 testText(1, 6, u
"g"_ustr
, 22500, 0);
348 testText(1, 7, u
"h"_ustr
, 20250, 0);
349 testText(1, 8, u
"i"_ustr
, 18000, 0);
350 testText(1, 9, u
"j"_ustr
, 15750, 0);
351 testText(1, 10, u
"k"_ustr
, 13500, 0);
352 testText(1, 11, u
"l"_ustr
, 11250, 0);
353 testText(1, 12, u
"m"_ustr
, 9000, 0);
354 testText(1, 13, u
"n"_ustr
, 6750, 0);
355 testText(1, 14, u
"o"_ustr
, 4500, 0);
356 testText(1, 15, u
"p"_ustr
, 2250, 0);
358 // Slide 3: autoTxRot == "grav"
359 testText(2, 0, u
"a"_ustr
, 0, 0);
360 testText(2, 1, u
"b"_ustr
, 33750, 0);
361 testText(2, 2, u
"c"_ustr
, 31500, 0);
362 testText(2, 3, u
"d"_ustr
, 29250, 0);
363 testText(2, 4, u
"e"_ustr
, 27000, 0);
364 testText(2, 5, u
"f"_ustr
, 24750, 180);
365 testText(2, 6, u
"g"_ustr
, 22500, 180);
366 testText(2, 7, u
"h"_ustr
, 20250, 180);
367 testText(2, 8, u
"i"_ustr
, 18000, 180);
368 testText(2, 9, u
"j"_ustr
, 15750, 180);
369 testText(2, 10, u
"k"_ustr
, 13500, 180);
370 testText(2, 11, u
"l"_ustr
, 11250, 180);
371 testText(2, 12, u
"m"_ustr
, 9000, 0);
372 testText(2, 13, u
"n"_ustr
, 6750, 0);
373 testText(2, 14, u
"o"_ustr
, 4500, 0);
374 testText(2, 15, u
"p"_ustr
, 2250, 0);
377 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBasicProcess
)
379 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
382 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testPyramid
)
384 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
387 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testPyramidOneChild
)
389 // Load a document with a pyra algorithm in it.
390 // Without the accompanying fix in place, this test would have crashed.
391 createSdImpressDoc("pptx/smartart-pyramid-1child.pptx");
392 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
393 uno::Reference
<text::XTextRange
> xText(getChildShape(getChildShape(xGroup
, 1), 1),
395 // Verify that the text of the only child is imported correctly.
396 CPPUNIT_ASSERT_EQUAL(u
"A"_ustr
, xText
->getString());
399 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testChevron
)
401 createSdImpressDoc("pptx/smartart-chevron.pptx");
402 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
403 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xShapeGroup
->getCount());
405 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
406 CPPUNIT_ASSERT_EQUAL(u
"a"_ustr
, xText0
->getString());
407 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
408 CPPUNIT_ASSERT_EQUAL(u
"b"_ustr
, xText1
->getString());
409 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
410 CPPUNIT_ASSERT_EQUAL(u
"c"_ustr
, xText2
->getString());
412 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
413 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
414 uno::Reference
<drawing::XShape
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
416 CPPUNIT_ASSERT(xShape0
->getPosition().X
< xShape1
->getPosition().X
);
417 CPPUNIT_ASSERT(xShape1
->getPosition().X
< xShape2
->getPosition().X
);
418 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().Y
, xShape1
->getPosition().Y
);
419 CPPUNIT_ASSERT_EQUAL(xShape1
->getPosition().Y
, xShape2
->getPosition().Y
);
422 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testCycle
)
424 createSdImpressDoc("pptx/smartart-cycle.pptx");
425 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
426 CPPUNIT_ASSERT(xGroup
.is());
428 // 11 children: background, 5 shapes, 5 connectors
429 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(11), xGroup
->getCount());
431 uno::Reference
<drawing::XShape
> xShape0(xGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
432 uno::Reference
<drawing::XShape
> xShapeConn(xGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
433 uno::Reference
<drawing::XShape
> xShape2(xGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
435 uno::Reference
<text::XText
> xText0(xShape0
, uno::UNO_QUERY_THROW
);
436 CPPUNIT_ASSERT_EQUAL(u
"a"_ustr
, xText0
->getString());
437 uno::Reference
<text::XText
> xText2(xShape2
, uno::UNO_QUERY_THROW
);
438 CPPUNIT_ASSERT_EQUAL(u
"b"_ustr
, xText2
->getString());
440 // xShapeConn is connector between shapes 0 and 2
441 // it should lay between them and be rotated 0 -> 2
442 CPPUNIT_ASSERT(xShape0
->getPosition().X
< xShapeConn
->getPosition().X
);
443 CPPUNIT_ASSERT(xShape0
->getPosition().Y
< xShapeConn
->getPosition().Y
);
444 CPPUNIT_ASSERT(xShapeConn
->getPosition().Y
< xShape2
->getPosition().Y
);
445 uno::Reference
<beans::XPropertySet
> xPropSetConn(xShapeConn
, uno::UNO_QUERY_THROW
);
446 CPPUNIT_ASSERT_EQUAL(sal_Int32(32400),
447 xPropSetConn
->getPropertyValue(u
"RotateAngle"_ustr
).get
<sal_Int32
>());
449 // Make sure that we have an arrow shape between the two shapes
450 comphelper::SequenceAsHashMap
aCustomShapeGeometry(
451 xPropSetConn
->getPropertyValue(u
"CustomShapeGeometry"_ustr
));
452 CPPUNIT_ASSERT(aCustomShapeGeometry
[u
"Type"_ustr
].has
<OUString
>());
453 OUString aType
= aCustomShapeGeometry
[u
"Type"_ustr
].get
<OUString
>();
454 CPPUNIT_ASSERT_EQUAL(u
"ooxml-rightArrow"_ustr
, aType
);
457 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testHierarchy
)
459 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
462 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testmatrix
)
464 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
467 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testvenndiagram
)
469 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
472 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testInvertedPyramid
)
474 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
477 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testMultidirectional
)
479 // similar document as cycle, but arrows are pointing in both directions
480 createSdImpressDoc("pptx/smartart-multidirectional.pptx");
481 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
482 CPPUNIT_ASSERT(xGroup
.is());
484 // 7 children: background, 3 shapes, 3 connectors
485 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(7), xGroup
->getCount());
487 uno::Reference
<drawing::XShape
> xShapeConn(xGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
488 uno::Reference
<beans::XPropertySet
> xPropSetConn(xShapeConn
, uno::UNO_QUERY_THROW
);
489 comphelper::SequenceAsHashMap
aCustomShapeGeometry(
490 xPropSetConn
->getPropertyValue(u
"CustomShapeGeometry"_ustr
));
491 CPPUNIT_ASSERT(aCustomShapeGeometry
[u
"Type"_ustr
].has
<OUString
>());
492 OUString aType
= aCustomShapeGeometry
[u
"Type"_ustr
].get
<OUString
>();
493 CPPUNIT_ASSERT_EQUAL(u
"ooxml-leftRightArrow"_ustr
, aType
);
496 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testHorizontalBulletList
)
498 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
501 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testEquation
)
503 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
506 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBasicRadicals
)
508 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
511 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testSegmentedCycle
)
513 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
516 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBaseRtoL
)
518 createSdImpressDoc("pptx/smartart-rightoleftblockdiagram.pptx");
519 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
520 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xShapeGroup
->getCount());
522 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
523 CPPUNIT_ASSERT_EQUAL(u
"a"_ustr
, xText0
->getString());
524 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
525 CPPUNIT_ASSERT_EQUAL(u
"b"_ustr
, xText1
->getString());
526 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
527 CPPUNIT_ASSERT_EQUAL(u
"c"_ustr
, xText2
->getString());
528 uno::Reference
<text::XText
> xText3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
529 CPPUNIT_ASSERT_EQUAL(u
"d"_ustr
, xText3
->getString());
530 uno::Reference
<text::XText
> xText4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
531 CPPUNIT_ASSERT_EQUAL(u
"e"_ustr
, xText4
->getString());
533 uno::Reference
<beans::XPropertySet
> xShape(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
536 xShape
->getPropertyValue(u
"FillColor"_ustr
) >>= nFillColor
;
537 CPPUNIT_ASSERT_EQUAL(Color(0x4F81BD), nFillColor
);
539 sal_Int16 nParaAdjust
= 0;
540 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
541 uno::Reference
<beans::XPropertySet
> xPropSet(xParagraph
, uno::UNO_QUERY_THROW
);
542 xPropSet
->getPropertyValue(u
"ParaAdjust"_ustr
) >>= nParaAdjust
;
543 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
,
544 static_cast<style::ParagraphAdjust
>(nParaAdjust
));
546 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
547 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
548 uno::Reference
<drawing::XShape
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
549 uno::Reference
<drawing::XShape
> xShape3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
550 uno::Reference
<drawing::XShape
> xShape4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
561 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().Y
, xShape1
->getPosition().Y
);
562 CPPUNIT_ASSERT_EQUAL(xShape2
->getPosition().Y
, xShape3
->getPosition().Y
);
564 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().X
, xShape2
->getPosition().X
);
565 CPPUNIT_ASSERT_EQUAL(xShape1
->getPosition().X
, xShape3
->getPosition().X
);
567 CPPUNIT_ASSERT_EQUAL(xShape2
->getPosition().Y
- xShape0
->getPosition().Y
,
568 xShape4
->getPosition().Y
- xShape2
->getPosition().Y
);
569 CPPUNIT_ASSERT_EQUAL(xShape1
->getPosition().X
- xShape0
->getPosition().X
,
570 xShape3
->getPosition().X
- xShape2
->getPosition().X
);
571 CPPUNIT_ASSERT_DOUBLES_EQUAL(xShape2
->getPosition().X
+ xShape3
->getPosition().X
,
572 2 * xShape4
->getPosition().X
, 1);
574 CPPUNIT_ASSERT(xShape2
->getPosition().Y
> xShape0
->getPosition().Y
);
575 CPPUNIT_ASSERT(xShape4
->getPosition().Y
> xShape2
->getPosition().Y
);
576 CPPUNIT_ASSERT(xShape0
->getPosition().X
> xShape1
->getPosition().X
);
577 CPPUNIT_ASSERT(xShape2
->getPosition().X
> xShape3
->getPosition().X
);
578 CPPUNIT_ASSERT((xShape2
->getPosition().X
> xShape4
->getPosition().X
));
579 CPPUNIT_ASSERT((xShape3
->getPosition().X
< xShape4
->getPosition().X
));
582 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testVerticalBoxList
)
584 createSdImpressDoc("pptx/smartart-vertical-box-list.pptx");
585 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
586 // Without the accompanying fix in place, this test would have failed with
588 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xShapeGroup
->getCount());
590 uno::Reference
<drawing::XShapes
> xFirstChild(xShapeGroup
->getByIndex(1), uno::UNO_QUERY
);
591 CPPUNIT_ASSERT(xFirstChild
.is());
592 uno::Reference
<drawing::XShape
> xParentText(xFirstChild
->getByIndex(1), uno::UNO_QUERY
);
593 CPPUNIT_ASSERT(xParentText
.is());
594 // Without the accompanying fix in place, this test would have failed with
595 // 'actual: 7361', i.e. the width was not the 70% of the parent as the
596 // constraint wanted.
597 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(11852), xParentText
->getSize().Width
);
599 uno::Reference
<drawing::XShape
> xChildText(xShapeGroup
->getByIndex(2), uno::UNO_QUERY
);
600 CPPUNIT_ASSERT(xChildText
.is());
601 // Without the accompanying fix in place, this test would have failed with
602 // 'actual: 7361' (and with the fix: 'actual: 16932', i.e. the width of the
604 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(10000), xChildText
->getSize().Width
);
606 // Assert that the right edge of the parent text is closer to the slide
607 // boundary than the right edge of the parent text.
608 // Without the accompanying fix in place, this test would have failed with
609 // 'Expected greater than: 25656, Actual : 21165'.
610 CPPUNIT_ASSERT_GREATER(xParentText
->getPosition().X
+ xParentText
->getSize().Width
,
611 xChildText
->getPosition().X
+ xChildText
->getSize().Width
);
614 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testVerticalBracketList
)
616 createSdImpressDoc("pptx/vertical-bracket-list.pptx");
617 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY_THROW
);
618 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xShapeGroup
->getCount());
620 uno::Reference
<drawing::XShapes
> xFirstChild(xShapeGroup
->getByIndex(1), uno::UNO_QUERY
);
621 CPPUNIT_ASSERT(xFirstChild
.is());
622 // Without the accompanying fix in place, this test would have failed with
623 // 'actual: 2', i.e. one child shape (with its "A" text) was missing.
624 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xFirstChild
->getCount());
627 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTableList
)
629 createSdImpressDoc("pptx/table-list.pptx");
630 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
631 CPPUNIT_ASSERT(xShapeGroup
.is());
632 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xShapeGroup
->getCount());
634 uno::Reference
<text::XText
> xParentText(xShapeGroup
->getByIndex(1), uno::UNO_QUERY
);
635 CPPUNIT_ASSERT(xParentText
.is());
636 CPPUNIT_ASSERT_EQUAL(u
"Parent"_ustr
, xParentText
->getString());
637 uno::Reference
<drawing::XShape
> xParent(xParentText
, uno::UNO_QUERY
);
638 CPPUNIT_ASSERT(xParent
.is());
639 int nParentRight
= xParent
->getPosition().X
+ xParent
->getSize().Width
;
641 uno::Reference
<drawing::XShapes
> xChildren(xShapeGroup
->getByIndex(2), uno::UNO_QUERY
);
642 CPPUNIT_ASSERT(xChildren
.is());
643 uno::Reference
<text::XText
> xChild2Text(xChildren
->getByIndex(1), uno::UNO_QUERY
);
644 CPPUNIT_ASSERT(xChild2Text
.is());
645 CPPUNIT_ASSERT_EQUAL(u
"Child 2"_ustr
, xChild2Text
->getString());
646 uno::Reference
<drawing::XShape
> xChild2(xChild2Text
, uno::UNO_QUERY
);
647 CPPUNIT_ASSERT(xChild2
.is());
648 int nChild2Right
= xChild2
->getPosition().X
+ xChild2
->getSize().Width
;
650 // Without the accompanying fix in place, this test would have failed with
651 // 'Expected less than: 100, Actual : 22014', i.e. the second child was
652 // shifted to the right too much.
653 CPPUNIT_ASSERT_LESS(100, abs(nChild2Right
- nParentRight
));
656 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testAccentProcess
)
658 createSdImpressDoc("pptx/smartart-accent-process.pptx");
659 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
660 CPPUNIT_ASSERT(xGroup
.is());
661 // 3 children: first pair, connector, second pair.
662 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xGroup
->getCount());
663 uno::Reference
<drawing::XShape
> xGroupShape(xGroup
, uno::UNO_QUERY
);
664 CPPUNIT_ASSERT(xGroupShape
.is());
666 // The pair is a parent (shape + text) and a child, so 3 shapes in total.
667 // The order is important, first is at the back, last is at the front.
668 uno::Reference
<drawing::XShapes
> xFirstPair(xGroup
->getByIndex(1), uno::UNO_QUERY
);
669 CPPUNIT_ASSERT(xFirstPair
.is());
670 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xFirstPair
->getCount());
672 uno::Reference
<text::XText
> xFirstParentText(xFirstPair
->getByIndex(1), uno::UNO_QUERY
);
673 CPPUNIT_ASSERT(xFirstParentText
.is());
674 CPPUNIT_ASSERT_EQUAL(u
"a"_ustr
, xFirstParentText
->getString());
675 uno::Reference
<drawing::XShape
> xFirstParent(xFirstParentText
, uno::UNO_QUERY
);
676 CPPUNIT_ASSERT(xFirstParent
.is());
677 int nFirstParentTop
= xFirstParent
->getPosition().Y
;
679 uno::Reference
<text::XText
> xFirstChildText(xFirstPair
->getByIndex(2), uno::UNO_QUERY
);
680 CPPUNIT_ASSERT(xFirstChildText
.is());
681 CPPUNIT_ASSERT_EQUAL(u
"b"_ustr
, xFirstChildText
->getString());
682 uno::Reference
<drawing::XShape
> xFirstChild(xFirstChildText
, uno::UNO_QUERY
);
683 CPPUNIT_ASSERT(xFirstChildText
.is());
686 uno::Reference
<container::XEnumerationAccess
> xParasAccess(xFirstChildText
, uno::UNO_QUERY
);
687 uno::Reference
<container::XEnumeration
> xParas
= xParasAccess
->createEnumeration();
688 uno::Reference
<beans::XPropertySet
> xPara(xParas
->nextElement(), uno::UNO_QUERY
);
689 // Without the accompanying fix in place, this test would have failed
690 // with 'Expected: 0; Actual : 1270', i.e. there was a large
691 // unexpected left margin.
692 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0),
693 xPara
->getPropertyValue(u
"ParaLeftMargin"_ustr
).get
<sal_Int32
>());
695 uno::Reference
<container::XIndexAccess
> xRules(
696 xPara
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
697 comphelper::SequenceAsHashMap
aRule(xRules
->getByIndex(0));
698 CPPUNIT_ASSERT_EQUAL(u
"•"_ustr
, aRule
[u
"BulletChar"_ustr
].get
<OUString
>());
701 int nFirstChildTop
= xFirstChild
->getPosition().Y
;
702 int nFirstChildRight
= xFirstChild
->getPosition().X
+ xFirstChild
->getSize().Width
;
704 // First child is below the first parent.
705 // Without the accompanying fix in place, this test would have failed with
706 // 'Expected less than: 3881, Actual : 3881', i.e. xFirstChild was not
707 // below xFirstParent (a good position is 9081).
708 CPPUNIT_ASSERT_LESS(nFirstChildTop
, nFirstParentTop
);
710 // Make sure that we have an arrow shape between the two pairs.
711 uno::Reference
<beans::XPropertySet
> xArrow(xGroup
->getByIndex(2), uno::UNO_QUERY
);
712 CPPUNIT_ASSERT(xArrow
.is());
713 comphelper::SequenceAsHashMap
aCustomShapeGeometry(
714 xArrow
->getPropertyValue(u
"CustomShapeGeometry"_ustr
));
715 // Without the accompanying fix in place, this test would have failed, i.e.
716 // the custom shape lacked a type -> arrow was not visible.
717 CPPUNIT_ASSERT(aCustomShapeGeometry
[u
"Type"_ustr
].has
<OUString
>());
718 OUString aType
= aCustomShapeGeometry
[u
"Type"_ustr
].get
<OUString
>();
719 CPPUNIT_ASSERT_EQUAL(u
"ooxml-rightArrow"_ustr
, aType
);
721 // Make sure that height of the arrow is less than its width.
722 uno::Reference
<drawing::XShape
> xArrowShape(xArrow
, uno::UNO_QUERY
);
723 CPPUNIT_ASSERT(xArrowShape
.is());
724 awt::Size aArrowSize
= xArrowShape
->getSize();
725 CPPUNIT_ASSERT_LESS(aArrowSize
.Width
, aArrowSize
.Height
);
727 uno::Reference
<drawing::XShapes
> xSecondPair(xGroup
->getByIndex(3), uno::UNO_QUERY
);
728 CPPUNIT_ASSERT(xSecondPair
.is());
729 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xSecondPair
->getCount());
730 uno::Reference
<text::XText
> xSecondParentText(xSecondPair
->getByIndex(1), uno::UNO_QUERY
);
731 CPPUNIT_ASSERT(xFirstParentText
.is());
732 // Without the accompanying fix in place, this test would have failed with
733 // 'Expected: cc; Actual : c', i.e. non-first runs on data points were ignored.
734 CPPUNIT_ASSERT_EQUAL(u
"cc"_ustr
, xSecondParentText
->getString());
735 uno::Reference
<drawing::XShape
> xSecondParent(xSecondParentText
, uno::UNO_QUERY
);
736 CPPUNIT_ASSERT(xSecondParent
.is());
737 int nSecondParentLeft
= xSecondParent
->getPosition().X
;
738 // Without the accompanying fix in place, this test would have failed with
739 // 'Expected less than: 12700; Actual : 18540', i.e. the "b" and "c"
740 // shapes overlapped.
741 CPPUNIT_ASSERT_LESS(nSecondParentLeft
, nFirstChildRight
);
744 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testContinuousBlockProcess
)
746 createSdImpressDoc("pptx/smartart-continuous-block-process.pptx");
747 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
748 CPPUNIT_ASSERT(xGroup
.is());
749 // 3 children: diagram background, background arrow, foreground.
750 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xGroup
->getCount());
752 uno::Reference
<drawing::XShapes
> xLinear(xGroup
->getByIndex(2), uno::UNO_QUERY
);
753 CPPUNIT_ASSERT(xLinear
.is());
754 // 3 children: A, B and C.
755 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xLinear
->getCount());
757 uno::Reference
<text::XText
> xA(xLinear
->getByIndex(0), uno::UNO_QUERY
);
758 CPPUNIT_ASSERT(xA
.is());
759 CPPUNIT_ASSERT_EQUAL(u
"A"_ustr
, xA
->getString());
760 uno::Reference
<drawing::XShape
> xAShape(xA
, uno::UNO_QUERY
);
761 CPPUNIT_ASSERT(xAShape
.is());
762 // Without the accompanying fix in place, this test would have failed: the
763 // theoretically correct value is 5462 mm100 (16933 is the total width, and
764 // need to divide that to 1, 0.5, 1, 0.5 and 1 units), while the old value
765 // was 4703 and the new one is 5461.
766 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(5000), xAShape
->getSize().Width
);
769 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testOrgChart
)
771 // Simple org chart with 1 manager and 1 employee only.
772 createSdImpressDoc("pptx/smartart-org-chart.pptx");
773 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
774 CPPUNIT_ASSERT(xGroup
.is());
776 uno::Reference
<text::XText
> xManager(
777 getChildShape(getChildShape(getChildShape(xGroup
, 1), 0), 0), uno::UNO_QUERY
);
778 CPPUNIT_ASSERT(xManager
.is());
779 // Without the accompanying fix in place, this test would have failed: this
780 // was just "Manager", and the second paragraph was lost.
781 CPPUNIT_ASSERT_EQUAL(u
"Manager\nSecond para"_ustr
, xManager
->getString());
783 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xManager
, uno::UNO_QUERY
);
784 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
785 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
786 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xPara
, uno::UNO_QUERY
);
787 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
788 uno::Reference
<beans::XPropertySet
> xRun(xRunEnum
->nextElement(), uno::UNO_QUERY
);
790 xRun
->getPropertyValue(u
"CharColor"_ustr
) >>= nActualColor
;
791 // Without the accompanying fix in place, this test would have failed: the
792 // "Manager" font color was black, not white.
793 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, nActualColor
);
795 uno::Reference
<drawing::XShape
> xManagerShape(xManager
, uno::UNO_QUERY
);
796 CPPUNIT_ASSERT(xManagerShape
.is());
798 awt::Point aManagerPos
= xManagerShape
->getPosition();
799 awt::Size aManagerSize
= xManagerShape
->getSize();
801 // Make sure that the manager has 2 employees.
802 uno::Reference
<drawing::XShapes
> xEmployees(getChildShape(getChildShape(xGroup
, 1), 2),
804 CPPUNIT_ASSERT(xEmployees
.is());
805 // 4 children: connector, 1st employee, connector, 2nd employee.
806 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xEmployees
->getCount());
808 uno::Reference
<text::XText
> xEmployee(
810 getChildShape(getChildShape(getChildShape(getChildShape(xGroup
, 1), 2), 1), 0), 0),
812 CPPUNIT_ASSERT(xEmployee
.is());
813 CPPUNIT_ASSERT_EQUAL(u
"Employee"_ustr
, xEmployee
->getString());
815 uno::Reference
<drawing::XShape
> xEmployeeShape(xEmployee
, uno::UNO_QUERY
);
816 CPPUNIT_ASSERT(xEmployeeShape
.is());
818 awt::Point aEmployeePos
= xEmployeeShape
->getPosition();
819 awt::Size aEmployeeSize
= xEmployeeShape
->getSize();
821 CPPUNIT_ASSERT_EQUAL(aManagerPos
.X
, aEmployeePos
.X
);
823 // Without the accompanying fix in place, this test would have failed: the
824 // two shapes were overlapping, i.e. "manager" was not above "employee".
825 CPPUNIT_ASSERT_GREATER(aManagerPos
.Y
, aEmployeePos
.Y
);
827 // Make sure that the second employee is on the right of the first one.
828 // Without the accompanying fix in place, this test would have failed, as
829 // the second employee was below the first one.
830 uno::Reference
<text::XText
> xEmployee2(
832 getChildShape(getChildShape(getChildShape(getChildShape(xGroup
, 1), 2), 3), 0), 0),
834 CPPUNIT_ASSERT(xEmployee2
.is());
835 CPPUNIT_ASSERT_EQUAL(u
"Employee2"_ustr
, xEmployee2
->getString());
837 uno::Reference
<drawing::XShape
> xEmployee2Shape(xEmployee2
, uno::UNO_QUERY
);
838 CPPUNIT_ASSERT(xEmployee2Shape
.is());
840 awt::Point aEmployee2Pos
= xEmployee2Shape
->getPosition();
841 //awt::Size aEmployee2Size = xEmployee2Shape->getSize();
842 CPPUNIT_ASSERT_GREATER(aEmployeePos
.X
, aEmployee2Pos
.X
);
844 // Make sure that assistant is above employees.
845 uno::Reference
<text::XText
> xAssistant(
847 getChildShape(getChildShape(getChildShape(getChildShape(xGroup
, 1), 1), 1), 0), 0),
849 CPPUNIT_ASSERT_EQUAL(u
"Assistant"_ustr
, xAssistant
->getString());
851 uno::Reference
<drawing::XShape
> xAssistantShape(xAssistant
, uno::UNO_QUERY
);
852 CPPUNIT_ASSERT(xAssistantShape
.is());
854 awt::Point aAssistantPos
= xAssistantShape
->getPosition();
855 // Without the accompanying fix in place, this test would have failed: the
856 // assistant shape was below the employee shape.
857 CPPUNIT_ASSERT_GREATER(aAssistantPos
.Y
, aEmployeePos
.Y
);
859 // Make sure the connector of the assistant is above the shape.
860 uno::Reference
<drawing::XShape
> xAssistantConnector
861 = getChildShape(getChildShape(getChildShape(xGroup
, 1), 1), 0);
862 CPPUNIT_ASSERT(xAssistantConnector
.is());
863 //awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition();
864 // This failed, the vertical positions of the connector and the shape of
865 // the assistant were the same.
866 //CPPUNIT_ASSERT_LESS(aAssistantPos.Y, aAssistantConnectorPos.Y);
867 // connectors are hidden as they don't work correctly
869 // Make sure the height of xManager and xManager2 is the same.
870 uno::Reference
<text::XText
> xManager2(
871 getChildShape(getChildShape(getChildShape(xGroup
, 2), 0), 0), uno::UNO_QUERY
);
872 CPPUNIT_ASSERT(xManager2
.is());
873 CPPUNIT_ASSERT_EQUAL(u
"Manager2"_ustr
, xManager2
->getString());
875 uno::Reference
<drawing::XShape
> xManager2Shape(xManager2
, uno::UNO_QUERY
);
876 CPPUNIT_ASSERT(xManager2Shape
.is());
878 awt::Size aManager2Size
= xManager2Shape
->getSize();
879 // Without the accompanying fix in place, this test would have failed:
880 // xManager2's height was 3 times larger than xManager's height.
881 CPPUNIT_ASSERT_EQUAL(aManagerSize
.Height
, aManager2Size
.Height
);
883 // Make sure the employee nodes use the free space on the right, since
884 // manager2 has no assistants / employees.
885 //CPPUNIT_ASSERT_GREATER(aManagerSize.Width, aEmployeeSize.Width + aEmployee2Size.Width);
886 // currently disabled as causes problems in complex charts
888 // Without the accompanying fix in place, this test would have failed: an
889 // employee was exactly the third of the total height, without any spacing.
890 CPPUNIT_ASSERT_LESS(xGroup
->getSize().Height
/ 3, aEmployeeSize
.Height
);
893 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testCycleMatrix
)
895 createSdImpressDoc("pptx/smartart-cycle-matrix.pptx");
896 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
897 CPPUNIT_ASSERT(xGroup
.is());
899 // Without the accompanying fix in place, this test would have failed: the height was 12162,
900 // which is not the mm100 equivalent of the 4064000 EMU in the input file.
901 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(11288), xGroup
->getSize().Height
);
903 uno::Reference
<text::XText
> xA1(getChildShape(getChildShape(xGroup
, 2), 0), uno::UNO_QUERY
);
904 CPPUNIT_ASSERT(xA1
.is());
905 CPPUNIT_ASSERT_EQUAL(u
"A1"_ustr
, xA1
->getString());
907 // Test fill color of B1, should be orange.
908 uno::Reference
<text::XText
> xB1(getChildShape(getChildShape(xGroup
, 2), 1), uno::UNO_QUERY
);
909 CPPUNIT_ASSERT(xB1
.is());
910 CPPUNIT_ASSERT_EQUAL(u
"B1"_ustr
, xB1
->getString());
912 uno::Reference
<beans::XPropertySet
> xB1Props(xB1
, uno::UNO_QUERY
);
913 CPPUNIT_ASSERT(xB1Props
.is());
915 xB1Props
->getPropertyValue(u
"FillColor"_ustr
) >>= nFillColor
;
916 // Without the accompanying fix in place, this test would have failed: the background color was
917 // 0x4f81bd, i.e. blue, not orange.
918 CPPUNIT_ASSERT_EQUAL(Color(0xf79646), nFillColor
);
920 // Without the accompanying fix in place, this test would have failed: the
921 // content of the "A2" shape was lost.
922 uno::Reference
<text::XText
> xA2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 0), 1),
924 CPPUNIT_ASSERT(xA2
.is());
925 CPPUNIT_ASSERT_EQUAL(u
"A2"_ustr
, xA2
->getString());
927 // Test that the layout of shapes is like this:
931 uno::Reference
<drawing::XShape
> xA2Shape(xA2
, uno::UNO_QUERY
);
932 CPPUNIT_ASSERT(xA2Shape
.is());
934 uno::Reference
<text::XText
> xB2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 1), 1),
936 CPPUNIT_ASSERT(xB2
.is());
937 CPPUNIT_ASSERT_EQUAL(u
"B2"_ustr
, xB2
->getString());
938 uno::Reference
<drawing::XShape
> xB2Shape(xB2
, uno::UNO_QUERY
);
939 CPPUNIT_ASSERT(xB2Shape
.is());
941 // Test line color of B2, should be orange.
942 uno::Reference
<beans::XPropertySet
> xB2Props(xB2
, uno::UNO_QUERY
);
943 CPPUNIT_ASSERT(xB2Props
.is());
944 Color nLineColor
= 0;
945 xB2Props
->getPropertyValue(u
"LineColor"_ustr
) >>= nLineColor
;
946 CPPUNIT_ASSERT_EQUAL(Color(0xf79646), nLineColor
);
948 uno::Reference
<text::XText
> xC2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 2), 1),
950 CPPUNIT_ASSERT(xC2
.is());
951 // Without the accompanying fix in place, this test would have failed, i.e. the order of the
952 // lines in the shape were wrong: C2-1\nC2-4\nC2-3\nC2-2.
953 CPPUNIT_ASSERT_EQUAL(u
"C2-1\nC2-2\nC2-3\nC2-4"_ustr
, xC2
->getString());
954 uno::Reference
<drawing::XShape
> xC2Shape(xC2
, uno::UNO_QUERY
);
955 CPPUNIT_ASSERT(xC2Shape
.is());
957 uno::Reference
<text::XText
> xD2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 3), 1),
959 CPPUNIT_ASSERT(xD2
.is());
960 CPPUNIT_ASSERT_EQUAL(u
"D2"_ustr
, xD2
->getString());
961 uno::Reference
<drawing::XShape
> xD2Shape(xD2
, uno::UNO_QUERY
);
962 CPPUNIT_ASSERT(xD2Shape
.is());
964 // Without the accompanying fix in place, this test would have failed, i.e.
965 // the A2 and B2 shapes had the same horizontal position, while B2 should
966 // be on the right of A2.
967 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().X
, xB2Shape
->getPosition().X
);
968 CPPUNIT_ASSERT_EQUAL(xA2Shape
->getPosition().Y
, xB2Shape
->getPosition().Y
);
969 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().X
, xC2Shape
->getPosition().X
);
970 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().Y
, xC2Shape
->getPosition().Y
);
971 CPPUNIT_ASSERT_EQUAL(xA2Shape
->getPosition().X
, xD2Shape
->getPosition().X
);
972 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().Y
, xD2Shape
->getPosition().Y
);
974 // Without the accompanying fix in place, this test would have failed: width was expected to be
975 // 4887, was actually 7331.
976 uno::Reference
<drawing::XShape
> xA1Shape(xA1
, uno::UNO_QUERY
);
977 CPPUNIT_ASSERT(xA1Shape
.is());
978 CPPUNIT_ASSERT_EQUAL(xA1Shape
->getSize().Height
, xA1Shape
->getSize().Width
);
981 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testPictureStrip
)
983 createSdImpressDoc("pptx/smartart-picture-strip.pptx");
984 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
985 CPPUNIT_ASSERT(xGroup
.is());
987 uno::Reference
<beans::XPropertySet
> xFirstImage(getChildShape(getChildShape(xGroup
, 1), 1),
989 CPPUNIT_ASSERT(xFirstImage
.is());
990 drawing::FillStyle eFillStyle
= drawing::FillStyle_NONE
;
991 xFirstImage
->getPropertyValue(u
"FillStyle"_ustr
) >>= eFillStyle
;
992 // Without the accompanying fix in place, this test would have failed: fill style was solid, not
994 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, eFillStyle
);
996 uno::Reference
<graphic::XGraphic
> xGraphic
;
997 xFirstImage
->getPropertyValue(u
"FillBitmap"_ustr
) >>= xGraphic
;
998 Graphic
aFirstGraphic(xGraphic
);
1000 uno::Reference
<beans::XPropertySet
> xSecondImage(getChildShape(getChildShape(xGroup
, 2), 1),
1002 CPPUNIT_ASSERT(xSecondImage
.is());
1003 eFillStyle
= drawing::FillStyle_NONE
;
1004 xSecondImage
->getPropertyValue(u
"FillStyle"_ustr
) >>= eFillStyle
;
1005 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, eFillStyle
);
1007 xSecondImage
->getPropertyValue(u
"FillBitmap"_ustr
) >>= xGraphic
;
1008 Graphic
aSecondGraphic(xGraphic
);
1009 // Without the accompanying fix in place, this test would have failed: both xFirstImage and
1010 // xSecondImage had the bitmap fill from the second shape.
1011 CPPUNIT_ASSERT(aFirstGraphic
.GetChecksum() != aSecondGraphic
.GetChecksum());
1013 // Test that the 3 images are in a single column, in 3 rows.
1014 uno::Reference
<drawing::XShape
> xFirstImageShape(xFirstImage
, uno::UNO_QUERY
);
1015 CPPUNIT_ASSERT(xFirstImage
.is());
1016 uno::Reference
<drawing::XShape
> xSecondImageShape(xSecondImage
, uno::UNO_QUERY
);
1017 CPPUNIT_ASSERT(xSecondImage
.is());
1018 uno::Reference
<drawing::XShape
> xThirdImageShape
= getChildShape(getChildShape(xGroup
, 3), 1);
1019 CPPUNIT_ASSERT(xThirdImageShape
.is());
1020 // Without the accompanying fix in place, this test would have failed: the first and the second
1021 // image were in the same row.
1022 CPPUNIT_ASSERT_EQUAL(xFirstImageShape
->getPosition().X
, xSecondImageShape
->getPosition().X
);
1023 CPPUNIT_ASSERT_EQUAL(xSecondImageShape
->getPosition().X
, xThirdImageShape
->getPosition().X
);
1024 CPPUNIT_ASSERT_GREATER(xFirstImageShape
->getPosition().Y
, xSecondImageShape
->getPosition().Y
);
1025 CPPUNIT_ASSERT_GREATER(xSecondImageShape
->getPosition().Y
, xThirdImageShape
->getPosition().Y
);
1027 // Make sure that the title shape doesn't overlap with the diagram.
1028 // Note that real "no overlap" is asserted here, though in fact what we want is a less strict
1029 // condition: that no text part of the title shape and the diagram overlaps.
1030 uno::Reference
<drawing::XShape
> xTitle(getShapeFromPage(1, 0), uno::UNO_QUERY
);
1031 CPPUNIT_ASSERT(xTitle
.is());
1032 // Without the accompanying fix in place, this test would have failed with 'Expected greater
1033 // than: 2873; Actual : 2320', i.e. the title shape and the diagram overlapped.
1034 uno::Reference
<drawing::XShape
> xFirstPair
= getChildShape(xGroup
, 1);
1035 CPPUNIT_ASSERT_GREATER(xTitle
->getPosition().Y
+ xTitle
->getSize().Height
- 1069,
1036 xFirstPair
->getPosition().Y
);
1038 // Make sure that left margin is 60% of width (if you count width in points and margin in mms).
1039 uno::Reference
<beans::XPropertySet
> xFirstText(getChildShape(getChildShape(xGroup
, 1), 0),
1041 CPPUNIT_ASSERT(xFirstText
.is());
1042 sal_Int32 nTextLeftDistance
= 0;
1043 xFirstText
->getPropertyValue(u
"TextLeftDistance"_ustr
) >>= nTextLeftDistance
;
1044 uno::Reference
<drawing::XShape
> xFirstTextShape(xFirstText
, uno::UNO_QUERY
);
1045 CPPUNIT_ASSERT(xFirstTextShape
.is());
1046 sal_Int32 nWidth
= xFirstTextShape
->getSize().Width
;
1047 double fFactor
= oox::drawingml::convertPointToMms(0.6);
1048 // Without the accompanying fix in place, this test would have failed with 'Expected: 3440,
1049 // Actual : 263', i.e. the left margin was too small.
1050 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(nWidth
* fFactor
), nTextLeftDistance
);
1052 // Make sure that aspect ratio is not ignored, i.e. width is not larger than height 3 times.
1053 awt::Size aFirstPairSize
= xFirstPair
->getSize();
1054 // Without the accompanying fix in place, this test would have failed: bad width was 16932, good
1055 // width is 12540, but let's accept 12541 as well.
1056 CPPUNIT_ASSERT_LESSEQUAL(aFirstPairSize
.Height
* 3 + 1, aFirstPairSize
.Width
);
1059 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testInteropGrabBag
)
1061 createSdImpressDoc("pptx/smartart-interopgrabbag.pptx");
1062 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1063 CPPUNIT_ASSERT(xGroup
.is());
1065 uno::Reference
<beans::XPropertySet
> xPropertySet(xGroup
, uno::UNO_QUERY_THROW
);
1066 uno::Sequence
<beans::PropertyValue
> aGrabBagSeq
;
1067 xPropertySet
->getPropertyValue(u
"InteropGrabBag"_ustr
) >>= aGrabBagSeq
;
1068 comphelper::SequenceAsHashMap
aGrabBag(aGrabBagSeq
);
1069 CPPUNIT_ASSERT(aGrabBag
.find(u
"OOXData"_ustr
) != aGrabBag
.end());
1070 CPPUNIT_ASSERT(aGrabBag
.find(u
"OOXLayout"_ustr
) != aGrabBag
.end());
1071 CPPUNIT_ASSERT(aGrabBag
.find(u
"OOXStyle"_ustr
) != aGrabBag
.end());
1072 CPPUNIT_ASSERT(aGrabBag
.find(u
"OOXColor"_ustr
) != aGrabBag
.end());
1073 CPPUNIT_ASSERT(aGrabBag
.find(u
"OOXDrawing"_ustr
) != aGrabBag
.end());
1076 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBackground
)
1078 createSdImpressDoc("pptx/smartart-background.pptx");
1079 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1080 CPPUNIT_ASSERT(xGroup
.is());
1082 // background should fill whole diagram
1083 uno::Reference
<drawing::XShape
> xShapeGroup(xGroup
, uno::UNO_QUERY
);
1084 uno::Reference
<drawing::XShape
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
1085 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().X
, xShapeGroup
->getPosition().X
);
1086 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().Y
, xShapeGroup
->getPosition().Y
);
1087 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Width
, xShapeGroup
->getSize().Width
);
1088 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Height
, xShapeGroup
->getSize().Height
);
1090 uno::Reference
<beans::XPropertySet
> xPropertySet(xShape
, uno::UNO_QUERY_THROW
);
1091 drawing::FillStyle eFillStyle
= drawing::FillStyle_NONE
;
1092 xPropertySet
->getPropertyValue(u
"FillStyle"_ustr
) >>= eFillStyle
;
1093 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, eFillStyle
);
1096 xPropertySet
->getPropertyValue(u
"FillColor"_ustr
) >>= nFillColor
;
1097 CPPUNIT_ASSERT_EQUAL(Color(0x339933), nFillColor
);
1099 bool bMoveProtect
= false;
1100 xPropertySet
->getPropertyValue(u
"MoveProtect"_ustr
) >>= bMoveProtect
;
1101 CPPUNIT_ASSERT_EQUAL(true, bMoveProtect
);
1103 bool bSizeProtect
= false;
1104 xPropertySet
->getPropertyValue(u
"SizeProtect"_ustr
) >>= bSizeProtect
;
1105 CPPUNIT_ASSERT_EQUAL(true, bSizeProtect
);
1108 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBackgroundDrawingmlFallback
)
1110 // same as testBackground, but test file contains drawingML fallback
1112 createSdImpressDoc("pptx/smartart-background-drawingml-fallback.pptx");
1113 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1114 CPPUNIT_ASSERT(xGroup
.is());
1116 // background should fill whole diagram
1117 uno::Reference
<drawing::XShape
> xShapeGroup(xGroup
, uno::UNO_QUERY
);
1118 uno::Reference
<drawing::XShape
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
1119 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().X
, xShapeGroup
->getPosition().X
);
1120 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().Y
, xShapeGroup
->getPosition().Y
);
1121 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Width
, xShapeGroup
->getSize().Width
);
1122 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Height
, xShapeGroup
->getSize().Height
);
1124 uno::Reference
<beans::XPropertySet
> xPropertySet(xShape
, uno::UNO_QUERY_THROW
);
1125 drawing::FillStyle eFillStyle
= drawing::FillStyle_NONE
;
1126 xPropertySet
->getPropertyValue(u
"FillStyle"_ustr
) >>= eFillStyle
;
1127 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, eFillStyle
);
1130 xPropertySet
->getPropertyValue(u
"FillColor"_ustr
) >>= nFillColor
;
1131 CPPUNIT_ASSERT_EQUAL(Color(0x339933), nFillColor
);
1133 bool bMoveProtect
= false;
1134 xPropertySet
->getPropertyValue(u
"MoveProtect"_ustr
) >>= bMoveProtect
;
1135 CPPUNIT_ASSERT_EQUAL(true, bMoveProtect
);
1137 bool bSizeProtect
= false;
1138 xPropertySet
->getPropertyValue(u
"SizeProtect"_ustr
) >>= bSizeProtect
;
1139 CPPUNIT_ASSERT_EQUAL(true, bSizeProtect
);
1142 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testCenterCycle
)
1144 createSdImpressDoc("pptx/smartart-center-cycle.pptx");
1145 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1146 CPPUNIT_ASSERT(xGroup
.is());
1148 uno::Reference
<drawing::XShapes
> xGroupNested(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1149 CPPUNIT_ASSERT(xGroupNested
.is());
1151 uno::Reference
<drawing::XShape
> xShapeCenter(xGroupNested
->getByIndex(0), uno::UNO_QUERY
);
1152 uno::Reference
<drawing::XShape
> xShapeA(xGroupNested
->getByIndex(1), uno::UNO_QUERY
);
1153 uno::Reference
<drawing::XShape
> xShapeB(xGroupNested
->getByIndex(2), uno::UNO_QUERY
);
1154 uno::Reference
<drawing::XShape
> xShapeC(xGroupNested
->getByIndex(3), uno::UNO_QUERY
);
1156 uno::Reference
<text::XText
> xTextCenter(xShapeCenter
, uno::UNO_QUERY
);
1157 CPPUNIT_ASSERT(xTextCenter
.is());
1158 CPPUNIT_ASSERT_EQUAL(u
"center"_ustr
, xTextCenter
->getString());
1160 CPPUNIT_ASSERT_LESS(xShapeCenter
->getPosition().Y
, xShapeA
->getPosition().Y
);
1161 CPPUNIT_ASSERT_GREATER(xShapeCenter
->getPosition().X
, xShapeB
->getPosition().X
);
1162 CPPUNIT_ASSERT_GREATER(xShapeCenter
->getPosition().Y
, xShapeB
->getPosition().Y
);
1163 CPPUNIT_ASSERT_LESS(xShapeCenter
->getPosition().X
, xShapeC
->getPosition().X
);
1164 CPPUNIT_ASSERT_GREATER(xShapeCenter
->getPosition().Y
, xShapeC
->getPosition().Y
);
1167 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testFontSize
)
1169 createSdImpressDoc("pptx/smartart-font-size.pptx");
1171 uno::Reference
<drawing::XShapes
> xGroup1(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1172 uno::Reference
<beans::XPropertySet
> xShape1(xGroup1
->getByIndex(1), uno::UNO_QUERY
);
1173 uno::Reference
<text::XTextRange
> xParagraph1(getParagraphFromShape(0, xShape1
));
1174 uno::Reference
<text::XTextRange
> xRun1(getRunFromParagraph(0, xParagraph1
));
1175 uno::Reference
<beans::XPropertySet
> xPropSet1(xRun1
, uno::UNO_QUERY
);
1176 double fFontSize1
= xPropSet1
->getPropertyValue(u
"CharHeight"_ustr
).get
<double>();
1177 CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, fFontSize1
, 0.01);
1179 uno::Reference
<drawing::XShapes
> xGroup2(getShapeFromPage(1, 0), uno::UNO_QUERY
);
1180 uno::Reference
<beans::XPropertySet
> xShape2(xGroup2
->getByIndex(1), uno::UNO_QUERY
);
1181 uno::Reference
<text::XTextRange
> xParagraph2(getParagraphFromShape(0, xShape2
));
1182 uno::Reference
<text::XTextRange
> xRun2(getRunFromParagraph(0, xParagraph2
));
1183 uno::Reference
<beans::XPropertySet
> xPropSet2(xRun2
, uno::UNO_QUERY
);
1184 double fFontSize2
= xPropSet2
->getPropertyValue(u
"CharHeight"_ustr
).get
<double>();
1185 CPPUNIT_ASSERT_EQUAL(32.0, fFontSize2
);
1187 uno::Reference
<drawing::XShapes
> xGroup3(getShapeFromPage(2, 0), uno::UNO_QUERY
);
1188 uno::Reference
<beans::XPropertySet
> xShape3(xGroup3
->getByIndex(1), uno::UNO_QUERY
);
1189 drawing::TextFitToSizeType eTextFitToSize
= drawing::TextFitToSizeType_NONE
;
1190 xShape3
->getPropertyValue(u
"TextFitToSize"_ustr
) >>= eTextFitToSize
;
1191 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_AUTOFIT
, eTextFitToSize
);
1194 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testVerticalBlockList
)
1196 createSdImpressDoc("pptx/smartart-vertical-block-list.pptx");
1197 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1198 CPPUNIT_ASSERT(xGroup
.is());
1200 uno::Reference
<drawing::XShapes
> xGroup1(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1201 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xGroup1
->getCount());
1202 uno::Reference
<drawing::XShape
> xShapeA(xGroup1
->getByIndex(1), uno::UNO_QUERY
);
1203 uno::Reference
<drawing::XShape
> xShapeBC(xGroup1
->getByIndex(0), uno::UNO_QUERY
);
1204 uno::Reference
<text::XText
> xTextA(xShapeA
, uno::UNO_QUERY
);
1205 uno::Reference
<text::XText
> xTextBC(xShapeBC
, uno::UNO_QUERY
);
1206 CPPUNIT_ASSERT_EQUAL(u
"a"_ustr
, xTextA
->getString());
1207 CPPUNIT_ASSERT_EQUAL(u
"b\nc"_ustr
, xTextBC
->getString());
1209 uno::Reference
<beans::XPropertySet
> xPropSetBC(xShapeBC
, uno::UNO_QUERY
);
1210 CPPUNIT_ASSERT_EQUAL(sal_Int32(27000),
1211 xPropSetBC
->getPropertyValue(u
"RotateAngle"_ustr
).get
<sal_Int32
>());
1213 // BC shape is rotated 90*, so width and height is swapped
1214 CPPUNIT_ASSERT_GREATER(xShapeA
->getSize().Width
, xShapeBC
->getSize().Height
);
1215 CPPUNIT_ASSERT_LESS(xShapeA
->getSize().Height
, xShapeBC
->getSize().Width
);
1216 CPPUNIT_ASSERT_GREATER(xShapeA
->getPosition().X
, xShapeBC
->getPosition().X
);
1217 CPPUNIT_ASSERT_GREATER(xShapeA
->getPosition().Y
, xShapeBC
->getPosition().Y
);
1219 uno::Reference
<drawing::XShapes
> xGroup3(xGroup
->getByIndex(3), uno::UNO_QUERY
);
1220 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), xGroup3
->getCount());
1221 uno::Reference
<drawing::XShape
> xShapeEmpty(xGroup3
->getByIndex(0), uno::UNO_QUERY
);
1222 uno::Reference
<text::XText
> xTextEmpty(xShapeEmpty
, uno::UNO_QUERY
);
1223 CPPUNIT_ASSERT_EQUAL(u
"empty"_ustr
, xTextEmpty
->getString());
1225 CPPUNIT_ASSERT_EQUAL(xShapeA
->getSize().Width
, xShapeEmpty
->getSize().Width
);
1226 CPPUNIT_ASSERT_EQUAL(xShapeA
->getSize().Height
, xShapeEmpty
->getSize().Height
);
1227 CPPUNIT_ASSERT_EQUAL(xShapeA
->getPosition().X
, xShapeEmpty
->getPosition().X
);
1228 CPPUNIT_ASSERT_GREATER(xShapeA
->getPosition().Y
+ 2 * xShapeA
->getSize().Height
,
1229 xShapeEmpty
->getPosition().Y
);
1231 uno::Reference
<drawing::XShape
> xGroupShape(xGroup
, uno::UNO_QUERY
);
1232 CPPUNIT_ASSERT_EQUAL(xGroupShape
->getPosition().Y
+ xGroupShape
->getSize().Height
,
1233 xShapeEmpty
->getPosition().Y
+ xShapeEmpty
->getSize().Height
);
1236 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testMissingBulletAndIndent
)
1238 createSdImpressDoc("pptx/smartart-missing-bullet.pptx");
1239 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1240 uno::Reference
<drawing::XShapes
> xGroup1(xGroup
->getByIndex(2), uno::UNO_QUERY
);
1241 uno::Reference
<drawing::XShapes
> xGroup2(xGroup1
->getByIndex(0), uno::UNO_QUERY
);
1242 uno::Reference
<text::XText
> xText(xGroup2
->getByIndex(0), uno::UNO_QUERY
);
1243 CPPUNIT_ASSERT(xText
.is());
1245 uno::Reference
<container::XEnumerationAccess
> xParasAccess(xText
, uno::UNO_QUERY
);
1246 uno::Reference
<container::XEnumeration
> xParas
= xParasAccess
->createEnumeration();
1247 xParas
->nextElement(); // skip parent
1249 uno::Reference
<beans::XPropertySet
> xPara1(xParas
->nextElement(), uno::UNO_QUERY
);
1250 CPPUNIT_ASSERT(xPara1
.is());
1252 sal_Int16 nNumberingLevel
= -1;
1253 xPara1
->getPropertyValue(u
"NumberingLevel"_ustr
) >>= nNumberingLevel
;
1254 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nNumberingLevel
);
1256 uno::Reference
<container::XIndexAccess
> xNumRule
;
1257 xPara1
->getPropertyValue(u
"NumberingRules"_ustr
) >>= xNumRule
;
1258 uno::Sequence
<beans::PropertyValue
> aBulletProps
;
1259 xNumRule
->getByIndex(1) >>= aBulletProps
;
1261 for (beans::PropertyValue
const& rProp
: aBulletProps
)
1263 if (rProp
.Name
== "LeftMargin")
1264 CPPUNIT_ASSERT_EQUAL(sal_Int32(309), rProp
.Value
.get
<sal_Int32
>());
1268 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testBulletList
)
1270 createSdImpressDoc("pptx/smartart-bullet-list.pptx");
1271 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1272 CPPUNIT_ASSERT(xGroup
.is());
1274 uno::Reference
<text::XText
> xText(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1275 uno::Reference
<container::XEnumerationAccess
> xParasAccess(xText
, uno::UNO_QUERY
);
1276 uno::Reference
<container::XEnumeration
> xParas
= xParasAccess
->createEnumeration();
1277 xParas
->nextElement(); // skip parent
1279 // child levels should have bullets
1280 uno::Reference
<beans::XPropertySet
> xPara1(xParas
->nextElement(), uno::UNO_QUERY
);
1281 uno::Reference
<container::XIndexAccess
> xRules1(
1282 xPara1
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
1283 comphelper::SequenceAsHashMap
aRule1(xRules1
->getByIndex(1));
1284 CPPUNIT_ASSERT_EQUAL(u
"•"_ustr
, aRule1
[u
"BulletChar"_ustr
].get
<OUString
>());
1286 uno::Reference
<beans::XPropertySet
> xPara2(xParas
->nextElement(), uno::UNO_QUERY
);
1287 uno::Reference
<container::XIndexAccess
> xRules2(
1288 xPara2
->getPropertyValue(u
"NumberingRules"_ustr
), uno::UNO_QUERY
);
1289 comphelper::SequenceAsHashMap
aRule2(xRules2
->getByIndex(2));
1290 CPPUNIT_ASSERT_EQUAL(u
"•"_ustr
, aRule2
[u
"BulletChar"_ustr
].get
<OUString
>());
1293 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testRecursion
)
1295 createSdImpressDoc("pptx/smartart-recursion.pptx");
1297 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1298 uno::Reference
<drawing::XShapes
> xGroup1(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1300 uno::Reference
<drawing::XShapes
> xGroupA(xGroup1
->getByIndex(0), uno::UNO_QUERY
);
1301 uno::Reference
<text::XText
> xTextA(xGroupA
->getByIndex(0), uno::UNO_QUERY
);
1302 CPPUNIT_ASSERT_EQUAL(u
"A"_ustr
, xTextA
->getString());
1304 uno::Reference
<drawing::XShapes
> xGroupB(xGroup1
->getByIndex(1), uno::UNO_QUERY
);
1305 // 5 connectors, B1 with children, B2 with children
1306 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(7), xGroupB
->getCount());
1308 uno::Reference
<drawing::XShapes
> xGroupB1(xGroupB
->getByIndex(1), uno::UNO_QUERY
);
1310 uno::Reference
<drawing::XShapes
> xGroupB1a(xGroupB1
->getByIndex(0), uno::UNO_QUERY
);
1311 uno::Reference
<text::XText
> xTextB1(xGroupB1a
->getByIndex(0), uno::UNO_QUERY
);
1312 CPPUNIT_ASSERT_EQUAL(u
"B1"_ustr
, xTextB1
->getString());
1314 uno::Reference
<drawing::XShape
> xGroupC12(xGroupB1
->getByIndex(1), uno::UNO_QUERY
);
1315 uno::Reference
<text::XText
> xTextC1(
1316 getChildShape(getChildShape(getChildShape(xGroupC12
, 0), 0), 0), uno::UNO_QUERY
);
1317 CPPUNIT_ASSERT_EQUAL(u
"C1"_ustr
, xTextC1
->getString());
1318 uno::Reference
<text::XText
> xTextC2(
1319 getChildShape(getChildShape(getChildShape(xGroupC12
, 1), 0), 0), uno::UNO_QUERY
);
1320 CPPUNIT_ASSERT_EQUAL(u
"C2"_ustr
, xTextC2
->getString());
1322 uno::Reference
<drawing::XShapes
> xGroupB2(xGroupB
->getByIndex(5), uno::UNO_QUERY
);
1324 uno::Reference
<drawing::XShapes
> xGroupB2a(xGroupB2
->getByIndex(0), uno::UNO_QUERY
);
1325 uno::Reference
<text::XText
> xTextB2(xGroupB2a
->getByIndex(0), uno::UNO_QUERY
);
1326 CPPUNIT_ASSERT_EQUAL(u
"B2"_ustr
, xTextB2
->getString());
1328 uno::Reference
<drawing::XShape
> xGroupC3(xGroupB2
->getByIndex(1), uno::UNO_QUERY
);
1329 uno::Reference
<text::XText
> xTextC3(
1330 getChildShape(getChildShape(getChildShape(xGroupC3
, 0), 0), 0), uno::UNO_QUERY
);
1331 CPPUNIT_ASSERT_EQUAL(u
"C3"_ustr
, xTextC3
->getString());
1334 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testDataFollow
)
1336 // checks if data nodes are followed correctly
1337 // different variables are set for two presentation points with the same name
1338 // they should be layouted differently - one horizontally and one vertically
1340 createSdImpressDoc("pptx/smartart-data-follow.pptx");
1342 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1344 uno::Reference
<drawing::XShapes
> xGroupLeft(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1345 uno::Reference
<drawing::XShape
> xGroupB(xGroupLeft
->getByIndex(1), uno::UNO_QUERY
);
1346 uno::Reference
<drawing::XShape
> xShapeB1
1347 = getChildShape(getChildShape(getChildShape(xGroupB
, 1), 0), 0);
1348 uno::Reference
<text::XText
> xTextB1(xShapeB1
, uno::UNO_QUERY
);
1349 CPPUNIT_ASSERT_EQUAL(u
"B1"_ustr
, xTextB1
->getString());
1350 uno::Reference
<drawing::XShape
> xShapeB2
1351 = getChildShape(getChildShape(getChildShape(xGroupB
, 3), 0), 0);
1352 uno::Reference
<text::XText
> xTextB2(xShapeB2
, uno::UNO_QUERY
);
1353 CPPUNIT_ASSERT_EQUAL(u
"B2"_ustr
, xTextB2
->getString());
1355 CPPUNIT_ASSERT_EQUAL(xShapeB1
->getPosition().Y
, xShapeB2
->getPosition().Y
);
1356 CPPUNIT_ASSERT_GREATEREQUAL(xShapeB1
->getPosition().X
+ xShapeB1
->getSize().Width
,
1357 xShapeB2
->getPosition().X
);
1359 uno::Reference
<drawing::XShapes
> xGroupRight(xGroup
->getByIndex(2), uno::UNO_QUERY
);
1360 uno::Reference
<drawing::XShape
> xGroupC(xGroupRight
->getByIndex(1), uno::UNO_QUERY
);
1361 uno::Reference
<drawing::XShape
> xShapeC1
1362 = getChildShape(getChildShape(getChildShape(xGroupC
, 3), 0), 0);
1363 uno::Reference
<text::XText
> xTextC1(xShapeC1
, uno::UNO_QUERY
);
1364 CPPUNIT_ASSERT_EQUAL(u
"C1"_ustr
, xTextC1
->getString());
1365 uno::Reference
<drawing::XShape
> xShapeC2
1366 = getChildShape(getChildShape(getChildShape(xGroupC
, 5), 0), 0);
1367 uno::Reference
<text::XText
> xTextC2(xShapeC2
, uno::UNO_QUERY
);
1368 CPPUNIT_ASSERT_EQUAL(u
"C2"_ustr
, xTextC2
->getString());
1370 CPPUNIT_ASSERT_EQUAL(xShapeC1
->getPosition().X
, xShapeC2
->getPosition().X
);
1371 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC1
->getPosition().Y
+ xShapeC1
->getSize().Height
,
1372 xShapeC2
->getPosition().Y
);
1375 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testOrgChart2
)
1377 createSdImpressDoc("pptx/smartart-org-chart2.pptx");
1378 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1380 uno::Reference
<drawing::XShape
> xShapeC1
= findChildShapeByText(xGroup
, u
"C1"_ustr
);
1381 uno::Reference
<drawing::XShape
> xShapeC2
= findChildShapeByText(xGroup
, u
"C2"_ustr
);
1382 uno::Reference
<drawing::XShape
> xShapeC3
= findChildShapeByText(xGroup
, u
"C3"_ustr
);
1383 uno::Reference
<drawing::XShape
> xShapeC4
= findChildShapeByText(xGroup
, u
"C4"_ustr
);
1384 uno::Reference
<drawing::XShape
> xShapeD1
= findChildShapeByText(xGroup
, u
"D1"_ustr
);
1385 uno::Reference
<drawing::XShape
> xShapeD2
= findChildShapeByText(xGroup
, u
"D2"_ustr
);
1387 CPPUNIT_ASSERT(xShapeC1
.is());
1388 CPPUNIT_ASSERT(xShapeC2
.is());
1389 CPPUNIT_ASSERT(xShapeC3
.is());
1390 CPPUNIT_ASSERT(xShapeC4
.is());
1391 CPPUNIT_ASSERT(xShapeD1
.is());
1392 CPPUNIT_ASSERT(xShapeD2
.is());
1394 CPPUNIT_ASSERT_EQUAL(xShapeC1
->getPosition().Y
, xShapeC2
->getPosition().Y
);
1395 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC1
->getPosition().X
+ xShapeC1
->getSize().Width
,
1396 xShapeC2
->getPosition().X
);
1398 CPPUNIT_ASSERT_EQUAL(xShapeC3
->getPosition().X
, xShapeC4
->getPosition().X
);
1399 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC3
->getPosition().Y
+ xShapeC3
->getSize().Height
,
1400 xShapeC4
->getPosition().Y
);
1402 CPPUNIT_ASSERT_EQUAL(xShapeD1
->getPosition().X
, xShapeD2
->getPosition().X
);
1403 CPPUNIT_ASSERT_GREATEREQUAL(xShapeD1
->getPosition().Y
+ xShapeD1
->getSize().Height
,
1404 xShapeD2
->getPosition().Y
);
1406 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC2
->getPosition().X
, xShapeD1
->getPosition().X
);
1407 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC2
->getPosition().Y
+ xShapeC2
->getSize().Height
,
1408 xShapeD1
->getPosition().Y
);
1410 CPPUNIT_ASSERT_GREATEREQUAL(xShapeD1
->getPosition().X
+ xShapeD1
->getSize().Width
,
1411 xShapeC4
->getPosition().X
);
1414 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf131553
)
1416 createSdImpressDoc("pptx/tdf131553.pptx");
1418 const SdrPage
* pPage
= GetPage(1);
1419 const SdrObjGroup
* pObjGroup
= dynamic_cast<SdrObjGroup
*>(pPage
->GetObj(0));
1420 CPPUNIT_ASSERT(pObjGroup
);
1421 const SdrObject
* pObj
= pObjGroup
->GetSubList()->GetObj(1);
1422 CPPUNIT_ASSERT_MESSAGE("no object", pObj
!= nullptr);
1423 CPPUNIT_ASSERT_EQUAL(SdrObjKind::OLE2
, pObj
->GetObjIdentifier());
1426 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testFillColorList
)
1428 createSdImpressDoc("pptx/fill-color-list.pptx");
1429 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1430 uno::Reference
<drawing::XShape
> xShape
= getChildShape(getChildShape(xGroup
, 1), 0);
1431 uno::Reference
<beans::XPropertySet
> xPropertySet(xShape
, uno::UNO_QUERY_THROW
);
1433 xPropertySet
->getPropertyValue(u
"FillColor"_ustr
) >>= nFillColor
;
1434 // Without the accompanying fix in place, this test would have failed with:
1435 // - Expected: 12603469 (0xc0504d)
1436 // - Actual : 16225862 (0xf79646)
1437 // i.e. the background of the "A" shape was orange-ish, rather than red-ish.
1438 CPPUNIT_ASSERT_EQUAL(Color(0xC0504D), nFillColor
);
1440 // Without the accompanying fix in place, this test would have failed with:
1443 // i.e. the "A" shape's height/width aspect ratio was not 0.4 but rather close to 1.0, even if
1444 // ppt/diagrams/layout1.xml's <dgm:constr type="h" refType="w" op="lte" fact="0.4"/> requested
1446 awt::Size aActualSize
= xShape
->getSize();
1447 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2239), aActualSize
.Height
);
1449 // Without the accompanying fix in place, this test would have failed with:
1450 // - Expected greater than: 1738 (2766)
1452 // i.e. the columns were not centered vertically.
1453 sal_Int32 nGroupTop
= xGroup
->getPosition().Y
;
1454 sal_Int32 nShapeTop
= xShape
->getPosition().Y
;
1455 CPPUNIT_ASSERT_GREATER(nGroupTop
, nShapeTop
);
1458 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf134221
)
1460 createSdImpressDoc("pptx/smartart-tdf134221.pptx");
1461 saveAndReload(u
"Impress Office Open XML"_ustr
);
1462 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1463 uno::Reference
<drawing::XShape
> xShapeB
= findChildShapeByText(xGroup
, u
"B"_ustr
);
1464 CPPUNIT_ASSERT(xShapeB
.is());
1465 uno::Reference
<beans::XPropertySet
> xTxtProps(xShapeB
, uno::UNO_QUERY_THROW
);
1467 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(-248),
1468 xTxtProps
->getPropertyValue(u
"TextUpperDistance"_ustr
).get
<sal_Int32
>());
1471 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testLinearRule
)
1473 createSdImpressDoc("pptx/smartart-linear-rule.pptx");
1475 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1476 // Last child, then first child inside that.
1477 // It is first as backgroundArrow is last, but chOrder="t" is set to reverse the order.
1478 uno::Reference
<drawing::XShape
> xShape
= getChildShape(getChildShape(xGroup
, 1), 0);
1480 // Without the accompanying fix in place, this test would have failed with:
1481 // - Expected greater than: 17500 (19867)
1483 // i.e. the width of the background arrow was too small.
1484 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(17500), xShape
->getSize().Width
);
1486 // Without the accompanying fix in place, this test would have failed with:
1489 // i.e. there was unexpected spacing on the left of the arrow.
1490 // Then the imported version of the test document failed with:
1493 // i.e. the spacing on the left of the arrow was so large that the shape was mostly outside the
1495 sal_Int32 nGroupLeft
= xGroup
->getPosition().X
;
1496 sal_Int32 nArrowLeft
= xShape
->getPosition().X
;
1497 CPPUNIT_ASSERT_EQUAL(nGroupLeft
, nArrowLeft
);
1499 // Without the accompanying fix in place, this test would have failed with:
1500 // - Expected less or equal than: 10092
1502 // i.e. the arrow height was larger than the canvas given to the smartart on slide 1.
1503 CPPUNIT_ASSERT_LESSEQUAL(static_cast<sal_Int32
>(10092), xShape
->getSize().Height
);
1506 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testLinearRuleVert
)
1508 createSdImpressDoc("pptx/smartart-linear-rule-vert.pptx");
1510 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1511 // Get the P1 shape.
1512 uno::Reference
<drawing::XShape
> xShape
= getChildShape(getChildShape(xGroup
, 1), 1);
1513 uno::Reference
<text::XTextRange
> xShapeText(xShape
, uno::UNO_QUERY
);
1514 CPPUNIT_ASSERT_EQUAL(u
"P1"_ustr
, xShapeText
->getString());
1516 // Without the accompanying fix in place, this test would have failed with:
1519 // i.e. the first item on the vertical linear layout used ~all space, the other items were not
1521 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2020), xShape
->getSize().Height
);
1524 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testAutofitSync
)
1526 createSdImpressDoc("pptx/smartart-autofit-sync.pptx");
1528 uno::Reference
<drawing::XShape
> xDiagram(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1529 uno::Reference
<drawing::XShape
> xMiddle
= getChildShape(xDiagram
, 2);
1530 uno::Reference
<beans::XPropertySet
> xFirstInner(getChildShape(getChildShape(xMiddle
, 0), 0),
1532 double fFirstScale
= 0;
1533 CPPUNIT_ASSERT(xFirstInner
->getPropertyValue(u
"TextFitToSizeFontScale"_ustr
) >>= fFirstScale
);
1534 CPPUNIT_ASSERT_GREATER(0.0, fFirstScale
);
1535 CPPUNIT_ASSERT_LESS(100.0, fFirstScale
);
1537 uno::Reference
<beans::XPropertySet
> xSecondInner(getChildShape(getChildShape(xMiddle
, 2), 0),
1539 double fSecondScale
= 0;
1540 CPPUNIT_ASSERT(xSecondInner
->getPropertyValue(u
"TextFitToSizeFontScale"_ustr
) >>= fSecondScale
);
1542 // Without the accompanying fix in place, this test would have failed with:
1545 // i.e. the left shape had no scale-down and the right shape was scaled down, even if it was
1546 // requested that their scaling matches.
1547 CPPUNIT_ASSERT_EQUAL(fSecondScale
, fFirstScale
);
1549 // Without the accompanying fix in place, this test would have failed with:
1550 // - Expected: 0 (drawing::TextFitToSizeType_NONE)
1551 // - Actual : 3 (TextFitToSizeType_AUTOFIT)
1552 // i.e. the 3rd shape had font size as direct formatting, but its automatic text scale was not
1554 uno::Reference
<beans::XPropertySet
> xThirdInner(getChildShape(getChildShape(xMiddle
, 4), 0),
1556 drawing::TextFitToSizeType eType
{};
1557 CPPUNIT_ASSERT(xThirdInner
->getPropertyValue(u
"TextFitToSize"_ustr
) >>= eType
);
1558 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE
, eType
);
1561 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testSnakeRows
)
1563 // Load a smartart which contains a snake algorithm.
1564 // The expected layout of the 6 children is a 3x2 grid.
1565 createSdImpressDoc("pptx/smartart-snake-rows.pptx");
1567 uno::Reference
<drawing::XShapes
> xDiagram(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1568 // Collect position of the background and the real child shapes. First row and background has
1569 // the same top position, unless some unexpected spacing happens, since this is a
1570 // "left-to-right, then top-to-bottom" snake direction.
1571 std::set
<sal_Int32
> aYPositions
;
1572 for (sal_Int32 nChild
= 0; nChild
< xDiagram
->getCount(); ++nChild
)
1574 uno::Reference
<drawing::XShape
> xChild(xDiagram
->getByIndex(nChild
), uno::UNO_QUERY
);
1575 aYPositions
.insert(xChild
->getPosition().Y
);
1578 // Without the accompanying fix in place, this test would have failed with:
1581 // i.e. an unwanted row appeared.
1582 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aYPositions
.size());
1585 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testCompositeInferRight
)
1587 // Load a smartart which contains a composite algorithm.
1588 // One constraint says that the left of the text should be the right of the image.
1589 createSdImpressDoc("pptx/smartart-composite-infer-right.pptx");
1591 uno::Reference
<drawing::XShape
> xDiagram(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1592 uno::Reference
<drawing::XShape
> xMiddle
= getChildShape(xDiagram
, 1);
1593 uno::Reference
<drawing::XShape
> xImage
= getChildShape(xMiddle
, 1);
1594 uno::Reference
<drawing::XShape
> xText
= getChildShape(xMiddle
, 2);
1595 sal_Int32 nRightOfImage
= xImage
->getPosition().X
+ xImage
->getSize().Width
;
1596 sal_Int32 nLeftOfText
= xText
->getPosition().X
;
1598 // Without the accompanying fix in place, this test would have failed with:
1599 // - Expected greater than: 7925
1601 // i.e. the text was overlapping with the image.
1602 CPPUNIT_ASSERT_GREATER(nRightOfImage
, nLeftOfText
);
1605 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf149551Pie
)
1607 // The file contains a diagram of type "Basic Pie".
1608 createSdImpressDoc("pptx/tdf149551_SmartArt_Pie.pptx");
1609 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1610 // shape at index 0 is the background shape
1611 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1612 CPPUNIT_ASSERT(xShape
.is());
1613 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1614 CPPUNIT_ASSERT(pCustomShape
);
1615 tools::Rectangle aTextRect
;
1616 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1617 // without fix the text area rectangle had LT [7787,3420] and RB[16677,12312]. The values from
1618 // txXfrm were ignored.
1619 // The used tolerance is estimated.
1620 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(12658), sal_Int32(aTextRect
.Left()), 4);
1621 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5073), sal_Int32(aTextRect
.Top()), 4);
1622 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(15627), sal_Int32(aTextRect
.Right()), 4);
1623 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7990), sal_Int32(aTextRect
.Bottom()), 4);
1626 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf149551Pyramid
)
1628 // The file contains a diagram of type "Basic Pyramid".
1629 createSdImpressDoc("pptx/tdf149551_SmartArt_Pyramid.pptx");
1630 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1631 // shape at index 0 is the background shape
1632 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1633 CPPUNIT_ASSERT(xShape
.is());
1634 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1635 CPPUNIT_ASSERT(pCustomShape
);
1636 tools::Rectangle aTextRect
;
1637 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1638 // without fix the text area rectangle had LT [9369,2700] and RB[14632,6185]. The values from
1639 // txXfrm were ignored.
1640 // The used tolerance is estimated.
1641 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7591), sal_Int32(aTextRect
.Left()), 4);
1642 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1515), sal_Int32(aTextRect
.Top()), 4);
1643 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(16410), sal_Int32(aTextRect
.Right()), 4);
1644 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7370), sal_Int32(aTextRect
.Bottom()), 4);
1647 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf149551Venn
)
1649 // The file contains a diagram of type "Stacked Venn".
1650 createSdImpressDoc("pptx/tdf149551_SmartArt_Venn.pptx");
1651 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1652 // shape at index 0 is the background shape
1653 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1654 CPPUNIT_ASSERT(xShape
.is());
1655 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1656 CPPUNIT_ASSERT(pCustomShape
);
1657 tools::Rectangle aTextRect
;
1658 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1659 // without fix the text area rectangle had LT [6865,3396] and RB[17136,4600]. The values from
1660 // txXfrm were ignored.
1661 // The used tolerance is estimated.
1662 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(8772), sal_Int32(aTextRect
.Left()), 4);
1663 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(1834), sal_Int32(aTextRect
.Top()), 4);
1664 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(15229), sal_Int32(aTextRect
.Right()), 4);
1665 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(6162), sal_Int32(aTextRect
.Bottom()), 4);
1668 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf149551Gear
)
1670 // The file contains a diagram of type "Gear".
1671 createSdImpressDoc("pptx/tdf149551_SmartArt_Gear.pptx");
1672 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1673 // shape at index 0 is the background shape
1674 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1675 CPPUNIT_ASSERT(xShape
.is());
1676 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1677 CPPUNIT_ASSERT(pCustomShape
);
1678 tools::Rectangle aTextRect
;
1679 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1680 // without fix the text area rectangle had LT [4101,1014] and RB[8019,4932]. The values from
1681 // txXfrm were ignored.
1682 // The used tolerance is estimated.
1683 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5501), sal_Int32(aTextRect
.Left()), 4);
1684 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4500), sal_Int32(aTextRect
.Top()), 4);
1685 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(11000), sal_Int32(aTextRect
.Right()), 4);
1686 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(9999), sal_Int32(aTextRect
.Bottom()), 4);
1689 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf145528Matrix
)
1691 // The file contains a diagram of type "Titled Matrix". Such is build from shapes of type
1693 createSdImpressDoc("pptx/tdf145528_SmartArt_Matrix.pptx");
1694 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1696 sal_Int32 nLeft
[]{ 4001, 12001, 12001, 18501 };
1697 sal_Int32 nTop
[]{ 9999, 1999, 12499, 5999 };
1698 // nWidth = 10292, nHeight = 4499
1699 // Without the fix in place the values were
1700 // nLeft {2001, 12001, 12001, 22001}
1701 // nTop {7999. 1999, 13999, 7999}
1702 // nWidth {6000, 10000, 10000, 6000}
1703 // nHeight {10000, 6000, 6000, 10000}
1704 tools::Rectangle aTextRect
;
1705 for (auto i
: { 1, 2, 3, 4 }) // shape at index 0 is the background shape
1707 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, i
);
1708 CPPUNIT_ASSERT(xShape
.is());
1710 = dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1711 CPPUNIT_ASSERT(pCustomShape
);
1712 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1713 CPPUNIT_ASSERT_DOUBLES_EQUAL(nLeft
[i
- 1], sal_Int32(aTextRect
.Left()), 4);
1714 CPPUNIT_ASSERT_DOUBLES_EQUAL(nTop
[i
- 1], sal_Int32(aTextRect
.Top()), 4);
1715 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(10293), sal_Int32(aTextRect
.GetWidth()), 4);
1716 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(4500), sal_Int32(aTextRect
.GetHeight()), 4);
1720 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf135953TextPosition
)
1722 // The file contains a diagram of type "Detailed Process". There the text area rectangle
1723 // is at the left edge of the shape and rotated there.
1724 createSdImpressDoc("pptx/tdf135953_SmartArt_textposition.pptx");
1725 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1726 // shape at index 0 is the background shape
1727 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1728 CPPUNIT_ASSERT(xShape
.is());
1729 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1730 CPPUNIT_ASSERT(pCustomShape
);
1731 tools::Rectangle aTextRect
;
1732 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1733 // without fix the text area rectangle had LT[-2213,2336] and RB[4123,4575]. It was not
1734 // considered that the txXfrm and the preset text area rectangle have different centers in this
1735 // case and thus the text was far off.
1736 // The used tolerance is estimated.
1737 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(3223), sal_Int32(aTextRect
.Left()), 4);
1738 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(-1661), sal_Int32(aTextRect
.Top()), 4);
1739 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(9559), sal_Int32(aTextRect
.Right()), 4);
1740 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(578), sal_Int32(aTextRect
.Bottom()), 4);
1743 CPPUNIT_TEST_FIXTURE(SdImportTestSmartArt
, testTdf132302RightArrow
)
1745 // The file contains a diagram of type "Process Arrows". It uses shapes of type "rightArrow".
1746 // The text starts not at the left edge but in the middle to have space for a circle. Error was
1747 // that the text starts left and so was hidden by the circle.
1748 createSdImpressDoc("pptx/tdf132302_SmartArt_rightArrow.pptx");
1749 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0), uno::UNO_QUERY
);
1750 // shape at index 0 is the background shape
1751 uno::Reference
<drawing::XShape
> xShape
= getChildShape(xGroup
, 1);
1752 CPPUNIT_ASSERT(xShape
.is());
1753 auto pCustomShape
= dynamic_cast<SdrObjCustomShape
*>(SdrObject::getSdrObjectFromXShape(xShape
));
1754 CPPUNIT_ASSERT(pCustomShape
);
1755 tools::Rectangle aTextRect
;
1756 pCustomShape
->TakeTextAnchorRect(aTextRect
);
1757 // without fix the text area rectangle had LT[2790,59] and RB[11591,7940]. Position and size
1758 // given in txXfrm in drawing.xml were not considered.
1759 // The used tolerance is estimated.
1760 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(5078), sal_Int32(aTextRect
.Left()), 4);
1761 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(58), sal_Int32(aTextRect
.Top()), 4);
1762 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(11989), sal_Int32(aTextRect
.Right()), 4);
1763 CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(7940), sal_Int32(aTextRect
.Bottom()), 4);
1766 CPPUNIT_PLUGIN_IMPLEMENT();
1768 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */