Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sd / qa / unit / export-tests.cxx
blob92971d4b4221d8ac7a6a662420b2e90758948328
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 <sal/config.h>
12 #include <officecfg/Office/Common.hxx>
13 #include "sdmodeltestbase.hxx"
14 #include <sdpage.hxx>
16 #include <comphelper/sequenceashashmap.hxx>
17 #include <editeng/editobj.hxx>
18 #include <editeng/outlobj.hxx>
19 #include <editeng/colritem.hxx>
20 #include <editeng/eeitem.hxx>
22 #include <svx/svdotext.hxx>
23 #include <svx/svdograf.hxx>
24 #include <svx/svdomedia.hxx>
25 #include <rtl/ustring.hxx>
27 #include <com/sun/star/drawing/BitmapMode.hpp>
28 #include <com/sun/star/drawing/FillStyle.hpp>
29 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
30 #include <com/sun/star/drawing/XDrawPage.hpp>
31 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
32 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/awt/XBitmap.hpp>
35 #include <com/sun/star/graphic/XGraphic.hpp>
36 #include <com/sun/star/graphic/GraphicType.hpp>
37 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
38 #include <com/sun/star/table/BorderLine2.hpp>
39 #include <com/sun/star/text/WritingMode2.hpp>
40 #include <com/sun/star/text/XTextColumns.hpp>
42 #include <svx/svdotable.hxx>
43 #include <vcl/filter/PDFiumLibrary.hxx>
45 using namespace css;
46 using namespace css::animations;
48 class SdExportTest : public SdModelTestBase
50 public:
51 SdExportTest()
52 : SdModelTestBase("/sd/qa/unit/data/")
56 protected:
57 uno::Reference<awt::XBitmap> getBitmapFromTable(OUString const& rName);
60 uno::Reference<awt::XBitmap> SdExportTest::getBitmapFromTable(OUString const& rName)
62 uno::Reference<awt::XBitmap> xBitmap;
64 uno::Reference<css::lang::XMultiServiceFactory> xFactory(mxComponent, uno::UNO_QUERY);
66 try
68 uno::Reference<container::XNameAccess> xBitmapTable(
69 xFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY);
70 uno::Any rValue = xBitmapTable->getByName(rName);
71 if (rValue.has<uno::Reference<awt::XBitmap>>())
73 return rValue.get<uno::Reference<awt::XBitmap>>();
76 catch (const uno::Exception& /*rEx*/)
80 return xBitmap;
83 CPPUNIT_TEST_FIXTURE(SdExportTest, testBackgroundImage)
85 // Initial bug: N821567
87 // Check if Slide background image is imported from PPTX and exported to PPTX, PPT and ODP correctly
89 OUString bgImageName;
90 createSdImpressDoc("pptx/n821567.pptx");
92 // Check that imported background image from PPTX exists
94 uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW);
95 CPPUNIT_ASSERT_EQUAL_MESSAGE("not exactly one page", static_cast<sal_Int32>(1),
96 xDoc->getDrawPages()->getCount());
97 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
99 uno::Reference<beans::XPropertySet> xPropertySet(xPage, uno::UNO_QUERY);
100 uno::Any aAny = xPropertySet->getPropertyValue("Background");
101 if (aAny.has<uno::Reference<beans::XPropertySet>>())
103 uno::Reference<beans::XPropertySet> xBackgroundPropSet;
104 aAny >>= xBackgroundPropSet;
105 aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName");
106 aAny >>= bgImageName;
108 CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not imported from PPTX correctly",
109 OUString("msFillBitmap 1"), bgImageName);
111 uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(bgImageName);
112 CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when imported from PPTX",
113 xBitmap.is());
116 // Save as PPTX, reload and check again so we make sure exporting to PPTX is working correctly
118 saveAndReload("Impress Office Open XML");
119 uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW);
120 CPPUNIT_ASSERT_EQUAL_MESSAGE("not exactly one page", static_cast<sal_Int32>(1),
121 xDoc->getDrawPages()->getCount());
122 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
124 uno::Reference<beans::XPropertySet> xPropertySet(xPage, uno::UNO_QUERY);
125 uno::Any aAny = xPropertySet->getPropertyValue("Background");
126 if (aAny.hasValue())
128 uno::Reference<beans::XPropertySet> xBackgroundPropSet;
129 aAny >>= xBackgroundPropSet;
130 aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName");
131 aAny >>= bgImageName;
133 CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide Background is not exported from PPTX correctly",
134 OUString("msFillBitmap 1"), bgImageName);
136 uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(bgImageName);
137 CPPUNIT_ASSERT_MESSAGE("Slide Background Bitmap is missing when exported from PPTX",
138 xBitmap.is());
141 // Save as ODP, reload and check again so we make sure exporting and importing to ODP is working correctly
143 saveAndReload("impress8");
144 uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW);
145 CPPUNIT_ASSERT_EQUAL_MESSAGE("not exactly one page", static_cast<sal_Int32>(1),
146 xDoc->getDrawPages()->getCount());
147 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
149 uno::Reference<beans::XPropertySet> xPropertySet(xPage, uno::UNO_QUERY);
150 uno::Any aAny = xPropertySet->getPropertyValue("Background");
151 if (aAny.hasValue())
153 uno::Reference<beans::XPropertySet> xBackgroundPropSet;
154 aAny >>= xBackgroundPropSet;
155 aAny = xBackgroundPropSet->getPropertyValue("FillBitmapName");
156 aAny >>= bgImageName;
158 CPPUNIT_ASSERT_EQUAL_MESSAGE(
159 "Slide Background is not exported or imported from ODP correctly",
160 OUString("msFillBitmap 1"), bgImageName);
162 uno::Reference<awt::XBitmap> xBitmap = getBitmapFromTable(bgImageName);
163 CPPUNIT_ASSERT_MESSAGE(
164 "Slide Background Bitmap is missing when exported or imported from ODP", xBitmap.is());
168 namespace
170 template <typename ItemValue, typename ItemType>
171 void checkFontAttributes(const SdrTextObj* pObj, ItemValue nVal, sal_uInt32 nId)
173 CPPUNIT_ASSERT_MESSAGE("no object", pObj != nullptr);
174 const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject();
175 std::vector<EECharAttrib> rLst;
176 aEdit.GetCharAttribs(0, rLst);
177 for (std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it != rLst.rend(); ++it)
179 const ItemType* pAttrib = dynamic_cast<const ItemType*>((*it).pAttr);
180 if (pAttrib && pAttrib->Which() == nId)
182 CPPUNIT_ASSERT_EQUAL(nVal, static_cast<ItemValue>(pAttrib->GetValue()));
188 CPPUNIT_TEST_FIXTURE(SdExportTest, testTransparentBackground)
190 createSdImpressDoc("odp/transparent_background.odp");
191 saveAndReload("impress8");
193 const SdrPage* pPage = GetPage(1);
195 const SdrTextObj* pObj1 = DynCastSdrTextObj(pPage->GetObj(0));
196 checkFontAttributes<Color, SvxColorItem>(pObj1, COL_TRANSPARENT, EE_CHAR_BKGCOLOR);
198 const SdrTextObj* pObj2 = DynCastSdrTextObj(pPage->GetObj(1));
199 checkFontAttributes<Color, SvxColorItem>(pObj2, COL_YELLOW, EE_CHAR_BKGCOLOR);
202 CPPUNIT_TEST_FIXTURE(SdExportTest, testDecorative)
204 createSdImpressDoc("pptx/tdf141058-1.pptx");
206 auto doTest = [this](OString const test) {
207 ::std::set<OString> const decorative = {
208 "Picture 6",
209 "Rectangle 7",
210 "Group 24",
211 "Connector: Elbow 9",
212 "Connector: Elbow 11",
213 "Connector: Elbow 14",
214 "Connector: Elbow 17",
215 "Straight Arrow Connector 21",
216 "Straight Arrow Connector 22",
217 "Straight Arrow Connector 23",
220 uno::Reference<drawing::XDrawPage> const xPage(getPage(0));
221 CPPUNIT_ASSERT_EQUAL_MESSAGE(test.getStr(), sal_Int32(5), xPage->getCount());
222 auto nDecorative(0);
223 auto nShapes(0);
224 auto nInnerDecorative(0);
225 auto nInnerShapes(0);
226 for (auto i = xPage->getCount(); i != 0; --i)
228 uno::Reference<beans::XPropertySet> xShape(getShape(i - 1, xPage));
229 uno::Reference<container::XNamed> xNamed(xShape, uno::UNO_QUERY);
230 OString const name(OUStringToOString(xNamed->getName(), RTL_TEXTENCODING_UTF8));
231 if (decorative.find(name) != decorative.end())
233 CPPUNIT_ASSERT_MESSAGE(OString(test + name).getStr(),
234 xShape->getPropertyValue("Decorative").get<bool>());
235 ++nDecorative;
237 else
239 CPPUNIT_ASSERT_MESSAGE(OString(test + name).getStr(),
240 !xShape->getPropertyValue("Decorative").get<bool>());
241 ++nShapes;
243 uno::Reference<drawing::XShapes> const xShapes(xShape, uno::UNO_QUERY);
244 if (xShapes.is())
246 for (auto j = xShapes->getCount(); j != 0; --j)
248 uno::Reference<beans::XPropertySet> xInnerShape(xShapes->getByIndex(i - 1),
249 uno::UNO_QUERY);
250 uno::Reference<container::XNamed> xInnerNamed(xInnerShape, uno::UNO_QUERY);
251 OString const innerName(
252 OUStringToOString(xInnerNamed->getName(), RTL_TEXTENCODING_UTF8));
253 if (decorative.find(innerName) != decorative.end())
255 CPPUNIT_ASSERT_MESSAGE(
256 OString(test + innerName).getStr(),
257 xInnerShape->getPropertyValue("Decorative").get<bool>());
258 ++nInnerDecorative;
260 else
262 CPPUNIT_ASSERT_MESSAGE(
263 OString(test + innerName).getStr(),
264 !xInnerShape->getPropertyValue("Decorative").get<bool>());
265 ++nInnerShapes;
270 CPPUNIT_ASSERT_EQUAL_MESSAGE(test.getStr(), static_cast<decltype(nDecorative)>(3),
271 nDecorative);
272 CPPUNIT_ASSERT_EQUAL_MESSAGE(test.getStr(), static_cast<decltype(nShapes)>(2), nShapes);
273 CPPUNIT_ASSERT_EQUAL_MESSAGE(test.getStr(), static_cast<decltype(nInnerDecorative)>(7),
274 nInnerDecorative);
275 CPPUNIT_ASSERT_EQUAL_MESSAGE(test.getStr(), static_cast<decltype(nInnerShapes)>(16),
276 nInnerShapes);
279 doTest("initial pptx load: ");
281 saveAndReload("Impress Office Open XML");
282 doTest("reload OOXML: ");
284 saveAndReload("impress8");
285 doTest("reload ODF: ");
288 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf142716)
290 createSdImpressDoc("pptx/tdf142716.pptx");
291 saveAndReload("Impress Office Open XML");
293 const SdrPage* pPage = GetPage(1);
294 const SdrTextObj* pObj = DynCastSdrTextObj(pPage->GetObj(0));
296 OUString sText = pObj->GetOutlinerParaObject()->GetTextObject().GetText(0);
298 // Without fix "yyy" part will be lost.
299 CPPUNIT_ASSERT_EQUAL(OUString("xxx and yyy"), sText);
302 CPPUNIT_TEST_FIXTURE(SdExportTest, testMediaEmbedding)
304 createSdImpressDoc("media_embedding.odp");
306 const SdrPage* pPage = GetPage(1);
308 // Second object is a sound
309 SdrMediaObj* pMediaObj = dynamic_cast<SdrMediaObj*>(pPage->GetObj(3));
310 CPPUNIT_ASSERT_MESSAGE("missing media object", pMediaObj != nullptr);
311 CPPUNIT_ASSERT_EQUAL(OUString("vnd.sun.star.Package:Media/button-1.wav"),
312 pMediaObj->getMediaProperties().getURL());
313 CPPUNIT_ASSERT_EQUAL(OUString("application/vnd.sun.star.media"),
314 pMediaObj->getMediaProperties().getMimeType());
317 CPPUNIT_TEST_FIXTURE(SdExportTest, testFillBitmapUnused)
319 createSdImpressDoc("odp/fillbitmap2.odp");
320 save("impress8");
322 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
323 // shapes
324 assertXPath(
325 pXmlDoc,
326 "//style:style[@style:family='graphic']/style:graphic-properties[@draw:fill='bitmap']", 1);
327 assertXPath(
328 pXmlDoc,
329 "//style:style[@style:family='graphic']/style:graphic-properties[@draw:fill='bitmap']",
330 "fill-image-name", "nav_5f_up");
331 assertXPath(
332 pXmlDoc,
333 "//style:style[@style:family='graphic']/style:graphic-properties[@draw:fill='solid']", 1);
334 assertXPath(pXmlDoc,
335 "//style:style[@style:family='graphic']/"
336 "style:graphic-properties[@draw:fill='solid' and @draw:fill-image-name]",
338 assertXPath(
339 pXmlDoc,
340 "//style:style[@style:family='graphic']/style:graphic-properties[@draw:fill='solid']",
341 "fill-color", "#808080");
343 xmlDocUniquePtr pStyles = parseExport("styles.xml");
344 // master slide presentation style
345 assertXPath(pStyles,
346 "/office:document-styles/office:styles/style:style[@style:family='presentation' "
347 "and @style:name='Default-background']/style:graphic-properties",
348 "fill", "bitmap");
349 assertXPath(pStyles,
350 "/office:document-styles/office:styles/style:style[@style:family='presentation' "
351 "and @style:name='Default-background']/style:graphic-properties",
352 "fill-image-name", "nav_5f_up");
353 assertXPath(pStyles,
354 "/office:document-styles/office:styles/style:style[@style:family='presentation' "
355 "and @style:name='Default_20_1-background']/style:graphic-properties",
356 "fill", "solid");
357 assertXPath(pStyles,
358 "/office:document-styles/office:styles/style:style[@style:family='presentation' "
359 "and @style:name='Default_20_1-background']/style:graphic-properties",
360 "fill-color", "#808080");
361 assertXPath(
362 pStyles,
363 "/office:document-styles/office:styles/style:style[@style:family='presentation' and "
364 "@style:name='Default_20_1-background']/style:graphic-properties[@draw:fill-image-name]",
366 // master slide drawing-page style
367 assertXPath(pStyles,
368 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp1']/"
369 "style:drawing-page-properties",
370 "fill", "bitmap");
371 assertXPath(pStyles,
372 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp1']/"
373 "style:drawing-page-properties",
374 "fill-image-name", "nav_5f_up");
375 assertXPath(pStyles,
376 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/"
377 "style:drawing-page-properties",
378 "fill", "solid");
379 assertXPath(pStyles,
380 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/"
381 "style:drawing-page-properties",
382 "fill-color", "#808080");
383 assertXPath(pStyles,
384 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/"
385 "style:drawing-page-properties[@draw:fill-image-name]",
388 // the named items
389 assertXPath(pStyles, "/office:document-styles/office:styles/draw:fill-image", 1);
390 assertXPath(pStyles, "/office:document-styles/office:styles/draw:fill-image", "name",
391 "nav_5f_up");
394 CPPUNIT_TEST_FIXTURE(SdExportTest, testFdo84043)
396 createSdImpressDoc("fdo84043.odp");
397 saveAndReload("impress8");
399 // the bug was duplicate attributes, causing crash in a build with asserts
400 const SdrPage* pPage = GetPage(1);
401 SdrObject const* pShape = pPage->GetObj(1);
402 CPPUNIT_ASSERT_MESSAGE("no shape", pShape != nullptr);
405 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf97630)
407 createSdImpressDoc("fit-to-size.fodp");
409 uno::Reference<drawing::XDrawPage> xDP(getPage(0));
411 drawing::TextFitToSizeType tmp;
412 // text shapes
413 uno::Reference<beans::XPropertySet> xShape0(xDP->getByIndex(0), uno::UNO_QUERY);
414 xShape0->getPropertyValue("TextFitToSize") >>= tmp;
415 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
416 uno::Reference<beans::XPropertySet> xShape1(xDP->getByIndex(1), uno::UNO_QUERY);
417 xShape1->getPropertyValue("TextFitToSize") >>= tmp;
418 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
419 uno::Reference<beans::XPropertySet> xShape2(xDP->getByIndex(2), uno::UNO_QUERY);
420 xShape2->getPropertyValue("TextFitToSize") >>= tmp;
421 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_ALLLINES, tmp);
422 uno::Reference<beans::XPropertySet> xShape3(xDP->getByIndex(3), uno::UNO_QUERY);
423 xShape3->getPropertyValue("TextFitToSize") >>= tmp;
424 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_AUTOFIT, tmp);
426 // fontworks
427 uno::Reference<beans::XPropertySet> xShape4(xDP->getByIndex(4), uno::UNO_QUERY);
428 xShape4->getPropertyValue("TextFitToSize") >>= tmp;
429 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
430 uno::Reference<beans::XPropertySet> xShape5(xDP->getByIndex(5), uno::UNO_QUERY);
431 xShape5->getPropertyValue("TextFitToSize") >>= tmp;
432 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_ALLLINES, tmp);
435 saveAndReload("impress8");
438 uno::Reference<drawing::XDrawPage> xDP(getPage(0));
440 drawing::TextFitToSizeType tmp;
441 // text shapes
442 uno::Reference<beans::XPropertySet> xShape0(xDP->getByIndex(0), uno::UNO_QUERY);
443 xShape0->getPropertyValue("TextFitToSize") >>= tmp;
444 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
445 uno::Reference<beans::XPropertySet> xShape1(xDP->getByIndex(1), uno::UNO_QUERY);
446 xShape1->getPropertyValue("TextFitToSize") >>= tmp;
447 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
448 uno::Reference<beans::XPropertySet> xShape2(xDP->getByIndex(2), uno::UNO_QUERY);
449 xShape2->getPropertyValue("TextFitToSize") >>= tmp;
450 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
451 uno::Reference<beans::XPropertySet> xShape3(xDP->getByIndex(3), uno::UNO_QUERY);
452 xShape3->getPropertyValue("TextFitToSize") >>= tmp;
453 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_AUTOFIT, tmp);
455 // fontworks
456 uno::Reference<beans::XPropertySet> xShape4(xDP->getByIndex(4), uno::UNO_QUERY);
457 xShape4->getPropertyValue("TextFitToSize") >>= tmp;
458 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
459 uno::Reference<beans::XPropertySet> xShape5(xDP->getByIndex(5), uno::UNO_QUERY);
460 xShape5->getPropertyValue("TextFitToSize") >>= tmp;
461 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
464 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
465 // text shapes
466 assertXPath(pXmlDoc,
467 "//style:style[@style:family='presentation']/"
468 "style:graphic-properties[@draw:fit-to-size='false' and "
469 "@style:shrink-to-fit='false']",
471 assertXPath(pXmlDoc,
472 "//style:style[@style:family='presentation']/"
473 "style:graphic-properties[@draw:fit-to-size='true' and "
474 "@style:shrink-to-fit='false']",
476 assertXPath(pXmlDoc,
477 "//style:style[@style:family='presentation']/"
478 "style:graphic-properties[@draw:fit-to-size='false' and "
479 "@style:shrink-to-fit='true']",
481 // fontworks
482 assertXPath(pXmlDoc,
483 "//style:style[@style:family='graphic']/"
484 "style:graphic-properties[@draw:fit-to-size='false' and "
485 "@style:shrink-to-fit='false']",
487 assertXPath(pXmlDoc,
488 "//style:style[@style:family='graphic']/"
489 "style:graphic-properties[@draw:fit-to-size='true' and "
490 "@style:shrink-to-fit='false']",
494 CPPUNIT_TEST_FIXTURE(SdExportTest, testImpressPasswordExport)
496 std::vector<OUString> vFormat{ "impress8", "Impress Office Open XML" };
498 for (size_t i = 0; i < vFormat.size(); i++)
500 createSdImpressDoc();
502 saveAndReload(vFormat[i], /*pPassword*/ "test");
506 CPPUNIT_TEST_FIXTURE(SdExportTest, testDrawPasswordExport)
508 createSdDrawDoc();
510 saveAndReload("draw8", /*pPassword*/ "test");
513 CPPUNIT_TEST_FIXTURE(SdExportTest, testSwappedOutImageExport)
515 // Problem was with the swapped out images, which were not swapped in during export.
517 std::vector<OUString> vFormat{ "impress8", "Impress Office Open XML", "MS PowerPoint 97" };
519 for (size_t i = 0; i < vFormat.size(); i++)
521 // Load the original file with one image
522 createSdImpressDoc("odp/document_with_two_images.odp");
523 const OString sFailedMessage = "Failed on filter: " + vFormat[i].toUtf8();
525 // Export the document and import again for a check
526 saveAndReload(vFormat[i]);
528 // Check whether graphic exported well after it was swapped out
529 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
530 uno::UNO_QUERY_THROW);
531 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2),
532 xDrawPagesSupplier->getDrawPages()->getCount());
533 uno::Reference<drawing::XDrawPage> xDrawPage(
534 xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
536 uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY);
537 uno::Reference<beans::XPropertySet> XPropSet(xImage, uno::UNO_QUERY_THROW);
539 // Check Graphic, Size
541 uno::Reference<graphic::XGraphic> xGraphic;
542 XPropSet->getPropertyValue("Graphic") >>= xGraphic;
543 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
544 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(),
545 xGraphic->getType() != graphic::GraphicType::EMPTY);
546 uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
547 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
548 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610),
549 xBitmap->getSize().Width);
550 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381),
551 xBitmap->getSize().Height);
554 // Second Image
555 xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW);
556 xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY);
557 XPropSet.set(xImage, uno::UNO_QUERY_THROW);
559 // Check Graphic, Size
561 uno::Reference<graphic::XGraphic> xGraphic;
562 XPropSet->getPropertyValue("Graphic") >>= xGraphic;
563 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
564 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(),
565 xGraphic->getType() != graphic::GraphicType::EMPTY);
566 uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
567 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
568 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900),
569 xBitmap->getSize().Width);
570 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600),
571 xBitmap->getSize().Height);
576 CPPUNIT_TEST_FIXTURE(SdExportTest, testOOoXMLAnimations)
578 createSdImpressDoc("sxi/ooo41061-1.sxi");
580 // FIXME: Error: unexpected attribute "presentation:preset-property"
581 skipValidation();
583 save("impress8");
585 // the problem was that legacy OOoXML animations were lost if store
586 // immediately follows load because they were "converted" async by a timer
587 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
588 assertXPath(pXmlDoc, "//anim:par[@presentation:node-type='timing-root']", 26);
589 // currently getting 52 of these without the fix (depends on timing)
590 assertXPath(pXmlDoc, "//anim:par", 223);
593 CPPUNIT_TEST_FIXTURE(SdExportTest, testBnc480256)
595 createSdImpressDoc("pptx/bnc480256.pptx");
596 // In the document, there are two tables with table background properties.
597 // Make sure colors are set properly for individual cells.
599 // TODO: If you are working on improving table background support, expect
600 // this unit test to fail. In that case, feel free to change the numbers.
602 const SdrPage* pPage = GetPage(1);
604 sdr::table::SdrTableObj* pTableObj;
605 uno::Reference<table::XCellRange> xTable;
606 uno::Reference<beans::XPropertySet> xCell;
607 Color nColor;
608 table::BorderLine2 aBorderLine;
610 pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
611 CPPUNIT_ASSERT(pTableObj);
612 xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
614 xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
615 xCell->getPropertyValue("FillColor") >>= nColor;
616 CPPUNIT_ASSERT_EQUAL(Color(0x9bc3ee), nColor);
617 xCell->getPropertyValue("LeftBorder") >>= aBorderLine;
618 CPPUNIT_ASSERT_EQUAL(Color(0x5597d3), Color(ColorTransparency, aBorderLine.Color));
620 xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
621 xCell->getPropertyValue("FillColor") >>= nColor;
622 CPPUNIT_ASSERT_EQUAL(Color(0xc6ddff), nColor);
623 xCell->getPropertyValue("TopBorder") >>= aBorderLine;
624 CPPUNIT_ASSERT_EQUAL(Color(0x5597d3), Color(ColorTransparency, aBorderLine.Color));
626 pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(1));
627 CPPUNIT_ASSERT(pTableObj);
628 xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
630 xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
631 xCell->getPropertyValue("FillColor") >>= nColor;
632 CPPUNIT_ASSERT_EQUAL(Color(0x6bace6), nColor);
633 xCell->getPropertyValue("LeftBorder") >>= aBorderLine;
634 CPPUNIT_ASSERT_EQUAL(Color(0xbecfe6), Color(ColorTransparency, aBorderLine.Color));
636 xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
637 xCell->getPropertyValue("FillColor") >>= nColor;
638 CPPUNIT_ASSERT_EQUAL(Color(0x4697e0), nColor);
640 // This border should be invisible.
641 xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
642 xCell->getPropertyValue("BottomBorder") >>= aBorderLine;
643 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), sal_Int32(aBorderLine.LineWidth));
646 CPPUNIT_TEST_FIXTURE(SdExportTest, testUnknownAttributes)
648 createSdImpressDoc("unknown-attribute.fodp");
650 // FIXME: Error: unexpected attribute "foo:non-existent-att"
651 skipValidation();
653 save("impress8");
655 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
656 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/"
657 "style:style[@style:name='gr1']/"
658 "style:graphic-properties[@foo:non-existent-att='bar']");
659 // TODO: if the namespace is *known*, the attribute is not preserved, but that seems to be a pre-existing problem, or maybe it's even intentional?
660 // assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/style:graphic-properties[@svg:non-existent-att='blah']");
661 // this was on style:graphic-properties on the import, but the export moves it to root node which is OK
662 assertXPathNSDef(pXmlDoc, "/office:document-content", u"foo", u"http://example.com/");
665 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf80020)
667 createSdImpressDoc("odp/tdf80020.odp");
669 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
670 uno::UNO_QUERY);
671 uno::Reference<container::XNameAccess> xStyleFamilies
672 = xStyleFamiliesSupplier->getStyleFamilies();
673 uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("graphics"),
674 uno::UNO_QUERY);
675 uno::Reference<style::XStyle> xStyle(xStyleFamily->getByName("Test Style"), uno::UNO_QUERY);
676 CPPUNIT_ASSERT_EQUAL(OUString("text"), xStyle->getParentStyle());
677 saveAndReload("impress8");
679 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
680 uno::UNO_QUERY);
681 uno::Reference<container::XNameAccess> xStyleFamilies
682 = xStyleFamiliesSupplier->getStyleFamilies();
683 uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("graphics"),
684 uno::UNO_QUERY);
685 uno::Reference<style::XStyle> xStyle(xStyleFamily->getByName("Test Style"), uno::UNO_QUERY);
686 CPPUNIT_ASSERT_EQUAL(OUString("text"), xStyle->getParentStyle());
689 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf128985)
691 createSdImpressDoc("odp/tdf128985.odp");
693 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
694 uno::UNO_QUERY);
695 uno::Reference<container::XNameAccess> xStyleFamilies
696 = xStyleFamiliesSupplier->getStyleFamilies();
697 uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("LushGreen"),
698 uno::UNO_QUERY);
699 uno::Reference<style::XStyle> xStyle(xStyleFamily->getByName("outline1"), uno::UNO_QUERY);
700 uno::Reference<beans::XPropertySet> xPropSet(xStyle, uno::UNO_QUERY);
702 sal_Int16 nWritingMode = 0;
703 xPropSet->getPropertyValue("WritingMode") >>= nWritingMode;
704 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nWritingMode);
706 xPropSet->setPropertyValue("WritingMode", uno::Any(text::WritingMode2::LR_TB));
708 saveAndReload("impress8");
710 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
711 uno::UNO_QUERY);
712 uno::Reference<container::XNameAccess> xStyleFamilies
713 = xStyleFamiliesSupplier->getStyleFamilies();
714 uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("LushGreen"),
715 uno::UNO_QUERY);
716 uno::Reference<style::XStyle> xStyle(xStyleFamily->getByName("outline1"), uno::UNO_QUERY);
717 uno::Reference<beans::XPropertySet> xPropSet(xStyle, uno::UNO_QUERY);
719 sal_Int16 nWritingMode = 0;
720 xPropSet->getPropertyValue("WritingMode") >>= nWritingMode;
722 // Without the fix in place, this test would have failed with
723 // - Expected: 0
724 // - Actual : 1
725 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nWritingMode);
728 CPPUNIT_TEST_FIXTURE(SdExportTest, testLinkedGraphicRT)
730 // FIXME: PPTX fails
731 std::vector<OUString> vFormat{ "impress8", "MS PowerPoint 97" };
732 for (size_t i = 0; i < vFormat.size(); i++)
734 // Load the original file with one image
735 createSdImpressDoc("odp/document_with_linked_graphic.odp");
737 // Check if the graphic has been imported correctly (before doing the export/import run)
739 const OString sFailedImportMessage = "Failed to correctly import the document";
740 SdXImpressDocument* pXImpressDocument
741 = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
742 CPPUNIT_ASSERT(pXImpressDocument);
743 SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
744 CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pDoc != nullptr);
745 const SdrPage* pPage = pDoc->GetPage(1);
746 CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pPage != nullptr);
747 SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
748 CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject != nullptr);
749 CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject->IsLinkedGraphic());
751 const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
752 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), int(GraphicType::Bitmap),
753 int(rGraphicObj.GetGraphic().GetType()));
754 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), sal_uLong(864900),
755 rGraphicObj.GetGraphic().GetSizeBytes());
758 // Save and reload
759 saveAndReload(vFormat[i]);
761 // Check whether graphic imported well after export
763 const OString sFailedMessage = "Failed on filter: " + vFormat[i].toUtf8();
765 SdXImpressDocument* pXImpressDocument
766 = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
767 CPPUNIT_ASSERT(pXImpressDocument);
768 SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
769 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pDoc != nullptr);
770 const SdrPage* pPage = pDoc->GetPage(1);
771 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pPage != nullptr);
772 SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
773 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pObject != nullptr);
774 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pObject->IsLinkedGraphic());
776 const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
777 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), int(GraphicType::Bitmap),
778 int(rGraphicObj.GetGraphic().GetType()));
779 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_uLong(864900),
780 rGraphicObj.GetGraphic().GetSizeBytes());
785 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf79082)
787 createSdImpressDoc("ppt/tdf79082.ppt");
788 save("impress8");
789 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
791 // P1 should have 6 tab stops defined
792 assertXPathChildren(
793 pXmlDoc, "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops", 6);
794 assertXPath(pXmlDoc,
795 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
796 "style:tab-stop[1]",
797 "position", "0cm");
798 assertXPath(pXmlDoc,
799 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
800 "style:tab-stop[2]",
801 "position", "5.08cm");
802 assertXPath(pXmlDoc,
803 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
804 "style:tab-stop[3]",
805 "position", "10.16cm");
806 assertXPath(pXmlDoc,
807 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
808 "style:tab-stop[4]",
809 "position", "15.24cm");
810 assertXPath(pXmlDoc,
811 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
812 "style:tab-stop[5]",
813 "position", "20.32cm");
814 assertXPath(pXmlDoc,
815 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
816 "style:tab-stop[6]",
817 "position", "25.4cm");
820 CPPUNIT_TEST_FIXTURE(SdExportTest, testImageWithSpecialID)
822 // Check how LO handles when the imported graphic's ID is different from that one
823 // which is generated by LO.
825 std::vector<OUString> vFormat{ "impress8", "Impress Office Open XML", "MS PowerPoint 97" };
826 for (size_t i = 0; i < vFormat.size(); i++)
828 // Load the original file
829 createSdImpressDoc("odp/images_with_special_IDs.odp");
830 const OString sFailedMessage = "Failed on filter: " + vFormat[i].toUtf8();
831 saveAndReload(vFormat[i]);
833 // Check whether graphic was exported well
834 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
835 uno::UNO_QUERY_THROW);
836 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2),
837 xDrawPagesSupplier->getDrawPages()->getCount());
838 uno::Reference<drawing::XDrawPage> xDrawPage(
839 xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
841 uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY);
842 uno::Reference<beans::XPropertySet> XPropSet(xImage, uno::UNO_QUERY_THROW);
844 // Check Graphic, Size
846 uno::Reference<graphic::XGraphic> xGraphic;
847 XPropSet->getPropertyValue("Graphic") >>= xGraphic;
848 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
849 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(),
850 xGraphic->getType() != graphic::GraphicType::EMPTY);
851 uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
852 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
853 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610),
854 xBitmap->getSize().Width);
855 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381),
856 xBitmap->getSize().Height);
859 // Second Image
860 xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW);
861 xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY);
862 XPropSet.set(xImage, uno::UNO_QUERY_THROW);
864 // Check Graphic, Size
866 uno::Reference<graphic::XGraphic> xGraphic;
867 XPropSet->getPropertyValue("Graphic") >>= xGraphic;
868 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
869 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(),
870 xGraphic->getType() != graphic::GraphicType::EMPTY);
871 uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
872 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
873 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900),
874 xBitmap->getSize().Width);
875 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600),
876 xBitmap->getSize().Height);
881 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf62176)
883 createSdImpressDoc("odp/Tdf62176.odp");
884 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
886 //there should be only *one* shape
887 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage->getCount());
889 uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage));
890 //checking Paragraph's Left Margin with expected value
891 sal_Int32 nParaLeftMargin = 0;
892 xShape->getPropertyValue("ParaLeftMargin") >>= nParaLeftMargin;
893 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), nParaLeftMargin);
894 //checking Paragraph's First Line Indent with expected value
895 sal_Int32 nParaFirstLineIndent = 0;
896 xShape->getPropertyValue("ParaFirstLineIndent") >>= nParaFirstLineIndent;
897 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1300), nParaFirstLineIndent);
899 //Checking the *Text* in TextBox
900 uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xShape));
901 CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), xParagraph->getString());
903 //Saving and Reloading the file
904 saveAndReload("impress8");
905 uno::Reference<drawing::XDrawPage> xPage2(getPage(0));
906 //there should be only *one* shape
907 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage2->getCount());
909 uno::Reference<beans::XPropertySet> xShape2(getShape(0, xPage2));
910 //checking Paragraph's Left Margin with expected value
911 sal_Int32 nParaLeftMargin2 = 0;
912 xShape2->getPropertyValue("ParaLeftMargin") >>= nParaLeftMargin2;
913 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), nParaLeftMargin2);
914 //checking Paragraph's First Line Indent with expected value
915 sal_Int32 nParaFirstLineIndent2 = 0;
916 xShape2->getPropertyValue("ParaFirstLineIndent") >>= nParaFirstLineIndent2;
917 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1300), nParaFirstLineIndent2);
919 //Checking the *Text* in TextBox
920 uno::Reference<text::XTextRange> xParagraph2(getParagraphFromShape(0, xShape2));
921 CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), xParagraph2->getString());
924 CPPUNIT_TEST_FIXTURE(SdExportTest, testEmbeddedPdf)
926 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
927 if (!pPdfium)
929 return;
932 createSdImpressDoc("odp/embedded-pdf.odp");
933 saveAndReload("impress8");
934 uno::Reference<drawing::XDrawPage> xPage = getPage(0);
935 uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
936 uno::Reference<graphic::XGraphic> xGraphic;
937 xShape->getPropertyValue("ReplacementGraphic") >>= xGraphic;
938 CPPUNIT_ASSERT(xGraphic.is());
941 CPPUNIT_TEST_FIXTURE(SdExportTest, testEmbeddedText)
943 createSdDrawDoc("objectwithtext.fodg");
944 saveAndReload("draw8");
946 uno::Reference<drawing::XDrawPage> xPage = getPage(0);
947 uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
948 uno::Reference<text::XText> xText(xShape, uno::UNO_QUERY);
949 CPPUNIT_ASSERT(xText.is());
951 uno::Reference<container::XEnumerationAccess> xEA(xShape, uno::UNO_QUERY);
952 CPPUNIT_ASSERT(xEA->hasElements());
953 uno::Reference<container::XEnumeration> xEnum(xEA->createEnumeration());
954 uno::Reference<text::XTextContent> xTC;
955 xEnum->nextElement() >>= xTC;
956 CPPUNIT_ASSERT(xTC.is());
958 uno::Reference<container::XEnumerationAccess> xParaEA(xTC, uno::UNO_QUERY);
959 uno::Reference<container::XEnumeration> xParaEnum(xParaEA->createEnumeration());
960 uno::Reference<beans::XPropertySet> xPortion(xParaEnum->nextElement(), uno::UNO_QUERY);
961 CPPUNIT_ASSERT(xPortion.is());
962 uno::Reference<text::XTextRange> xRange(xPortion, uno::UNO_QUERY);
963 OUString type;
964 xPortion->getPropertyValue("TextPortionType") >>= type;
965 CPPUNIT_ASSERT_EQUAL(OUString("Text"), type);
966 CPPUNIT_ASSERT_EQUAL(OUString("foobar"), xRange->getString()); //tdf#112547
969 CPPUNIT_TEST_FIXTURE(SdExportTest, testTransparenText)
971 createSdDrawDoc("transparent-text.fodg");
972 saveAndReload("draw8");
974 uno::Reference<drawing::XDrawPage> xPage = getPage(0);
975 uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
976 sal_Int16 nCharTransparence = 0;
977 xShape->getPropertyValue("CharTransparence") >>= nCharTransparence;
979 // Without the accompanying fix in place, this test would have failed with:
980 // - Expected: 75
981 // - Actual : 0
982 // i.e. the 75% transparent text was turned into a "not transparent at all" text.
983 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(75), nCharTransparence);
986 CPPUNIT_TEST_FIXTURE(SdExportTest, testDefaultSubscripts)
988 createSdDrawDoc("tdf80194_defaultSubscripts.fodg");
989 saveAndReload("draw8");
991 uno::Reference<drawing::XDrawPage> xPage = getPage(0);
992 uno::Reference<drawing::XShape> xShape(xPage->getByIndex(1), uno::UNO_QUERY);
993 // Default subscripts were too large, enlarging the gap between the next line.
994 // The exact size isn't important. Was 18975, now 16604.
995 CPPUNIT_ASSERT(17000 > xShape->getSize().Height);
998 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf98477)
1000 createSdImpressDoc("pptx/tdf98477grow.pptx");
1001 save("impress8");
1003 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1004 assertXPath(pXmlDoc, "//anim:animateTransform", "by", "0.5,0.5");
1007 CPPUNIT_TEST_FIXTURE(SdExportTest, testAuthorField)
1009 createSdImpressDoc("odp/author_fixed.odp");
1011 saveAndReload("impress8");
1013 uno::Reference<text::XTextField> xField = getTextFieldFromPage(0, 0, 0, 0);
1014 CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is());
1016 uno::Reference<beans::XPropertySet> xPropSet(xField, uno::UNO_QUERY_THROW);
1017 bool bFixed = false;
1018 xPropSet->getPropertyValue("IsFixed") >>= bFixed;
1019 CPPUNIT_ASSERT_MESSAGE("Author field is not fixed", bFixed);
1022 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf50499)
1024 createSdImpressDoc("pptx/tdf50499.pptx");
1026 save("impress8");
1028 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1029 assertXPath(pXmlDoc, "//anim:animate[1]", "from", "(-width/2)");
1030 assertXPath(pXmlDoc, "//anim:animate[1]", "to", "(x)");
1031 assertXPath(pXmlDoc, "//anim:animate[3]", "by", "(height/3+width*0.1)");
1034 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf100926)
1036 createSdImpressDoc("pptx/tdf100926_ODP.pptx");
1038 saveAndReload("impress8");
1040 const SdrPage* pPage = GetPage(1);
1041 CPPUNIT_ASSERT(pPage != nullptr);
1043 sdr::table::SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1044 CPPUNIT_ASSERT(pTableObj != nullptr);
1045 uno::Reference<table::XCellRange> xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
1047 sal_Int32 nRotation = 0;
1048 uno::Reference<beans::XPropertySet> xCell(xTable->getCellByPosition(0, 0),
1049 uno::UNO_QUERY_THROW);
1050 xCell->getPropertyValue("RotateAngle") >>= nRotation;
1051 CPPUNIT_ASSERT_EQUAL(sal_Int32(27000), nRotation);
1053 xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
1054 xCell->getPropertyValue("RotateAngle") >>= nRotation;
1055 CPPUNIT_ASSERT_EQUAL(sal_Int32(9000), nRotation);
1057 xCell.set(xTable->getCellByPosition(2, 0), uno::UNO_QUERY_THROW);
1058 xCell->getPropertyValue("RotateAngle") >>= nRotation;
1059 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRotation);
1062 CPPUNIT_TEST_FIXTURE(SdExportTest, testPageWithTransparentBackground)
1064 createSdImpressDoc("odp/page_transparent_background.odp");
1066 saveAndReload("impress8");
1067 uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW);
1068 CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one page", static_cast<sal_Int32>(1),
1069 xDoc->getDrawPages()->getCount());
1071 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
1073 uno::Reference<beans::XPropertySet> xPropSet(xPage, uno::UNO_QUERY);
1074 uno::Any aAny = xPropSet->getPropertyValue("Background");
1075 CPPUNIT_ASSERT_MESSAGE("Slide background is missing", aAny.hasValue());
1077 uno::Reference<beans::XPropertySet> aXBackgroundPropSet;
1078 aAny >>= aXBackgroundPropSet;
1079 sal_Int32 nTransparence;
1080 aAny = aXBackgroundPropSet->getPropertyValue("FillTransparence");
1081 aAny >>= nTransparence;
1082 CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide background transparency is wrong", sal_Int32(42),
1083 nTransparence);
1086 CPPUNIT_TEST_FIXTURE(SdExportTest, testTextRotation)
1088 // Save behavior depends on whether ODF strict or extended is used.
1089 Resetter _([]() {
1090 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
1091 comphelper::ConfigurationChanges::create());
1092 officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch);
1093 return pBatch->commit();
1096 // The contained shape has a text rotation vert="vert" which corresponds to
1097 // loext:writing-mode="tb-rl90" in the graphic-properties of the style of the shape in ODF 1.3
1098 // extended.
1099 // Save to ODF 1.3 extended. Adapt 3 (=ODFVER_LATEST) to a to be ODFVER_013_EXTENDED when
1100 // attribute value "tb-rl90" is included in ODF strict.
1102 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
1103 comphelper::ConfigurationChanges::create());
1104 officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch);
1105 pBatch->commit();
1107 createSdImpressDoc("pptx/shape-text-rotate.pptx");
1108 saveAndReload("impress8");
1110 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
1111 uno::Reference<beans::XPropertySet> xPropSet(getShape(0, xPage));
1112 CPPUNIT_ASSERT(xPropSet.is());
1114 auto aWritingMode = xPropSet->getPropertyValue("WritingMode").get<sal_Int16>();
1115 CPPUNIT_ASSERT_EQUAL(sal_Int16(text::WritingMode2::TB_RL90), aWritingMode);
1117 // In ODF 1.3 strict the workaround to use the TextRotateAngle is used instead.
1119 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
1120 comphelper::ConfigurationChanges::create());
1121 officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch);
1122 pBatch->commit();
1124 createSdImpressDoc("pptx/shape-text-rotate.pptx");
1125 saveAndReload("impress8");
1127 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
1128 uno::Reference<beans::XPropertySet> xPropSet(getShape(0, xPage));
1130 CPPUNIT_ASSERT(xPropSet.is());
1131 auto aGeomPropSeq = xPropSet->getPropertyValue("CustomShapeGeometry")
1132 .get<uno::Sequence<beans::PropertyValue>>();
1133 comphelper::SequenceAsHashMap aCustomShapeGeometry(aGeomPropSeq);
1135 auto it = aCustomShapeGeometry.find("TextRotateAngle");
1136 CPPUNIT_ASSERT(it != aCustomShapeGeometry.end());
1138 CPPUNIT_ASSERT_EQUAL(double(-90), aCustomShapeGeometry["TextRotateAngle"].get<double>());
1142 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf115394PPT)
1144 createSdImpressDoc("ppt/tdf115394.ppt");
1146 // Export the document and import again for a check
1147 saveAndReload("MS PowerPoint 97");
1149 double fTransitionDuration;
1151 // Fast
1152 SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
1153 CPPUNIT_ASSERT(pXImpressDocument);
1154 SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
1155 SdPage* pPage1 = pDoc->GetSdPage(0, PageKind::Standard);
1156 fTransitionDuration = pPage1->getTransitionDuration();
1157 CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration);
1159 // Medium
1160 SdPage* pPage2 = pDoc->GetSdPage(1, PageKind::Standard);
1161 fTransitionDuration = pPage2->getTransitionDuration();
1162 CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration);
1164 // Slow
1165 SdPage* pPage3 = pDoc->GetSdPage(2, PageKind::Standard);
1166 fTransitionDuration = pPage3->getTransitionDuration();
1167 CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration);
1170 CPPUNIT_TEST_FIXTURE(SdExportTest, testBulletsAsImageImpress8)
1172 createSdImpressDoc("odp/BulletsAsImage.odp");
1173 saveAndReload("impress8");
1175 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1176 uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
1177 uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
1179 uno::Reference<container::XIndexAccess> xLevels(xPropSet->getPropertyValue("NumberingRules"),
1180 uno::UNO_QUERY_THROW);
1181 uno::Sequence<beans::PropertyValue> aProperties;
1182 xLevels->getByIndex(0) >>= aProperties; // 1st level
1184 uno::Reference<awt::XBitmap> xBitmap;
1185 awt::Size aSize;
1186 sal_Int16 nNumberingType = -1;
1188 for (beans::PropertyValue const& rProperty : std::as_const(aProperties))
1190 if (rProperty.Name == "NumberingType")
1192 nNumberingType = rProperty.Value.get<sal_Int16>();
1194 else if (rProperty.Name == "GraphicBitmap")
1196 xBitmap = rProperty.Value.get<uno::Reference<awt::XBitmap>>();
1198 else if (rProperty.Name == "GraphicSize")
1200 aSize = rProperty.Value.get<awt::Size>();
1204 CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType);
1206 // Graphic Bitmap
1207 CPPUNIT_ASSERT_MESSAGE("No bitmap for the bullets", xBitmap.is());
1208 Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY));
1209 CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
1210 CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > o3tl::make_unsigned(0));
1212 CPPUNIT_ASSERT_EQUAL(tools::Long(16), aGraphic.GetSizePixel().Width());
1213 CPPUNIT_ASSERT_EQUAL(tools::Long(16), aGraphic.GetSizePixel().Height());
1215 // Graphic Size
1216 CPPUNIT_ASSERT_EQUAL(sal_Int32(500), aSize.Width);
1217 CPPUNIT_ASSERT_EQUAL(sal_Int32(500), aSize.Height);
1220 CPPUNIT_TEST_FIXTURE(SdExportTest, testBulletsAsImageImpressOfficeOpenXml)
1222 createSdImpressDoc("odp/BulletsAsImage.odp");
1223 saveAndReload("Impress Office Open XML");
1225 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1226 uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
1227 uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
1229 uno::Reference<container::XIndexAccess> xLevels(xPropSet->getPropertyValue("NumberingRules"),
1230 uno::UNO_QUERY_THROW);
1231 uno::Sequence<beans::PropertyValue> aProperties;
1232 xLevels->getByIndex(0) >>= aProperties; // 1st level
1234 uno::Reference<awt::XBitmap> xBitmap;
1235 awt::Size aSize;
1236 sal_Int16 nNumberingType = -1;
1238 for (beans::PropertyValue const& rProperty : std::as_const(aProperties))
1240 if (rProperty.Name == "NumberingType")
1242 nNumberingType = rProperty.Value.get<sal_Int16>();
1244 else if (rProperty.Name == "GraphicBitmap")
1246 xBitmap = rProperty.Value.get<uno::Reference<awt::XBitmap>>();
1248 else if (rProperty.Name == "GraphicSize")
1250 aSize = rProperty.Value.get<awt::Size>();
1254 CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType);
1256 // Graphic Bitmap
1257 CPPUNIT_ASSERT_MESSAGE("No bitmap for the bullets", xBitmap.is());
1258 Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY));
1259 CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
1260 CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > o3tl::make_unsigned(0));
1262 // FIXME: what happened here
1263 CPPUNIT_ASSERT_EQUAL(tools::Long(64), aGraphic.GetSizePixel().Width());
1264 CPPUNIT_ASSERT_EQUAL(tools::Long(64), aGraphic.GetSizePixel().Height());
1266 // Graphic Size
1267 // FIXME: totally wrong
1268 CPPUNIT_ASSERT_EQUAL(sal_Int32(790), aSize.Width);
1269 CPPUNIT_ASSERT_EQUAL(sal_Int32(790), aSize.Height);
1272 CPPUNIT_TEST_FIXTURE(SdExportTest, testBulletsAsImageMsPowerpoint97)
1274 createSdImpressDoc("odp/BulletsAsImage.odp");
1275 saveAndReload("MS PowerPoint 97");
1277 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1278 uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
1279 uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
1281 uno::Reference<container::XIndexAccess> xLevels(xPropSet->getPropertyValue("NumberingRules"),
1282 uno::UNO_QUERY_THROW);
1283 uno::Sequence<beans::PropertyValue> aProperties;
1284 xLevels->getByIndex(0) >>= aProperties; // 1st level
1286 uno::Reference<awt::XBitmap> xBitmap;
1287 awt::Size aSize;
1288 sal_Int16 nNumberingType = -1;
1290 for (beans::PropertyValue const& rProperty : std::as_const(aProperties))
1292 if (rProperty.Name == "NumberingType")
1294 nNumberingType = rProperty.Value.get<sal_Int16>();
1296 else if (rProperty.Name == "GraphicBitmap")
1298 xBitmap = rProperty.Value.get<uno::Reference<awt::XBitmap>>();
1300 else if (rProperty.Name == "GraphicSize")
1302 aSize = rProperty.Value.get<awt::Size>();
1306 CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType);
1308 // Graphic Bitmap
1309 CPPUNIT_ASSERT_MESSAGE("No bitmap for the bullets", xBitmap.is());
1310 Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY));
1311 CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
1312 CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > o3tl::make_unsigned(0));
1314 CPPUNIT_ASSERT_EQUAL(tools::Long(16), aGraphic.GetSizePixel().Width());
1315 CPPUNIT_ASSERT_EQUAL(tools::Long(16), aGraphic.GetSizePixel().Height());
1317 // Graphic Size
1318 // seems like a conversion error
1319 CPPUNIT_ASSERT_EQUAL(sal_Int32(504), aSize.Width);
1320 CPPUNIT_ASSERT_EQUAL(sal_Int32(504), aSize.Height);
1323 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf113822)
1325 createSdImpressDoc("pptx/tdf113822underline.pptx");
1327 // Was unable to export iterate container (tdf#99213).
1328 saveAndReload("Impress Office Open XML");
1329 // Was unable to import iterate container (tdf#113822).
1330 save("impress8");
1332 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1334 // IterateContainer was created as ParallelTimeContainer before, so
1335 // the iterate type is not set too.
1336 assertXPath(pXmlDoc, "//anim:iterate", "iterate-type", "by-letter");
1337 // The target of the child animation nodes need to be in the iterate container.
1338 assertXPath(pXmlDoc, "//anim:iterate", "targetElement", "id1");
1339 assertXPath(pXmlDoc, "//anim:iterate/anim:set", "attributeName", "text-underline");
1340 assertXPath(pXmlDoc, "//anim:iterate/anim:set", "to", "solid");
1343 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf113818)
1345 createSdImpressDoc("pptx/tdf113818-swivel.pptx");
1346 saveAndReload("MS PowerPoint 97");
1347 saveAndReload("Impress Office Open XML");
1348 save("impress8");
1350 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1351 assertXPath(pXmlDoc, "//anim:animate[1]", "formula", "width*sin(2.5*pi*$)");
1352 assertXPath(pXmlDoc, "//anim:animate[1]", "values", "0;1");
1355 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf119629)
1357 createSdImpressDoc("ppt/tdf119629.ppt");
1358 saveAndReload("MS PowerPoint 97");
1359 save("impress8");
1361 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1363 // MSO's effect node type Click parallel node, with group node, after group node
1364 // were missing.
1365 assertXPath(pXmlDoc,
1366 "//draw:page"
1367 "/anim:par[@presentation:node-type='timing-root']"
1368 "/anim:seq[@presentation:node-type='main-sequence']"
1369 "/anim:par[@presentation:node-type='on-click']"
1370 "/anim:par[@presentation:node-type='with-previous']"
1371 "/anim:par[@presentation:node-type='on-click']"
1372 "/anim:animate[@anim:formula='width*sin(2.5*pi*$)']",
1376 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf141269)
1378 createSdImpressDoc("odp/tdf141269.odp");
1379 saveAndReload("MS PowerPoint 97");
1381 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW);
1382 CPPUNIT_ASSERT(xShape.is());
1384 uno::Reference<graphic::XGraphic> xGraphic;
1385 xShape->getPropertyValue("Graphic") >>= xGraphic;
1386 CPPUNIT_ASSERT(xGraphic.is());
1388 Graphic aGraphic(xGraphic);
1389 BitmapEx aBitmap(aGraphic.GetBitmapEx());
1390 CPPUNIT_ASSERT_EQUAL(tools::Long(1920), aBitmap.GetSizePixel().Width());
1391 CPPUNIT_ASSERT_EQUAL(tools::Long(1080), aBitmap.GetSizePixel().Height());
1393 Color aExpectedColor(0xC2DEEA);
1394 aExpectedColor.SetAlpha(0xF);
1396 // Without the fix in place, this test would have failed with
1397 // - Expected: Color: R:194 G:222 B:234 A:240
1398 // - Actual : Color: R:194 G:222 B:234 A:15
1399 CPPUNIT_ASSERT_EQUAL(aExpectedColor, aBitmap.GetPixelColor(960, 540));
1402 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf123557)
1404 createSdImpressDoc("pptx/trigger.pptx");
1405 saveAndReload("Impress Office Open XML");
1406 save("impress8");
1407 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1409 // Contains 2 interactive sequences and 3 triggered effects.
1410 assertXPath(pXmlDoc, "//draw:page", 1);
1411 assertXPath(pXmlDoc, "//draw:page/anim:par", 1);
1412 assertXPath(pXmlDoc,
1413 "//draw:page"
1414 "/anim:par[@presentation:node-type='timing-root']"
1415 "/anim:seq[@presentation:node-type='interactive-sequence']",
1417 assertXPath(pXmlDoc,
1418 "//draw:page"
1419 "/anim:par[@presentation:node-type='timing-root']"
1420 "/anim:seq[@presentation:node-type='interactive-sequence']"
1421 "/anim:par[@smil:begin]",
1425 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf126761)
1427 createSdImpressDoc("ppt/tdf126761.ppt");
1428 saveAndReload("impress8");
1429 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1431 // Get first paragraph of the text
1432 uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
1434 // Get first run of the paragraph
1435 uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
1436 uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW);
1438 // Check character underline, to make sure it has been set correctly
1439 sal_uInt32 nCharUnderline;
1440 xPropSet->getPropertyValue("CharUnderline") >>= nCharUnderline;
1441 CPPUNIT_ASSERT_EQUAL(sal_uInt32(1), nCharUnderline);
1444 CPPUNIT_TEST_FIXTURE(SdExportTest, testGlow)
1446 createSdDrawDoc("odg/glow.odg");
1447 saveAndReload("draw8");
1448 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1450 // Check glow properties
1451 sal_Int32 nGlowEffectRad = 0;
1452 CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectRadius") >>= nGlowEffectRad);
1453 CPPUNIT_ASSERT_EQUAL(sal_Int32(529), nGlowEffectRad); // 15 pt = 529.166... mm/100
1454 Color nGlowEffectColor;
1455 CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectColor") >>= nGlowEffectColor);
1456 CPPUNIT_ASSERT_EQUAL(Color(0x00FF4000), nGlowEffectColor); // "Brick"
1457 sal_Int16 nGlowEffectTransparency = 0;
1458 CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectTransparency") >>= nGlowEffectTransparency);
1459 CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nGlowEffectTransparency); // 60%
1461 // Test ODF element
1462 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1464 // check that we actually test graphic style
1465 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[2]",
1466 "family", "graphic");
1467 // check loext graphic attributes
1468 assertXPath(
1469 pXmlDoc,
1470 "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
1471 "glow-radius", "0.529cm");
1472 assertXPath(
1473 pXmlDoc,
1474 "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
1475 "glow-color", "#ff4000");
1476 assertXPath(
1477 pXmlDoc,
1478 "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
1479 "glow-transparency", "60%");
1482 CPPUNIT_TEST_FIXTURE(SdExportTest, testSoftEdges)
1484 createSdDrawDoc("odg/softedges.odg");
1485 saveAndReload("draw8");
1486 auto xShapeProps(getShapeFromPage(0, 0));
1488 // Check property
1489 sal_Int32 nRad = 0;
1490 CPPUNIT_ASSERT(xShapeProps->getPropertyValue("SoftEdgeRadius") >>= nRad);
1491 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), nRad); // 18 pt
1493 // Test ODF element
1494 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1496 // check that we actually test graphic style
1497 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[2]",
1498 "family", "graphic");
1499 // check loext graphic attribute
1500 assertXPath(
1501 pXmlDoc,
1502 "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties",
1503 "softedge-radius", "0.635cm");
1506 CPPUNIT_TEST_FIXTURE(SdExportTest, testShadowBlur)
1508 createSdImpressDoc("odp/shadow-blur.odp");
1509 saveAndReload("draw8");
1510 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1512 sal_Int32 nRad = 0;
1513 CPPUNIT_ASSERT(xShape->getPropertyValue("ShadowBlur") >>= nRad);
1514 CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRad); // 11 pt = 388 Hmm
1516 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1518 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[3]",
1519 "family", "graphic");
1520 assertXPath(
1521 pXmlDoc,
1522 "/office:document-content/office:automatic-styles/style:style[3]/style:graphic-properties",
1523 "shadow-blur", "0.388cm");
1526 CPPUNIT_TEST_FIXTURE(SdExportTest, testRhbz1870501)
1528 //Without the fix in place, it would crash at export time
1529 createSdDrawDoc("odg/rhbz1870501.odg");
1530 saveAndReload("draw8");
1533 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf152606)
1535 //Without the fix in place, it would crash at import time
1536 createSdImpressDoc("pptx/tdf152606.pptx");
1537 saveAndReload("Impress Office Open XML");
1539 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
1540 uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
1541 uno::UNO_QUERY);
1542 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xDrawPage->getCount());
1545 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf154754)
1547 //Without the fix in place, it would crash at export time
1548 skipValidation();
1549 createSdImpressDoc("odp/tdf154754.odp");
1550 saveAndReload("impress8");
1553 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf91060)
1555 //Without the fix in place, it would crash at import time
1556 createSdImpressDoc("pptx/tdf91060.pptx");
1557 saveAndReload("Impress Office Open XML");
1560 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf128550)
1562 createSdImpressDoc("pptx/tdf128550.pptx");
1563 save("impress8");
1564 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1565 assertXPath(pXmlDoc, "//anim:iterate[@anim:sub-item='background']", 1);
1566 assertXPath(pXmlDoc, "//anim:iterate[@anim:sub-item='text']", 4);
1569 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf140714)
1571 //Without the fix in place, shape will be imported as GraphicObjectShape instead of CustomShape.
1573 createSdImpressDoc("pptx/tdf140714.pptx");
1574 saveAndReload("Impress Office Open XML");
1576 uno::Reference<drawing::XShape> xShape(getShapeFromPage(0, 0), uno::UNO_QUERY);
1577 CPPUNIT_ASSERT_EQUAL(OUString{ "com.sun.star.drawing.CustomShape" }, xShape->getShapeType());
1580 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf156649)
1582 createSdImpressDoc("pptx/tdf156649.pptx");
1583 saveAndReload("Impress Office Open XML");
1585 auto xShapeProps(getShapeFromPage(0, 0));
1586 // Without the fix in place, this test would have failed with
1587 //- Expected: 55
1588 //- Actual : 0
1589 // i.e. alphaModFix wasn't imported as fill transparency for the custom shape
1590 CPPUNIT_ASSERT_EQUAL(sal_Int16(55),
1591 xShapeProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1594 CPPUNIT_TEST_FIXTURE(SdExportTest, testMasterPageBackgroundFullSize)
1596 createSdImpressDoc("odp/background.odp");
1598 // BackgroundFullSize exists on master pages only
1599 // (note: this document can't be created with the UI because UI keeps
1600 // page margins and the flag synchronized across all master pages)
1601 uno::Reference<drawing::XMasterPagesSupplier> xMPS(mxComponent, uno::UNO_QUERY);
1602 uno::Reference<drawing::XDrawPages> xMPs(xMPS->getMasterPages());
1603 Color nFillColor;
1605 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(0), uno::UNO_QUERY);
1606 CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1607 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1608 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1609 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1610 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1611 uno::Reference<beans::XPropertySet> xBackgroundProps(
1612 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1613 CPPUNIT_ASSERT_EQUAL(
1614 drawing::FillStyle_SOLID,
1615 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1616 xBackgroundProps->getPropertyValue("FillColor") >>= nFillColor;
1617 CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), nFillColor);
1618 CPPUNIT_ASSERT_EQUAL(
1619 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1622 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(1), uno::UNO_QUERY);
1623 CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1624 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1625 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1626 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1627 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1628 uno::Reference<beans::XPropertySet> xBackgroundProps(
1629 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1630 CPPUNIT_ASSERT_EQUAL(
1631 drawing::FillStyle_SOLID,
1632 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1633 xBackgroundProps->getPropertyValue("FillColor") >>= nFillColor;
1634 CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), nFillColor);
1635 CPPUNIT_ASSERT_EQUAL(
1636 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1639 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(2), uno::UNO_QUERY);
1640 CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1641 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1642 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1643 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1644 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1645 uno::Reference<beans::XPropertySet> xBackgroundProps(
1646 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1647 CPPUNIT_ASSERT_EQUAL(
1648 drawing::FillStyle_BITMAP,
1649 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1650 CPPUNIT_ASSERT_EQUAL(
1651 drawing::BitmapMode_STRETCH,
1652 xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
1653 CPPUNIT_ASSERT_EQUAL(
1654 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1657 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(3), uno::UNO_QUERY);
1658 CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1659 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1660 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1661 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1662 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1663 uno::Reference<beans::XPropertySet> xBackgroundProps(
1664 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1665 CPPUNIT_ASSERT_EQUAL(
1666 drawing::FillStyle_BITMAP,
1667 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1668 CPPUNIT_ASSERT_EQUAL(
1669 drawing::BitmapMode_STRETCH,
1670 xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
1671 CPPUNIT_ASSERT_EQUAL(
1672 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1675 saveAndReload("impress8");
1677 xMPS.set(mxComponent, uno::UNO_QUERY);
1678 xMPs.set(xMPS->getMasterPages());
1680 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(0), uno::UNO_QUERY);
1681 CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1682 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1683 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1684 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1685 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1686 uno::Reference<beans::XPropertySet> xBackgroundProps(
1687 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1688 CPPUNIT_ASSERT_EQUAL(
1689 drawing::FillStyle_SOLID,
1690 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1691 xBackgroundProps->getPropertyValue("FillColor") >>= nFillColor;
1692 CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), nFillColor);
1693 CPPUNIT_ASSERT_EQUAL(
1694 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1697 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(1), uno::UNO_QUERY);
1698 CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1699 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1700 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1701 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1702 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1703 uno::Reference<beans::XPropertySet> xBackgroundProps(
1704 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1705 CPPUNIT_ASSERT_EQUAL(
1706 drawing::FillStyle_SOLID,
1707 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1708 xBackgroundProps->getPropertyValue("FillColor") >>= nFillColor;
1709 CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), nFillColor);
1710 CPPUNIT_ASSERT_EQUAL(
1711 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1714 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(2), uno::UNO_QUERY);
1715 CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1716 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1717 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1718 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1719 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1720 uno::Reference<beans::XPropertySet> xBackgroundProps(
1721 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1722 CPPUNIT_ASSERT_EQUAL(
1723 drawing::FillStyle_BITMAP,
1724 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1725 CPPUNIT_ASSERT_EQUAL(
1726 drawing::BitmapMode_STRETCH,
1727 xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
1728 CPPUNIT_ASSERT_EQUAL(
1729 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1732 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(3), uno::UNO_QUERY);
1733 CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1734 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1735 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1736 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1737 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1738 uno::Reference<beans::XPropertySet> xBackgroundProps(
1739 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1740 CPPUNIT_ASSERT_EQUAL(
1741 drawing::FillStyle_BITMAP,
1742 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1743 CPPUNIT_ASSERT_EQUAL(
1744 drawing::BitmapMode_STRETCH,
1745 xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
1746 CPPUNIT_ASSERT_EQUAL(
1747 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1750 xmlDocUniquePtr pXmlDoc = parseExport("styles.xml");
1751 assertXPath(pXmlDoc,
1752 "/office:document-styles/office:automatic-styles/"
1753 "style:style[@style:family='drawing-page' and @style:name = "
1754 "/office:document-styles/office:master-styles/"
1755 "style:master-page[@style:name='Default']/attribute::draw:style-name"
1756 "]/style:drawing-page-properties",
1757 "background-size", "border");
1758 assertXPath(pXmlDoc,
1759 "/office:document-styles/office:automatic-styles/"
1760 "style:style[@style:family='drawing-page' and @style:name = "
1761 "/office:document-styles/office:master-styles/"
1762 "style:master-page[@style:name='Default_20_3']/attribute::draw:style-name"
1763 "]/style:drawing-page-properties",
1764 "background-size", "full");
1765 assertXPath(pXmlDoc,
1766 "/office:document-styles/office:automatic-styles/"
1767 "style:style[@style:family='drawing-page' and @style:name = "
1768 "/office:document-styles/office:master-styles/"
1769 "style:master-page[@style:name='Default_20_2']/attribute::draw:style-name"
1770 "]/style:drawing-page-properties",
1771 "background-size", "border");
1772 assertXPath(pXmlDoc,
1773 "/office:document-styles/office:automatic-styles/"
1774 "style:style[@style:family='drawing-page' and @style:name = "
1775 "/office:document-styles/office:master-styles/"
1776 "style:master-page[@style:name='Default_20_1']/attribute::draw:style-name"
1777 "]/style:drawing-page-properties",
1778 "background-size", "full");
1781 CPPUNIT_TEST_FIXTURE(SdExportTest, testColumnsODG)
1783 createSdDrawDoc("odg/two_columns.odg");
1786 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
1787 uno::UNO_QUERY_THROW);
1788 uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages();
1789 uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW);
1790 uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW);
1791 uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
1792 uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW);
1793 uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"),
1794 uno::UNO_QUERY_THROW);
1795 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCols->getColumnCount());
1796 uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW);
1797 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(700)),
1798 xColProps->getPropertyValue("AutomaticDistance"));
1800 auto pTextObj = DynCastSdrTextObj(SdrObject::getSdrObjectFromXShape(xShape));
1801 CPPUNIT_ASSERT(pTextObj);
1803 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pTextObj->GetTextColumnsNumber());
1804 CPPUNIT_ASSERT_EQUAL(sal_Int32(700), pTextObj->GetTextColumnsSpacing());
1807 saveAndReload("draw8");
1810 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
1811 uno::UNO_QUERY_THROW);
1812 uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages();
1813 uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW);
1814 uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW);
1815 uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
1816 uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW);
1817 uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"),
1818 uno::UNO_QUERY_THROW);
1819 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCols->getColumnCount());
1820 uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW);
1821 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(700)),
1822 xColProps->getPropertyValue("AutomaticDistance"));
1824 auto pTextObj = DynCastSdrTextObj(SdrObject::getSdrObjectFromXShape(xShape));
1825 CPPUNIT_ASSERT(pTextObj);
1827 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pTextObj->GetTextColumnsNumber());
1828 CPPUNIT_ASSERT_EQUAL(sal_Int32(700), pTextObj->GetTextColumnsSpacing());
1831 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1832 assertXPath(pXmlDoc,
1833 "/office:document-content/office:automatic-styles/style:style/"
1834 "style:graphic-properties/style:columns",
1835 "column-count", "2");
1836 assertXPath(pXmlDoc,
1837 "/office:document-content/office:automatic-styles/style:style/"
1838 "style:graphic-properties/style:columns",
1839 "column-gap", "0.7cm");
1842 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf112126)
1844 createSdDrawDoc("tdf112126.odg");
1845 saveAndReload("draw8");
1846 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
1847 uno::Reference<beans::XPropertySet> xPropertySet(xPage, uno::UNO_QUERY);
1849 OUString xPageName;
1850 xPropertySet->getPropertyValue("LinkDisplayName") >>= xPageName;
1852 // without the fix in place, it fails with
1853 // - Expected: Page 1
1854 // - Actual : Slide 1
1855 CPPUNIT_ASSERT_EQUAL(OUString("Page 1"), xPageName);
1858 CPPUNIT_TEST_FIXTURE(SdExportTest, testCellProperties)
1860 // Silence unrelated failure:
1861 // Error: element "table:table-template" is missing "first-row-start-column" attribute
1862 // Looks like an oversight in the schema, as the docs claim this attribute is deprecated.
1863 skipValidation();
1865 createSdDrawDoc("odg/tablestyles.fodg");
1866 saveAndReload("draw8");
1868 const SdrPage* pPage = GetPage(1);
1869 auto pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1870 CPPUNIT_ASSERT(pTableObj != nullptr);
1871 uno::Reference<beans::XPropertySet> xCell(pTableObj->getTable()->getCellByPosition(0, 0),
1872 uno::UNO_QUERY_THROW);
1874 Color nColor;
1875 table::BorderLine2 aBorderLine;
1876 drawing::TextVerticalAdjust aTextAdjust;
1877 sal_Int32 nPadding;
1879 xCell->getPropertyValue("FillColor") >>= nColor;
1880 CPPUNIT_ASSERT_EQUAL(Color(0xffcc99), nColor);
1881 xCell->getPropertyValue("RightBorder") >>= aBorderLine;
1882 CPPUNIT_ASSERT_EQUAL(Color(0x99ccff), Color(ColorTransparency, aBorderLine.Color));
1883 CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aBorderLine.LineWidth);
1884 xCell->getPropertyValue("TextRightDistance") >>= nPadding;
1885 CPPUNIT_ASSERT_EQUAL(sal_Int32(300), nPadding);
1886 xCell->getPropertyValue("TextVerticalAdjust") >>= aTextAdjust;
1887 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust::TextVerticalAdjust_CENTER, aTextAdjust);
1890 CPPUNIT_TEST_FIXTURE(SdExportTest, testUserTableStyles)
1892 // Silence unrelated failure:
1893 // Error: element "table:table-template" is missing "first-row-start-column" attribute
1894 // Looks like an oversight in the schema, as the docs claim this attribute is deprecated.
1895 skipValidation();
1897 createSdDrawDoc("odg/tablestyles.fodg");
1898 saveAndReload("draw8");
1900 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
1901 uno::UNO_QUERY);
1902 uno::Reference<container::XNameAccess> xStyleFamily(
1903 xStyleFamiliesSupplier->getStyleFamilies()->getByName("table"), uno::UNO_QUERY);
1905 uno::Reference<style::XStyle> xTableStyle(xStyleFamily->getByName("default"), uno::UNO_QUERY);
1906 CPPUNIT_ASSERT(!xTableStyle->isUserDefined());
1908 uno::Reference<container::XNameAccess> xNameAccess(xTableStyle, uno::UNO_QUERY);
1909 uno::Reference<style::XStyle> xCellStyle(xNameAccess->getByName("first-row"), uno::UNO_QUERY);
1910 CPPUNIT_ASSERT(xCellStyle);
1911 CPPUNIT_ASSERT_EQUAL(OUString("userdefined"), xCellStyle->getName());
1913 CPPUNIT_ASSERT(xStyleFamily->hasByName("userdefined"));
1914 xTableStyle.set(xStyleFamily->getByName("userdefined"), uno::UNO_QUERY);
1915 CPPUNIT_ASSERT(xTableStyle->isUserDefined());
1918 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf153179)
1920 createSdImpressDoc("pptx/ole-emf_min.pptx");
1921 saveAndReload("impress8");
1923 // Check number of shapes after export.
1924 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getPage(0)->getCount());
1927 CPPUNIT_PLUGIN_IMPLEMENT();
1929 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */