nss: upgrade to release 3.73
[LibreOffice.git] / sd / qa / unit / import-tests-smartart.cxx
blob9c9a55fc2b5ddaa571219079b8be6bc5ee9c7b60
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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/svdpage.hxx>
21 #include <svx/svdogrp.hxx>
22 #include <comphelper/sequenceashashmap.hxx>
23 #include <oox/drawingml/drawingmltypes.hxx>
25 using namespace ::com::sun::star;
27 namespace
29 /// Gets one child of xShape, which one is specified by nIndex.
30 uno::Reference<drawing::XShape> getChildShape(const uno::Reference<drawing::XShape>& xShape,
31 sal_Int32 nIndex)
33 uno::Reference<container::XIndexAccess> xGroup(xShape, uno::UNO_QUERY);
34 CPPUNIT_ASSERT(xGroup.is());
36 CPPUNIT_ASSERT(xGroup->getCount() > nIndex);
38 uno::Reference<drawing::XShape> xRet(xGroup->getByIndex(nIndex), uno::UNO_QUERY);
39 CPPUNIT_ASSERT(xRet.is());
41 return xRet;
44 uno::Reference<drawing::XShape> findChildShapeByText(const uno::Reference<drawing::XShape>& xShape,
45 const OUString& sText)
47 uno::Reference<text::XText> xText(xShape, uno::UNO_QUERY);
48 if (xText.is() && xText->getString() == sText)
49 return xShape;
51 uno::Reference<container::XIndexAccess> xGroup(xShape, uno::UNO_QUERY);
52 if (!xGroup.is())
53 return uno::Reference<drawing::XShape>();
55 for (sal_Int32 i = 0; i < xGroup->getCount(); i++)
57 uno::Reference<drawing::XShape> xChildShape(xGroup->getByIndex(i), uno::UNO_QUERY);
58 uno::Reference<drawing::XShape> xReturnShape = findChildShapeByText(xChildShape, sText);
59 if (xReturnShape.is())
60 return xReturnShape;
63 return uno::Reference<drawing::XShape>();
67 class SdImportTestSmartArt : public SdModelTestBase
69 public:
70 void testBase();
71 void testChildren();
72 void testText();
73 void testCnt();
74 void testDir();
75 void testMaxDepth();
76 void testRotation();
77 void testTextAutoRotation();
78 void testPyramid();
79 void testPyramidOneChild();
80 void testChevron();
81 void testCycle();
82 void testvenndiagram();
83 void testmatrix();
84 void testHierarchy();
85 void testInvertedPyramid();
86 void testBasicProcess();
87 void testMultidirectional();
88 void testHorizontalBulletList();
89 void testBasicRadicals();
90 void testEquation();
91 void testSegmentedCycle();
92 void testBaseRtoL();
93 void testVerticalBoxList();
94 void testVerticalBracketList();
95 void testTableList();
96 void testAccentProcess();
97 void testContinuousBlockProcess();
98 void testOrgChart();
99 void testCycleMatrix();
100 void testPictureStrip();
101 void testInteropGrabBag();
102 void testBackground();
103 void testBackgroundDrawingmlFallback();
104 void testCenterCycle();
105 void testFontSize();
106 void testVerticalBlockList();
107 void testBulletList();
108 void testMissingBulletAndIndent();
109 void testRecursion();
110 void testDataFollow();
111 void testOrgChart2();
112 void testTdf131553();
113 void testFillColorList();
114 void testTdf134221();
115 void testLinearRule();
116 void testLinearRuleVert();
117 void testAutofitSync();
118 void testSnakeRows();
119 void testCompositeInferRight();
121 CPPUNIT_TEST_SUITE(SdImportTestSmartArt);
123 CPPUNIT_TEST(testBase);
124 CPPUNIT_TEST(testChildren);
125 CPPUNIT_TEST(testText);
126 CPPUNIT_TEST(testCnt);
127 CPPUNIT_TEST(testDir);
128 CPPUNIT_TEST(testMaxDepth);
129 CPPUNIT_TEST(testRotation);
130 CPPUNIT_TEST(testTextAutoRotation);
131 CPPUNIT_TEST(testPyramid);
132 CPPUNIT_TEST(testPyramidOneChild);
133 CPPUNIT_TEST(testChevron);
134 CPPUNIT_TEST(testCycle);
135 CPPUNIT_TEST(testHierarchy);
136 CPPUNIT_TEST(testmatrix);
137 CPPUNIT_TEST(testvenndiagram);
138 CPPUNIT_TEST(testInvertedPyramid);
139 CPPUNIT_TEST(testBasicProcess);
140 CPPUNIT_TEST(testMultidirectional);
141 CPPUNIT_TEST(testHorizontalBulletList);
142 CPPUNIT_TEST(testBasicRadicals);
143 CPPUNIT_TEST(testEquation);
144 CPPUNIT_TEST(testSegmentedCycle);
145 CPPUNIT_TEST(testBaseRtoL);
146 CPPUNIT_TEST(testVerticalBoxList);
147 CPPUNIT_TEST(testVerticalBracketList);
148 CPPUNIT_TEST(testTableList);
149 CPPUNIT_TEST(testAccentProcess);
150 CPPUNIT_TEST(testContinuousBlockProcess);
151 CPPUNIT_TEST(testOrgChart);
152 CPPUNIT_TEST(testCycleMatrix);
153 CPPUNIT_TEST(testPictureStrip);
154 CPPUNIT_TEST(testInteropGrabBag);
155 CPPUNIT_TEST(testBackground);
156 CPPUNIT_TEST(testBackgroundDrawingmlFallback);
157 CPPUNIT_TEST(testCenterCycle);
158 CPPUNIT_TEST(testFontSize);
159 CPPUNIT_TEST(testVerticalBlockList);
160 CPPUNIT_TEST(testBulletList);
161 CPPUNIT_TEST(testMissingBulletAndIndent);
162 CPPUNIT_TEST(testRecursion);
163 CPPUNIT_TEST(testDataFollow);
164 CPPUNIT_TEST(testOrgChart2);
165 CPPUNIT_TEST(testTdf131553);
166 CPPUNIT_TEST(testFillColorList);
167 CPPUNIT_TEST(testTdf134221);
168 CPPUNIT_TEST(testLinearRule);
169 CPPUNIT_TEST(testLinearRuleVert);
170 CPPUNIT_TEST(testAutofitSync);
171 CPPUNIT_TEST(testSnakeRows);
172 CPPUNIT_TEST(testCompositeInferRight);
174 CPPUNIT_TEST_SUITE_END();
177 void SdImportTestSmartArt::testBase()
179 sd::DrawDocShellRef xDocShRef
180 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart1.pptx"), PPTX);
181 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
182 uno::UNO_QUERY_THROW);
183 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xShapeGroup->getCount());
185 uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
186 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0->getString());
187 uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
188 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1->getString());
189 uno::Reference<text::XText> xText2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW);
190 CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2->getString());
191 uno::Reference<text::XText> xText3(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW);
192 CPPUNIT_ASSERT_EQUAL(OUString("d"), xText3->getString());
193 uno::Reference<text::XText> xText4(xShapeGroup->getByIndex(5), uno::UNO_QUERY_THROW);
194 CPPUNIT_ASSERT_EQUAL(OUString("e"), xText4->getString());
196 uno::Reference<beans::XPropertySet> xShape(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
198 sal_Int32 nFillColor = 0;
199 xShape->getPropertyValue("FillColor") >>= nFillColor;
200 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4F81BD), nFillColor);
202 sal_Int16 nParaAdjust = 0;
203 uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xShape));
204 uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
205 xPropSet->getPropertyValue("ParaAdjust") >>= nParaAdjust;
206 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER,
207 static_cast<style::ParagraphAdjust>(nParaAdjust));
209 uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
210 uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
211 uno::Reference<drawing::XShape> xShape2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW);
212 uno::Reference<drawing::XShape> xShape3(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW);
213 uno::Reference<drawing::XShape> xShape4(xShapeGroup->getByIndex(5), uno::UNO_QUERY_THROW);
214 CPPUNIT_ASSERT_EQUAL(xShape0->getPosition().Y, xShape1->getPosition().Y);
215 CPPUNIT_ASSERT_EQUAL(xShape2->getPosition().Y, xShape3->getPosition().Y);
216 CPPUNIT_ASSERT(xShape2->getPosition().Y > xShape0->getPosition().Y);
217 CPPUNIT_ASSERT(xShape4->getPosition().Y > xShape2->getPosition().Y);
218 CPPUNIT_ASSERT(xShape0->getPosition().X < xShape1->getPosition().X);
219 CPPUNIT_ASSERT(xShape2->getPosition().X < xShape3->getPosition().X);
220 CPPUNIT_ASSERT((xShape2->getPosition().X < xShape4->getPosition().X)
221 && (xShape3->getPosition().X > xShape4->getPosition().X));
223 xDocShRef->DoClose();
226 void SdImportTestSmartArt::testChildren()
228 sd::DrawDocShellRef xDocShRef
229 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-children.pptx"), PPTX);
230 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
231 uno::UNO_QUERY_THROW);
232 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup->getCount());
234 uno::Reference<drawing::XShapes> xShapeGroup0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
235 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup0->getCount());
236 uno::Reference<text::XText> xTextA(xShapeGroup0->getByIndex(0), uno::UNO_QUERY_THROW);
237 CPPUNIT_ASSERT_EQUAL(OUString("a"), xTextA->getString());
239 uno::Reference<drawing::XShapes> xChildren0(xShapeGroup0->getByIndex(1), uno::UNO_QUERY_THROW);
240 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xChildren0->getCount());
241 uno::Reference<drawing::XShapes> xChildB(xChildren0->getByIndex(0), uno::UNO_QUERY_THROW);
242 uno::Reference<text::XText> xTextB(xChildB->getByIndex(0), uno::UNO_QUERY_THROW);
243 CPPUNIT_ASSERT_EQUAL(OUString("b"), xTextB->getString());
244 uno::Reference<drawing::XShapes> xChildC(xChildren0->getByIndex(1), uno::UNO_QUERY_THROW);
245 uno::Reference<text::XText> xTextC(xChildC->getByIndex(0), uno::UNO_QUERY_THROW);
246 CPPUNIT_ASSERT_EQUAL(OUString("c"), xTextC->getString());
248 uno::Reference<drawing::XShapes> xShapeGroup1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
249 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xShapeGroup1->getCount());
250 uno::Reference<text::XText> xTextX(xShapeGroup1->getByIndex(0), uno::UNO_QUERY_THROW);
251 CPPUNIT_ASSERT_EQUAL(OUString("x"), xTextX->getString());
253 uno::Reference<drawing::XShapes> xChildren1(xShapeGroup1->getByIndex(1), uno::UNO_QUERY_THROW);
254 CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xChildren1->getCount());
255 uno::Reference<drawing::XShapes> xChildY(xChildren1->getByIndex(0), uno::UNO_QUERY_THROW);
256 uno::Reference<text::XText> xTextY(xChildY->getByIndex(0), uno::UNO_QUERY_THROW);
257 CPPUNIT_ASSERT_EQUAL(OUString("y"), xTextY->getString());
258 uno::Reference<drawing::XShapes> xChildZ(xChildren1->getByIndex(1), uno::UNO_QUERY_THROW);
259 uno::Reference<text::XText> xTextZ(xChildZ->getByIndex(0), uno::UNO_QUERY_THROW);
260 CPPUNIT_ASSERT_EQUAL(OUString("z"), xTextZ->getString());
262 xDocShRef->DoClose();
265 void SdImportTestSmartArt::testText()
267 sd::DrawDocShellRef xDocShRef
268 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-text.pptx"), PPTX);
269 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
270 uno::UNO_QUERY_THROW);
271 uno::Reference<drawing::XShapes> xShapeGroup2(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
273 uno::Reference<text::XText> xText0(xShapeGroup2->getByIndex(0), uno::UNO_QUERY_THROW);
274 CPPUNIT_ASSERT(xText0->getString().isEmpty());
276 uno::Reference<text::XText> xText1(xShapeGroup2->getByIndex(1), uno::UNO_QUERY_THROW);
277 CPPUNIT_ASSERT_EQUAL(OUString("test"), xText1->getString());
279 xDocShRef->DoClose();
282 void SdImportTestSmartArt::testCnt()
284 sd::DrawDocShellRef xDocShRef
285 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-cnt.pptx"), PPTX);
286 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
287 uno::UNO_QUERY_THROW);
288 sal_Int32 nCount = xShapeGroup->getCount();
289 sal_Int32 nCorrect = 0;
290 for (sal_Int32 i = 0; i < nCount; i++)
292 uno::Reference<text::XText> xText(xShapeGroup->getByIndex(i), uno::UNO_QUERY);
293 if (xText.is() && !xText->getString().isEmpty())
294 nCorrect++;
296 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), nCorrect);
298 xDocShRef->DoClose();
301 void SdImportTestSmartArt::testDir()
303 sd::DrawDocShellRef xDocShRef
304 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-dir.pptx"), PPTX);
305 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
306 uno::UNO_QUERY_THROW);
307 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup->getCount());
309 uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
310 uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
311 CPPUNIT_ASSERT(xShape0->getPosition().X > xShape1->getPosition().X);
313 xDocShRef->DoClose();
316 void SdImportTestSmartArt::testMaxDepth()
318 sd::DrawDocShellRef xDocShRef
319 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-maxdepth.pptx"), PPTX);
320 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
321 uno::UNO_QUERY_THROW);
322 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xShapeGroup->getCount());
324 uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
325 CPPUNIT_ASSERT_EQUAL(OUString("first"), xText0->getString());
326 uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
327 CPPUNIT_ASSERT_EQUAL(OUString("second"), xText1->getString());
329 uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
330 uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
331 CPPUNIT_ASSERT_EQUAL(xShape0->getPosition().Y,
332 xShape1->getPosition().Y); // Confirms shapes are in same Y axis-level.
334 xDocShRef->DoClose();
337 void SdImportTestSmartArt::testRotation()
339 sd::DrawDocShellRef xDocShRef
340 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-rotation.pptx"), PPTX);
341 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
342 uno::UNO_QUERY_THROW);
344 uno::Reference<beans::XPropertySet> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
345 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xShape0->getPropertyValue("RotateAngle").get<sal_Int32>());
347 uno::Reference<beans::XPropertySet> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
348 CPPUNIT_ASSERT_EQUAL(sal_Int32(24000),
349 xShape1->getPropertyValue("RotateAngle").get<sal_Int32>());
351 uno::Reference<beans::XPropertySet> xShape2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW);
352 CPPUNIT_ASSERT_EQUAL(sal_Int32(12000),
353 xShape2->getPropertyValue("RotateAngle").get<sal_Int32>());
355 xDocShRef->DoClose();
358 void SdImportTestSmartArt::testTextAutoRotation()
360 sd::DrawDocShellRef xDocShRef = loadURL(
361 m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-autoTxRot.pptx"), PPTX);
363 auto testText = [&](int pageNo, sal_Int32 txtNo, const OUString& expTx, sal_Int32 expShRot,
364 sal_Int32 expTxRot) {
365 OString msgText = "Page: " + OString::number(pageNo) + " text: " + OString::number(txtNo);
366 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, pageNo, xDocShRef),
367 uno::UNO_QUERY_THROW);
369 txtNo++; //skip background
370 uno::Reference<text::XText> xTxt(xShapeGroup->getByIndex(txtNo), uno::UNO_QUERY_THROW);
371 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText.getStr(), expTx, xTxt->getString());
372 uno::Reference<beans::XPropertySet> xTxtProps(xTxt, uno::UNO_QUERY_THROW);
373 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText.getStr(), expShRot,
374 xTxtProps->getPropertyValue("RotateAngle").get<sal_Int32>());
376 auto aGeomPropSeq = xTxtProps->getPropertyValue("CustomShapeGeometry")
377 .get<uno::Sequence<beans::PropertyValue>>();
378 comphelper::SequenceAsHashMap aCustomShapeGeometry(aGeomPropSeq);
380 auto it = aCustomShapeGeometry.find("TextPreRotateAngle");
381 if (it == aCustomShapeGeometry.end())
383 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText.getStr(), sal_Int32(0), expTxRot);
385 else
387 CPPUNIT_ASSERT_EQUAL_MESSAGE(msgText.getStr(), expTxRot, it->second.get<sal_Int32>());
391 // Slide 1: absent autoTxRot => defaults to "upr"
392 testText(0, 0, "a", 0, 0);
393 testText(0, 1, "b", 33750, 0);
394 testText(0, 2, "c", 31500, 0);
395 testText(0, 3, "d", 29250, 90);
396 testText(0, 4, "e", 27000, 90);
397 testText(0, 5, "f", 24750, 90);
398 testText(0, 6, "g", 22500, 180);
399 testText(0, 7, "h", 20250, 180);
400 testText(0, 8, "i", 18000, 180);
401 testText(0, 9, "j", 15750, 180);
402 testText(0, 10, "k", 13500, 180);
403 testText(0, 11, "l", 11250, 270);
404 testText(0, 12, "m", 9000, 270);
405 testText(0, 13, "n", 6750, 270);
406 testText(0, 14, "o", 4500, 0);
407 testText(0, 15, "p", 2250, 0);
409 // Slide 2: autoTxRot == "none"
410 testText(1, 0, "a", 0, 0);
411 testText(1, 1, "b", 33750, 0);
412 testText(1, 2, "c", 31500, 0);
413 testText(1, 3, "d", 29250, 0);
414 testText(1, 4, "e", 27000, 0);
415 testText(1, 5, "f", 24750, 0);
416 testText(1, 6, "g", 22500, 0);
417 testText(1, 7, "h", 20250, 0);
418 testText(1, 8, "i", 18000, 0);
419 testText(1, 9, "j", 15750, 0);
420 testText(1, 10, "k", 13500, 0);
421 testText(1, 11, "l", 11250, 0);
422 testText(1, 12, "m", 9000, 0);
423 testText(1, 13, "n", 6750, 0);
424 testText(1, 14, "o", 4500, 0);
425 testText(1, 15, "p", 2250, 0);
427 // Slide 3: autoTxRot == "grav"
428 testText(2, 0, "a", 0, 0);
429 testText(2, 1, "b", 33750, 0);
430 testText(2, 2, "c", 31500, 0);
431 testText(2, 3, "d", 29250, 0);
432 testText(2, 4, "e", 27000, 0);
433 testText(2, 5, "f", 24750, 180);
434 testText(2, 6, "g", 22500, 180);
435 testText(2, 7, "h", 20250, 180);
436 testText(2, 8, "i", 18000, 180);
437 testText(2, 9, "j", 15750, 180);
438 testText(2, 10, "k", 13500, 180);
439 testText(2, 11, "l", 11250, 180);
440 testText(2, 12, "m", 9000, 0);
441 testText(2, 13, "n", 6750, 0);
442 testText(2, 14, "o", 4500, 0);
443 testText(2, 15, "p", 2250, 0);
445 xDocShRef->DoClose();
448 void SdImportTestSmartArt::testBasicProcess()
450 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
453 void SdImportTestSmartArt::testPyramid()
455 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
458 void SdImportTestSmartArt::testPyramidOneChild()
460 // Load a document with a pyra algorithm in it.
461 // Without the accompanying fix in place, this test would have crashed.
462 sd::DrawDocShellRef xDocShRef = loadURL(
463 m_directories.getURLFromSrc(u"sd/qa/unit/data/pptx/smartart-pyramid-1child.pptx"), PPTX);
464 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
465 uno::Reference<text::XTextRange> xText(getChildShape(getChildShape(xGroup, 1), 1),
466 uno::UNO_QUERY);
467 // Verify that the text of the only child is imported correctly.
468 CPPUNIT_ASSERT_EQUAL(OUString("A"), xText->getString());
471 void SdImportTestSmartArt::testChevron()
473 sd::DrawDocShellRef xDocShRef
474 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-chevron.pptx"), PPTX);
475 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
476 uno::UNO_QUERY_THROW);
477 CPPUNIT_ASSERT_EQUAL(sal_Int32(4), xShapeGroup->getCount());
479 uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
480 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0->getString());
481 uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
482 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1->getString());
483 uno::Reference<text::XText> xText2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW);
484 CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2->getString());
486 uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
487 uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
488 uno::Reference<drawing::XShape> xShape2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW);
490 CPPUNIT_ASSERT(xShape0->getPosition().X < xShape1->getPosition().X
491 && xShape1->getPosition().X < xShape2->getPosition().X);
492 CPPUNIT_ASSERT_EQUAL(xShape0->getPosition().Y, xShape1->getPosition().Y);
493 CPPUNIT_ASSERT_EQUAL(xShape1->getPosition().Y, xShape2->getPosition().Y);
495 xDocShRef->DoClose();
498 void SdImportTestSmartArt::testCycle()
500 sd::DrawDocShellRef xDocShRef
501 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-cycle.pptx"), PPTX);
502 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
503 CPPUNIT_ASSERT(xGroup.is());
505 // 11 children: background, 5 shapes, 5 connectors
506 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11), xGroup->getCount());
508 uno::Reference<drawing::XShape> xShape0(xGroup->getByIndex(1), uno::UNO_QUERY_THROW);
509 uno::Reference<drawing::XShape> xShapeConn(xGroup->getByIndex(2), uno::UNO_QUERY_THROW);
510 uno::Reference<drawing::XShape> xShape2(xGroup->getByIndex(3), uno::UNO_QUERY_THROW);
512 uno::Reference<text::XText> xText0(xShape0, uno::UNO_QUERY_THROW);
513 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0->getString());
514 uno::Reference<text::XText> xText2(xShape2, uno::UNO_QUERY_THROW);
515 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText2->getString());
517 // xShapeConn is connector between shapes 0 and 2
518 // it should lay between them and be rotated 0 -> 2
519 CPPUNIT_ASSERT(xShape0->getPosition().X < xShapeConn->getPosition().X);
520 CPPUNIT_ASSERT(xShape0->getPosition().Y < xShapeConn->getPosition().Y
521 && xShapeConn->getPosition().Y < xShape2->getPosition().Y);
522 uno::Reference<beans::XPropertySet> xPropSetConn(xShapeConn, uno::UNO_QUERY_THROW);
523 CPPUNIT_ASSERT_EQUAL(sal_Int32(32400),
524 xPropSetConn->getPropertyValue("RotateAngle").get<sal_Int32>());
526 // Make sure that we have an arrow shape between the two shapes
527 comphelper::SequenceAsHashMap aCustomShapeGeometry(
528 xPropSetConn->getPropertyValue("CustomShapeGeometry"));
529 CPPUNIT_ASSERT(aCustomShapeGeometry["Type"].has<OUString>());
530 OUString aType = aCustomShapeGeometry["Type"].get<OUString>();
531 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-rightArrow"), aType);
534 void SdImportTestSmartArt::testHierarchy()
536 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
539 void SdImportTestSmartArt::testmatrix()
541 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
544 void SdImportTestSmartArt::testvenndiagram()
546 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
549 void SdImportTestSmartArt::testInvertedPyramid()
551 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
554 void SdImportTestSmartArt::testMultidirectional()
556 // similar document as cycle, but arrows are pointing in both directions
558 sd::DrawDocShellRef xDocShRef = loadURL(
559 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-multidirectional.pptx"), PPTX);
560 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
561 CPPUNIT_ASSERT(xGroup.is());
563 // 7 children: background, 3 shapes, 3 connectors
564 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(7), xGroup->getCount());
566 uno::Reference<drawing::XShape> xShapeConn(xGroup->getByIndex(2), uno::UNO_QUERY_THROW);
567 uno::Reference<beans::XPropertySet> xPropSetConn(xShapeConn, uno::UNO_QUERY_THROW);
568 comphelper::SequenceAsHashMap aCustomShapeGeometry(
569 xPropSetConn->getPropertyValue("CustomShapeGeometry"));
570 CPPUNIT_ASSERT(aCustomShapeGeometry["Type"].has<OUString>());
571 OUString aType = aCustomShapeGeometry["Type"].get<OUString>();
572 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-leftRightArrow"), aType);
575 void SdImportTestSmartArt::testHorizontalBulletList()
577 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
580 void SdImportTestSmartArt::testEquation()
582 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
585 void SdImportTestSmartArt::testBasicRadicals()
587 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
590 void SdImportTestSmartArt::testSegmentedCycle()
592 //FIXME : so far this only introduce the test document, but the actual importer was not fixed yet.
595 void SdImportTestSmartArt::testBaseRtoL()
597 sd::DrawDocShellRef xDocShRef = loadURL(
598 m_directories.getURLFromSrc("sd/qa/unit/data/pptx/smartart-rightoleftblockdiagram.pptx"),
599 PPTX);
600 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
601 uno::UNO_QUERY_THROW);
602 CPPUNIT_ASSERT_EQUAL(sal_Int32(6), xShapeGroup->getCount());
604 uno::Reference<text::XText> xText0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
605 CPPUNIT_ASSERT_EQUAL(OUString("a"), xText0->getString());
606 uno::Reference<text::XText> xText1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
607 CPPUNIT_ASSERT_EQUAL(OUString("b"), xText1->getString());
608 uno::Reference<text::XText> xText2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW);
609 CPPUNIT_ASSERT_EQUAL(OUString("c"), xText2->getString());
610 uno::Reference<text::XText> xText3(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW);
611 CPPUNIT_ASSERT_EQUAL(OUString("d"), xText3->getString());
612 uno::Reference<text::XText> xText4(xShapeGroup->getByIndex(5), uno::UNO_QUERY_THROW);
613 CPPUNIT_ASSERT_EQUAL(OUString("e"), xText4->getString());
615 uno::Reference<beans::XPropertySet> xShape(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
617 sal_Int32 nFillColor = 0;
618 xShape->getPropertyValue("FillColor") >>= nFillColor;
619 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x4F81BD), nFillColor);
621 sal_Int16 nParaAdjust = 0;
622 uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xShape));
623 uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
624 xPropSet->getPropertyValue("ParaAdjust") >>= nParaAdjust;
625 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER,
626 static_cast<style::ParagraphAdjust>(nParaAdjust));
628 uno::Reference<drawing::XShape> xShape0(xShapeGroup->getByIndex(1), uno::UNO_QUERY_THROW);
629 uno::Reference<drawing::XShape> xShape1(xShapeGroup->getByIndex(2), uno::UNO_QUERY_THROW);
630 uno::Reference<drawing::XShape> xShape2(xShapeGroup->getByIndex(3), uno::UNO_QUERY_THROW);
631 uno::Reference<drawing::XShape> xShape3(xShapeGroup->getByIndex(4), uno::UNO_QUERY_THROW);
632 uno::Reference<drawing::XShape> xShape4(xShapeGroup->getByIndex(5), uno::UNO_QUERY_THROW);
633 CPPUNIT_ASSERT_EQUAL(xShape0->getPosition().Y, xShape1->getPosition().Y);
634 CPPUNIT_ASSERT_EQUAL(xShape2->getPosition().Y, xShape3->getPosition().Y);
635 CPPUNIT_ASSERT(xShape2->getPosition().Y > xShape0->getPosition().Y);
636 CPPUNIT_ASSERT(xShape4->getPosition().Y > xShape2->getPosition().Y);
637 CPPUNIT_ASSERT(xShape0->getPosition().X > xShape1->getPosition().X);
638 CPPUNIT_ASSERT(xShape2->getPosition().X > xShape3->getPosition().X);
639 CPPUNIT_ASSERT((xShape2->getPosition().X > xShape4->getPosition().X)
640 && (xShape3->getPosition().X < xShape4->getPosition().X));
642 xDocShRef->DoClose();
645 void SdImportTestSmartArt::testVerticalBoxList()
647 sd::DrawDocShellRef xDocShRef = loadURL(
648 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-vertical-box-list.pptx"), PPTX);
649 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
650 uno::UNO_QUERY_THROW);
651 // Without the accompanying fix in place, this test would have failed with
652 // 'actual: 0'.
653 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xShapeGroup->getCount());
655 uno::Reference<drawing::XShapes> xFirstChild(xShapeGroup->getByIndex(1), uno::UNO_QUERY);
656 CPPUNIT_ASSERT(xFirstChild.is());
657 uno::Reference<drawing::XShape> xParentText(xFirstChild->getByIndex(1), uno::UNO_QUERY);
658 CPPUNIT_ASSERT(xParentText.is());
659 // Without the accompanying fix in place, this test would have failed with
660 // 'actual: 7361', i.e. the width was not the 70% of the parent as the
661 // constraint wanted.
662 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11852), xParentText->getSize().Width);
664 uno::Reference<drawing::XShape> xChildText(xShapeGroup->getByIndex(2), uno::UNO_QUERY);
665 CPPUNIT_ASSERT(xChildText.is());
666 // Without the accompanying fix in place, this test would have failed with
667 // 'actual: 7361' (and with the fix: 'actual: 16932', i.e. the width of the
668 // parent).
669 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(10000), xChildText->getSize().Width);
671 // Assert that the right edge of the parent text is closer to the slide
672 // boundary than the right edge of the parent text.
673 // Without the accompanying fix in place, this test would have failed with
674 // 'Expected greater than: 25656, Actual : 21165'.
675 CPPUNIT_ASSERT_GREATER(xParentText->getPosition().X + xParentText->getSize().Width,
676 xChildText->getPosition().X + xChildText->getSize().Width);
678 xDocShRef->DoClose();
681 void SdImportTestSmartArt::testVerticalBracketList()
683 sd::DrawDocShellRef xDocShRef = loadURL(
684 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/vertical-bracket-list.pptx"), PPTX);
685 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef),
686 uno::UNO_QUERY_THROW);
687 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xShapeGroup->getCount());
689 uno::Reference<drawing::XShapes> xFirstChild(xShapeGroup->getByIndex(1), uno::UNO_QUERY);
690 CPPUNIT_ASSERT(xFirstChild.is());
691 // Without the accompanying fix in place, this test would have failed with
692 // 'actual: 2', i.e. one child shape (with its "A" text) was missing.
693 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xFirstChild->getCount());
695 xDocShRef->DoClose();
698 void SdImportTestSmartArt::testTableList()
700 sd::DrawDocShellRef xDocShRef
701 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/table-list.pptx"), PPTX);
702 uno::Reference<drawing::XShapes> xShapeGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
703 CPPUNIT_ASSERT(xShapeGroup.is());
704 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xShapeGroup->getCount());
706 uno::Reference<text::XText> xParentText(xShapeGroup->getByIndex(1), uno::UNO_QUERY);
707 CPPUNIT_ASSERT(xParentText.is());
708 CPPUNIT_ASSERT_EQUAL(OUString("Parent"), xParentText->getString());
709 uno::Reference<drawing::XShape> xParent(xParentText, uno::UNO_QUERY);
710 CPPUNIT_ASSERT(xParent.is());
711 int nParentRight = xParent->getPosition().X + xParent->getSize().Width;
713 uno::Reference<drawing::XShapes> xChildren(xShapeGroup->getByIndex(2), uno::UNO_QUERY);
714 CPPUNIT_ASSERT(xChildren.is());
715 uno::Reference<text::XText> xChild2Text(xChildren->getByIndex(1), uno::UNO_QUERY);
716 CPPUNIT_ASSERT(xChild2Text.is());
717 CPPUNIT_ASSERT_EQUAL(OUString("Child 2"), xChild2Text->getString());
718 uno::Reference<drawing::XShape> xChild2(xChild2Text, uno::UNO_QUERY);
719 CPPUNIT_ASSERT(xChild2.is());
720 int nChild2Right = xChild2->getPosition().X + xChild2->getSize().Width;
722 // Without the accompanying fix in place, this test would have failed with
723 // 'Expected less than: 100, Actual : 22014', i.e. the second child was
724 // shifted to the right too much.
725 CPPUNIT_ASSERT_LESS(100, abs(nChild2Right - nParentRight));
727 xDocShRef->DoClose();
730 void SdImportTestSmartArt::testAccentProcess()
732 sd::DrawDocShellRef xDocShRef = loadURL(
733 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-accent-process.pptx"), PPTX);
734 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
735 CPPUNIT_ASSERT(xGroup.is());
736 // 3 children: first pair, connector, second pair.
737 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xGroup->getCount());
738 uno::Reference<drawing::XShape> xGroupShape(xGroup, uno::UNO_QUERY);
739 CPPUNIT_ASSERT(xGroupShape.is());
741 // The pair is a parent (shape + text) and a child, so 3 shapes in total.
742 // The order is important, first is at the back, last is at the front.
743 uno::Reference<drawing::XShapes> xFirstPair(xGroup->getByIndex(1), uno::UNO_QUERY);
744 CPPUNIT_ASSERT(xFirstPair.is());
745 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xFirstPair->getCount());
747 uno::Reference<text::XText> xFirstParentText(xFirstPair->getByIndex(1), uno::UNO_QUERY);
748 CPPUNIT_ASSERT(xFirstParentText.is());
749 CPPUNIT_ASSERT_EQUAL(OUString("a"), xFirstParentText->getString());
750 uno::Reference<drawing::XShape> xFirstParent(xFirstParentText, uno::UNO_QUERY);
751 CPPUNIT_ASSERT(xFirstParent.is());
752 int nFirstParentTop = xFirstParent->getPosition().Y;
754 uno::Reference<text::XText> xFirstChildText(xFirstPair->getByIndex(2), uno::UNO_QUERY);
755 CPPUNIT_ASSERT(xFirstChildText.is());
756 CPPUNIT_ASSERT_EQUAL(OUString("b"), xFirstChildText->getString());
757 uno::Reference<drawing::XShape> xFirstChild(xFirstChildText, uno::UNO_QUERY);
758 CPPUNIT_ASSERT(xFirstChildText.is());
761 uno::Reference<container::XEnumerationAccess> xParasAccess(xFirstChildText, uno::UNO_QUERY);
762 uno::Reference<container::XEnumeration> xParas = xParasAccess->createEnumeration();
763 uno::Reference<beans::XPropertySet> xPara(xParas->nextElement(), uno::UNO_QUERY);
764 // Without the accompanying fix in place, this test would have failed
765 // with 'Expected: 0; Actual : 1270', i.e. there was a large
766 // unexpected left margin.
767 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0),
768 xPara->getPropertyValue("ParaLeftMargin").get<sal_Int32>());
770 uno::Reference<container::XIndexAccess> xRules(xPara->getPropertyValue("NumberingRules"),
771 uno::UNO_QUERY);
772 comphelper::SequenceAsHashMap aRule(xRules->getByIndex(0));
773 CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"•"), aRule["BulletChar"].get<OUString>());
776 int nFirstChildTop = xFirstChild->getPosition().Y;
777 int nFirstChildRight = xFirstChild->getPosition().X + xFirstChild->getSize().Width;
779 // First child is below the first parent.
780 // Without the accompanying fix in place, this test would have failed with
781 // 'Expected less than: 3881, Actual : 3881', i.e. xFirstChild was not
782 // below xFirstParent (a good position is 9081).
783 CPPUNIT_ASSERT_LESS(nFirstChildTop, nFirstParentTop);
785 // Make sure that we have an arrow shape between the two pairs.
786 uno::Reference<beans::XPropertySet> xArrow(xGroup->getByIndex(2), uno::UNO_QUERY);
787 CPPUNIT_ASSERT(xArrow.is());
788 comphelper::SequenceAsHashMap aCustomShapeGeometry(
789 xArrow->getPropertyValue("CustomShapeGeometry"));
790 // Without the accompanying fix in place, this test would have failed, i.e.
791 // the custom shape lacked a type -> arrow was not visible.
792 CPPUNIT_ASSERT(aCustomShapeGeometry["Type"].has<OUString>());
793 OUString aType = aCustomShapeGeometry["Type"].get<OUString>();
794 CPPUNIT_ASSERT_EQUAL(OUString("ooxml-rightArrow"), aType);
796 // Make sure that height of the arrow is less than its width.
797 uno::Reference<drawing::XShape> xArrowShape(xArrow, uno::UNO_QUERY);
798 CPPUNIT_ASSERT(xArrowShape.is());
799 awt::Size aArrowSize = xArrowShape->getSize();
800 CPPUNIT_ASSERT_LESS(aArrowSize.Width, aArrowSize.Height);
802 uno::Reference<drawing::XShapes> xSecondPair(xGroup->getByIndex(3), uno::UNO_QUERY);
803 CPPUNIT_ASSERT(xSecondPair.is());
804 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xSecondPair->getCount());
805 uno::Reference<text::XText> xSecondParentText(xSecondPair->getByIndex(1), uno::UNO_QUERY);
806 CPPUNIT_ASSERT(xFirstParentText.is());
807 // Without the accompanying fix in place, this test would have failed with
808 // 'Expected: cc; Actual : c', i.e. non-first runs on data points were ignored.
809 CPPUNIT_ASSERT_EQUAL(OUString("cc"), xSecondParentText->getString());
810 uno::Reference<drawing::XShape> xSecondParent(xSecondParentText, uno::UNO_QUERY);
811 CPPUNIT_ASSERT(xSecondParent.is());
812 int nSecondParentLeft = xSecondParent->getPosition().X;
813 // Without the accompanying fix in place, this test would have failed with
814 // 'Expected less than: 12700; Actual : 18540', i.e. the "b" and "c"
815 // shapes overlapped.
816 CPPUNIT_ASSERT_LESS(nSecondParentLeft, nFirstChildRight);
818 xDocShRef->DoClose();
821 void SdImportTestSmartArt::testContinuousBlockProcess()
823 sd::DrawDocShellRef xDocShRef = loadURL(
824 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-continuous-block-process.pptx"),
825 PPTX);
826 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
827 CPPUNIT_ASSERT(xGroup.is());
828 // 3 children: diagram background, background arrow, foreground.
829 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xGroup->getCount());
831 uno::Reference<drawing::XShapes> xLinear(xGroup->getByIndex(2), uno::UNO_QUERY);
832 CPPUNIT_ASSERT(xLinear.is());
833 // 3 children: A, B and C.
834 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(3), xLinear->getCount());
836 uno::Reference<text::XText> xA(xLinear->getByIndex(0), uno::UNO_QUERY);
837 CPPUNIT_ASSERT(xA.is());
838 CPPUNIT_ASSERT_EQUAL(OUString("A"), xA->getString());
839 uno::Reference<drawing::XShape> xAShape(xA, uno::UNO_QUERY);
840 CPPUNIT_ASSERT(xAShape.is());
841 // Without the accompanying fix in place, this test would have failed: the
842 // theoretically correct value is 5462 mm100 (16933 is the total width, and
843 // need to divide that to 1, 0.5, 1, 0.5 and 1 units), while the old value
844 // was 4703 and the new one is 5461.
845 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(5000), xAShape->getSize().Width);
847 xDocShRef->DoClose();
850 void SdImportTestSmartArt::testOrgChart()
852 // Simple org chart with 1 manager and 1 employee only.
853 sd::DrawDocShellRef xDocShRef = loadURL(
854 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-org-chart.pptx"), PPTX);
855 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
856 CPPUNIT_ASSERT(xGroup.is());
858 uno::Reference<text::XText> xManager(
859 getChildShape(getChildShape(getChildShape(xGroup, 1), 0), 0), uno::UNO_QUERY);
860 CPPUNIT_ASSERT(xManager.is());
861 // Without the accompanying fix in place, this test would have failed: this
862 // was just "Manager", and the second paragraph was lost.
863 CPPUNIT_ASSERT_EQUAL(OUString("Manager\nSecond para"), xManager->getString());
865 uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xManager, uno::UNO_QUERY);
866 uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
867 uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
868 uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xPara, uno::UNO_QUERY);
869 uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
870 uno::Reference<beans::XPropertySet> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
871 sal_Int32 nActualColor = xRun->getPropertyValue("CharColor").get<sal_Int32>();
872 // Without the accompanying fix in place, this test would have failed: the
873 // "Manager" font color was black, not white.
874 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xffffff), nActualColor);
876 uno::Reference<drawing::XShape> xManagerShape(xManager, uno::UNO_QUERY);
877 CPPUNIT_ASSERT(xManagerShape.is());
879 awt::Point aManagerPos = xManagerShape->getPosition();
880 awt::Size aManagerSize = xManagerShape->getSize();
882 // Make sure that the manager has 2 employees.
883 uno::Reference<drawing::XShapes> xEmployees(getChildShape(getChildShape(xGroup, 1), 2),
884 uno::UNO_QUERY);
885 CPPUNIT_ASSERT(xEmployees.is());
886 // 4 children: connector, 1st employee, connector, 2nd employee.
887 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), xEmployees->getCount());
889 uno::Reference<text::XText> xEmployee(
890 getChildShape(
891 getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 1), 2), 1), 0), 0),
892 uno::UNO_QUERY);
893 CPPUNIT_ASSERT(xEmployee.is());
894 CPPUNIT_ASSERT_EQUAL(OUString("Employee"), xEmployee->getString());
896 uno::Reference<drawing::XShape> xEmployeeShape(xEmployee, uno::UNO_QUERY);
897 CPPUNIT_ASSERT(xEmployeeShape.is());
899 awt::Point aEmployeePos = xEmployeeShape->getPosition();
900 awt::Size aEmployeeSize = xEmployeeShape->getSize();
902 CPPUNIT_ASSERT_EQUAL(aManagerPos.X, aEmployeePos.X);
904 // Without the accompanying fix in place, this test would have failed: the
905 // two shapes were overlapping, i.e. "manager" was not above "employee".
906 CPPUNIT_ASSERT_GREATER(aManagerPos.Y, aEmployeePos.Y);
908 // Make sure that the second employee is on the right of the first one.
909 // Without the accompanying fix in place, this test would have failed, as
910 // the second employee was below the first one.
911 uno::Reference<text::XText> xEmployee2(
912 getChildShape(
913 getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 1), 2), 3), 0), 0),
914 uno::UNO_QUERY);
915 CPPUNIT_ASSERT(xEmployee2.is());
916 CPPUNIT_ASSERT_EQUAL(OUString("Employee2"), xEmployee2->getString());
918 uno::Reference<drawing::XShape> xEmployee2Shape(xEmployee2, uno::UNO_QUERY);
919 CPPUNIT_ASSERT(xEmployee2Shape.is());
921 awt::Point aEmployee2Pos = xEmployee2Shape->getPosition();
922 //awt::Size aEmployee2Size = xEmployee2Shape->getSize();
923 CPPUNIT_ASSERT_GREATER(aEmployeePos.X, aEmployee2Pos.X);
925 // Make sure that assistant is above employees.
926 uno::Reference<text::XText> xAssistant(
927 getChildShape(
928 getChildShape(getChildShape(getChildShape(getChildShape(xGroup, 1), 1), 1), 0), 0),
929 uno::UNO_QUERY);
930 CPPUNIT_ASSERT_EQUAL(OUString("Assistant"), xAssistant->getString());
932 uno::Reference<drawing::XShape> xAssistantShape(xAssistant, uno::UNO_QUERY);
933 CPPUNIT_ASSERT(xAssistantShape.is());
935 awt::Point aAssistantPos = xAssistantShape->getPosition();
936 // Without the accompanying fix in place, this test would have failed: the
937 // assistant shape was below the employee shape.
938 CPPUNIT_ASSERT_GREATER(aAssistantPos.Y, aEmployeePos.Y);
940 // Make sure the connector of the assistant is above the shape.
941 uno::Reference<drawing::XShape> xAssistantConnector
942 = getChildShape(getChildShape(getChildShape(xGroup, 1), 1), 0);
943 CPPUNIT_ASSERT(xAssistantConnector.is());
944 //awt::Point aAssistantConnectorPos = xAssistantConnector->getPosition();
945 // This failed, the vertical positions of the connector and the shape of
946 // the assistant were the same.
947 //CPPUNIT_ASSERT_LESS(aAssistantPos.Y, aAssistantConnectorPos.Y);
948 // connectors are hidden as they don't work correctly
950 // Make sure the height of xManager and xManager2 is the same.
951 uno::Reference<text::XText> xManager2(
952 getChildShape(getChildShape(getChildShape(xGroup, 2), 0), 0), uno::UNO_QUERY);
953 CPPUNIT_ASSERT(xManager2.is());
954 CPPUNIT_ASSERT_EQUAL(OUString("Manager2"), xManager2->getString());
956 uno::Reference<drawing::XShape> xManager2Shape(xManager2, uno::UNO_QUERY);
957 CPPUNIT_ASSERT(xManager2Shape.is());
959 awt::Size aManager2Size = xManager2Shape->getSize();
960 // Without the accompanying fix in place, this test would have failed:
961 // xManager2's height was 3 times larger than xManager's height.
962 CPPUNIT_ASSERT_EQUAL(aManagerSize.Height, aManager2Size.Height);
964 // Make sure the employee nodes use the free space on the right, since
965 // manager2 has no assistants / employees.
966 //CPPUNIT_ASSERT_GREATER(aManagerSize.Width, aEmployeeSize.Width + aEmployee2Size.Width);
967 // currently disabled as causes problems in complex charts
969 // Without the accompanying fix in place, this test would have failed: an
970 // employee was exactly the third of the total height, without any spacing.
971 CPPUNIT_ASSERT_LESS(xGroup->getSize().Height / 3, aEmployeeSize.Height);
973 xDocShRef->DoClose();
976 void SdImportTestSmartArt::testCycleMatrix()
978 sd::DrawDocShellRef xDocShRef = loadURL(
979 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-cycle-matrix.pptx"), PPTX);
980 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
981 CPPUNIT_ASSERT(xGroup.is());
983 // Without the accompanying fix in place, this test would have failed: the height was 12162,
984 // which is not the mm100 equivalent of the 4064000 EMU in the input file.
985 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(11288), xGroup->getSize().Height);
987 uno::Reference<text::XText> xA1(getChildShape(getChildShape(xGroup, 2), 0), uno::UNO_QUERY);
988 CPPUNIT_ASSERT(xA1.is());
989 CPPUNIT_ASSERT_EQUAL(OUString("A1"), xA1->getString());
991 // Test fill color of B1, should be orange.
992 uno::Reference<text::XText> xB1(getChildShape(getChildShape(xGroup, 2), 1), uno::UNO_QUERY);
993 CPPUNIT_ASSERT(xB1.is());
994 CPPUNIT_ASSERT_EQUAL(OUString("B1"), xB1->getString());
996 uno::Reference<beans::XPropertySet> xB1Props(xB1, uno::UNO_QUERY);
997 CPPUNIT_ASSERT(xB1Props.is());
998 sal_Int32 nFillColor = 0;
999 xB1Props->getPropertyValue("FillColor") >>= nFillColor;
1000 // Without the accompanying fix in place, this test would have failed: the background color was
1001 // 0x4f81bd, i.e. blue, not orange.
1002 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xf79646), nFillColor);
1004 // Without the accompanying fix in place, this test would have failed: the
1005 // content of the "A2" shape was lost.
1006 uno::Reference<text::XText> xA2(getChildShape(getChildShape(getChildShape(xGroup, 1), 0), 1),
1007 uno::UNO_QUERY);
1008 CPPUNIT_ASSERT(xA2.is());
1009 CPPUNIT_ASSERT_EQUAL(OUString("A2"), xA2->getString());
1011 // Test that the layout of shapes is like this:
1012 // A2 B2
1013 // D2 C2
1015 uno::Reference<drawing::XShape> xA2Shape(xA2, uno::UNO_QUERY);
1016 CPPUNIT_ASSERT(xA2Shape.is());
1018 uno::Reference<text::XText> xB2(getChildShape(getChildShape(getChildShape(xGroup, 1), 1), 1),
1019 uno::UNO_QUERY);
1020 CPPUNIT_ASSERT(xB2.is());
1021 CPPUNIT_ASSERT_EQUAL(OUString("B2"), xB2->getString());
1022 uno::Reference<drawing::XShape> xB2Shape(xB2, uno::UNO_QUERY);
1023 CPPUNIT_ASSERT(xB2Shape.is());
1025 // Test line color of B2, should be orange.
1026 uno::Reference<beans::XPropertySet> xB2Props(xB2, uno::UNO_QUERY);
1027 CPPUNIT_ASSERT(xB2Props.is());
1028 sal_Int32 nLineColor = 0;
1029 xB2Props->getPropertyValue("LineColor") >>= nLineColor;
1030 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xf79646), nLineColor);
1032 uno::Reference<text::XText> xC2(getChildShape(getChildShape(getChildShape(xGroup, 1), 2), 1),
1033 uno::UNO_QUERY);
1034 CPPUNIT_ASSERT(xC2.is());
1035 // Without the accompanying fix in place, this test would have failed, i.e. the order of the
1036 // lines in the shape were wrong: C2-1\nC2-4\nC2-3\nC2-2.
1037 CPPUNIT_ASSERT_EQUAL(OUString("C2-1\nC2-2\nC2-3\nC2-4"), xC2->getString());
1038 uno::Reference<drawing::XShape> xC2Shape(xC2, uno::UNO_QUERY);
1039 CPPUNIT_ASSERT(xC2Shape.is());
1041 uno::Reference<text::XText> xD2(getChildShape(getChildShape(getChildShape(xGroup, 1), 3), 1),
1042 uno::UNO_QUERY);
1043 CPPUNIT_ASSERT(xD2.is());
1044 CPPUNIT_ASSERT_EQUAL(OUString("D2"), xD2->getString());
1045 uno::Reference<drawing::XShape> xD2Shape(xD2, uno::UNO_QUERY);
1046 CPPUNIT_ASSERT(xD2Shape.is());
1048 // Without the accompanying fix in place, this test would have failed, i.e.
1049 // the A2 and B2 shapes had the same horizontal position, while B2 should
1050 // be on the right of A2.
1051 CPPUNIT_ASSERT_GREATER(xA2Shape->getPosition().X, xB2Shape->getPosition().X);
1052 CPPUNIT_ASSERT_EQUAL(xA2Shape->getPosition().Y, xB2Shape->getPosition().Y);
1053 CPPUNIT_ASSERT_GREATER(xA2Shape->getPosition().X, xC2Shape->getPosition().X);
1054 CPPUNIT_ASSERT_GREATER(xA2Shape->getPosition().Y, xC2Shape->getPosition().Y);
1055 CPPUNIT_ASSERT_EQUAL(xA2Shape->getPosition().X, xD2Shape->getPosition().X);
1056 CPPUNIT_ASSERT_GREATER(xA2Shape->getPosition().Y, xD2Shape->getPosition().Y);
1058 // Without the accompanying fix in place, this test would have failed: width was expected to be
1059 // 4887, was actually 7331.
1060 uno::Reference<drawing::XShape> xA1Shape(xA1, uno::UNO_QUERY);
1061 CPPUNIT_ASSERT(xA1Shape.is());
1062 CPPUNIT_ASSERT_EQUAL(xA1Shape->getSize().Height, xA1Shape->getSize().Width);
1064 xDocShRef->DoClose();
1067 void SdImportTestSmartArt::testPictureStrip()
1069 sd::DrawDocShellRef xDocShRef = loadURL(
1070 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-picture-strip.pptx"), PPTX);
1071 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1072 CPPUNIT_ASSERT(xGroup.is());
1074 uno::Reference<beans::XPropertySet> xFirstImage(getChildShape(getChildShape(xGroup, 1), 1),
1075 uno::UNO_QUERY);
1076 CPPUNIT_ASSERT(xFirstImage.is());
1077 drawing::FillStyle eFillStyle = drawing::FillStyle_NONE;
1078 xFirstImage->getPropertyValue("FillStyle") >>= eFillStyle;
1079 // Without the accompanying fix in place, this test would have failed: fill style was solid, not
1080 // bitmap.
1081 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, eFillStyle);
1083 uno::Reference<graphic::XGraphic> xGraphic;
1084 xFirstImage->getPropertyValue("FillBitmap") >>= xGraphic;
1085 Graphic aFirstGraphic(xGraphic);
1087 uno::Reference<beans::XPropertySet> xSecondImage(getChildShape(getChildShape(xGroup, 2), 1),
1088 uno::UNO_QUERY);
1089 CPPUNIT_ASSERT(xSecondImage.is());
1090 eFillStyle = drawing::FillStyle_NONE;
1091 xSecondImage->getPropertyValue("FillStyle") >>= eFillStyle;
1092 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, eFillStyle);
1094 xSecondImage->getPropertyValue("FillBitmap") >>= xGraphic;
1095 Graphic aSecondGraphic(xGraphic);
1096 // Without the accompanying fix in place, this test would have failed: both xFirstImage and
1097 // xSecondImage had the bitmap fill from the second shape.
1098 CPPUNIT_ASSERT(aFirstGraphic.GetChecksum() != aSecondGraphic.GetChecksum());
1100 // Test that the 3 images are in a single column, in 3 rows.
1101 uno::Reference<drawing::XShape> xFirstImageShape(xFirstImage, uno::UNO_QUERY);
1102 CPPUNIT_ASSERT(xFirstImage.is());
1103 uno::Reference<drawing::XShape> xSecondImageShape(xSecondImage, uno::UNO_QUERY);
1104 CPPUNIT_ASSERT(xSecondImage.is());
1105 uno::Reference<drawing::XShape> xThirdImageShape = getChildShape(getChildShape(xGroup, 3), 1);
1106 CPPUNIT_ASSERT(xThirdImageShape.is());
1107 // Without the accompanying fix in place, this test would have failed: the first and the second
1108 // image were in the same row.
1109 CPPUNIT_ASSERT_EQUAL(xFirstImageShape->getPosition().X, xSecondImageShape->getPosition().X);
1110 CPPUNIT_ASSERT_EQUAL(xSecondImageShape->getPosition().X, xThirdImageShape->getPosition().X);
1111 CPPUNIT_ASSERT_GREATER(xFirstImageShape->getPosition().Y, xSecondImageShape->getPosition().Y);
1112 CPPUNIT_ASSERT_GREATER(xSecondImageShape->getPosition().Y, xThirdImageShape->getPosition().Y);
1114 // Make sure that the title shape doesn't overlap with the diagram.
1115 // Note that real "no overlap" is asserted here, though in fact what we want is a less strict
1116 // condition: that no text part of the title shape and the diagram overlaps.
1117 uno::Reference<drawing::XShape> xTitle(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY);
1118 CPPUNIT_ASSERT(xTitle.is());
1119 // Without the accompanying fix in place, this test would have failed with 'Expected greater
1120 // than: 2873; Actual : 2320', i.e. the title shape and the diagram overlapped.
1121 uno::Reference<drawing::XShape> xFirstPair = getChildShape(xGroup, 1);
1122 CPPUNIT_ASSERT_GREATER(xTitle->getPosition().Y + xTitle->getSize().Height,
1123 xFirstPair->getPosition().Y);
1125 // Make sure that left margin is 60% of width (if you count width in points and margin in mms).
1126 uno::Reference<beans::XPropertySet> xFirstText(getChildShape(getChildShape(xGroup, 1), 0),
1127 uno::UNO_QUERY);
1128 CPPUNIT_ASSERT(xFirstText.is());
1129 sal_Int32 nTextLeftDistance = 0;
1130 xFirstText->getPropertyValue("TextLeftDistance") >>= nTextLeftDistance;
1131 uno::Reference<drawing::XShape> xFirstTextShape(xFirstText, uno::UNO_QUERY);
1132 CPPUNIT_ASSERT(xFirstTextShape.is());
1133 sal_Int32 nWidth = xFirstTextShape->getSize().Width;
1134 double fFactor = oox::drawingml::convertPointToMms(0.6);
1135 // Without the accompanying fix in place, this test would have failed with 'Expected: 3440,
1136 // Actual : 263', i.e. the left margin was too small.
1137 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(nWidth * fFactor), nTextLeftDistance);
1139 // Make sure that aspect ratio is not ignored, i.e. width is not larger than height 3 times.
1140 awt::Size aFirstPairSize = xFirstPair->getSize();
1141 // Without the accompanying fix in place, this test would have failed: bad width was 16932, good
1142 // width is 12540, but let's accept 12541 as well.
1143 CPPUNIT_ASSERT_LESSEQUAL(aFirstPairSize.Height * 3 + 1, aFirstPairSize.Width);
1145 xDocShRef->DoClose();
1148 void SdImportTestSmartArt::testInteropGrabBag()
1150 sd::DrawDocShellRef xDocShRef = loadURL(
1151 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-interopgrabbag.pptx"), PPTX);
1152 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1153 CPPUNIT_ASSERT(xGroup.is());
1155 uno::Reference<beans::XPropertySet> xPropertySet(xGroup, uno::UNO_QUERY_THROW);
1156 uno::Sequence<beans::PropertyValue> aGrabBagSeq;
1157 xPropertySet->getPropertyValue("InteropGrabBag") >>= aGrabBagSeq;
1158 comphelper::SequenceAsHashMap aGrabBag(aGrabBagSeq);
1159 CPPUNIT_ASSERT(aGrabBag.find("OOXData") != aGrabBag.end());
1160 CPPUNIT_ASSERT(aGrabBag.find("OOXLayout") != aGrabBag.end());
1161 CPPUNIT_ASSERT(aGrabBag.find("OOXStyle") != aGrabBag.end());
1162 CPPUNIT_ASSERT(aGrabBag.find("OOXColor") != aGrabBag.end());
1163 CPPUNIT_ASSERT(aGrabBag.find("OOXDrawing") != aGrabBag.end());
1165 xDocShRef->DoClose();
1168 void SdImportTestSmartArt::testBackground()
1170 sd::DrawDocShellRef xDocShRef = loadURL(
1171 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-background.pptx"), PPTX);
1172 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1173 CPPUNIT_ASSERT(xGroup.is());
1175 // background should fill whole diagram
1176 uno::Reference<drawing::XShape> xShapeGroup(xGroup, uno::UNO_QUERY);
1177 uno::Reference<drawing::XShape> xShape(xGroup->getByIndex(0), uno::UNO_QUERY);
1178 CPPUNIT_ASSERT_EQUAL(xShape->getPosition().X, xShapeGroup->getPosition().X);
1179 CPPUNIT_ASSERT_EQUAL(xShape->getPosition().Y, xShapeGroup->getPosition().Y);
1180 CPPUNIT_ASSERT_EQUAL(xShape->getSize().Width, xShapeGroup->getSize().Width);
1181 CPPUNIT_ASSERT_EQUAL(xShape->getSize().Height, xShapeGroup->getSize().Height);
1183 uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY_THROW);
1184 drawing::FillStyle eFillStyle = drawing::FillStyle_NONE;
1185 xPropertySet->getPropertyValue("FillStyle") >>= eFillStyle;
1186 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, eFillStyle);
1188 sal_Int32 nFillColor = 0;
1189 xPropertySet->getPropertyValue("FillColor") >>= nFillColor;
1190 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x339933), nFillColor);
1192 bool bMoveProtect = false;
1193 xPropertySet->getPropertyValue("MoveProtect") >>= bMoveProtect;
1194 CPPUNIT_ASSERT_EQUAL(true, bMoveProtect);
1196 bool bSizeProtect = false;
1197 xPropertySet->getPropertyValue("SizeProtect") >>= bSizeProtect;
1198 CPPUNIT_ASSERT_EQUAL(true, bSizeProtect);
1200 xDocShRef->DoClose();
1203 void SdImportTestSmartArt::testBackgroundDrawingmlFallback()
1205 // same as testBackground, but test file contains drawingML fallback
1207 sd::DrawDocShellRef xDocShRef
1208 = loadURL(m_directories.getURLFromSrc(
1209 "/sd/qa/unit/data/pptx/smartart-background-drawingml-fallback.pptx"),
1210 PPTX);
1211 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1212 CPPUNIT_ASSERT(xGroup.is());
1214 // background should fill whole diagram
1215 uno::Reference<drawing::XShape> xShapeGroup(xGroup, uno::UNO_QUERY);
1216 uno::Reference<drawing::XShape> xShape(xGroup->getByIndex(0), uno::UNO_QUERY);
1217 CPPUNIT_ASSERT_EQUAL(xShape->getPosition().X, xShapeGroup->getPosition().X);
1218 CPPUNIT_ASSERT_EQUAL(xShape->getPosition().Y, xShapeGroup->getPosition().Y);
1219 CPPUNIT_ASSERT_EQUAL(xShape->getSize().Width, xShapeGroup->getSize().Width);
1220 CPPUNIT_ASSERT_EQUAL(xShape->getSize().Height, xShapeGroup->getSize().Height);
1222 uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY_THROW);
1223 drawing::FillStyle eFillStyle = drawing::FillStyle_NONE;
1224 xPropertySet->getPropertyValue("FillStyle") >>= eFillStyle;
1225 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, eFillStyle);
1227 sal_Int32 nFillColor = 0;
1228 xPropertySet->getPropertyValue("FillColor") >>= nFillColor;
1229 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x339933), nFillColor);
1231 bool bMoveProtect = false;
1232 xPropertySet->getPropertyValue("MoveProtect") >>= bMoveProtect;
1233 CPPUNIT_ASSERT_EQUAL(true, bMoveProtect);
1235 bool bSizeProtect = false;
1236 xPropertySet->getPropertyValue("SizeProtect") >>= bSizeProtect;
1237 CPPUNIT_ASSERT_EQUAL(true, bSizeProtect);
1239 xDocShRef->DoClose();
1242 void SdImportTestSmartArt::testCenterCycle()
1244 sd::DrawDocShellRef xDocShRef = loadURL(
1245 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-center-cycle.pptx"), PPTX);
1246 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1247 CPPUNIT_ASSERT(xGroup.is());
1249 uno::Reference<drawing::XShapes> xGroupNested(xGroup->getByIndex(1), uno::UNO_QUERY);
1250 CPPUNIT_ASSERT(xGroupNested.is());
1252 uno::Reference<drawing::XShape> xShapeCenter(xGroupNested->getByIndex(0), uno::UNO_QUERY);
1253 uno::Reference<drawing::XShape> xShapeA(xGroupNested->getByIndex(1), uno::UNO_QUERY);
1254 uno::Reference<drawing::XShape> xShapeB(xGroupNested->getByIndex(2), uno::UNO_QUERY);
1255 uno::Reference<drawing::XShape> xShapeC(xGroupNested->getByIndex(3), uno::UNO_QUERY);
1257 uno::Reference<text::XText> xTextCenter(xShapeCenter, uno::UNO_QUERY);
1258 CPPUNIT_ASSERT(xTextCenter.is());
1259 CPPUNIT_ASSERT_EQUAL(OUString("center"), xTextCenter->getString());
1261 CPPUNIT_ASSERT_LESS(xShapeCenter->getPosition().Y, xShapeA->getPosition().Y);
1262 CPPUNIT_ASSERT_GREATER(xShapeCenter->getPosition().X, xShapeB->getPosition().X);
1263 CPPUNIT_ASSERT_GREATER(xShapeCenter->getPosition().Y, xShapeB->getPosition().Y);
1264 CPPUNIT_ASSERT_LESS(xShapeCenter->getPosition().X, xShapeC->getPosition().X);
1265 CPPUNIT_ASSERT_GREATER(xShapeCenter->getPosition().Y, xShapeC->getPosition().Y);
1267 xDocShRef->DoClose();
1270 void SdImportTestSmartArt::testFontSize()
1272 sd::DrawDocShellRef xDocShRef = loadURL(
1273 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-font-size.pptx"), PPTX);
1275 uno::Reference<drawing::XShapes> xGroup1(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1276 uno::Reference<beans::XPropertySet> xShape1(xGroup1->getByIndex(1), uno::UNO_QUERY);
1277 uno::Reference<text::XTextRange> xParagraph1(getParagraphFromShape(0, xShape1));
1278 uno::Reference<text::XTextRange> xRun1(getRunFromParagraph(0, xParagraph1));
1279 uno::Reference<beans::XPropertySet> xPropSet1(xRun1, uno::UNO_QUERY);
1280 double fFontSize1 = xPropSet1->getPropertyValue("CharHeight").get<double>();
1281 CPPUNIT_ASSERT_DOUBLES_EQUAL(65.0, fFontSize1, 0.01);
1283 uno::Reference<drawing::XShapes> xGroup2(getShapeFromPage(1, 0, xDocShRef), uno::UNO_QUERY);
1284 uno::Reference<beans::XPropertySet> xShape2(xGroup2->getByIndex(1), uno::UNO_QUERY);
1285 uno::Reference<text::XTextRange> xParagraph2(getParagraphFromShape(0, xShape2));
1286 uno::Reference<text::XTextRange> xRun2(getRunFromParagraph(0, xParagraph2));
1287 uno::Reference<beans::XPropertySet> xPropSet2(xRun2, uno::UNO_QUERY);
1288 double fFontSize2 = xPropSet2->getPropertyValue("CharHeight").get<double>();
1289 CPPUNIT_ASSERT_EQUAL(32.0, fFontSize2);
1291 uno::Reference<drawing::XShapes> xGroup3(getShapeFromPage(2, 0, xDocShRef), uno::UNO_QUERY);
1292 uno::Reference<beans::XPropertySet> xShape3(xGroup3->getByIndex(1), uno::UNO_QUERY);
1293 drawing::TextFitToSizeType eTextFitToSize = drawing::TextFitToSizeType_NONE;
1294 xShape3->getPropertyValue("TextFitToSize") >>= eTextFitToSize;
1295 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_AUTOFIT, eTextFitToSize);
1297 xDocShRef->DoClose();
1300 void SdImportTestSmartArt::testVerticalBlockList()
1302 sd::DrawDocShellRef xDocShRef = loadURL(
1303 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-vertical-block-list.pptx"),
1304 PPTX);
1305 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1306 CPPUNIT_ASSERT(xGroup.is());
1308 uno::Reference<drawing::XShapes> xGroup1(xGroup->getByIndex(1), uno::UNO_QUERY);
1309 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2), xGroup1->getCount());
1310 uno::Reference<drawing::XShape> xShapeA(xGroup1->getByIndex(1), uno::UNO_QUERY);
1311 uno::Reference<drawing::XShape> xShapeBC(xGroup1->getByIndex(0), uno::UNO_QUERY);
1312 uno::Reference<text::XText> xTextA(xShapeA, uno::UNO_QUERY);
1313 uno::Reference<text::XText> xTextBC(xShapeBC, uno::UNO_QUERY);
1314 CPPUNIT_ASSERT_EQUAL(OUString("a"), xTextA->getString());
1315 CPPUNIT_ASSERT_EQUAL(OUString("b\nc"), xTextBC->getString());
1317 uno::Reference<beans::XPropertySet> xPropSetBC(xShapeBC, uno::UNO_QUERY);
1318 CPPUNIT_ASSERT_EQUAL(sal_Int32(27000),
1319 xPropSetBC->getPropertyValue("RotateAngle").get<sal_Int32>());
1321 // BC shape is rotated 90*, so width and height is swapped
1322 CPPUNIT_ASSERT_GREATER(xShapeA->getSize().Width, xShapeBC->getSize().Height);
1323 CPPUNIT_ASSERT_LESS(xShapeA->getSize().Height, xShapeBC->getSize().Width);
1324 CPPUNIT_ASSERT_GREATER(xShapeA->getPosition().X, xShapeBC->getPosition().X);
1325 CPPUNIT_ASSERT_GREATER(xShapeA->getPosition().Y, xShapeBC->getPosition().Y);
1327 uno::Reference<drawing::XShapes> xGroup3(xGroup->getByIndex(3), uno::UNO_QUERY);
1328 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), xGroup3->getCount());
1329 uno::Reference<drawing::XShape> xShapeEmpty(xGroup3->getByIndex(0), uno::UNO_QUERY);
1330 uno::Reference<text::XText> xTextEmpty(xShapeEmpty, uno::UNO_QUERY);
1331 CPPUNIT_ASSERT_EQUAL(OUString("empty"), xTextEmpty->getString());
1333 CPPUNIT_ASSERT_EQUAL(xShapeA->getSize().Width, xShapeEmpty->getSize().Width);
1334 CPPUNIT_ASSERT_EQUAL(xShapeA->getSize().Height, xShapeEmpty->getSize().Height);
1335 CPPUNIT_ASSERT_EQUAL(xShapeA->getPosition().X, xShapeEmpty->getPosition().X);
1336 CPPUNIT_ASSERT_GREATER(xShapeA->getPosition().Y + 2 * xShapeA->getSize().Height,
1337 xShapeEmpty->getPosition().Y);
1339 uno::Reference<drawing::XShape> xGroupShape(xGroup, uno::UNO_QUERY);
1340 CPPUNIT_ASSERT_EQUAL(xGroupShape->getPosition().Y + xGroupShape->getSize().Height,
1341 xShapeEmpty->getPosition().Y + xShapeEmpty->getSize().Height);
1343 xDocShRef->DoClose();
1346 void SdImportTestSmartArt::testMissingBulletAndIndent()
1348 sd::DrawDocShellRef xDocShRef = loadURL(
1349 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-missing-bullet.pptx"), PPTX);
1350 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1351 uno::Reference<drawing::XShapes> xGroup1(xGroup->getByIndex(2), uno::UNO_QUERY);
1352 uno::Reference<drawing::XShapes> xGroup2(xGroup1->getByIndex(0), uno::UNO_QUERY);
1353 uno::Reference<text::XText> xText(xGroup2->getByIndex(0), uno::UNO_QUERY);
1354 CPPUNIT_ASSERT(xText.is());
1356 uno::Reference<container::XEnumerationAccess> xParasAccess(xText, uno::UNO_QUERY);
1357 uno::Reference<container::XEnumeration> xParas = xParasAccess->createEnumeration();
1358 xParas->nextElement(); // skip parent
1360 uno::Reference<beans::XPropertySet> xPara1(xParas->nextElement(), uno::UNO_QUERY);
1361 CPPUNIT_ASSERT(xPara1.is());
1363 sal_Int16 nNumberingLevel = -1;
1364 xPara1->getPropertyValue("NumberingLevel") >>= nNumberingLevel;
1365 CPPUNIT_ASSERT_EQUAL(sal_Int16(1), nNumberingLevel);
1367 uno::Reference<container::XIndexAccess> xNumRule;
1368 xPara1->getPropertyValue("NumberingRules") >>= xNumRule;
1369 uno::Sequence<beans::PropertyValue> aBulletProps;
1370 xNumRule->getByIndex(1) >>= aBulletProps;
1372 for (beans::PropertyValue const& rProp : std::as_const(aBulletProps))
1374 if (rProp.Name == "LeftMargin")
1375 CPPUNIT_ASSERT_EQUAL(sal_Int32(309), rProp.Value.get<sal_Int32>());
1379 void SdImportTestSmartArt::testBulletList()
1381 sd::DrawDocShellRef xDocShRef = loadURL(
1382 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-bullet-list.pptx"), PPTX);
1383 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1384 CPPUNIT_ASSERT(xGroup.is());
1386 uno::Reference<text::XText> xText(xGroup->getByIndex(1), uno::UNO_QUERY);
1387 uno::Reference<container::XEnumerationAccess> xParasAccess(xText, uno::UNO_QUERY);
1388 uno::Reference<container::XEnumeration> xParas = xParasAccess->createEnumeration();
1389 xParas->nextElement(); // skip parent
1391 // child levels should have bullets
1392 uno::Reference<beans::XPropertySet> xPara1(xParas->nextElement(), uno::UNO_QUERY);
1393 uno::Reference<container::XIndexAccess> xRules1(xPara1->getPropertyValue("NumberingRules"),
1394 uno::UNO_QUERY);
1395 comphelper::SequenceAsHashMap aRule1(xRules1->getByIndex(1));
1396 CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"•"), aRule1["BulletChar"].get<OUString>());
1398 uno::Reference<beans::XPropertySet> xPara2(xParas->nextElement(), uno::UNO_QUERY);
1399 uno::Reference<container::XIndexAccess> xRules2(xPara2->getPropertyValue("NumberingRules"),
1400 uno::UNO_QUERY);
1401 comphelper::SequenceAsHashMap aRule2(xRules2->getByIndex(2));
1402 CPPUNIT_ASSERT_EQUAL(OUString::fromUtf8(u8"•"), aRule2["BulletChar"].get<OUString>());
1404 xDocShRef->DoClose();
1407 void SdImportTestSmartArt::testRecursion()
1409 sd::DrawDocShellRef xDocShRef = loadURL(
1410 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-recursion.pptx"), PPTX);
1412 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1413 uno::Reference<drawing::XShapes> xGroup1(xGroup->getByIndex(1), uno::UNO_QUERY);
1415 uno::Reference<drawing::XShapes> xGroupA(xGroup1->getByIndex(0), uno::UNO_QUERY);
1416 uno::Reference<text::XText> xTextA(xGroupA->getByIndex(0), uno::UNO_QUERY);
1417 CPPUNIT_ASSERT_EQUAL(OUString("A"), xTextA->getString());
1419 uno::Reference<drawing::XShapes> xGroupB(xGroup1->getByIndex(1), uno::UNO_QUERY);
1420 // 5 connectors, B1 with children, B2 with children
1421 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(7), xGroupB->getCount());
1423 uno::Reference<drawing::XShapes> xGroupB1(xGroupB->getByIndex(1), uno::UNO_QUERY);
1425 uno::Reference<drawing::XShapes> xGroupB1a(xGroupB1->getByIndex(0), uno::UNO_QUERY);
1426 uno::Reference<text::XText> xTextB1(xGroupB1a->getByIndex(0), uno::UNO_QUERY);
1427 CPPUNIT_ASSERT_EQUAL(OUString("B1"), xTextB1->getString());
1429 uno::Reference<drawing::XShape> xGroupC12(xGroupB1->getByIndex(1), uno::UNO_QUERY);
1430 uno::Reference<text::XText> xTextC1(
1431 getChildShape(getChildShape(getChildShape(xGroupC12, 0), 0), 0), uno::UNO_QUERY);
1432 CPPUNIT_ASSERT_EQUAL(OUString("C1"), xTextC1->getString());
1433 uno::Reference<text::XText> xTextC2(
1434 getChildShape(getChildShape(getChildShape(xGroupC12, 1), 0), 0), uno::UNO_QUERY);
1435 CPPUNIT_ASSERT_EQUAL(OUString("C2"), xTextC2->getString());
1437 uno::Reference<drawing::XShapes> xGroupB2(xGroupB->getByIndex(5), uno::UNO_QUERY);
1439 uno::Reference<drawing::XShapes> xGroupB2a(xGroupB2->getByIndex(0), uno::UNO_QUERY);
1440 uno::Reference<text::XText> xTextB2(xGroupB2a->getByIndex(0), uno::UNO_QUERY);
1441 CPPUNIT_ASSERT_EQUAL(OUString("B2"), xTextB2->getString());
1443 uno::Reference<drawing::XShape> xGroupC3(xGroupB2->getByIndex(1), uno::UNO_QUERY);
1444 uno::Reference<text::XText> xTextC3(
1445 getChildShape(getChildShape(getChildShape(xGroupC3, 0), 0), 0), uno::UNO_QUERY);
1446 CPPUNIT_ASSERT_EQUAL(OUString("C3"), xTextC3->getString());
1448 xDocShRef->DoClose();
1451 void SdImportTestSmartArt::testDataFollow()
1453 // checks if data nodes are followed correctly
1454 // different variables are set for two presentation points with the same name
1455 // they should be layouted differently - one horizontally and one vertically
1457 sd::DrawDocShellRef xDocShRef = loadURL(
1458 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-data-follow.pptx"), PPTX);
1460 uno::Reference<drawing::XShapes> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1462 uno::Reference<drawing::XShapes> xGroupLeft(xGroup->getByIndex(1), uno::UNO_QUERY);
1463 uno::Reference<drawing::XShape> xGroupB(xGroupLeft->getByIndex(1), uno::UNO_QUERY);
1464 uno::Reference<drawing::XShape> xShapeB1
1465 = getChildShape(getChildShape(getChildShape(xGroupB, 1), 0), 0);
1466 uno::Reference<text::XText> xTextB1(xShapeB1, uno::UNO_QUERY);
1467 CPPUNIT_ASSERT_EQUAL(OUString("B1"), xTextB1->getString());
1468 uno::Reference<drawing::XShape> xShapeB2
1469 = getChildShape(getChildShape(getChildShape(xGroupB, 3), 0), 0);
1470 uno::Reference<text::XText> xTextB2(xShapeB2, uno::UNO_QUERY);
1471 CPPUNIT_ASSERT_EQUAL(OUString("B2"), xTextB2->getString());
1473 CPPUNIT_ASSERT_EQUAL(xShapeB1->getPosition().Y, xShapeB2->getPosition().Y);
1474 CPPUNIT_ASSERT_GREATEREQUAL(xShapeB1->getPosition().X + xShapeB1->getSize().Width,
1475 xShapeB2->getPosition().X);
1477 uno::Reference<drawing::XShapes> xGroupRight(xGroup->getByIndex(2), uno::UNO_QUERY);
1478 uno::Reference<drawing::XShape> xGroupC(xGroupRight->getByIndex(1), uno::UNO_QUERY);
1479 uno::Reference<drawing::XShape> xShapeC1
1480 = getChildShape(getChildShape(getChildShape(xGroupC, 3), 0), 0);
1481 uno::Reference<text::XText> xTextC1(xShapeC1, uno::UNO_QUERY);
1482 CPPUNIT_ASSERT_EQUAL(OUString("C1"), xTextC1->getString());
1483 uno::Reference<drawing::XShape> xShapeC2
1484 = getChildShape(getChildShape(getChildShape(xGroupC, 5), 0), 0);
1485 uno::Reference<text::XText> xTextC2(xShapeC2, uno::UNO_QUERY);
1486 CPPUNIT_ASSERT_EQUAL(OUString("C2"), xTextC2->getString());
1488 CPPUNIT_ASSERT_EQUAL(xShapeC1->getPosition().X, xShapeC2->getPosition().X);
1489 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC1->getPosition().Y + xShapeC1->getSize().Height,
1490 xShapeC2->getPosition().Y);
1492 xDocShRef->DoClose();
1495 void SdImportTestSmartArt::testOrgChart2()
1497 sd::DrawDocShellRef xDocShRef = loadURL(
1498 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-org-chart2.pptx"), PPTX);
1499 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1501 uno::Reference<drawing::XShape> xShapeC1 = findChildShapeByText(xGroup, "C1");
1502 uno::Reference<drawing::XShape> xShapeC2 = findChildShapeByText(xGroup, "C2");
1503 uno::Reference<drawing::XShape> xShapeC3 = findChildShapeByText(xGroup, "C3");
1504 uno::Reference<drawing::XShape> xShapeC4 = findChildShapeByText(xGroup, "C4");
1505 uno::Reference<drawing::XShape> xShapeD1 = findChildShapeByText(xGroup, "D1");
1506 uno::Reference<drawing::XShape> xShapeD2 = findChildShapeByText(xGroup, "D2");
1508 CPPUNIT_ASSERT(xShapeC1.is());
1509 CPPUNIT_ASSERT(xShapeC2.is());
1510 CPPUNIT_ASSERT(xShapeC3.is());
1511 CPPUNIT_ASSERT(xShapeC4.is());
1512 CPPUNIT_ASSERT(xShapeD1.is());
1513 CPPUNIT_ASSERT(xShapeD2.is());
1515 CPPUNIT_ASSERT_EQUAL(xShapeC1->getPosition().Y, xShapeC2->getPosition().Y);
1516 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC1->getPosition().X + xShapeC1->getSize().Width,
1517 xShapeC2->getPosition().X);
1519 CPPUNIT_ASSERT_EQUAL(xShapeC3->getPosition().X, xShapeC4->getPosition().X);
1520 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC3->getPosition().Y + xShapeC3->getSize().Height,
1521 xShapeC4->getPosition().Y);
1523 CPPUNIT_ASSERT_EQUAL(xShapeD1->getPosition().X, xShapeD2->getPosition().X);
1524 CPPUNIT_ASSERT_GREATEREQUAL(xShapeD1->getPosition().Y + xShapeD1->getSize().Height,
1525 xShapeD2->getPosition().Y);
1527 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC2->getPosition().X, xShapeD1->getPosition().X);
1528 CPPUNIT_ASSERT_GREATEREQUAL(xShapeC2->getPosition().Y + xShapeC2->getSize().Height,
1529 xShapeD1->getPosition().Y);
1531 CPPUNIT_ASSERT_GREATEREQUAL(xShapeD1->getPosition().X + xShapeD1->getSize().Width,
1532 xShapeC4->getPosition().X);
1534 xDocShRef->DoClose();
1537 void SdImportTestSmartArt::testTdf131553()
1539 sd::DrawDocShellRef xDocShRef
1540 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf131553.pptx"), PPTX);
1541 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1543 const SdrPage* pPage = GetPage(1, xDocShRef);
1544 const SdrObjGroup* pObjGroup = dynamic_cast<SdrObjGroup*>(pPage->GetObj(0));
1545 CPPUNIT_ASSERT(pObjGroup);
1546 const SdrObject* pObj = pObjGroup->GetSubList()->GetObj(1);
1547 CPPUNIT_ASSERT_MESSAGE("no object", pObj != nullptr);
1548 CPPUNIT_ASSERT_EQUAL(OBJ_OLE2, pObj->GetObjIdentifier());
1550 xDocShRef->DoClose();
1553 void SdImportTestSmartArt::testFillColorList()
1555 sd::DrawDocShellRef xDocShRef
1556 = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/fill-color-list.pptx"), PPTX);
1557 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1558 uno::Reference<drawing::XShape> xShape = getChildShape(getChildShape(xGroup, 1), 0);
1559 uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY_THROW);
1560 sal_Int32 nFillColor = 0;
1561 xPropertySet->getPropertyValue("FillColor") >>= nFillColor;
1562 // Without the accompanying fix in place, this test would have failed with:
1563 // - Expected: 12603469 (0xc0504d)
1564 // - Actual : 16225862 (0xf79646)
1565 // i.e. the background of the "A" shape was orange-ish, rather than red-ish.
1566 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0xC0504D), nFillColor);
1568 // Without the accompanying fix in place, this test would have failed with:
1569 // - Expected: 2239
1570 // - Actual : 5199
1571 // i.e. the "A" shape's height/width aspect ratio was not 0.4 but rather close to 1.0, even if
1572 // ppt/diagrams/layout1.xml's <dgm:constr type="h" refType="w" op="lte" fact="0.4"/> requested
1573 // 0.4.
1574 awt::Size aActualSize = xShape->getSize();
1575 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2239), aActualSize.Height);
1577 // Without the accompanying fix in place, this test would have failed with:
1578 // - Expected greater than: 1738 (2766)
1579 // - Actual : 1738
1580 // i.e. the columns were not centered vertically.
1581 sal_Int32 nGroupTop = xGroup->getPosition().Y;
1582 sal_Int32 nShapeTop = xShape->getPosition().Y;
1583 CPPUNIT_ASSERT_GREATER(nGroupTop, nShapeTop);
1585 xDocShRef->DoClose();
1588 void SdImportTestSmartArt::testTdf134221()
1590 sd::DrawDocShellRef xDocShRef = loadURL(
1591 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-tdf134221.pptx"), PPTX);
1592 xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
1593 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1594 uno::Reference<drawing::XShape> xShapeB = findChildShapeByText(xGroup, "B");
1595 CPPUNIT_ASSERT(xShapeB.is());
1596 uno::Reference<beans::XPropertySet> xTxtProps(xShapeB, uno::UNO_QUERY_THROW);
1598 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(736),
1599 xTxtProps->getPropertyValue("TextUpperDistance").get<sal_Int32>());
1601 xDocShRef->DoClose();
1604 void SdImportTestSmartArt::testLinearRule()
1606 sd::DrawDocShellRef xDocShRef = loadURL(
1607 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-linear-rule.pptx"), PPTX);
1609 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1610 // Last child, then first child inside that.
1611 // It is first as backgroundArrow is last, but chOrder="t" is set to reverse the order.
1612 uno::Reference<drawing::XShape> xShape = getChildShape(getChildShape(xGroup, 1), 0);
1614 // Without the accompanying fix in place, this test would have failed with:
1615 // - Expected greater than: 17500 (19867)
1616 // - Actual : 4966
1617 // i.e. the width of the background arrow was too small.
1618 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(17500), xShape->getSize().Width);
1620 // Without the accompanying fix in place, this test would have failed with:
1621 // - Expected: 3160
1622 // - Actual : 8770
1623 // i.e. there was unexpected spacing on the left of the arrow.
1624 // Then the imported version of the test document failed with:
1625 // - Expected: 3160
1626 // - Actual : 19828
1627 // i.e. the spacing on the left of the arrow was so large that the shape was mostly outside the
1628 // slide.
1629 sal_Int32 nGroupLeft = xGroup->getPosition().X;
1630 sal_Int32 nArrowLeft = xShape->getPosition().X;
1631 CPPUNIT_ASSERT_EQUAL(nGroupLeft, nArrowLeft);
1633 // Without the accompanying fix in place, this test would have failed with:
1634 // - Expected less or equal than: 10092
1635 // - Actual : 20183
1636 // i.e. the arrow height was larger than the canvas given to the smartart on slide 1.
1637 CPPUNIT_ASSERT_LESSEQUAL(static_cast<sal_Int32>(10092), xShape->getSize().Height);
1639 xDocShRef->DoClose();
1642 void SdImportTestSmartArt::testLinearRuleVert()
1644 sd::DrawDocShellRef xDocShRef = loadURL(
1645 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-linear-rule-vert.pptx"), PPTX);
1647 uno::Reference<drawing::XShape> xGroup(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1648 // Get the P1 shape.
1649 uno::Reference<drawing::XShape> xShape = getChildShape(getChildShape(xGroup, 1), 1);
1650 uno::Reference<text::XTextRange> xShapeText(xShape, uno::UNO_QUERY);
1651 CPPUNIT_ASSERT_EQUAL(OUString("P1"), xShapeText->getString());
1653 // Without the accompanying fix in place, this test would have failed with:
1654 // - Expected: 2020
1655 // - Actual : 10308
1656 // i.e. the first item on the vertical linear layout used ~all space, the other items were not
1657 // visible.
1658 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(2020), xShape->getSize().Height);
1660 xDocShRef->DoClose();
1663 void SdImportTestSmartArt::testAutofitSync()
1665 sd::DrawDocShellRef xDocShRef = loadURL(
1666 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-autofit-sync.pptx"), PPTX);
1668 uno::Reference<drawing::XShape> xDiagram(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1669 uno::Reference<drawing::XShape> xMiddle = getChildShape(xDiagram, 2);
1670 uno::Reference<beans::XPropertySet> xFirstInner(getChildShape(getChildShape(xMiddle, 0), 0),
1671 uno::UNO_QUERY);
1672 sal_Int16 nFirstScale = 0;
1673 CPPUNIT_ASSERT(xFirstInner->getPropertyValue("TextFitToSizeScale") >>= nFirstScale);
1674 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int16>(0), nFirstScale);
1675 uno::Reference<beans::XPropertySet> xSecondInner(getChildShape(getChildShape(xMiddle, 2), 0),
1676 uno::UNO_QUERY);
1677 sal_Int16 nSecondScale = 0;
1678 CPPUNIT_ASSERT(xSecondInner->getPropertyValue("TextFitToSizeScale") >>= nSecondScale);
1679 CPPUNIT_ASSERT_GREATER(static_cast<sal_Int16>(0), nSecondScale);
1681 // Without the accompanying fix in place, this test would have failed with:
1682 // - Expected: 56
1683 // - Actual : 100
1684 // i.e. the left shape had no scale-down and the right shape was scaled down, even if it was
1685 // requested that their scaling matches.
1686 CPPUNIT_ASSERT_EQUAL(nSecondScale, nFirstScale);
1688 // Without the accompanying fix in place, this test would have failed with:
1689 // - Expected: 0 (drawing::TextFitToSizeType_NONE)
1690 // - Actual : 3 (TextFitToSizeType_AUTOFIT)
1691 // i.e. the 3rd shape had font size as direct formatting, but its automatic text scale was not
1692 // disabled.
1693 uno::Reference<beans::XPropertySet> xThirdInner(getChildShape(getChildShape(xMiddle, 4), 0),
1694 uno::UNO_QUERY);
1695 drawing::TextFitToSizeType eType{};
1696 CPPUNIT_ASSERT(xThirdInner->getPropertyValue("TextFitToSize") >>= eType);
1697 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, eType);
1699 xDocShRef->DoClose();
1702 void SdImportTestSmartArt::testSnakeRows()
1704 // Load a smartart which contains a snake algorithm.
1705 // The expected layout of the 6 children is a 3x2 grid.
1706 sd::DrawDocShellRef xDocShRef = loadURL(
1707 m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/smartart-snake-rows.pptx"), PPTX);
1709 uno::Reference<drawing::XShapes> xDiagram(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1710 // Collect position of the background and the real child shapes. First row and background has
1711 // the same top position, unless some unexpected spacing happens, since this is a
1712 // "left-to-right, then top-to-bottom" snake direction.
1713 std::set<sal_Int32> aYPositions;
1714 for (sal_Int32 nChild = 0; nChild < xDiagram->getCount(); ++nChild)
1716 uno::Reference<drawing::XShape> xChild(xDiagram->getByIndex(nChild), uno::UNO_QUERY);
1717 aYPositions.insert(xChild->getPosition().Y);
1720 // Without the accompanying fix in place, this test would have failed with:
1721 // - Expected: 2
1722 // - Actual : 3
1723 // i.e. an unwanted row appeared.
1724 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aYPositions.size());
1726 xDocShRef->DoClose();
1729 void SdImportTestSmartArt::testCompositeInferRight()
1731 // Load a smartart which contains a composite algorithm.
1732 // One contraint says that the left of the text should be the right of the image.
1733 sd::DrawDocShellRef xDocShRef = loadURL(
1734 m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/smartart-composite-infer-right.pptx"),
1735 PPTX);
1737 uno::Reference<drawing::XShape> xDiagram(getShapeFromPage(0, 0, xDocShRef), uno::UNO_QUERY);
1738 uno::Reference<drawing::XShape> xMiddle = getChildShape(xDiagram, 1);
1739 uno::Reference<drawing::XShape> xImage = getChildShape(xMiddle, 1);
1740 uno::Reference<drawing::XShape> xText = getChildShape(xMiddle, 2);
1741 sal_Int32 nRightOfImage = xImage->getPosition().X + xImage->getSize().Width;
1742 sal_Int32 nLeftOfText = xText->getPosition().X;
1744 // Without the accompanying fix in place, this test would have failed with:
1745 // - Expected greater than: 7925
1746 // - Actual : 2430
1747 // i.e. the text was overlapping with the image.
1748 CPPUNIT_ASSERT_GREATER(nRightOfImage, nLeftOfText);
1750 xDocShRef->DoClose();
1753 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTestSmartArt);
1755 CPPUNIT_PLUGIN_IMPLEMENT();
1757 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */