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 <comphelper/sequenceashashmap.hxx>
21 #include <oox/drawingml/drawingmltypes.hxx>
23 using namespace ::com::sun::star
;
27 /// Gets one child of xShape, which one is specified by nIndex.
28 uno::Reference
<drawing::XShape
> getChildShape(const uno::Reference
<drawing::XShape
>& xShape
, sal_Int32 nIndex
)
30 uno::Reference
<container::XIndexAccess
> xGroup(xShape
, uno::UNO_QUERY
);
31 CPPUNIT_ASSERT(xGroup
.is());
33 CPPUNIT_ASSERT(xGroup
->getCount() > nIndex
);
35 uno::Reference
<drawing::XShape
> xRet(xGroup
->getByIndex(nIndex
), uno::UNO_QUERY
);
36 CPPUNIT_ASSERT(xRet
.is());
41 uno::Reference
<drawing::XShape
> findChildShapeByText(const uno::Reference
<drawing::XShape
>& xShape
,
42 const OUString
& sText
)
44 uno::Reference
<text::XText
> xText(xShape
, uno::UNO_QUERY
);
45 if (xText
.is() && xText
->getString() == sText
)
48 uno::Reference
<container::XIndexAccess
> xGroup(xShape
, uno::UNO_QUERY
);
50 return uno::Reference
<drawing::XShape
>();
52 for (sal_Int32 i
= 0; i
< xGroup
->getCount(); i
++)
54 uno::Reference
<drawing::XShape
> xChildShape(xGroup
->getByIndex(i
), uno::UNO_QUERY
);
55 uno::Reference
<drawing::XShape
> xReturnShape
= findChildShapeByText(xChildShape
, sText
);
56 if (xReturnShape
.is())
60 return uno::Reference
<drawing::XShape
>();
64 class SdImportTestSmartArt
: public SdModelTestBase
74 void testTextAutoRotation();
78 void testvenndiagram();
81 void testInvertedPyramid();
82 void testBasicProcess();
83 void testMultidirectional();
84 void testHorizontalBulletList();
85 void testBasicRadicals();
87 void testSegmentedCycle();
89 void testVerticalBoxList();
90 void testVerticalBracketList();
92 void testAccentProcess();
93 void testContinuousBlockProcess();
95 void testCycleMatrix();
96 void testPictureStrip();
97 void testInteropGrabBag();
98 void testBackground();
99 void testBackgroundDrawingmlFallback();
100 void testCenterCycle();
102 void testVerticalBlockList();
103 void testBulletList();
104 void testRecursion();
105 void testDataFollow();
106 void testOrgChart2();
108 CPPUNIT_TEST_SUITE(SdImportTestSmartArt
);
110 CPPUNIT_TEST(testBase
);
111 CPPUNIT_TEST(testChildren
);
112 CPPUNIT_TEST(testText
);
113 CPPUNIT_TEST(testCnt
);
114 CPPUNIT_TEST(testDir
);
115 CPPUNIT_TEST(testMaxDepth
);
116 CPPUNIT_TEST(testRotation
);
117 CPPUNIT_TEST(testTextAutoRotation
);
118 CPPUNIT_TEST(testPyramid
);
119 CPPUNIT_TEST(testChevron
);
120 CPPUNIT_TEST(testCycle
);
121 CPPUNIT_TEST(testHierarchy
);
122 CPPUNIT_TEST(testmatrix
);
123 CPPUNIT_TEST(testvenndiagram
);
124 CPPUNIT_TEST(testInvertedPyramid
);
125 CPPUNIT_TEST(testBasicProcess
);
126 CPPUNIT_TEST(testMultidirectional
);
127 CPPUNIT_TEST(testHorizontalBulletList
);
128 CPPUNIT_TEST(testBasicRadicals
);
129 CPPUNIT_TEST(testEquation
);
130 CPPUNIT_TEST(testSegmentedCycle
);
131 CPPUNIT_TEST(testBaseRtoL
);
132 CPPUNIT_TEST(testVerticalBoxList
);
133 CPPUNIT_TEST(testVerticalBracketList
);
134 CPPUNIT_TEST(testTableList
);
135 CPPUNIT_TEST(testAccentProcess
);
136 CPPUNIT_TEST(testContinuousBlockProcess
);
137 CPPUNIT_TEST(testOrgChart
);
138 CPPUNIT_TEST(testCycleMatrix
);
139 CPPUNIT_TEST(testPictureStrip
);
140 CPPUNIT_TEST(testInteropGrabBag
);
141 CPPUNIT_TEST(testBackground
);
142 CPPUNIT_TEST(testBackgroundDrawingmlFallback
);
143 CPPUNIT_TEST(testCenterCycle
);
144 CPPUNIT_TEST(testFontSize
);
145 CPPUNIT_TEST(testVerticalBlockList
);
146 CPPUNIT_TEST(testBulletList
);
147 CPPUNIT_TEST(testRecursion
);
148 CPPUNIT_TEST(testDataFollow
);
149 CPPUNIT_TEST(testOrgChart2
);
151 CPPUNIT_TEST_SUITE_END();
154 void SdImportTestSmartArt::testBase()
156 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/smartart1.pptx"), PPTX
);
157 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
158 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xShapeGroup
->getCount());
160 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
161 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0
->getString());
162 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
163 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1
->getString());
164 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
165 CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2
->getString());
166 uno::Reference
<text::XText
> xText3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
167 CPPUNIT_ASSERT_EQUAL(OUString("d"), xText3
->getString());
168 uno::Reference
<text::XText
> xText4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
169 CPPUNIT_ASSERT_EQUAL(OUString("e"), xText4
->getString());
171 uno::Reference
<beans::XPropertySet
> xShape(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
173 sal_Int32 nFillColor
= 0;
174 xShape
->getPropertyValue("FillColor") >>= nFillColor
;
175 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4F81BD), nFillColor
);
177 sal_Int16 nParaAdjust
= 0;
178 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
179 uno::Reference
<beans::XPropertySet
> xPropSet(xParagraph
, uno::UNO_QUERY_THROW
);
180 xPropSet
->getPropertyValue("ParaAdjust") >>= nParaAdjust
;
181 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(nParaAdjust
));
183 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
184 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
185 uno::Reference
<drawing::XShape
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
186 uno::Reference
<drawing::XShape
> xShape3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
187 uno::Reference
<drawing::XShape
> xShape4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
188 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().Y
,xShape1
->getPosition().Y
);
189 CPPUNIT_ASSERT_EQUAL(xShape2
->getPosition().Y
,xShape3
->getPosition().Y
);
190 CPPUNIT_ASSERT(xShape2
->getPosition().Y
> xShape0
->getPosition().Y
);
191 CPPUNIT_ASSERT(xShape4
->getPosition().Y
> xShape2
->getPosition().Y
);
192 CPPUNIT_ASSERT(xShape0
->getPosition().X
< xShape1
->getPosition().X
);
193 CPPUNIT_ASSERT(xShape2
->getPosition().X
< xShape3
->getPosition().X
);
194 CPPUNIT_ASSERT((xShape2
->getPosition().X
< xShape4
->getPosition().X
) && (xShape3
->getPosition().X
> xShape4
->getPosition().X
));
196 xDocShRef
->DoClose();
199 void SdImportTestSmartArt::testChildren()
201 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/smartart-children.pptx"), PPTX
);
202 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
203 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup
->getCount());
205 uno::Reference
<drawing::XShapes
> xShapeGroup0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
206 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup0
->getCount());
207 uno::Reference
<text::XText
> xTextA(xShapeGroup0
->getByIndex(0), uno::UNO_QUERY_THROW
);
208 CPPUNIT_ASSERT_EQUAL(OUString("a"), xTextA
->getString());
210 uno::Reference
<drawing::XShapes
> xChildren0(xShapeGroup0
->getByIndex(1), uno::UNO_QUERY_THROW
);
211 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xChildren0
->getCount());
212 uno::Reference
<drawing::XShapes
> xChildB(xChildren0
->getByIndex(0), uno::UNO_QUERY_THROW
);
213 uno::Reference
<text::XText
> xTextB(xChildB
->getByIndex(0), uno::UNO_QUERY_THROW
);
214 CPPUNIT_ASSERT_EQUAL(OUString("b"), xTextB
->getString());
215 uno::Reference
<drawing::XShapes
> xChildC(xChildren0
->getByIndex(1), uno::UNO_QUERY_THROW
);
216 uno::Reference
<text::XText
> xTextC(xChildC
->getByIndex(0), uno::UNO_QUERY_THROW
);
217 CPPUNIT_ASSERT_EQUAL(OUString("c"), xTextC
->getString());
219 uno::Reference
<drawing::XShapes
> xShapeGroup1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
220 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup1
->getCount());
221 uno::Reference
<text::XText
> xTextX(xShapeGroup1
->getByIndex(0), uno::UNO_QUERY_THROW
);
222 CPPUNIT_ASSERT_EQUAL(OUString("x"), xTextX
->getString());
224 uno::Reference
<drawing::XShapes
> xChildren1(xShapeGroup1
->getByIndex(1), uno::UNO_QUERY_THROW
);
225 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xChildren1
->getCount());
226 uno::Reference
<drawing::XShapes
> xChildY(xChildren1
->getByIndex(0), uno::UNO_QUERY_THROW
);
227 uno::Reference
<text::XText
> xTextY(xChildY
->getByIndex(0), uno::UNO_QUERY_THROW
);
228 CPPUNIT_ASSERT_EQUAL(OUString("y"), xTextY
->getString());
229 uno::Reference
<drawing::XShapes
> xChildZ(xChildren1
->getByIndex(1), uno::UNO_QUERY_THROW
);
230 uno::Reference
<text::XText
> xTextZ(xChildZ
->getByIndex(0), uno::UNO_QUERY_THROW
);
231 CPPUNIT_ASSERT_EQUAL(OUString("z"), xTextZ
->getString());
233 xDocShRef
->DoClose();
236 void SdImportTestSmartArt::testText()
238 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/smartart-text.pptx"), PPTX
);
239 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
240 uno::Reference
<drawing::XShapes
> xShapeGroup2(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
242 uno::Reference
<text::XText
> xText0(xShapeGroup2
->getByIndex(0), uno::UNO_QUERY_THROW
);
243 CPPUNIT_ASSERT(xText0
->getString().isEmpty());
245 uno::Reference
<text::XText
> xText1(xShapeGroup2
->getByIndex(1), uno::UNO_QUERY_THROW
);
246 CPPUNIT_ASSERT_EQUAL(OUString("test"), xText1
->getString());
248 xDocShRef
->DoClose();
251 void SdImportTestSmartArt::testCnt()
253 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/smartart-cnt.pptx"), PPTX
);
254 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
255 sal_Int32 nCount
= xShapeGroup
->getCount();
256 sal_Int32 nCorrect
= 0;
257 for (sal_Int32 i
=0; i
<nCount
; i
++)
259 uno::Reference
<text::XText
> xText(xShapeGroup
->getByIndex(i
), uno::UNO_QUERY
);
260 if (xText
.is() && !xText
->getString().isEmpty())
263 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nCorrect
);
265 xDocShRef
->DoClose();
268 void SdImportTestSmartArt::testDir()
270 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/smartart-dir.pptx"), PPTX
);
271 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
272 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup
->getCount());
274 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
275 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
276 CPPUNIT_ASSERT(xShape0
->getPosition().X
> xShape1
->getPosition().X
);
278 xDocShRef
->DoClose();
281 void SdImportTestSmartArt::testMaxDepth()
283 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/smartart-maxdepth.pptx"), PPTX
);
284 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
285 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup
->getCount());
287 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
288 CPPUNIT_ASSERT_EQUAL(OUString("first"), xText0
->getString());
289 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
290 CPPUNIT_ASSERT_EQUAL(OUString("second"), xText1
->getString());
292 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
293 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
294 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().Y
, xShape1
->getPosition().Y
); // Confirms shapes are in same Y axis-level.
296 xDocShRef
->DoClose();
299 void SdImportTestSmartArt::testRotation()
301 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/smartart-rotation.pptx"), PPTX
);
302 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
304 uno::Reference
<beans::XPropertySet
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
305 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape0
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
307 uno::Reference
<beans::XPropertySet
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
308 CPPUNIT_ASSERT_EQUAL(sal_Int32(24000), xShape1
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
310 uno::Reference
<beans::XPropertySet
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
311 CPPUNIT_ASSERT_EQUAL(sal_Int32(12000), xShape2
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
313 xDocShRef
->DoClose();
316 void SdImportTestSmartArt::testTextAutoRotation()
318 sd::DrawDocShellRef xDocShRef
= loadURL(
319 m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/smartart-autoTxRot.pptx"), PPTX
);
321 auto testText
= [&](int pageNo
, sal_Int32 txtNo
, const OUString
& expTx
, sal_Int32 expShRot
,
322 sal_Int32 expTxRot
) {
323 OString msgText
= "Page: " + OString::number(pageNo
) + " text: " + OString::number(txtNo
);
324 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, pageNo
, xDocShRef
),
325 uno::UNO_QUERY_THROW
);
327 txtNo
++; //skip background
328 uno::Reference
<text::XText
> xTxt(xShapeGroup
->getByIndex(txtNo
), uno::UNO_QUERY_THROW
);
329 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), expTx
, xTxt
->getString());
330 uno::Reference
<beans::XPropertySet
> xTxtProps(xTxt
, uno::UNO_QUERY_THROW
);
331 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), expShRot
,
332 xTxtProps
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
334 auto aGeomPropSeq
= xTxtProps
->getPropertyValue("CustomShapeGeometry")
335 .get
<uno::Sequence
<beans::PropertyValue
>>();
336 comphelper::SequenceAsHashMap
aCustomShapeGeometry(aGeomPropSeq
);
338 auto it
= aCustomShapeGeometry
.find("TextPreRotateAngle");
339 if (it
== aCustomShapeGeometry
.end())
341 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), sal_Int32(0), expTxRot
);
345 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText
.getStr(), expTxRot
, it
->second
.get
<sal_Int32
>());
349 // Slide 1: absent autoTxRot => defaults to "upr"
350 testText(0, 0, "a", 0, 0);
351 testText(0, 1, "b", 33750, 0);
352 testText(0, 2, "c", 31500, 0);
353 testText(0, 3, "d", 29250, 90);
354 testText(0, 4, "e", 27000, 90);
355 testText(0, 5, "f", 24750, 90);
356 testText(0, 6, "g", 22500, 180);
357 testText(0, 7, "h", 20250, 180);
358 testText(0, 8, "i", 18000, 180);
359 testText(0, 9, "j", 15750, 180);
360 testText(0, 10, "k", 13500, 180);
361 testText(0, 11, "l", 11250, 270);
362 testText(0, 12, "m", 9000, 270);
363 testText(0, 13, "n", 6750, 270);
364 testText(0, 14, "o", 4500, 0);
365 testText(0, 15, "p", 2250, 0);
367 // Slide 2: autoTxRot == "none"
368 testText(1, 0, "a", 0, 0);
369 testText(1, 1, "b", 33750, 0);
370 testText(1, 2, "c", 31500, 0);
371 testText(1, 3, "d", 29250, 0);
372 testText(1, 4, "e", 27000, 0);
373 testText(1, 5, "f", 24750, 0);
374 testText(1, 6, "g", 22500, 0);
375 testText(1, 7, "h", 20250, 0);
376 testText(1, 8, "i", 18000, 0);
377 testText(1, 9, "j", 15750, 0);
378 testText(1, 10, "k", 13500, 0);
379 testText(1, 11, "l", 11250, 0);
380 testText(1, 12, "m", 9000, 0);
381 testText(1, 13, "n", 6750, 0);
382 testText(1, 14, "o", 4500, 0);
383 testText(1, 15, "p", 2250, 0);
385 // Slide 3: autoTxRot == "grav"
386 testText(2, 0, "a", 0, 0);
387 testText(2, 1, "b", 33750, 0);
388 testText(2, 2, "c", 31500, 0);
389 testText(2, 3, "d", 29250, 0);
390 testText(2, 4, "e", 27000, 0);
391 testText(2, 5, "f", 24750, 180);
392 testText(2, 6, "g", 22500, 180);
393 testText(2, 7, "h", 20250, 180);
394 testText(2, 8, "i", 18000, 180);
395 testText(2, 9, "j", 15750, 180);
396 testText(2, 10, "k", 13500, 180);
397 testText(2, 11, "l", 11250, 180);
398 testText(2, 12, "m", 9000, 0);
399 testText(2, 13, "n", 6750, 0);
400 testText(2, 14, "o", 4500, 0);
401 testText(2, 15, "p", 2250, 0);
403 xDocShRef
->DoClose();
406 void SdImportTestSmartArt::testBasicProcess()
408 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
411 void SdImportTestSmartArt::testPyramid()
413 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
416 void SdImportTestSmartArt::testChevron()
418 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/smartart-chevron.pptx"), PPTX
);
419 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
420 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xShapeGroup
->getCount());
422 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
423 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0
->getString());
424 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
425 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1
->getString());
426 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
427 CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2
->getString());
429 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
430 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
431 uno::Reference
<drawing::XShape
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
433 CPPUNIT_ASSERT(xShape0
->getPosition().X
< xShape1
->getPosition().X
&& xShape1
->getPosition().X
< xShape2
->getPosition().X
);
434 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().Y
, xShape1
->getPosition().Y
);
435 CPPUNIT_ASSERT_EQUAL(xShape1
->getPosition().Y
, xShape2
->getPosition().Y
);
437 xDocShRef
->DoClose();
440 void SdImportTestSmartArt::testCycle()
442 sd::DrawDocShellRef xDocShRef
= loadURL(
443 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-cycle.pptx"), PPTX
);
444 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
445 CPPUNIT_ASSERT(xGroup
.is());
447 // 11 children: background, 5 shapes, 5 connectors
448 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(11), xGroup
->getCount());
450 uno::Reference
<drawing::XShape
> xShape0(xGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
451 uno::Reference
<drawing::XShape
> xShapeConn(xGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
452 uno::Reference
<drawing::XShape
> xShape2(xGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
454 uno::Reference
<text::XText
> xText0(xShape0
, uno::UNO_QUERY_THROW
);
455 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0
->getString());
456 uno::Reference
<text::XText
> xText2(xShape2
, uno::UNO_QUERY_THROW
);
457 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText2
->getString());
459 // xShapeConn is connector between shapes 0 and 2
460 // it should lay between them and be rotated 0 -> 2
461 CPPUNIT_ASSERT(xShape0
->getPosition().X
< xShapeConn
->getPosition().X
);
462 CPPUNIT_ASSERT(xShape0
->getPosition().Y
< xShapeConn
->getPosition().Y
&& xShapeConn
->getPosition().Y
< xShape2
->getPosition().Y
);
463 uno::Reference
<beans::XPropertySet
> xPropSetConn(xShapeConn
, uno::UNO_QUERY_THROW
);
464 CPPUNIT_ASSERT_EQUAL(sal_Int32(32400), xPropSetConn
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
466 // Make sure that we have an arrow shape between the two shapes
467 comphelper::SequenceAsHashMap
aCustomShapeGeometry(
468 xPropSetConn
->getPropertyValue("CustomShapeGeometry"));
469 CPPUNIT_ASSERT(aCustomShapeGeometry
["Type"].has
<OUString
>());
470 OUString aType
= aCustomShapeGeometry
["Type"].get
<OUString
>();
471 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-rightArrow"), aType
);
474 void SdImportTestSmartArt::testHierarchy()
476 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
479 void SdImportTestSmartArt::testmatrix()
481 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
484 void SdImportTestSmartArt::testvenndiagram()
486 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
489 void SdImportTestSmartArt::testInvertedPyramid()
491 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
494 void SdImportTestSmartArt::testMultidirectional()
496 // similar document as cycle, but arrows are pointing in both directions
498 sd::DrawDocShellRef xDocShRef
499 = loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-multidirectional.pptx"), PPTX
);
500 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
501 CPPUNIT_ASSERT(xGroup
.is());
503 // 7 children: background, 3 shapes, 3 connectors
504 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(7), xGroup
->getCount());
506 uno::Reference
<drawing::XShape
> xShapeConn(xGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
507 uno::Reference
<beans::XPropertySet
> xPropSetConn(xShapeConn
, uno::UNO_QUERY_THROW
);
508 comphelper::SequenceAsHashMap
aCustomShapeGeometry(
509 xPropSetConn
->getPropertyValue("CustomShapeGeometry"));
510 CPPUNIT_ASSERT(aCustomShapeGeometry
["Type"].has
<OUString
>());
511 OUString aType
= aCustomShapeGeometry
["Type"].get
<OUString
>();
512 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-leftRightArrow"), aType
);
515 void SdImportTestSmartArt::testHorizontalBulletList()
517 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
520 void SdImportTestSmartArt::testEquation()
522 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
525 void SdImportTestSmartArt::testBasicRadicals()
527 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
530 void SdImportTestSmartArt::testSegmentedCycle()
532 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
535 void SdImportTestSmartArt::testBaseRtoL()
537 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/smartart-rightoleftblockdiagram.pptx"), PPTX
);
538 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY_THROW
);
539 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xShapeGroup
->getCount());
541 uno::Reference
<text::XText
> xText0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
542 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0
->getString());
543 uno::Reference
<text::XText
> xText1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
544 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1
->getString());
545 uno::Reference
<text::XText
> xText2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
546 CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2
->getString());
547 uno::Reference
<text::XText
> xText3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
548 CPPUNIT_ASSERT_EQUAL(OUString("d"), xText3
->getString());
549 uno::Reference
<text::XText
> xText4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
550 CPPUNIT_ASSERT_EQUAL(OUString("e"), xText4
->getString());
552 uno::Reference
<beans::XPropertySet
> xShape(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
554 sal_Int32 nFillColor
= 0;
555 xShape
->getPropertyValue("FillColor") >>= nFillColor
;
556 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4F81BD), nFillColor
);
558 sal_Int16 nParaAdjust
= 0;
559 uno::Reference
<text::XTextRange
> xParagraph(getParagraphFromShape(0, xShape
));
560 uno::Reference
<beans::XPropertySet
> xPropSet(xParagraph
, uno::UNO_QUERY_THROW
);
561 xPropSet
->getPropertyValue("ParaAdjust") >>= nParaAdjust
;
562 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(nParaAdjust
));
564 uno::Reference
<drawing::XShape
> xShape0(xShapeGroup
->getByIndex(1), uno::UNO_QUERY_THROW
);
565 uno::Reference
<drawing::XShape
> xShape1(xShapeGroup
->getByIndex(2), uno::UNO_QUERY_THROW
);
566 uno::Reference
<drawing::XShape
> xShape2(xShapeGroup
->getByIndex(3), uno::UNO_QUERY_THROW
);
567 uno::Reference
<drawing::XShape
> xShape3(xShapeGroup
->getByIndex(4), uno::UNO_QUERY_THROW
);
568 uno::Reference
<drawing::XShape
> xShape4(xShapeGroup
->getByIndex(5), uno::UNO_QUERY_THROW
);
569 CPPUNIT_ASSERT_EQUAL(xShape0
->getPosition().Y
,xShape1
->getPosition().Y
);
570 CPPUNIT_ASSERT_EQUAL(xShape2
->getPosition().Y
,xShape3
->getPosition().Y
);
571 CPPUNIT_ASSERT(xShape2
->getPosition().Y
> xShape0
->getPosition().Y
);
572 CPPUNIT_ASSERT(xShape4
->getPosition().Y
> xShape2
->getPosition().Y
);
573 CPPUNIT_ASSERT(xShape0
->getPosition().X
> xShape1
->getPosition().X
);
574 CPPUNIT_ASSERT(xShape2
->getPosition().X
> xShape3
->getPosition().X
);
575 CPPUNIT_ASSERT((xShape2
->getPosition().X
> xShape4
->getPosition().X
) && (xShape3
->getPosition().X
< xShape4
->getPosition().X
));
577 xDocShRef
->DoClose();
580 void SdImportTestSmartArt::testVerticalBoxList()
582 sd::DrawDocShellRef xDocShRef
= loadURL(
583 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-vertical-box-list.pptx"), PPTX
);
584 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
),
585 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
);
613 xDocShRef
->DoClose();
616 void SdImportTestSmartArt::testVerticalBracketList()
618 sd::DrawDocShellRef xDocShRef
= loadURL(
619 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/vertical-bracket-list.pptx"), PPTX
);
620 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
),
621 uno::UNO_QUERY_THROW
);
622 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xShapeGroup
->getCount());
624 uno::Reference
<drawing::XShapes
> xFirstChild(xShapeGroup
->getByIndex(1), uno::UNO_QUERY
);
625 CPPUNIT_ASSERT(xFirstChild
.is());
626 // Without the accompanying fix in place, this test would have failed with
627 // 'actual: 2', i.e. one child shape (with its "A" text) was missing.
628 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xFirstChild
->getCount());
630 xDocShRef
->DoClose();
633 void SdImportTestSmartArt::testTableList()
635 sd::DrawDocShellRef xDocShRef
= loadURL(
636 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/table-list.pptx"), PPTX
);
637 uno::Reference
<drawing::XShapes
> xShapeGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
638 CPPUNIT_ASSERT(xShapeGroup
.is());
639 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xShapeGroup
->getCount());
641 uno::Reference
<text::XText
> xParentText(xShapeGroup
->getByIndex(1), uno::UNO_QUERY
);
642 CPPUNIT_ASSERT(xParentText
.is());
643 CPPUNIT_ASSERT_EQUAL(OUString("Parent"), xParentText
->getString());
644 uno::Reference
<drawing::XShape
> xParent(xParentText
, uno::UNO_QUERY
);
645 CPPUNIT_ASSERT(xParent
.is());
646 int nParentRight
= xParent
->getPosition().X
+ xParent
->getSize().Width
;
648 uno::Reference
<drawing::XShapes
> xChildren(xShapeGroup
->getByIndex(2), uno::UNO_QUERY
);
649 CPPUNIT_ASSERT(xChildren
.is());
650 uno::Reference
<text::XText
> xChild2Text(xChildren
->getByIndex(1), uno::UNO_QUERY
);
651 CPPUNIT_ASSERT(xChild2Text
.is());
652 CPPUNIT_ASSERT_EQUAL(OUString("Child 2"), xChild2Text
->getString());
653 uno::Reference
<drawing::XShape
> xChild2(xChild2Text
, uno::UNO_QUERY
);
654 CPPUNIT_ASSERT(xChild2
.is());
655 int nChild2Right
= xChild2
->getPosition().X
+ xChild2
->getSize().Width
;
657 // Without the accompanying fix in place, this test would have failed with
658 // 'Expected less than: 100, Actual : 22014', i.e. the second child was
659 // shifted to the right too much.
660 CPPUNIT_ASSERT_LESS(100, abs(nChild2Right
- nParentRight
));
662 xDocShRef
->DoClose();
665 void SdImportTestSmartArt::testAccentProcess()
667 sd::DrawDocShellRef xDocShRef
= loadURL(
668 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-accent-process.pptx"), PPTX
);
669 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
670 CPPUNIT_ASSERT(xGroup
.is());
671 // 3 children: first pair, connector, second pair.
672 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xGroup
->getCount());
673 uno::Reference
<drawing::XShape
> xGroupShape(xGroup
, uno::UNO_QUERY
);
674 CPPUNIT_ASSERT(xGroupShape
.is());
676 // The pair is a parent (shape + text) and a child, so 3 shapes in total.
677 // The order is important, first is at the back, last is at the front.
678 uno::Reference
<drawing::XShapes
> xFirstPair(xGroup
->getByIndex(1), uno::UNO_QUERY
);
679 CPPUNIT_ASSERT(xFirstPair
.is());
680 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xFirstPair
->getCount());
682 uno::Reference
<text::XText
> xFirstParentText(xFirstPair
->getByIndex(1), uno::UNO_QUERY
);
683 CPPUNIT_ASSERT(xFirstParentText
.is());
684 CPPUNIT_ASSERT_EQUAL(OUString("a"), xFirstParentText
->getString());
685 uno::Reference
<drawing::XShape
> xFirstParent(xFirstParentText
, uno::UNO_QUERY
);
686 CPPUNIT_ASSERT(xFirstParent
.is());
687 int nFirstParentTop
= xFirstParent
->getPosition().Y
;
689 uno::Reference
<text::XText
> xFirstChildText(xFirstPair
->getByIndex(2), uno::UNO_QUERY
);
690 CPPUNIT_ASSERT(xFirstChildText
.is());
691 CPPUNIT_ASSERT_EQUAL(OUString("b"), xFirstChildText
->getString());
692 uno::Reference
<drawing::XShape
> xFirstChild(xFirstChildText
, uno::UNO_QUERY
);
693 CPPUNIT_ASSERT(xFirstChildText
.is());
696 uno::Reference
<container::XEnumerationAccess
> xParasAccess(xFirstChildText
, uno::UNO_QUERY
);
697 uno::Reference
<container::XEnumeration
> xParas
= xParasAccess
->createEnumeration();
698 uno::Reference
<beans::XPropertySet
> xPara(xParas
->nextElement(), uno::UNO_QUERY
);
699 // Without the accompanying fix in place, this test would have failed
700 // with 'Expected: 0; Actual : 1270', i.e. there was a large
701 // unexpected left margin.
702 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0),
703 xPara
->getPropertyValue("ParaLeftMargin").get
<sal_Int32
>());
705 uno::Reference
<container::XIndexAccess
> xRules(xPara
->getPropertyValue("NumberingRules"),
707 comphelper::SequenceAsHashMap
aRule(xRules
->getByIndex(0));
708 CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8
"•"), aRule
["BulletChar"].get
<OUString
>());
711 int nFirstChildTop
= xFirstChild
->getPosition().Y
;
712 int nFirstChildRight
= xFirstChild
->getPosition().X
+ xFirstChild
->getSize().Width
;
714 // First child is below the first parent.
715 // Without the accompanying fix in place, this test would have failed with
716 // 'Expected less than: 3881, Actual : 3881', i.e. xFirstChild was not
717 // below xFirstParent (a good position is 9081).
718 CPPUNIT_ASSERT_LESS(nFirstChildTop
, nFirstParentTop
);
720 // Make sure that we have an arrow shape between the two pairs.
721 uno::Reference
<beans::XPropertySet
> xArrow(xGroup
->getByIndex(2), uno::UNO_QUERY
);
722 CPPUNIT_ASSERT(xArrow
.is());
723 comphelper::SequenceAsHashMap
aCustomShapeGeometry(
724 xArrow
->getPropertyValue("CustomShapeGeometry"));
725 // Without the accompanying fix in place, this test would have failed, i.e.
726 // the custom shape lacked a type -> arrow was not visible.
727 CPPUNIT_ASSERT(aCustomShapeGeometry
["Type"].has
<OUString
>());
728 OUString aType
= aCustomShapeGeometry
["Type"].get
<OUString
>();
729 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-rightArrow"), aType
);
731 // Make sure that height of the arrow is less than its width.
732 uno::Reference
<drawing::XShape
> xArrowShape(xArrow
, uno::UNO_QUERY
);
733 CPPUNIT_ASSERT(xArrowShape
.is());
734 awt::Size aArrowSize
= xArrowShape
->getSize();
735 CPPUNIT_ASSERT_LESS(aArrowSize
.Width
, aArrowSize
.Height
);
737 uno::Reference
<drawing::XShapes
> xSecondPair(xGroup
->getByIndex(3), uno::UNO_QUERY
);
738 CPPUNIT_ASSERT(xSecondPair
.is());
739 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xSecondPair
->getCount());
740 uno::Reference
<text::XText
> xSecondParentText(xSecondPair
->getByIndex(1), uno::UNO_QUERY
);
741 CPPUNIT_ASSERT(xFirstParentText
.is());
742 // Without the accompanying fix in place, this test would have failed with
743 // 'Expected: cc; Actual : c', i.e. non-first runs on data points were ignored.
744 CPPUNIT_ASSERT_EQUAL(OUString("cc"), xSecondParentText
->getString());
745 uno::Reference
<drawing::XShape
> xSecondParent(xSecondParentText
, uno::UNO_QUERY
);
746 CPPUNIT_ASSERT(xSecondParent
.is());
747 int nSecondParentLeft
= xSecondParent
->getPosition().X
;
748 // Without the accompanying fix in place, this test would have failed with
749 // 'Expected less than: 12700; Actual : 18540', i.e. the "b" and "c"
750 // shapes overlapped.
751 CPPUNIT_ASSERT_LESS(nSecondParentLeft
, nFirstChildRight
);
753 xDocShRef
->DoClose();
756 void SdImportTestSmartArt::testContinuousBlockProcess()
758 sd::DrawDocShellRef xDocShRef
= loadURL(
759 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx"),
761 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
762 CPPUNIT_ASSERT(xGroup
.is());
763 // 3 children: diagram background, background arrow, foreground.
764 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xGroup
->getCount());
766 uno::Reference
<drawing::XShapes
> xLinear(xGroup
->getByIndex(2), uno::UNO_QUERY
);
767 CPPUNIT_ASSERT(xLinear
.is());
768 // 3 children: A, B and C.
769 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(3), xLinear
->getCount());
771 uno::Reference
<text::XText
> xA(xLinear
->getByIndex(0), uno::UNO_QUERY
);
772 CPPUNIT_ASSERT(xA
.is());
773 CPPUNIT_ASSERT_EQUAL(OUString("A"), xA
->getString());
774 uno::Reference
<drawing::XShape
> xAShape(xA
, uno::UNO_QUERY
);
775 CPPUNIT_ASSERT(xAShape
.is());
776 // Without the accompanying fix in place, this test would have failed: the
777 // theoretically correct value is 5462 mm100 (16933 is the total width, and
778 // need to divide that to 1, 0.5, 1, 0.5 and 1 units), while the old value
779 // was 4703 and the new one is 5461.
780 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32
>(5000), xAShape
->getSize().Width
);
782 xDocShRef
->DoClose();
785 void SdImportTestSmartArt::testOrgChart()
787 // Simple org chart with 1 manager and 1 employee only.
788 sd::DrawDocShellRef xDocShRef
= loadURL(
789 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-org-chart.pptx"),
791 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
792 CPPUNIT_ASSERT(xGroup
.is());
794 uno::Reference
<text::XText
> xManager(
795 getChildShape(getChildShape(getChildShape(xGroup
, 1), 0), 0), uno::UNO_QUERY
);
796 CPPUNIT_ASSERT(xManager
.is());
797 // Without the accompanying fix in place, this test would have failed: this
798 // was just "Manager", and the second paragraph was lost.
799 OUString
aExpected("Manager\nSecond para");
800 CPPUNIT_ASSERT_EQUAL(aExpected
, xManager
->getString());
802 uno::Reference
<container::XEnumerationAccess
> xParaEnumAccess(xManager
, uno::UNO_QUERY
);
803 uno::Reference
<container::XEnumeration
> xParaEnum
= xParaEnumAccess
->createEnumeration();
804 uno::Reference
<text::XTextRange
> xPara(xParaEnum
->nextElement(), uno::UNO_QUERY
);
805 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xPara
, uno::UNO_QUERY
);
806 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
807 uno::Reference
<beans::XPropertySet
> xRun(xRunEnum
->nextElement(), uno::UNO_QUERY
);
808 sal_Int32 nActualColor
= xRun
->getPropertyValue("CharColor").get
<sal_Int32
>();
809 // Without the accompanying fix in place, this test would have failed: the
810 // "Manager" font color was black, not white.
811 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0xffffff), nActualColor
);
813 uno::Reference
<drawing::XShape
> xManagerShape(xManager
, uno::UNO_QUERY
);
814 CPPUNIT_ASSERT(xManagerShape
.is());
816 awt::Point aManagerPos
= xManagerShape
->getPosition();
817 awt::Size aManagerSize
= xManagerShape
->getSize();
819 // Make sure that the manager has 2 employees.
820 uno::Reference
<drawing::XShapes
> xEmployees(getChildShape(getChildShape(xGroup
, 1), 2),
822 CPPUNIT_ASSERT(xEmployees
.is());
823 // 4 children: connector, 1st employee, connector, 2nd employee.
824 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(4), xEmployees
->getCount());
826 uno::Reference
<text::XText
> xEmployee(
828 getChildShape(getChildShape(getChildShape(getChildShape(xGroup
, 1), 2), 1), 0), 0),
830 CPPUNIT_ASSERT(xEmployee
.is());
831 CPPUNIT_ASSERT_EQUAL(OUString("Employee"), xEmployee
->getString());
833 uno::Reference
<drawing::XShape
> xEmployeeShape(xEmployee
, uno::UNO_QUERY
);
834 CPPUNIT_ASSERT(xEmployeeShape
.is());
836 awt::Point aEmployeePos
= xEmployeeShape
->getPosition();
837 awt::Size aEmployeeSize
= xEmployeeShape
->getSize();
839 CPPUNIT_ASSERT_EQUAL(aManagerPos
.X
, aEmployeePos
.X
);
841 // Without the accompanying fix in place, this test would have failed: the
842 // two shapes were overlapping, i.e. "manager" was not above "employee".
843 CPPUNIT_ASSERT_GREATER(aManagerPos
.Y
, aEmployeePos
.Y
);
845 // Make sure that the second employee is on the right of the first one.
846 // Without the accompanying fix in place, this test would have failed, as
847 // the second employee was below the first one.
848 uno::Reference
<text::XText
> xEmployee2(
850 getChildShape(getChildShape(getChildShape(getChildShape(xGroup
, 1), 2), 3), 0), 0),
852 CPPUNIT_ASSERT(xEmployee2
.is());
853 CPPUNIT_ASSERT_EQUAL(OUString("Employee2"), xEmployee2
->getString());
855 uno::Reference
<drawing::XShape
> xEmployee2Shape(xEmployee2
, uno::UNO_QUERY
);
856 CPPUNIT_ASSERT(xEmployee2Shape
.is());
858 awt::Point aEmployee2Pos
= xEmployee2Shape
->getPosition();
859 //awt::Size aEmployee2Size = xEmployee2Shape->getSize();
860 CPPUNIT_ASSERT_GREATER(aEmployeePos
.X
, aEmployee2Pos
.X
);
862 // Make sure that assistant is above employees.
863 uno::Reference
<text::XText
> xAssistant(
865 getChildShape(getChildShape(getChildShape(getChildShape(xGroup
, 1), 1), 1), 0), 0),
867 CPPUNIT_ASSERT_EQUAL(OUString("Assistant"), xAssistant
->getString());
869 uno::Reference
<drawing::XShape
> xAssistantShape(xAssistant
, uno::UNO_QUERY
);
870 CPPUNIT_ASSERT(xAssistantShape
.is());
872 awt::Point aAssistantPos
= xAssistantShape
->getPosition();
873 // Without the accompanying fix in place, this test would have failed: the
874 // assistant shape was below the employee shape.
875 CPPUNIT_ASSERT_GREATER(aAssistantPos
.Y
, aEmployeePos
.Y
);
877 // Make sure the connector of the assistant is above the shape.
878 uno::Reference
<drawing::XShape
> xAssistantConnector
=
879 getChildShape(getChildShape(getChildShape(xGroup
, 1), 1), 0);
880 CPPUNIT_ASSERT(xAssistantConnector
.is());
881 //awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition();
882 // This failed, the vertical positions of the connector and the shape of
883 // the assistant were the same.
884 //CPPUNIT_ASSERT_LESS(aAssistantPos.Y, aAssistantConnectorPos.Y);
885 // connectors are hidden as they don't work correctly
887 // Make sure the height of xManager and xManager2 is the same.
888 uno::Reference
<text::XText
> xManager2(
889 getChildShape(getChildShape(getChildShape(xGroup
, 2), 0), 0), uno::UNO_QUERY
);
890 CPPUNIT_ASSERT(xManager2
.is());
891 CPPUNIT_ASSERT_EQUAL(OUString("Manager2"), xManager2
->getString());
893 uno::Reference
<drawing::XShape
> xManager2Shape(xManager2
, uno::UNO_QUERY
);
894 CPPUNIT_ASSERT(xManager2Shape
.is());
896 awt::Size aManager2Size
= xManager2Shape
->getSize();
897 // Without the accompanying fix in place, this test would have failed:
898 // xManager2's height was 3 times larger than xManager's height.
899 CPPUNIT_ASSERT_EQUAL(aManagerSize
.Height
, aManager2Size
.Height
);
901 // Make sure the employee nodes use the free space on the right, since
902 // manager2 has no assistants / employees.
903 //CPPUNIT_ASSERT_GREATER(aManagerSize.Width, aEmployeeSize.Width + aEmployee2Size.Width);
904 // currently disabled as causes problems in complex charts
906 // Without the accompanying fix in place, this test would have failed: an
907 // employee was exactly the third of the total height, without any spacing.
908 CPPUNIT_ASSERT_LESS(xGroup
->getSize().Height
/ 3, aEmployeeSize
.Height
);
910 xDocShRef
->DoClose();
913 void SdImportTestSmartArt::testCycleMatrix()
915 sd::DrawDocShellRef xDocShRef
= loadURL(
916 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-cycle-matrix.pptx"), PPTX
);
917 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
918 CPPUNIT_ASSERT(xGroup
.is());
920 // Without the accompanying fix in place, this test would have failed: the height was 12162,
921 // which is not the mm100 equivalent of the 4064000 EMU in the input file.
922 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(11288), xGroup
->getSize().Height
);
924 uno::Reference
<text::XText
> xA1(getChildShape(getChildShape(xGroup
, 2), 0), uno::UNO_QUERY
);
925 CPPUNIT_ASSERT(xA1
.is());
926 CPPUNIT_ASSERT_EQUAL(OUString("A1"), xA1
->getString());
928 // Test fill color of B1, should be orange.
929 uno::Reference
<text::XText
> xB1(getChildShape(getChildShape(xGroup
, 2), 1), uno::UNO_QUERY
);
930 CPPUNIT_ASSERT(xB1
.is());
931 CPPUNIT_ASSERT_EQUAL(OUString("B1"), xB1
->getString());
933 uno::Reference
<beans::XPropertySet
> xB1Props(xB1
, uno::UNO_QUERY
);
934 CPPUNIT_ASSERT(xB1Props
.is());
935 sal_Int32 nFillColor
= 0;
936 xB1Props
->getPropertyValue("FillColor") >>= nFillColor
;
937 // Without the accompanying fix in place, this test would have failed: the background color was
938 // 0x4f81bd, i.e. blue, not orange.
939 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0xf79646), nFillColor
);
941 // Without the accompanying fix in place, this test would have failed: the
942 // content of the "A2" shape was lost.
943 uno::Reference
<text::XText
> xA2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 0), 1),
945 CPPUNIT_ASSERT(xA2
.is());
946 CPPUNIT_ASSERT_EQUAL(OUString("A2"), xA2
->getString());
948 // Test that the layout of shapes is like this:
952 uno::Reference
<drawing::XShape
> xA2Shape(xA2
, uno::UNO_QUERY
);
953 CPPUNIT_ASSERT(xA2Shape
.is());
955 uno::Reference
<text::XText
> xB2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 1), 1),
957 CPPUNIT_ASSERT(xB2
.is());
958 CPPUNIT_ASSERT_EQUAL(OUString("B2"), xB2
->getString());
959 uno::Reference
<drawing::XShape
> xB2Shape(xB2
, uno::UNO_QUERY
);
960 CPPUNIT_ASSERT(xB2Shape
.is());
962 // Test line color of B2, should be orange.
963 uno::Reference
<beans::XPropertySet
> xB2Props(xB2
, uno::UNO_QUERY
);
964 CPPUNIT_ASSERT(xB2Props
.is());
965 sal_Int32 nLineColor
= 0;
966 xB2Props
->getPropertyValue("LineColor") >>= nLineColor
;
967 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0xf79646), nLineColor
);
969 uno::Reference
<text::XText
> xC2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 2), 1),
971 CPPUNIT_ASSERT(xC2
.is());
972 // Without the accompanying fix in place, this test would have failed, i.e. the order of the
973 // lines in the shape were wrong: C2-1\nC2-4\nC2-3\nC2-2.
974 CPPUNIT_ASSERT_EQUAL(OUString("C2-1\nC2-2\nC2-3\nC2-4"), xC2
->getString());
975 uno::Reference
<drawing::XShape
> xC2Shape(xC2
, uno::UNO_QUERY
);
976 CPPUNIT_ASSERT(xC2Shape
.is());
978 uno::Reference
<text::XText
> xD2(getChildShape(getChildShape(getChildShape(xGroup
, 1), 3), 1),
980 CPPUNIT_ASSERT(xD2
.is());
981 CPPUNIT_ASSERT_EQUAL(OUString("D2"), xD2
->getString());
982 uno::Reference
<drawing::XShape
> xD2Shape(xD2
, uno::UNO_QUERY
);
983 CPPUNIT_ASSERT(xD2Shape
.is());
985 // Without the accompanying fix in place, this test would have failed, i.e.
986 // the A2 and B2 shapes had the same horizontal position, while B2 should
987 // be on the right of A2.
988 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().X
, xB2Shape
->getPosition().X
);
989 CPPUNIT_ASSERT_EQUAL(xA2Shape
->getPosition().Y
, xB2Shape
->getPosition().Y
);
990 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().X
, xC2Shape
->getPosition().X
);
991 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().Y
, xC2Shape
->getPosition().Y
);
992 CPPUNIT_ASSERT_EQUAL(xA2Shape
->getPosition().X
, xD2Shape
->getPosition().X
);
993 CPPUNIT_ASSERT_GREATER(xA2Shape
->getPosition().Y
, xD2Shape
->getPosition().Y
);
995 // Without the accompanying fix in place, this test would have failed: width was expected to be
996 // 4887, was actually 7331.
997 uno::Reference
<drawing::XShape
> xA1Shape(xA1
, uno::UNO_QUERY
);
998 CPPUNIT_ASSERT(xA1Shape
.is());
999 CPPUNIT_ASSERT_EQUAL(xA1Shape
->getSize().Height
, xA1Shape
->getSize().Width
);
1001 xDocShRef
->DoClose();
1004 void SdImportTestSmartArt::testPictureStrip()
1006 sd::DrawDocShellRef xDocShRef
= loadURL(
1007 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-picture-strip.pptx"), PPTX
);
1008 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1009 CPPUNIT_ASSERT(xGroup
.is());
1011 uno::Reference
<beans::XPropertySet
> xFirstImage(getChildShape(getChildShape(xGroup
, 1), 1),
1013 CPPUNIT_ASSERT(xFirstImage
.is());
1014 drawing::FillStyle eFillStyle
= drawing::FillStyle_NONE
;
1015 xFirstImage
->getPropertyValue("FillStyle") >>= eFillStyle
;
1016 // Without the accompanying fix in place, this test would have failed: fill style was solid, not
1018 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, eFillStyle
);
1020 uno::Reference
<graphic::XGraphic
> xGraphic
;
1021 xFirstImage
->getPropertyValue("FillBitmap") >>= xGraphic
;
1022 Graphic
aFirstGraphic(xGraphic
);
1024 uno::Reference
<beans::XPropertySet
> xSecondImage(getChildShape(getChildShape(xGroup
, 2), 1),
1026 CPPUNIT_ASSERT(xSecondImage
.is());
1027 eFillStyle
= drawing::FillStyle_NONE
;
1028 xSecondImage
->getPropertyValue("FillStyle") >>= eFillStyle
;
1029 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP
, eFillStyle
);
1031 xSecondImage
->getPropertyValue("FillBitmap") >>= xGraphic
;
1032 Graphic
aSecondGraphic(xGraphic
);
1033 // Without the accompanying fix in place, this test would have failed: both xFirstImage and
1034 // xSecondImage had the bitmap fill from the second shape.
1035 CPPUNIT_ASSERT(aFirstGraphic
.GetChecksum() != aSecondGraphic
.GetChecksum());
1037 // Test that the 3 images are in a single column, in 3 rows.
1038 uno::Reference
<drawing::XShape
> xFirstImageShape(xFirstImage
, uno::UNO_QUERY
);
1039 CPPUNIT_ASSERT(xFirstImage
.is());
1040 uno::Reference
<drawing::XShape
> xSecondImageShape(xSecondImage
, uno::UNO_QUERY
);
1041 CPPUNIT_ASSERT(xSecondImage
.is());
1042 uno::Reference
<drawing::XShape
> xThirdImageShape
= getChildShape(getChildShape(xGroup
, 3), 1);
1043 CPPUNIT_ASSERT(xThirdImageShape
.is());
1044 // Without the accompanying fix in place, this test would have failed: the first and the second
1045 // image were in the same row.
1046 CPPUNIT_ASSERT_EQUAL(xFirstImageShape
->getPosition().X
, xSecondImageShape
->getPosition().X
);
1047 CPPUNIT_ASSERT_EQUAL(xSecondImageShape
->getPosition().X
, xThirdImageShape
->getPosition().X
);
1048 CPPUNIT_ASSERT_GREATER(xFirstImageShape
->getPosition().Y
, xSecondImageShape
->getPosition().Y
);
1049 CPPUNIT_ASSERT_GREATER(xSecondImageShape
->getPosition().Y
, xThirdImageShape
->getPosition().Y
);
1051 // Make sure that the title shape doesn't overlap with the diagram.
1052 // Note that real "no overlap" is asserted here, though in fact what we want is a less strict
1053 // condition: that no text part of the title shape and the diagram overlaps.
1054 uno::Reference
<drawing::XShape
> xTitle(getShapeFromPage(1, 0, xDocShRef
), uno::UNO_QUERY
);
1055 CPPUNIT_ASSERT(xTitle
.is());
1056 // Without the accompanying fix in place, this test would have failed with 'Expected greater
1057 // than: 2873; Actual : 2320', i.e. the title shape and the diagram overlapped.
1058 uno::Reference
<drawing::XShape
> xFirstPair
= getChildShape(xGroup
, 1);
1059 CPPUNIT_ASSERT_GREATER(xTitle
->getPosition().Y
+ xTitle
->getSize().Height
,
1060 xFirstPair
->getPosition().Y
);
1062 // Make sure that left margin is 60% of width (if you count width in points and margin in mms).
1063 uno::Reference
<beans::XPropertySet
> xFirstText(getChildShape(getChildShape(xGroup
, 1), 0),
1065 CPPUNIT_ASSERT(xFirstText
.is());
1066 sal_Int32 nTextLeftDistance
= 0;
1067 xFirstText
->getPropertyValue("TextLeftDistance") >>= nTextLeftDistance
;
1068 uno::Reference
<drawing::XShape
> xFirstTextShape(xFirstText
, uno::UNO_QUERY
);
1069 CPPUNIT_ASSERT(xFirstTextShape
.is());
1070 sal_Int32 nWidth
= xFirstTextShape
->getSize().Width
;
1071 double fFactor
= oox::drawingml::convertPointToMms(0.6);
1072 // Without the accompanying fix in place, this test would have failed with 'Expected: 3440,
1073 // Actual : 263', i.e. the left margin was too small.
1074 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(nWidth
* fFactor
), nTextLeftDistance
);
1076 // Make sure that aspect ratio is not ignored, i.e. width is not larger than height 3 times.
1077 awt::Size aFirstPairSize
= xFirstPair
->getSize();
1078 // Without the accompanying fix in place, this test would have failed: bad width was 16932, good
1079 // width is 12540, but let's accept 12541 as well.
1080 CPPUNIT_ASSERT_LESSEQUAL(aFirstPairSize
.Height
* 3 + 1, aFirstPairSize
.Width
);
1082 xDocShRef
->DoClose();
1085 void SdImportTestSmartArt::testInteropGrabBag()
1087 sd::DrawDocShellRef xDocShRef
= loadURL(
1088 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-interopgrabbag.pptx"), PPTX
);
1089 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1090 CPPUNIT_ASSERT(xGroup
.is());
1092 uno::Reference
<beans::XPropertySet
> xPropertySet(xGroup
, uno::UNO_QUERY_THROW
);
1093 uno::Sequence
<beans::PropertyValue
> aGrabBagSeq
;
1094 xPropertySet
->getPropertyValue("InteropGrabBag") >>= aGrabBagSeq
;
1095 comphelper::SequenceAsHashMap
aGrabBag(aGrabBagSeq
);
1096 CPPUNIT_ASSERT(aGrabBag
.find("OOXData") != aGrabBag
.end());
1097 CPPUNIT_ASSERT(aGrabBag
.find("OOXLayout") != aGrabBag
.end());
1098 CPPUNIT_ASSERT(aGrabBag
.find("OOXStyle") != aGrabBag
.end());
1099 CPPUNIT_ASSERT(aGrabBag
.find("OOXColor") != aGrabBag
.end());
1100 CPPUNIT_ASSERT(aGrabBag
.find("OOXDrawing") != aGrabBag
.end());
1102 xDocShRef
->DoClose();
1105 void SdImportTestSmartArt::testBackground()
1107 sd::DrawDocShellRef xDocShRef
= loadURL(
1108 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-background.pptx"), PPTX
);
1109 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1110 CPPUNIT_ASSERT(xGroup
.is());
1112 // background should fill whole diagram
1113 uno::Reference
<drawing::XShape
> xShapeGroup(xGroup
, uno::UNO_QUERY
);
1114 uno::Reference
<drawing::XShape
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
1115 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().X
, xShapeGroup
->getPosition().X
);
1116 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().Y
, xShapeGroup
->getPosition().Y
);
1117 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Width
, xShapeGroup
->getSize().Width
);
1118 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Height
, xShapeGroup
->getSize().Height
);
1120 uno::Reference
<beans::XPropertySet
> xPropertySet(xShape
, uno::UNO_QUERY_THROW
);
1121 drawing::FillStyle eFillStyle
= drawing::FillStyle_NONE
;
1122 xPropertySet
->getPropertyValue("FillStyle") >>= eFillStyle
;
1123 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, eFillStyle
);
1125 sal_Int32 nFillColor
= 0;
1126 xPropertySet
->getPropertyValue("FillColor") >>= nFillColor
;
1127 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0x339933), nFillColor
);
1129 bool bMoveProtect
= false;
1130 xPropertySet
->getPropertyValue("MoveProtect") >>= bMoveProtect
;
1131 CPPUNIT_ASSERT_EQUAL(true, bMoveProtect
);
1133 bool bSizeProtect
= false;
1134 xPropertySet
->getPropertyValue("SizeProtect") >>= bSizeProtect
;
1135 CPPUNIT_ASSERT_EQUAL(true, bSizeProtect
);
1137 xDocShRef
->DoClose();
1140 void SdImportTestSmartArt::testBackgroundDrawingmlFallback()
1142 // same as testBackground, but test file contains drawingML fallback
1144 sd::DrawDocShellRef xDocShRef
= loadURL(
1145 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-background-drawingml-fallback.pptx"), PPTX
);
1146 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1147 CPPUNIT_ASSERT(xGroup
.is());
1149 // background should fill whole diagram
1150 uno::Reference
<drawing::XShape
> xShapeGroup(xGroup
, uno::UNO_QUERY
);
1151 uno::Reference
<drawing::XShape
> xShape(xGroup
->getByIndex(0), uno::UNO_QUERY
);
1152 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().X
, xShapeGroup
->getPosition().X
);
1153 CPPUNIT_ASSERT_EQUAL(xShape
->getPosition().Y
, xShapeGroup
->getPosition().Y
);
1154 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Width
, xShapeGroup
->getSize().Width
);
1155 CPPUNIT_ASSERT_EQUAL(xShape
->getSize().Height
, xShapeGroup
->getSize().Height
);
1157 uno::Reference
<beans::XPropertySet
> xPropertySet(xShape
, uno::UNO_QUERY_THROW
);
1158 drawing::FillStyle eFillStyle
= drawing::FillStyle_NONE
;
1159 xPropertySet
->getPropertyValue("FillStyle") >>= eFillStyle
;
1160 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, eFillStyle
);
1162 sal_Int32 nFillColor
= 0;
1163 xPropertySet
->getPropertyValue("FillColor") >>= nFillColor
;
1164 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0x339933), nFillColor
);
1166 bool bMoveProtect
= false;
1167 xPropertySet
->getPropertyValue("MoveProtect") >>= bMoveProtect
;
1168 CPPUNIT_ASSERT_EQUAL(true, bMoveProtect
);
1170 bool bSizeProtect
= false;
1171 xPropertySet
->getPropertyValue("SizeProtect") >>= bSizeProtect
;
1172 CPPUNIT_ASSERT_EQUAL(true, bSizeProtect
);
1174 xDocShRef
->DoClose();
1177 void SdImportTestSmartArt::testCenterCycle()
1179 sd::DrawDocShellRef xDocShRef
= loadURL(
1180 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-center-cycle.pptx"), PPTX
);
1181 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1182 CPPUNIT_ASSERT(xGroup
.is());
1184 uno::Reference
<drawing::XShapes
> xGroupNested(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1185 CPPUNIT_ASSERT(xGroupNested
.is());
1187 uno::Reference
<drawing::XShape
> xShapeCenter(xGroupNested
->getByIndex(0), uno::UNO_QUERY
);
1188 uno::Reference
<drawing::XShape
> xShapeA(xGroupNested
->getByIndex(1), uno::UNO_QUERY
);
1189 uno::Reference
<drawing::XShape
> xShapeB(xGroupNested
->getByIndex(2), uno::UNO_QUERY
);
1190 uno::Reference
<drawing::XShape
> xShapeC(xGroupNested
->getByIndex(3), uno::UNO_QUERY
);
1192 uno::Reference
<text::XText
> xTextCenter(xShapeCenter
, uno::UNO_QUERY
);
1193 CPPUNIT_ASSERT(xTextCenter
.is());
1194 CPPUNIT_ASSERT_EQUAL(OUString("center"), xTextCenter
->getString());
1196 CPPUNIT_ASSERT_LESS(xShapeCenter
->getPosition().Y
, xShapeA
->getPosition().Y
);
1197 CPPUNIT_ASSERT_GREATER(xShapeCenter
->getPosition().X
, xShapeB
->getPosition().X
);
1198 CPPUNIT_ASSERT_GREATER(xShapeCenter
->getPosition().Y
, xShapeB
->getPosition().Y
);
1199 CPPUNIT_ASSERT_LESS(xShapeCenter
->getPosition().X
, xShapeC
->getPosition().X
);
1200 CPPUNIT_ASSERT_GREATER(xShapeCenter
->getPosition().Y
, xShapeC
->getPosition().Y
);
1202 xDocShRef
->DoClose();
1205 void SdImportTestSmartArt::testFontSize()
1207 sd::DrawDocShellRef xDocShRef
= loadURL(
1208 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-font-size.pptx"), PPTX
);
1210 uno::Reference
<drawing::XShapes
> xGroup1(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1211 uno::Reference
<beans::XPropertySet
> xShape1(xGroup1
->getByIndex(1), uno::UNO_QUERY
);
1212 uno::Reference
<text::XTextRange
> xParagraph1(getParagraphFromShape(0, xShape1
));
1213 uno::Reference
<text::XTextRange
> xRun1(getRunFromParagraph(0, xParagraph1
));
1214 uno::Reference
<beans::XPropertySet
> xPropSet1(xRun1
, uno::UNO_QUERY
);
1215 double fFontSize1
= xPropSet1
->getPropertyValue("CharHeight").get
<double>();
1216 CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, fFontSize1
, 0.01);
1218 uno::Reference
<drawing::XShapes
> xGroup2(getShapeFromPage(1, 0, xDocShRef
), uno::UNO_QUERY
);
1219 uno::Reference
<beans::XPropertySet
> xShape2(xGroup2
->getByIndex(1), uno::UNO_QUERY
);
1220 uno::Reference
<text::XTextRange
> xParagraph2(getParagraphFromShape(0, xShape2
));
1221 uno::Reference
<text::XTextRange
> xRun2(getRunFromParagraph(0, xParagraph2
));
1222 uno::Reference
<beans::XPropertySet
> xPropSet2(xRun2
, uno::UNO_QUERY
);
1223 double fFontSize2
= xPropSet2
->getPropertyValue("CharHeight").get
<double>();
1224 CPPUNIT_ASSERT_EQUAL(32.0, fFontSize2
);
1226 uno::Reference
<drawing::XShapes
> xGroup3(getShapeFromPage(2, 0, xDocShRef
), uno::UNO_QUERY
);
1227 uno::Reference
<beans::XPropertySet
> xShape3(xGroup3
->getByIndex(1), uno::UNO_QUERY
);
1228 drawing::TextFitToSizeType eTextFitToSize
= drawing::TextFitToSizeType_NONE
;
1229 xShape3
->getPropertyValue("TextFitToSize") >>= eTextFitToSize
;
1230 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_AUTOFIT
, eTextFitToSize
);
1232 xDocShRef
->DoClose();
1235 void SdImportTestSmartArt::testVerticalBlockList()
1237 sd::DrawDocShellRef xDocShRef
= loadURL(
1238 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-vertical-block-list.pptx"), PPTX
);
1239 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1240 CPPUNIT_ASSERT(xGroup
.is());
1242 uno::Reference
<drawing::XShapes
> xGroup1(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1243 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(2), xGroup1
->getCount());
1244 uno::Reference
<drawing::XShape
> xShapeA(xGroup1
->getByIndex(1), uno::UNO_QUERY
);
1245 uno::Reference
<drawing::XShape
> xShapeBC(xGroup1
->getByIndex(0), uno::UNO_QUERY
);
1246 uno::Reference
<text::XText
> xTextA(xShapeA
, uno::UNO_QUERY
);
1247 uno::Reference
<text::XText
> xTextBC(xShapeBC
, uno::UNO_QUERY
);
1248 CPPUNIT_ASSERT_EQUAL(OUString("a"), xTextA
->getString());
1249 CPPUNIT_ASSERT_EQUAL(OUString("b\nc"), xTextBC
->getString());
1251 uno::Reference
<beans::XPropertySet
> xPropSetBC(xShapeBC
, uno::UNO_QUERY
);
1252 CPPUNIT_ASSERT_EQUAL(sal_Int32(27000), xPropSetBC
->getPropertyValue("RotateAngle").get
<sal_Int32
>());
1254 // BC shape is rotated 90*, so width and height is swapped
1255 CPPUNIT_ASSERT_GREATER(xShapeA
->getSize().Width
, xShapeBC
->getSize().Height
);
1256 CPPUNIT_ASSERT_LESS(xShapeA
->getSize().Height
, xShapeBC
->getSize().Width
);
1257 CPPUNIT_ASSERT_GREATER(xShapeA
->getPosition().X
, xShapeBC
->getPosition().X
);
1258 CPPUNIT_ASSERT_GREATER(xShapeA
->getPosition().Y
, xShapeBC
->getPosition().Y
);
1260 uno::Reference
<drawing::XShapes
> xGroup3(xGroup
->getByIndex(3), uno::UNO_QUERY
);
1261 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(1), xGroup3
->getCount());
1262 uno::Reference
<drawing::XShape
> xShapeEmpty(xGroup3
->getByIndex(0), uno::UNO_QUERY
);
1263 uno::Reference
<text::XText
> xTextEmpty(xShapeEmpty
, uno::UNO_QUERY
);
1264 CPPUNIT_ASSERT_EQUAL(OUString("empty"), xTextEmpty
->getString());
1266 CPPUNIT_ASSERT_EQUAL(xShapeA
->getSize().Width
, xShapeEmpty
->getSize().Width
);
1267 CPPUNIT_ASSERT_EQUAL(xShapeA
->getSize().Height
, xShapeEmpty
->getSize().Height
);
1268 CPPUNIT_ASSERT_EQUAL(xShapeA
->getPosition().X
, xShapeEmpty
->getPosition().X
);
1269 CPPUNIT_ASSERT_GREATER(xShapeA
->getPosition().Y
+ 2*xShapeA
->getSize().Height
, xShapeEmpty
->getPosition().Y
);
1271 uno::Reference
<drawing::XShape
> xGroupShape(xGroup
, uno::UNO_QUERY
);
1272 CPPUNIT_ASSERT_EQUAL(xGroupShape
->getPosition().Y
+ xGroupShape
->getSize().Height
,
1273 xShapeEmpty
->getPosition().Y
+ xShapeEmpty
->getSize().Height
);
1275 xDocShRef
->DoClose();
1278 void SdImportTestSmartArt::testBulletList()
1280 sd::DrawDocShellRef xDocShRef
= loadURL(
1281 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-bullet-list.pptx"),
1283 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1284 CPPUNIT_ASSERT(xGroup
.is());
1286 uno::Reference
<text::XText
> xText(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1287 uno::Reference
<container::XEnumerationAccess
> xParasAccess(xText
, uno::UNO_QUERY
);
1288 uno::Reference
<container::XEnumeration
> xParas
= xParasAccess
->createEnumeration();
1289 xParas
->nextElement(); // skip parent
1291 // child levels should have bullets
1292 uno::Reference
<beans::XPropertySet
> xPara1(xParas
->nextElement(), uno::UNO_QUERY
);
1293 uno::Reference
<container::XIndexAccess
> xRules1(xPara1
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
1294 comphelper::SequenceAsHashMap
aRule1(xRules1
->getByIndex(1));
1295 CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8
"•"), aRule1
["BulletChar"].get
<OUString
>());
1297 uno::Reference
<beans::XPropertySet
> xPara2(xParas
->nextElement(), uno::UNO_QUERY
);
1298 uno::Reference
<container::XIndexAccess
> xRules2(xPara2
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
1299 comphelper::SequenceAsHashMap
aRule2(xRules2
->getByIndex(2));
1300 CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8
"•"), aRule2
["BulletChar"].get
<OUString
>());
1302 xDocShRef
->DoClose();
1305 void SdImportTestSmartArt::testRecursion()
1307 sd::DrawDocShellRef xDocShRef
= loadURL(
1308 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-recursion.pptx"), PPTX
);
1310 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1311 uno::Reference
<drawing::XShapes
> xGroup1(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1313 uno::Reference
<drawing::XShapes
> xGroupA(xGroup1
->getByIndex(0), uno::UNO_QUERY
);
1314 uno::Reference
<text::XText
> xTextA(xGroupA
->getByIndex(0), uno::UNO_QUERY
);
1315 CPPUNIT_ASSERT_EQUAL(OUString("A"), xTextA
->getString());
1317 uno::Reference
<drawing::XShapes
> xGroupB(xGroup1
->getByIndex(1), uno::UNO_QUERY
);
1318 // 5 connectors, B1 with children, B2 with children
1319 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(7), xGroupB
->getCount());
1321 uno::Reference
<drawing::XShapes
> xGroupB1(xGroupB
->getByIndex(1), uno::UNO_QUERY
);
1323 uno::Reference
<drawing::XShapes
> xGroupB1a(xGroupB1
->getByIndex(0), uno::UNO_QUERY
);
1324 uno::Reference
<text::XText
> xTextB1(xGroupB1a
->getByIndex(0), uno::UNO_QUERY
);
1325 CPPUNIT_ASSERT_EQUAL(OUString("B1"), xTextB1
->getString());
1327 uno::Reference
<drawing::XShape
> xGroupC12(xGroupB1
->getByIndex(1), uno::UNO_QUERY
);
1328 uno::Reference
<text::XText
> xTextC1(getChildShape(getChildShape(getChildShape(xGroupC12
, 0), 0), 0), uno::UNO_QUERY
);
1329 CPPUNIT_ASSERT_EQUAL(OUString("C1"), xTextC1
->getString());
1330 uno::Reference
<text::XText
> xTextC2(getChildShape(getChildShape(getChildShape(xGroupC12
, 1), 0), 0), uno::UNO_QUERY
);
1331 CPPUNIT_ASSERT_EQUAL(OUString("C2"), xTextC2
->getString());
1333 uno::Reference
<drawing::XShapes
> xGroupB2(xGroupB
->getByIndex(5), uno::UNO_QUERY
);
1335 uno::Reference
<drawing::XShapes
> xGroupB2a(xGroupB2
->getByIndex(0), uno::UNO_QUERY
);
1336 uno::Reference
<text::XText
> xTextB2(xGroupB2a
->getByIndex(0), uno::UNO_QUERY
);
1337 CPPUNIT_ASSERT_EQUAL(OUString("B2"), xTextB2
->getString());
1339 uno::Reference
<drawing::XShape
> xGroupC3(xGroupB2
->getByIndex(1), uno::UNO_QUERY
);
1340 uno::Reference
<text::XText
> xTextC3(getChildShape(getChildShape(getChildShape(xGroupC3
, 0), 0), 0), uno::UNO_QUERY
);
1341 CPPUNIT_ASSERT_EQUAL(OUString("C3"), xTextC3
->getString());
1343 xDocShRef
->DoClose();
1346 void SdImportTestSmartArt::testDataFollow()
1348 // checks if data nodes are followed correctly
1349 // different variables are set for two presentation points with the same name
1350 // they should be layouted differently - one horizontally and one vertically
1352 sd::DrawDocShellRef xDocShRef
= loadURL(
1353 m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-data-follow.pptx"), PPTX
);
1355 uno::Reference
<drawing::XShapes
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1357 uno::Reference
<drawing::XShapes
> xGroupLeft(xGroup
->getByIndex(1), uno::UNO_QUERY
);
1358 uno::Reference
<drawing::XShape
> xGroupB(xGroupLeft
->getByIndex(1), uno::UNO_QUERY
);
1359 uno::Reference
<drawing::XShape
> xShapeB1
= getChildShape(getChildShape(getChildShape(xGroupB
, 1), 0), 0);
1360 uno::Reference
<text::XText
> xTextB1(xShapeB1
, uno::UNO_QUERY
);
1361 CPPUNIT_ASSERT_EQUAL(OUString("B1"), xTextB1
->getString());
1362 uno::Reference
<drawing::XShape
> xShapeB2
= getChildShape(getChildShape(getChildShape(xGroupB
, 3), 0), 0);
1363 uno::Reference
<text::XText
> xTextB2(xShapeB2
, uno::UNO_QUERY
);
1364 CPPUNIT_ASSERT_EQUAL(OUString("B2"), xTextB2
->getString());
1366 CPPUNIT_ASSERT_EQUAL(xShapeB1
->getPosition().Y
, xShapeB2
->getPosition().Y
);
1367 CPPUNIT_ASSERT_GREATEREQUAL(xShapeB1
->getPosition().X
+ xShapeB1
->getSize().Width
, xShapeB2
->getPosition().X
);
1369 uno::Reference
<drawing::XShapes
> xGroupRight(xGroup
->getByIndex(2), uno::UNO_QUERY
);
1370 uno::Reference
<drawing::XShape
> xGroupC(xGroupRight
->getByIndex(1), uno::UNO_QUERY
);
1371 uno::Reference
<drawing::XShape
> xShapeC1
= getChildShape(getChildShape(getChildShape(xGroupC
, 3), 0), 0);
1372 uno::Reference
<text::XText
> xTextC1(xShapeC1
, uno::UNO_QUERY
);
1373 CPPUNIT_ASSERT_EQUAL(OUString("C1"), xTextC1
->getString());
1374 uno::Reference
<drawing::XShape
> xShapeC2
= getChildShape(getChildShape(getChildShape(xGroupC
, 5), 0), 0);
1375 uno::Reference
<text::XText
> xTextC2(xShapeC2
, uno::UNO_QUERY
);
1376 CPPUNIT_ASSERT_EQUAL(OUString("C2"), xTextC2
->getString());
1378 CPPUNIT_ASSERT_EQUAL(xShapeC1
->getPosition().X
, xShapeC2
->getPosition().X
);
1379 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC1
->getPosition().Y
+ xShapeC1
->getSize().Height
, xShapeC2
->getPosition().Y
);
1381 xDocShRef
->DoClose();
1384 void SdImportTestSmartArt::testOrgChart2()
1386 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-org-chart2.pptx"), PPTX
);
1387 uno::Reference
<drawing::XShape
> xGroup(getShapeFromPage(0, 0, xDocShRef
), uno::UNO_QUERY
);
1389 uno::Reference
<drawing::XShape
> xShapeC1
= findChildShapeByText(xGroup
, "C1");
1390 uno::Reference
<drawing::XShape
> xShapeC2
= findChildShapeByText(xGroup
, "C2");
1391 uno::Reference
<drawing::XShape
> xShapeC3
= findChildShapeByText(xGroup
, "C3");
1392 uno::Reference
<drawing::XShape
> xShapeC4
= findChildShapeByText(xGroup
, "C4");
1393 uno::Reference
<drawing::XShape
> xShapeD1
= findChildShapeByText(xGroup
, "D1");
1394 uno::Reference
<drawing::XShape
> xShapeD2
= findChildShapeByText(xGroup
, "D2");
1396 CPPUNIT_ASSERT(xShapeC1
.is());
1397 CPPUNIT_ASSERT(xShapeC2
.is());
1398 CPPUNIT_ASSERT(xShapeC3
.is());
1399 CPPUNIT_ASSERT(xShapeC4
.is());
1400 CPPUNIT_ASSERT(xShapeD1
.is());
1401 CPPUNIT_ASSERT(xShapeD2
.is());
1403 CPPUNIT_ASSERT_EQUAL(xShapeC1
->getPosition().Y
, xShapeC2
->getPosition().Y
);
1404 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC1
->getPosition().X
+ xShapeC1
->getSize().Width
, xShapeC2
->getPosition().X
);
1406 CPPUNIT_ASSERT_EQUAL(xShapeC3
->getPosition().X
, xShapeC4
->getPosition().X
);
1407 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC3
->getPosition().Y
+ xShapeC3
->getSize().Height
, xShapeC4
->getPosition().Y
);
1409 CPPUNIT_ASSERT_EQUAL(xShapeD1
->getPosition().X
, xShapeD2
->getPosition().X
);
1410 CPPUNIT_ASSERT_GREATEREQUAL(xShapeD1
->getPosition().Y
+ xShapeD1
->getSize().Height
, xShapeD2
->getPosition().Y
);
1412 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC2
->getPosition().X
, xShapeD1
->getPosition().X
);
1413 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC2
->getPosition().Y
+ xShapeC2
->getSize().Height
, xShapeD1
->getPosition().Y
);
1415 CPPUNIT_ASSERT_GREATEREQUAL(xShapeD1
->getPosition().X
+ xShapeD1
->getSize().Width
, xShapeC4
->getPosition().X
);
1417 xDocShRef
->DoClose();
1420 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt
);
1422 CPPUNIT_PLUGIN_IMPLEMENT();
1424 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */