Fix typos
[LibreOffice.git] / sd / qa / unit / export-tests.cxx
blob7ee6e3a5e8cddb3fefe15c3e0183ba7c9f69a23b
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"_ostr,
209 "Rectangle 7"_ostr,
210 "Group 24"_ostr,
211 "Connector: Elbow 9"_ostr,
212 "Connector: Elbow 11"_ostr,
213 "Connector: Elbow 14"_ostr,
214 "Connector: Elbow 17"_ostr,
215 "Straight Arrow Connector 21"_ostr,
216 "Straight Arrow Connector 22"_ostr,
217 "Straight Arrow Connector 23"_ostr,
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: "_ostr);
281 saveAndReload("Impress Office Open XML");
282 doTest("reload OOXML: "_ostr);
284 saveAndReload("impress8");
285 doTest("reload ODF: "_ostr);
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']"_ostr,
328 assertXPath(
329 pXmlDoc,
330 "//style:style[@style:family='graphic']/style:graphic-properties[@draw:fill='bitmap']"_ostr,
331 "fill-image-name"_ostr, "nav_5f_up");
332 assertXPath(
333 pXmlDoc,
334 "//style:style[@style:family='graphic']/style:graphic-properties[@draw:fill='solid']"_ostr,
336 assertXPath(pXmlDoc,
337 "//style:style[@style:family='graphic']/"
338 "style:graphic-properties[@draw:fill='solid' and @draw:fill-image-name]"_ostr,
340 assertXPath(
341 pXmlDoc,
342 "//style:style[@style:family='graphic']/style:graphic-properties[@draw:fill='solid']"_ostr,
343 "fill-color"_ostr, "#808080");
345 xmlDocUniquePtr pStyles = parseExport("styles.xml");
346 // master slide presentation style
347 assertXPath(pStyles,
348 "/office:document-styles/office:styles/style:style[@style:family='presentation' "
349 "and @style:name='Default-background']/style:graphic-properties"_ostr,
350 "fill"_ostr, "bitmap");
351 assertXPath(pStyles,
352 "/office:document-styles/office:styles/style:style[@style:family='presentation' "
353 "and @style:name='Default-background']/style:graphic-properties"_ostr,
354 "fill-image-name"_ostr, "nav_5f_up");
355 assertXPath(pStyles,
356 "/office:document-styles/office:styles/style:style[@style:family='presentation' "
357 "and @style:name='Default_20_1-background']/style:graphic-properties"_ostr,
358 "fill"_ostr, "solid");
359 assertXPath(pStyles,
360 "/office:document-styles/office:styles/style:style[@style:family='presentation' "
361 "and @style:name='Default_20_1-background']/style:graphic-properties"_ostr,
362 "fill-color"_ostr, "#808080");
363 assertXPath(
364 pStyles,
365 "/office:document-styles/office:styles/style:style[@style:family='presentation' and "
366 "@style:name='Default_20_1-background']/style:graphic-properties[@draw:fill-image-name]"_ostr,
368 // master slide drawing-page style
369 assertXPath(pStyles,
370 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp1']/"
371 "style:drawing-page-properties"_ostr,
372 "fill"_ostr, "bitmap");
373 assertXPath(pStyles,
374 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp1']/"
375 "style:drawing-page-properties"_ostr,
376 "fill-image-name"_ostr, "nav_5f_up");
377 assertXPath(pStyles,
378 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/"
379 "style:drawing-page-properties"_ostr,
380 "fill"_ostr, "solid");
381 assertXPath(pStyles,
382 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/"
383 "style:drawing-page-properties"_ostr,
384 "fill-color"_ostr, "#808080");
385 assertXPath(pStyles,
386 "/office:document-styles/office:automatic-styles/style:style[@style:name='Mdp2']/"
387 "style:drawing-page-properties[@draw:fill-image-name]"_ostr,
390 // the named items
391 assertXPath(pStyles, "/office:document-styles/office:styles/draw:fill-image"_ostr, 1);
392 assertXPath(pStyles, "/office:document-styles/office:styles/draw:fill-image"_ostr, "name"_ostr,
393 "nav_5f_up");
396 CPPUNIT_TEST_FIXTURE(SdExportTest, testFdo84043)
398 createSdImpressDoc("fdo84043.odp");
399 saveAndReload("impress8");
401 // the bug was duplicate attributes, causing crash in a build with asserts
402 const SdrPage* pPage = GetPage(1);
403 SdrObject const* pShape = pPage->GetObj(1);
404 CPPUNIT_ASSERT_MESSAGE("no shape", pShape != nullptr);
407 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf97630)
409 createSdImpressDoc("fit-to-size.fodp");
411 uno::Reference<drawing::XDrawPage> xDP(getPage(0));
413 drawing::TextFitToSizeType tmp;
414 // text shapes
415 uno::Reference<beans::XPropertySet> xShape0(xDP->getByIndex(0), uno::UNO_QUERY);
416 xShape0->getPropertyValue("TextFitToSize") >>= tmp;
417 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
418 uno::Reference<beans::XPropertySet> xShape1(xDP->getByIndex(1), uno::UNO_QUERY);
419 xShape1->getPropertyValue("TextFitToSize") >>= tmp;
420 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
421 uno::Reference<beans::XPropertySet> xShape2(xDP->getByIndex(2), uno::UNO_QUERY);
422 xShape2->getPropertyValue("TextFitToSize") >>= tmp;
423 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_ALLLINES, tmp);
424 uno::Reference<beans::XPropertySet> xShape3(xDP->getByIndex(3), uno::UNO_QUERY);
425 xShape3->getPropertyValue("TextFitToSize") >>= tmp;
426 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_AUTOFIT, tmp);
428 // fontworks
429 uno::Reference<beans::XPropertySet> xShape4(xDP->getByIndex(4), uno::UNO_QUERY);
430 xShape4->getPropertyValue("TextFitToSize") >>= tmp;
431 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
432 uno::Reference<beans::XPropertySet> xShape5(xDP->getByIndex(5), uno::UNO_QUERY);
433 xShape5->getPropertyValue("TextFitToSize") >>= tmp;
434 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_ALLLINES, tmp);
437 saveAndReload("impress8");
440 uno::Reference<drawing::XDrawPage> xDP(getPage(0));
442 drawing::TextFitToSizeType tmp;
443 // text shapes
444 uno::Reference<beans::XPropertySet> xShape0(xDP->getByIndex(0), uno::UNO_QUERY);
445 xShape0->getPropertyValue("TextFitToSize") >>= tmp;
446 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
447 uno::Reference<beans::XPropertySet> xShape1(xDP->getByIndex(1), uno::UNO_QUERY);
448 xShape1->getPropertyValue("TextFitToSize") >>= tmp;
449 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
450 uno::Reference<beans::XPropertySet> xShape2(xDP->getByIndex(2), uno::UNO_QUERY);
451 xShape2->getPropertyValue("TextFitToSize") >>= tmp;
452 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
453 uno::Reference<beans::XPropertySet> xShape3(xDP->getByIndex(3), uno::UNO_QUERY);
454 xShape3->getPropertyValue("TextFitToSize") >>= tmp;
455 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_AUTOFIT, tmp);
457 // fontworks
458 uno::Reference<beans::XPropertySet> xShape4(xDP->getByIndex(4), uno::UNO_QUERY);
459 xShape4->getPropertyValue("TextFitToSize") >>= tmp;
460 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_NONE, tmp);
461 uno::Reference<beans::XPropertySet> xShape5(xDP->getByIndex(5), uno::UNO_QUERY);
462 xShape5->getPropertyValue("TextFitToSize") >>= tmp;
463 CPPUNIT_ASSERT_EQUAL(drawing::TextFitToSizeType_PROPORTIONAL, tmp);
466 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
467 // text shapes
468 assertXPath(pXmlDoc,
469 "//style:style[@style:family='presentation']/"
470 "style:graphic-properties[@draw:fit-to-size='false' and "
471 "@style:shrink-to-fit='false']"_ostr,
473 assertXPath(pXmlDoc,
474 "//style:style[@style:family='presentation']/"
475 "style:graphic-properties[@draw:fit-to-size='true' and "
476 "@style:shrink-to-fit='false']"_ostr,
478 assertXPath(pXmlDoc,
479 "//style:style[@style:family='presentation']/"
480 "style:graphic-properties[@draw:fit-to-size='false' and "
481 "@style:shrink-to-fit='true']"_ostr,
483 // fontworks
484 assertXPath(pXmlDoc,
485 "//style:style[@style:family='graphic']/"
486 "style:graphic-properties[@draw:fit-to-size='false' and "
487 "@style:shrink-to-fit='false']"_ostr,
489 assertXPath(pXmlDoc,
490 "//style:style[@style:family='graphic']/"
491 "style:graphic-properties[@draw:fit-to-size='true' and "
492 "@style:shrink-to-fit='false']"_ostr,
496 CPPUNIT_TEST_FIXTURE(SdExportTest, testImpressPasswordExport)
498 std::vector<OUString> vFormat{ "impress8", "Impress Office Open XML" };
500 for (size_t i = 0; i < vFormat.size(); i++)
502 createSdImpressDoc();
504 saveAndReload(vFormat[i], /*pPassword*/ "test");
508 CPPUNIT_TEST_FIXTURE(SdExportTest, testDrawPasswordExport)
510 createSdDrawDoc();
512 saveAndReload("draw8", /*pPassword*/ "test");
515 CPPUNIT_TEST_FIXTURE(SdExportTest, testSwappedOutImageExport)
517 // Problem was with the swapped out images, which were not swapped in during export.
519 std::vector<OUString> vFormat{ "impress8", "Impress Office Open XML", "MS PowerPoint 97" };
521 for (size_t i = 0; i < vFormat.size(); i++)
523 // Load the original file with one image
524 createSdImpressDoc("odp/document_with_two_images.odp");
525 const OString sFailedMessage = "Failed on filter: " + vFormat[i].toUtf8();
527 // Export the document and import again for a check
528 saveAndReload(vFormat[i]);
530 // Check whether graphic exported well after it was swapped out
531 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
532 uno::UNO_QUERY_THROW);
533 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2),
534 xDrawPagesSupplier->getDrawPages()->getCount());
535 uno::Reference<drawing::XDrawPage> xDrawPage(
536 xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
538 uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY);
539 uno::Reference<beans::XPropertySet> XPropSet(xImage, uno::UNO_QUERY_THROW);
541 // Check Graphic, Size
543 uno::Reference<graphic::XGraphic> xGraphic;
544 XPropSet->getPropertyValue("Graphic") >>= xGraphic;
545 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
546 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(),
547 xGraphic->getType() != graphic::GraphicType::EMPTY);
548 uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
549 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
550 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610),
551 xBitmap->getSize().Width);
552 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381),
553 xBitmap->getSize().Height);
556 // Second Image
557 xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW);
558 xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY);
559 XPropSet.set(xImage, uno::UNO_QUERY_THROW);
561 // Check Graphic, Size
563 uno::Reference<graphic::XGraphic> xGraphic;
564 XPropSet->getPropertyValue("Graphic") >>= xGraphic;
565 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
566 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(),
567 xGraphic->getType() != graphic::GraphicType::EMPTY);
568 uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
569 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
570 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900),
571 xBitmap->getSize().Width);
572 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600),
573 xBitmap->getSize().Height);
578 CPPUNIT_TEST_FIXTURE(SdExportTest, testOOoXMLAnimations)
580 createSdImpressDoc("sxi/ooo41061-1.sxi");
582 // FIXME: Error: unexpected attribute "presentation:preset-property"
583 skipValidation();
585 save("impress8");
587 // the problem was that legacy OOoXML animations were lost if store
588 // immediately follows load because they were "converted" async by a timer
589 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
590 assertXPath(pXmlDoc, "//anim:par[@presentation:node-type='timing-root']"_ostr, 26);
591 // currently getting 52 of these without the fix (depends on timing)
592 assertXPath(pXmlDoc, "//anim:par"_ostr, 223);
595 CPPUNIT_TEST_FIXTURE(SdExportTest, testBnc480256)
597 createSdImpressDoc("pptx/bnc480256.pptx");
598 // In the document, there are two tables with table background properties.
599 // Make sure colors are set properly for individual cells.
601 // TODO: If you are working on improving table background support, expect
602 // this unit test to fail. In that case, feel free to change the numbers.
604 const SdrPage* pPage = GetPage(1);
606 sdr::table::SdrTableObj* pTableObj;
607 uno::Reference<table::XCellRange> xTable;
608 uno::Reference<beans::XPropertySet> xCell;
609 Color nColor;
610 table::BorderLine2 aBorderLine;
612 pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
613 CPPUNIT_ASSERT(pTableObj);
614 xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
616 xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
617 xCell->getPropertyValue("FillColor") >>= nColor;
618 CPPUNIT_ASSERT_EQUAL(Color(0x9bc3ee), nColor);
619 xCell->getPropertyValue("LeftBorder") >>= aBorderLine;
620 CPPUNIT_ASSERT_EQUAL(Color(0x5597d3), Color(ColorTransparency, aBorderLine.Color));
622 xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
623 xCell->getPropertyValue("FillColor") >>= nColor;
624 CPPUNIT_ASSERT_EQUAL(Color(0xc6ddff), nColor);
625 xCell->getPropertyValue("TopBorder") >>= aBorderLine;
626 CPPUNIT_ASSERT_EQUAL(Color(0x5597d3), Color(ColorTransparency, aBorderLine.Color));
628 pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(1));
629 CPPUNIT_ASSERT(pTableObj);
630 xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
632 xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
633 xCell->getPropertyValue("FillColor") >>= nColor;
634 CPPUNIT_ASSERT_EQUAL(Color(0x6bace6), nColor);
635 xCell->getPropertyValue("LeftBorder") >>= aBorderLine;
636 CPPUNIT_ASSERT_EQUAL(Color(0xbecfe6), Color(ColorTransparency, aBorderLine.Color));
638 xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
639 xCell->getPropertyValue("FillColor") >>= nColor;
640 CPPUNIT_ASSERT_EQUAL(Color(0x4697e0), nColor);
642 // This border should be invisible.
643 xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
644 xCell->getPropertyValue("BottomBorder") >>= aBorderLine;
645 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), sal_Int32(aBorderLine.LineWidth));
648 CPPUNIT_TEST_FIXTURE(SdExportTest, testUnknownAttributes)
650 createSdImpressDoc("unknown-attribute.fodp");
652 // FIXME: Error: unexpected attribute "foo:non-existent-att"
653 skipValidation();
655 save("impress8");
657 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
658 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/"
659 "style:style[@style:name='gr1']/"
660 "style:graphic-properties[@foo:non-existent-att='bar']"_ostr);
661 // 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?
662 // assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/style:graphic-properties[@svg:non-existent-att='blah']");
663 // this was on style:graphic-properties on the import, but the export moves it to root node which is OK
664 assertXPathNSDef(pXmlDoc, "/office:document-content"_ostr, u"foo", u"http://example.com/");
667 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf80020)
669 createSdImpressDoc("odp/tdf80020.odp");
671 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
672 uno::UNO_QUERY);
673 uno::Reference<container::XNameAccess> xStyleFamilies
674 = xStyleFamiliesSupplier->getStyleFamilies();
675 uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("graphics"),
676 uno::UNO_QUERY);
677 uno::Reference<style::XStyle> xStyle(xStyleFamily->getByName("Test Style"), uno::UNO_QUERY);
678 CPPUNIT_ASSERT_EQUAL(OUString("text"), xStyle->getParentStyle());
679 saveAndReload("impress8");
681 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
682 uno::UNO_QUERY);
683 uno::Reference<container::XNameAccess> xStyleFamilies
684 = xStyleFamiliesSupplier->getStyleFamilies();
685 uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("graphics"),
686 uno::UNO_QUERY);
687 uno::Reference<style::XStyle> xStyle(xStyleFamily->getByName("Test Style"), uno::UNO_QUERY);
688 CPPUNIT_ASSERT_EQUAL(OUString("text"), xStyle->getParentStyle());
691 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf128985)
693 createSdImpressDoc("odp/tdf128985.odp");
695 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
696 uno::UNO_QUERY);
697 uno::Reference<container::XNameAccess> xStyleFamilies
698 = xStyleFamiliesSupplier->getStyleFamilies();
699 uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("LushGreen"),
700 uno::UNO_QUERY);
701 uno::Reference<style::XStyle> xStyle(xStyleFamily->getByName("outline1"), uno::UNO_QUERY);
702 uno::Reference<beans::XPropertySet> xPropSet(xStyle, uno::UNO_QUERY);
704 sal_Int16 nWritingMode = 0;
705 xPropSet->getPropertyValue("WritingMode") >>= nWritingMode;
706 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nWritingMode);
708 xPropSet->setPropertyValue("WritingMode", uno::Any(text::WritingMode2::LR_TB));
710 saveAndReload("impress8");
712 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
713 uno::UNO_QUERY);
714 uno::Reference<container::XNameAccess> xStyleFamilies
715 = xStyleFamiliesSupplier->getStyleFamilies();
716 uno::Reference<container::XNameAccess> xStyleFamily(xStyleFamilies->getByName("LushGreen"),
717 uno::UNO_QUERY);
718 uno::Reference<style::XStyle> xStyle(xStyleFamily->getByName("outline1"), uno::UNO_QUERY);
719 uno::Reference<beans::XPropertySet> xPropSet(xStyle, uno::UNO_QUERY);
721 sal_Int16 nWritingMode = 0;
722 xPropSet->getPropertyValue("WritingMode") >>= nWritingMode;
724 // Without the fix in place, this test would have failed with
725 // - Expected: 0
726 // - Actual : 1
727 CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nWritingMode);
730 CPPUNIT_TEST_FIXTURE(SdExportTest, testLinkedGraphicRT)
732 // FIXME: PPTX fails
733 std::vector<OUString> vFormat{ "impress8", "MS PowerPoint 97" };
734 for (size_t i = 0; i < vFormat.size(); i++)
736 // Load the original file with one image
737 createSdImpressDoc("odp/document_with_linked_graphic.odp");
739 // Check if the graphic has been imported correctly (before doing the export/import run)
741 constexpr OString sFailedImportMessage = "Failed to correctly import the document"_ostr;
742 SdXImpressDocument* pXImpressDocument
743 = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
744 CPPUNIT_ASSERT(pXImpressDocument);
745 SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
746 CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pDoc != nullptr);
747 const SdrPage* pPage = pDoc->GetPage(1);
748 CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pPage != nullptr);
749 SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
750 CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject != nullptr);
751 CPPUNIT_ASSERT_MESSAGE(sFailedImportMessage.getStr(), pObject->IsLinkedGraphic());
753 const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
754 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), int(GraphicType::Bitmap),
755 int(rGraphicObj.GetGraphic().GetType()));
756 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedImportMessage.getStr(), sal_uLong(864900),
757 rGraphicObj.GetGraphic().GetSizeBytes());
760 // Save and reload
761 saveAndReload(vFormat[i]);
763 // Check whether graphic imported well after export
765 const OString sFailedMessage = "Failed on filter: " + vFormat[i].toUtf8();
767 SdXImpressDocument* pXImpressDocument
768 = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
769 CPPUNIT_ASSERT(pXImpressDocument);
770 SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
771 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pDoc != nullptr);
772 const SdrPage* pPage = pDoc->GetPage(1);
773 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pPage != nullptr);
774 SdrGrafObj* pObject = dynamic_cast<SdrGrafObj*>(pPage->GetObj(2));
775 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pObject != nullptr);
776 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pObject->IsLinkedGraphic());
778 const GraphicObject& rGraphicObj = pObject->GetGraphicObject(true);
779 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), int(GraphicType::Bitmap),
780 int(rGraphicObj.GetGraphic().GetType()));
781 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_uLong(864900),
782 rGraphicObj.GetGraphic().GetSizeBytes());
787 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf79082)
789 createSdImpressDoc("ppt/tdf79082.ppt");
790 save("impress8");
791 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
793 // P1 should have 6 tab stops defined
794 assertXPathChildren(
795 pXmlDoc, "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops"_ostr,
797 assertXPath(pXmlDoc,
798 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
799 "style:tab-stop[1]"_ostr,
800 "position"_ostr, "0cm");
801 assertXPath(pXmlDoc,
802 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
803 "style:tab-stop[2]"_ostr,
804 "position"_ostr, "5.08cm");
805 assertXPath(pXmlDoc,
806 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
807 "style:tab-stop[3]"_ostr,
808 "position"_ostr, "10.16cm");
809 assertXPath(pXmlDoc,
810 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
811 "style:tab-stop[4]"_ostr,
812 "position"_ostr, "15.24cm");
813 assertXPath(pXmlDoc,
814 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
815 "style:tab-stop[5]"_ostr,
816 "position"_ostr, "20.32cm");
817 assertXPath(pXmlDoc,
818 "//style:style[@style:name='P1']/style:paragraph-properties/style:tab-stops/"
819 "style:tab-stop[6]"_ostr,
820 "position"_ostr, "25.4cm");
823 CPPUNIT_TEST_FIXTURE(SdExportTest, testImageWithSpecialID)
825 // Check how LO handles when the imported graphic's ID is different from that one
826 // which is generated by LO.
828 std::vector<OUString> vFormat{ "impress8", "Impress Office Open XML", "MS PowerPoint 97" };
829 for (size_t i = 0; i < vFormat.size(); i++)
831 // Load the original file
832 createSdImpressDoc("odp/images_with_special_IDs.odp");
833 const OString sFailedMessage = "Failed on filter: " + vFormat[i].toUtf8();
834 saveAndReload(vFormat[i]);
836 // Check whether graphic was exported well
837 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
838 uno::UNO_QUERY_THROW);
839 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(2),
840 xDrawPagesSupplier->getDrawPages()->getCount());
841 uno::Reference<drawing::XDrawPage> xDrawPage(
842 xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW);
844 uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(2), uno::UNO_QUERY);
845 uno::Reference<beans::XPropertySet> XPropSet(xImage, uno::UNO_QUERY_THROW);
847 // Check Graphic, Size
849 uno::Reference<graphic::XGraphic> xGraphic;
850 XPropSet->getPropertyValue("Graphic") >>= xGraphic;
851 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
852 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(),
853 xGraphic->getType() != graphic::GraphicType::EMPTY);
854 uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
855 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
856 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(610),
857 xBitmap->getSize().Width);
858 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(381),
859 xBitmap->getSize().Height);
862 // Second Image
863 xDrawPage.set(xDrawPagesSupplier->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW);
864 xImage.set(xDrawPage->getByIndex(1), uno::UNO_QUERY);
865 XPropSet.set(xImage, uno::UNO_QUERY_THROW);
867 // Check Graphic, Size
869 uno::Reference<graphic::XGraphic> xGraphic;
870 XPropSet->getPropertyValue("Graphic") >>= xGraphic;
871 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
872 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(),
873 xGraphic->getType() != graphic::GraphicType::EMPTY);
874 uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
875 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xBitmap.is());
876 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(900),
877 xBitmap->getSize().Width);
878 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), static_cast<sal_Int32>(600),
879 xBitmap->getSize().Height);
884 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf62176)
886 createSdImpressDoc("odp/Tdf62176.odp");
887 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
889 //there should be only *one* shape
890 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage->getCount());
892 uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage));
893 //checking Paragraph's Left Margin with expected value
894 sal_Int32 nParaLeftMargin = 0;
895 xShape->getPropertyValue("ParaLeftMargin") >>= nParaLeftMargin;
896 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), nParaLeftMargin);
897 //checking Paragraph's First Line Indent with expected value
898 sal_Int32 nParaFirstLineIndent = 0;
899 xShape->getPropertyValue("ParaFirstLineIndent") >>= nParaFirstLineIndent;
900 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1300), nParaFirstLineIndent);
902 //Checking the *Text* in TextBox
903 uno::Reference<text::XTextRange> xParagraph(getParagraphFromShape(0, xShape));
904 CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), xParagraph->getString());
906 //Saving and Reloading the file
907 saveAndReload("impress8");
908 uno::Reference<drawing::XDrawPage> xPage2(getPage(0));
909 //there should be only *one* shape
910 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xPage2->getCount());
912 uno::Reference<beans::XPropertySet> xShape2(getShape(0, xPage2));
913 //checking Paragraph's Left Margin with expected value
914 sal_Int32 nParaLeftMargin2 = 0;
915 xShape2->getPropertyValue("ParaLeftMargin") >>= nParaLeftMargin2;
916 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), nParaLeftMargin2);
917 //checking Paragraph's First Line Indent with expected value
918 sal_Int32 nParaFirstLineIndent2 = 0;
919 xShape2->getPropertyValue("ParaFirstLineIndent") >>= nParaFirstLineIndent2;
920 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1300), nParaFirstLineIndent2);
922 //Checking the *Text* in TextBox
923 uno::Reference<text::XTextRange> xParagraph2(getParagraphFromShape(0, xShape2));
924 CPPUNIT_ASSERT_EQUAL(OUString("Hello World"), xParagraph2->getString());
927 CPPUNIT_TEST_FIXTURE(SdExportTest, testEmbeddedPdf)
929 auto pPdfium = vcl::pdf::PDFiumLibrary::get();
930 if (!pPdfium)
932 return;
935 createSdImpressDoc("odp/embedded-pdf.odp");
936 saveAndReload("impress8");
937 uno::Reference<drawing::XDrawPage> xPage = getPage(0);
938 uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
939 uno::Reference<graphic::XGraphic> xGraphic;
940 xShape->getPropertyValue("ReplacementGraphic") >>= xGraphic;
941 CPPUNIT_ASSERT(xGraphic.is());
944 CPPUNIT_TEST_FIXTURE(SdExportTest, testEmbeddedText)
946 createSdDrawDoc("objectwithtext.fodg");
947 saveAndReload("draw8");
949 uno::Reference<drawing::XDrawPage> xPage = getPage(0);
950 uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
951 uno::Reference<text::XText> xText(xShape, uno::UNO_QUERY);
952 CPPUNIT_ASSERT(xText.is());
954 uno::Reference<container::XEnumerationAccess> xEA(xShape, uno::UNO_QUERY);
955 CPPUNIT_ASSERT(xEA->hasElements());
956 uno::Reference<container::XEnumeration> xEnum(xEA->createEnumeration());
957 uno::Reference<text::XTextContent> xTC;
958 xEnum->nextElement() >>= xTC;
959 CPPUNIT_ASSERT(xTC.is());
961 uno::Reference<container::XEnumerationAccess> xParaEA(xTC, uno::UNO_QUERY);
962 uno::Reference<container::XEnumeration> xParaEnum(xParaEA->createEnumeration());
963 uno::Reference<beans::XPropertySet> xPortion(xParaEnum->nextElement(), uno::UNO_QUERY);
964 CPPUNIT_ASSERT(xPortion.is());
965 uno::Reference<text::XTextRange> xRange(xPortion, uno::UNO_QUERY);
966 OUString type;
967 xPortion->getPropertyValue("TextPortionType") >>= type;
968 CPPUNIT_ASSERT_EQUAL(OUString("Text"), type);
969 CPPUNIT_ASSERT_EQUAL(OUString("foobar"), xRange->getString()); //tdf#112547
972 CPPUNIT_TEST_FIXTURE(SdExportTest, testTransparenText)
974 createSdDrawDoc("transparent-text.fodg");
975 saveAndReload("draw8");
977 uno::Reference<drawing::XDrawPage> xPage = getPage(0);
978 uno::Reference<beans::XPropertySet> xShape(xPage->getByIndex(0), uno::UNO_QUERY);
979 sal_Int16 nCharTransparence = 0;
980 xShape->getPropertyValue("CharTransparence") >>= nCharTransparence;
982 // Without the accompanying fix in place, this test would have failed with:
983 // - Expected: 75
984 // - Actual : 0
985 // i.e. the 75% transparent text was turned into a "not transparent at all" text.
986 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(75), nCharTransparence);
989 CPPUNIT_TEST_FIXTURE(SdExportTest, testDefaultSubscripts)
991 createSdDrawDoc("tdf80194_defaultSubscripts.fodg");
992 saveAndReload("draw8");
994 uno::Reference<drawing::XDrawPage> xPage = getPage(0);
995 uno::Reference<drawing::XShape> xShape(xPage->getByIndex(1), uno::UNO_QUERY);
996 // Default subscripts were too large, enlarging the gap between the next line.
997 // The exact size isn't important. Was 18975, now 16604.
998 CPPUNIT_ASSERT(17000 > xShape->getSize().Height);
1001 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf98477)
1003 createSdImpressDoc("pptx/tdf98477grow.pptx");
1004 save("impress8");
1006 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1007 assertXPath(pXmlDoc, "//anim:animateTransform"_ostr, "by"_ostr, "0.5,0.5");
1010 CPPUNIT_TEST_FIXTURE(SdExportTest, testAuthorField)
1012 createSdImpressDoc("odp/author_fixed.odp");
1014 saveAndReload("impress8");
1016 uno::Reference<text::XTextField> xField = getTextFieldFromPage(0, 0, 0, 0);
1017 CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is());
1019 uno::Reference<beans::XPropertySet> xPropSet(xField, uno::UNO_QUERY_THROW);
1020 bool bFixed = false;
1021 xPropSet->getPropertyValue("IsFixed") >>= bFixed;
1022 CPPUNIT_ASSERT_MESSAGE("Author field is not fixed", bFixed);
1025 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf50499)
1027 createSdImpressDoc("pptx/tdf50499.pptx");
1029 save("impress8");
1031 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1032 assertXPath(pXmlDoc, "//anim:animate[1]"_ostr, "from"_ostr, "(-width/2)");
1033 assertXPath(pXmlDoc, "//anim:animate[1]"_ostr, "to"_ostr, "(x)");
1034 assertXPath(pXmlDoc, "//anim:animate[3]"_ostr, "by"_ostr, "(height/3+width*0.1)");
1037 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf100926)
1039 createSdImpressDoc("pptx/tdf100926_ODP.pptx");
1041 saveAndReload("impress8");
1043 const SdrPage* pPage = GetPage(1);
1044 CPPUNIT_ASSERT(pPage != nullptr);
1046 sdr::table::SdrTableObj* pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1047 CPPUNIT_ASSERT(pTableObj != nullptr);
1048 uno::Reference<table::XCellRange> xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
1050 sal_Int32 nRotation = 0;
1051 uno::Reference<beans::XPropertySet> xCell(xTable->getCellByPosition(0, 0),
1052 uno::UNO_QUERY_THROW);
1053 xCell->getPropertyValue("RotateAngle") >>= nRotation;
1054 CPPUNIT_ASSERT_EQUAL(sal_Int32(27000), nRotation);
1056 xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
1057 xCell->getPropertyValue("RotateAngle") >>= nRotation;
1058 CPPUNIT_ASSERT_EQUAL(sal_Int32(9000), nRotation);
1060 xCell.set(xTable->getCellByPosition(2, 0), uno::UNO_QUERY_THROW);
1061 xCell->getPropertyValue("RotateAngle") >>= nRotation;
1062 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), nRotation);
1065 CPPUNIT_TEST_FIXTURE(SdExportTest, testPageWithTransparentBackground)
1067 createSdImpressDoc("odp/page_transparent_background.odp");
1069 saveAndReload("impress8");
1070 uno::Reference<drawing::XDrawPagesSupplier> xDoc(mxComponent, uno::UNO_QUERY_THROW);
1071 CPPUNIT_ASSERT_EQUAL_MESSAGE("There should be exactly one page", static_cast<sal_Int32>(1),
1072 xDoc->getDrawPages()->getCount());
1074 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
1076 uno::Reference<beans::XPropertySet> xPropSet(xPage, uno::UNO_QUERY);
1077 uno::Any aAny = xPropSet->getPropertyValue("Background");
1078 CPPUNIT_ASSERT_MESSAGE("Slide background is missing", aAny.hasValue());
1080 uno::Reference<beans::XPropertySet> aXBackgroundPropSet;
1081 aAny >>= aXBackgroundPropSet;
1082 sal_Int32 nTransparence;
1083 aAny = aXBackgroundPropSet->getPropertyValue("FillTransparence");
1084 aAny >>= nTransparence;
1085 CPPUNIT_ASSERT_EQUAL_MESSAGE("Slide background transparency is wrong", sal_Int32(42),
1086 nTransparence);
1089 CPPUNIT_TEST_FIXTURE(SdExportTest, testTextRotation)
1091 // Save behavior depends on whether ODF strict or extended is used.
1092 Resetter _([]() {
1093 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
1094 comphelper::ConfigurationChanges::create());
1095 officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch);
1096 return pBatch->commit();
1099 // The contained shape has a text rotation vert="vert" which corresponds to
1100 // loext:writing-mode="tb-rl90" in the graphic-properties of the style of the shape in ODF 1.3
1101 // extended.
1102 // Save to ODF 1.3 extended. Adapt 3 (=ODFVER_LATEST) to a to be ODFVER_013_EXTENDED when
1103 // attribute value "tb-rl90" is included in ODF strict.
1105 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
1106 comphelper::ConfigurationChanges::create());
1107 officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch);
1108 pBatch->commit();
1110 createSdImpressDoc("pptx/shape-text-rotate.pptx");
1111 saveAndReload("impress8");
1113 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
1114 uno::Reference<beans::XPropertySet> xPropSet(getShape(0, xPage));
1115 CPPUNIT_ASSERT(xPropSet.is());
1117 auto aWritingMode = xPropSet->getPropertyValue("WritingMode").get<sal_Int16>();
1118 CPPUNIT_ASSERT_EQUAL(sal_Int16(text::WritingMode2::TB_RL90), aWritingMode);
1120 // In ODF 1.3 strict the workaround to use the TextRotateAngle is used instead.
1122 std::shared_ptr<comphelper::ConfigurationChanges> pBatch(
1123 comphelper::ConfigurationChanges::create());
1124 officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch);
1125 pBatch->commit();
1127 createSdImpressDoc("pptx/shape-text-rotate.pptx");
1128 saveAndReload("impress8");
1130 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
1131 uno::Reference<beans::XPropertySet> xPropSet(getShape(0, xPage));
1133 CPPUNIT_ASSERT(xPropSet.is());
1134 auto aGeomPropSeq = xPropSet->getPropertyValue("CustomShapeGeometry")
1135 .get<uno::Sequence<beans::PropertyValue>>();
1136 comphelper::SequenceAsHashMap aCustomShapeGeometry(aGeomPropSeq);
1138 auto it = aCustomShapeGeometry.find("TextRotateAngle");
1139 CPPUNIT_ASSERT(it != aCustomShapeGeometry.end());
1141 CPPUNIT_ASSERT_EQUAL(double(-90), aCustomShapeGeometry["TextRotateAngle"].get<double>());
1145 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf115394PPT)
1147 createSdImpressDoc("ppt/tdf115394.ppt");
1149 // Export the document and import again for a check
1150 saveAndReload("MS PowerPoint 97");
1152 double fTransitionDuration;
1154 // Fast
1155 SdXImpressDocument* pXImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get());
1156 CPPUNIT_ASSERT(pXImpressDocument);
1157 SdDrawDocument* pDoc = pXImpressDocument->GetDoc();
1158 SdPage* pPage1 = pDoc->GetSdPage(0, PageKind::Standard);
1159 fTransitionDuration = pPage1->getTransitionDuration();
1160 CPPUNIT_ASSERT_EQUAL(0.5, fTransitionDuration);
1162 // Medium
1163 SdPage* pPage2 = pDoc->GetSdPage(1, PageKind::Standard);
1164 fTransitionDuration = pPage2->getTransitionDuration();
1165 CPPUNIT_ASSERT_EQUAL(0.75, fTransitionDuration);
1167 // Slow
1168 SdPage* pPage3 = pDoc->GetSdPage(2, PageKind::Standard);
1169 fTransitionDuration = pPage3->getTransitionDuration();
1170 CPPUNIT_ASSERT_EQUAL(1.0, fTransitionDuration);
1173 CPPUNIT_TEST_FIXTURE(SdExportTest, testBulletsAsImageImpress8)
1175 createSdImpressDoc("odp/BulletsAsImage.odp");
1176 saveAndReload("impress8");
1178 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1179 uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
1180 uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
1182 uno::Reference<container::XIndexAccess> xLevels(xPropSet->getPropertyValue("NumberingRules"),
1183 uno::UNO_QUERY_THROW);
1184 uno::Sequence<beans::PropertyValue> aProperties;
1185 xLevels->getByIndex(0) >>= aProperties; // 1st level
1187 uno::Reference<awt::XBitmap> xBitmap;
1188 awt::Size aSize;
1189 sal_Int16 nNumberingType = -1;
1191 for (beans::PropertyValue const& rProperty : std::as_const(aProperties))
1193 if (rProperty.Name == "NumberingType")
1195 nNumberingType = rProperty.Value.get<sal_Int16>();
1197 else if (rProperty.Name == "GraphicBitmap")
1199 xBitmap = rProperty.Value.get<uno::Reference<awt::XBitmap>>();
1201 else if (rProperty.Name == "GraphicSize")
1203 aSize = rProperty.Value.get<awt::Size>();
1207 CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType);
1209 // Graphic Bitmap
1210 CPPUNIT_ASSERT_MESSAGE("No bitmap for the bullets", xBitmap.is());
1211 Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY));
1212 CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
1213 CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > o3tl::make_unsigned(0));
1215 CPPUNIT_ASSERT_EQUAL(tools::Long(16), aGraphic.GetSizePixel().Width());
1216 CPPUNIT_ASSERT_EQUAL(tools::Long(16), aGraphic.GetSizePixel().Height());
1218 // Graphic Size
1219 CPPUNIT_ASSERT_EQUAL(sal_Int32(500), aSize.Width);
1220 CPPUNIT_ASSERT_EQUAL(sal_Int32(500), aSize.Height);
1223 CPPUNIT_TEST_FIXTURE(SdExportTest, testBulletsAsImageImpressOfficeOpenXml)
1225 createSdImpressDoc("odp/BulletsAsImage.odp");
1226 saveAndReload("Impress Office Open XML");
1228 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1229 uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
1230 uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
1232 uno::Reference<container::XIndexAccess> xLevels(xPropSet->getPropertyValue("NumberingRules"),
1233 uno::UNO_QUERY_THROW);
1234 uno::Sequence<beans::PropertyValue> aProperties;
1235 xLevels->getByIndex(0) >>= aProperties; // 1st level
1237 uno::Reference<awt::XBitmap> xBitmap;
1238 awt::Size aSize;
1239 sal_Int16 nNumberingType = -1;
1241 for (beans::PropertyValue const& rProperty : std::as_const(aProperties))
1243 if (rProperty.Name == "NumberingType")
1245 nNumberingType = rProperty.Value.get<sal_Int16>();
1247 else if (rProperty.Name == "GraphicBitmap")
1249 xBitmap = rProperty.Value.get<uno::Reference<awt::XBitmap>>();
1251 else if (rProperty.Name == "GraphicSize")
1253 aSize = rProperty.Value.get<awt::Size>();
1257 CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType);
1259 // Graphic Bitmap
1260 CPPUNIT_ASSERT_MESSAGE("No bitmap for the bullets", xBitmap.is());
1261 Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY));
1262 CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
1263 CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > o3tl::make_unsigned(0));
1265 // FIXME: what happened here
1266 CPPUNIT_ASSERT_EQUAL(tools::Long(64), aGraphic.GetSizePixel().Width());
1267 CPPUNIT_ASSERT_EQUAL(tools::Long(64), aGraphic.GetSizePixel().Height());
1269 // Graphic Size
1270 // FIXME: totally wrong
1271 CPPUNIT_ASSERT_EQUAL(sal_Int32(790), aSize.Width);
1272 CPPUNIT_ASSERT_EQUAL(sal_Int32(790), aSize.Height);
1275 CPPUNIT_TEST_FIXTURE(SdExportTest, testBulletsAsImageMsPowerpoint97)
1277 createSdImpressDoc("odp/BulletsAsImage.odp");
1278 saveAndReload("MS PowerPoint 97");
1280 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1281 uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
1282 uno::Reference<beans::XPropertySet> xPropSet(xParagraph, uno::UNO_QUERY_THROW);
1284 uno::Reference<container::XIndexAccess> xLevels(xPropSet->getPropertyValue("NumberingRules"),
1285 uno::UNO_QUERY_THROW);
1286 uno::Sequence<beans::PropertyValue> aProperties;
1287 xLevels->getByIndex(0) >>= aProperties; // 1st level
1289 uno::Reference<awt::XBitmap> xBitmap;
1290 awt::Size aSize;
1291 sal_Int16 nNumberingType = -1;
1293 for (beans::PropertyValue const& rProperty : std::as_const(aProperties))
1295 if (rProperty.Name == "NumberingType")
1297 nNumberingType = rProperty.Value.get<sal_Int16>();
1299 else if (rProperty.Name == "GraphicBitmap")
1301 xBitmap = rProperty.Value.get<uno::Reference<awt::XBitmap>>();
1303 else if (rProperty.Name == "GraphicSize")
1305 aSize = rProperty.Value.get<awt::Size>();
1309 CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, nNumberingType);
1311 // Graphic Bitmap
1312 CPPUNIT_ASSERT_MESSAGE("No bitmap for the bullets", xBitmap.is());
1313 Graphic aGraphic(uno::Reference<graphic::XGraphic>(xBitmap, uno::UNO_QUERY));
1314 CPPUNIT_ASSERT_EQUAL(GraphicType::Bitmap, aGraphic.GetType());
1315 CPPUNIT_ASSERT(aGraphic.GetSizeBytes() > o3tl::make_unsigned(0));
1317 CPPUNIT_ASSERT_EQUAL(tools::Long(16), aGraphic.GetSizePixel().Width());
1318 CPPUNIT_ASSERT_EQUAL(tools::Long(16), aGraphic.GetSizePixel().Height());
1320 // Graphic Size
1321 // seems like a conversion error
1322 CPPUNIT_ASSERT_EQUAL(sal_Int32(504), aSize.Width);
1323 CPPUNIT_ASSERT_EQUAL(sal_Int32(504), aSize.Height);
1326 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf113822)
1328 createSdImpressDoc("pptx/tdf113822underline.pptx");
1330 // Was unable to export iterate container (tdf#99213).
1331 saveAndReload("Impress Office Open XML");
1332 // Was unable to import iterate container (tdf#113822).
1333 save("impress8");
1335 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1337 // IterateContainer was created as ParallelTimeContainer before, so
1338 // the iterate type is not set too.
1339 assertXPath(pXmlDoc, "//anim:iterate"_ostr, "iterate-type"_ostr, "by-letter");
1340 // The target of the child animation nodes need to be in the iterate container.
1341 assertXPath(pXmlDoc, "//anim:iterate"_ostr, "targetElement"_ostr, "id1");
1342 assertXPath(pXmlDoc, "//anim:iterate/anim:set"_ostr, "attributeName"_ostr, "text-underline");
1343 assertXPath(pXmlDoc, "//anim:iterate/anim:set"_ostr, "to"_ostr, "solid");
1346 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf113818)
1348 createSdImpressDoc("pptx/tdf113818-swivel.pptx");
1349 saveAndReload("MS PowerPoint 97");
1350 saveAndReload("Impress Office Open XML");
1351 save("impress8");
1353 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1354 assertXPath(pXmlDoc, "//anim:animate[1]"_ostr, "formula"_ostr, "width*sin(2.5*pi*$)");
1355 assertXPath(pXmlDoc, "//anim:animate[1]"_ostr, "values"_ostr, "0;1");
1358 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf119629)
1360 createSdImpressDoc("ppt/tdf119629.ppt");
1361 saveAndReload("MS PowerPoint 97");
1362 save("impress8");
1364 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1366 // MSO's effect node type Click parallel node, with group node, after group node
1367 // were missing.
1368 assertXPath(pXmlDoc,
1369 "//draw:page"
1370 "/anim:par[@presentation:node-type='timing-root']"
1371 "/anim:seq[@presentation:node-type='main-sequence']"
1372 "/anim:par[@presentation:node-type='on-click']"
1373 "/anim:par[@presentation:node-type='with-previous']"
1374 "/anim:par[@presentation:node-type='on-click']"
1375 "/anim:animate[@anim:formula='width*sin(2.5*pi*$)']"_ostr,
1379 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf141269)
1381 createSdImpressDoc("odp/tdf141269.odp");
1382 saveAndReload("MS PowerPoint 97");
1384 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0), uno::UNO_SET_THROW);
1385 CPPUNIT_ASSERT(xShape.is());
1387 uno::Reference<graphic::XGraphic> xGraphic;
1388 xShape->getPropertyValue("Graphic") >>= xGraphic;
1389 CPPUNIT_ASSERT(xGraphic.is());
1391 Graphic aGraphic(xGraphic);
1392 BitmapEx aBitmap(aGraphic.GetBitmapEx());
1393 CPPUNIT_ASSERT_EQUAL(tools::Long(1920), aBitmap.GetSizePixel().Width());
1394 CPPUNIT_ASSERT_EQUAL(tools::Long(1080), aBitmap.GetSizePixel().Height());
1396 Color aExpectedColor(0xC2DEEA);
1397 aExpectedColor.SetAlpha(0xF);
1399 // Without the fix in place, this test would have failed with
1400 // - Expected: Color: R:194 G:222 B:234 A:240
1401 // - Actual : Color: R:194 G:222 B:234 A:15
1402 CPPUNIT_ASSERT_EQUAL(aExpectedColor, aBitmap.GetPixelColor(960, 540));
1405 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf123557)
1407 createSdImpressDoc("pptx/trigger.pptx");
1408 saveAndReload("Impress Office Open XML");
1409 save("impress8");
1410 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1412 // Contains 2 interactive sequences and 3 triggered effects.
1413 assertXPath(pXmlDoc, "//draw:page"_ostr, 1);
1414 assertXPath(pXmlDoc, "//draw:page/anim:par"_ostr, 1);
1415 assertXPath(pXmlDoc,
1416 "//draw:page"
1417 "/anim:par[@presentation:node-type='timing-root']"
1418 "/anim:seq[@presentation:node-type='interactive-sequence']"_ostr,
1420 assertXPath(pXmlDoc,
1421 "//draw:page"
1422 "/anim:par[@presentation:node-type='timing-root']"
1423 "/anim:seq[@presentation:node-type='interactive-sequence']"
1424 "/anim:par[@smil:begin]"_ostr,
1428 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf126761)
1430 createSdImpressDoc("ppt/tdf126761.ppt");
1431 saveAndReload("impress8");
1432 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1434 // Get first paragraph of the text
1435 uno::Reference<text::XTextRange> const xParagraph(getParagraphFromShape(0, xShape));
1437 // Get first run of the paragraph
1438 uno::Reference<text::XTextRange> xRun(getRunFromParagraph(0, xParagraph));
1439 uno::Reference<beans::XPropertySet> xPropSet(xRun, uno::UNO_QUERY_THROW);
1441 // Check character underline, to make sure it has been set correctly
1442 sal_uInt32 nCharUnderline;
1443 xPropSet->getPropertyValue("CharUnderline") >>= nCharUnderline;
1444 CPPUNIT_ASSERT_EQUAL(sal_uInt32(1), nCharUnderline);
1447 CPPUNIT_TEST_FIXTURE(SdExportTest, testGlow)
1449 createSdDrawDoc("odg/glow.odg");
1450 saveAndReload("draw8");
1451 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1453 // Check glow properties
1454 sal_Int32 nGlowEffectRad = 0;
1455 CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectRadius") >>= nGlowEffectRad);
1456 CPPUNIT_ASSERT_EQUAL(sal_Int32(529), nGlowEffectRad); // 15 pt = 529.166... mm/100
1457 Color nGlowEffectColor;
1458 CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectColor") >>= nGlowEffectColor);
1459 CPPUNIT_ASSERT_EQUAL(Color(0x00FF4000), nGlowEffectColor); // "Brick"
1460 sal_Int16 nGlowEffectTransparency = 0;
1461 CPPUNIT_ASSERT(xShape->getPropertyValue("GlowEffectTransparency") >>= nGlowEffectTransparency);
1462 CPPUNIT_ASSERT_EQUAL(sal_Int16(60), nGlowEffectTransparency); // 60%
1464 // Test ODF element
1465 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1467 // check that we actually test graphic style
1468 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[2]"_ostr,
1469 "family"_ostr, "graphic");
1470 // check loext graphic attributes
1471 assertXPath(
1472 pXmlDoc,
1473 "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties"_ostr,
1474 "glow-radius"_ostr, "0.529cm");
1475 assertXPath(
1476 pXmlDoc,
1477 "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties"_ostr,
1478 "glow-color"_ostr, "#ff4000");
1479 assertXPath(
1480 pXmlDoc,
1481 "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties"_ostr,
1482 "glow-transparency"_ostr, "60%");
1485 CPPUNIT_TEST_FIXTURE(SdExportTest, testSoftEdges)
1487 createSdDrawDoc("odg/softedges.odg");
1488 saveAndReload("draw8");
1489 auto xShapeProps(getShapeFromPage(0, 0));
1491 // Check property
1492 sal_Int32 nRad = 0;
1493 CPPUNIT_ASSERT(xShapeProps->getPropertyValue("SoftEdgeRadius") >>= nRad);
1494 CPPUNIT_ASSERT_EQUAL(sal_Int32(635), nRad); // 18 pt
1496 // Test ODF element
1497 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1499 // check that we actually test graphic style
1500 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[2]"_ostr,
1501 "family"_ostr, "graphic");
1502 // check loext graphic attribute
1503 assertXPath(
1504 pXmlDoc,
1505 "/office:document-content/office:automatic-styles/style:style[2]/style:graphic-properties"_ostr,
1506 "softedge-radius"_ostr, "0.635cm");
1509 CPPUNIT_TEST_FIXTURE(SdExportTest, testShadowBlur)
1511 createSdImpressDoc("odp/shadow-blur.odp");
1512 saveAndReload("draw8");
1513 uno::Reference<beans::XPropertySet> xShape(getShapeFromPage(0, 0));
1515 sal_Int32 nRad = 0;
1516 CPPUNIT_ASSERT(xShape->getPropertyValue("ShadowBlur") >>= nRad);
1517 CPPUNIT_ASSERT_EQUAL(sal_Int32(388), nRad); // 11 pt = 388 Hmm
1519 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1521 assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[3]"_ostr,
1522 "family"_ostr, "graphic");
1523 assertXPath(
1524 pXmlDoc,
1525 "/office:document-content/office:automatic-styles/style:style[3]/style:graphic-properties"_ostr,
1526 "shadow-blur"_ostr, "0.388cm");
1529 CPPUNIT_TEST_FIXTURE(SdExportTest, testRhbz1870501)
1531 //Without the fix in place, it would crash at export time
1532 createSdDrawDoc("odg/rhbz1870501.odg");
1533 saveAndReload("draw8");
1536 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf152606)
1538 //Without the fix in place, it would crash at import time
1539 createSdImpressDoc("pptx/tdf152606.pptx");
1540 saveAndReload("Impress Office Open XML");
1542 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
1543 uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
1544 uno::UNO_QUERY);
1545 CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xDrawPage->getCount());
1548 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf154754)
1550 //Without the fix in place, it would crash at export time
1551 skipValidation();
1552 createSdImpressDoc("odp/tdf154754.odp");
1553 saveAndReload("impress8");
1556 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf91060)
1558 //Without the fix in place, it would crash at import time
1559 createSdImpressDoc("pptx/tdf91060.pptx");
1560 saveAndReload("Impress Office Open XML");
1563 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf128550)
1565 createSdImpressDoc("pptx/tdf128550.pptx");
1566 save("impress8");
1567 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1568 assertXPath(pXmlDoc, "//anim:iterate[@anim:sub-item='background']"_ostr, 1);
1569 assertXPath(pXmlDoc, "//anim:iterate[@anim:sub-item='text']"_ostr, 4);
1572 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf140714)
1574 //Without the fix in place, shape will be imported as GraphicObjectShape instead of CustomShape.
1576 createSdImpressDoc("pptx/tdf140714.pptx");
1577 saveAndReload("Impress Office Open XML");
1579 uno::Reference<drawing::XShape> xShape(getShapeFromPage(0, 0), uno::UNO_QUERY);
1580 CPPUNIT_ASSERT_EQUAL(OUString{ "com.sun.star.drawing.CustomShape" }, xShape->getShapeType());
1583 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf156649)
1585 createSdImpressDoc("pptx/tdf156649.pptx");
1586 saveAndReload("Impress Office Open XML");
1588 auto xShapeProps(getShapeFromPage(0, 0));
1589 // Without the fix in place, this test would have failed with
1590 //- Expected: 55
1591 //- Actual : 0
1592 // i.e. alphaModFix wasn't imported as fill transparency for the custom shape
1593 CPPUNIT_ASSERT_EQUAL(sal_Int16(55),
1594 xShapeProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1597 CPPUNIT_TEST_FIXTURE(SdExportTest, testMasterPageBackgroundFullSize)
1599 createSdImpressDoc("odp/background.odp");
1601 // BackgroundFullSize exists on master pages only
1602 // (note: this document can't be created with the UI because UI keeps
1603 // page margins and the flag synchronized across all master pages)
1604 uno::Reference<drawing::XMasterPagesSupplier> xMPS(mxComponent, uno::UNO_QUERY);
1605 uno::Reference<drawing::XDrawPages> xMPs(xMPS->getMasterPages());
1606 Color nFillColor;
1608 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(0), uno::UNO_QUERY);
1609 CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1610 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1611 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1612 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1613 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1614 uno::Reference<beans::XPropertySet> xBackgroundProps(
1615 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1616 CPPUNIT_ASSERT_EQUAL(
1617 drawing::FillStyle_SOLID,
1618 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1619 xBackgroundProps->getPropertyValue("FillColor") >>= nFillColor;
1620 CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), nFillColor);
1621 CPPUNIT_ASSERT_EQUAL(
1622 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1625 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(1), uno::UNO_QUERY);
1626 CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1627 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1628 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1629 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1630 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1631 uno::Reference<beans::XPropertySet> xBackgroundProps(
1632 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1633 CPPUNIT_ASSERT_EQUAL(
1634 drawing::FillStyle_SOLID,
1635 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1636 xBackgroundProps->getPropertyValue("FillColor") >>= nFillColor;
1637 CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), nFillColor);
1638 CPPUNIT_ASSERT_EQUAL(
1639 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1642 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(2), uno::UNO_QUERY);
1643 CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1644 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1645 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1646 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1647 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1648 uno::Reference<beans::XPropertySet> xBackgroundProps(
1649 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1650 CPPUNIT_ASSERT_EQUAL(
1651 drawing::FillStyle_BITMAP,
1652 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1653 CPPUNIT_ASSERT_EQUAL(
1654 drawing::BitmapMode_STRETCH,
1655 xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
1656 CPPUNIT_ASSERT_EQUAL(
1657 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1660 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(3), uno::UNO_QUERY);
1661 CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1662 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1663 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1664 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1665 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1666 uno::Reference<beans::XPropertySet> xBackgroundProps(
1667 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1668 CPPUNIT_ASSERT_EQUAL(
1669 drawing::FillStyle_BITMAP,
1670 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1671 CPPUNIT_ASSERT_EQUAL(
1672 drawing::BitmapMode_STRETCH,
1673 xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
1674 CPPUNIT_ASSERT_EQUAL(
1675 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1678 saveAndReload("impress8");
1680 xMPS.set(mxComponent, uno::UNO_QUERY);
1681 xMPs.set(xMPS->getMasterPages());
1683 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(0), uno::UNO_QUERY);
1684 CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1685 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1686 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1687 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1688 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1689 uno::Reference<beans::XPropertySet> xBackgroundProps(
1690 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1691 CPPUNIT_ASSERT_EQUAL(
1692 drawing::FillStyle_SOLID,
1693 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1694 xBackgroundProps->getPropertyValue("FillColor") >>= nFillColor;
1695 CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), nFillColor);
1696 CPPUNIT_ASSERT_EQUAL(
1697 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1700 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(1), uno::UNO_QUERY);
1701 CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1702 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1703 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1704 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1705 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1706 uno::Reference<beans::XPropertySet> xBackgroundProps(
1707 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1708 CPPUNIT_ASSERT_EQUAL(
1709 drawing::FillStyle_SOLID,
1710 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1711 xBackgroundProps->getPropertyValue("FillColor") >>= nFillColor;
1712 CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), nFillColor);
1713 CPPUNIT_ASSERT_EQUAL(
1714 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1717 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(2), uno::UNO_QUERY);
1718 CPPUNIT_ASSERT(!xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1719 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1720 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1721 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1722 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1723 uno::Reference<beans::XPropertySet> xBackgroundProps(
1724 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1725 CPPUNIT_ASSERT_EQUAL(
1726 drawing::FillStyle_BITMAP,
1727 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1728 CPPUNIT_ASSERT_EQUAL(
1729 drawing::BitmapMode_STRETCH,
1730 xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
1731 CPPUNIT_ASSERT_EQUAL(
1732 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1735 uno::Reference<beans::XPropertySet> xMP(xMPs->getByIndex(3), uno::UNO_QUERY);
1736 CPPUNIT_ASSERT(xMP->getPropertyValue("BackgroundFullSize").get<bool>());
1737 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderTop").get<sal_Int32>());
1738 CPPUNIT_ASSERT_EQUAL(sal_Int32(2000), xMP->getPropertyValue("BorderLeft").get<sal_Int32>());
1739 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderBottom").get<sal_Int32>());
1740 CPPUNIT_ASSERT_EQUAL(sal_Int32(0), xMP->getPropertyValue("BorderRight").get<sal_Int32>());
1741 uno::Reference<beans::XPropertySet> xBackgroundProps(
1742 xMP->getPropertyValue("Background").get<uno::Reference<beans::XPropertySet>>());
1743 CPPUNIT_ASSERT_EQUAL(
1744 drawing::FillStyle_BITMAP,
1745 xBackgroundProps->getPropertyValue("FillStyle").get<drawing::FillStyle>());
1746 CPPUNIT_ASSERT_EQUAL(
1747 drawing::BitmapMode_STRETCH,
1748 xBackgroundProps->getPropertyValue("FillBitmapMode").get<drawing::BitmapMode>());
1749 CPPUNIT_ASSERT_EQUAL(
1750 sal_Int16(0), xBackgroundProps->getPropertyValue("FillTransparence").get<sal_Int16>());
1753 xmlDocUniquePtr pXmlDoc = parseExport("styles.xml");
1754 assertXPath(pXmlDoc,
1755 "/office:document-styles/office:automatic-styles/"
1756 "style:style[@style:family='drawing-page' and @style:name = "
1757 "/office:document-styles/office:master-styles/"
1758 "style:master-page[@style:name='Default']/attribute::draw:style-name"
1759 "]/style:drawing-page-properties"_ostr,
1760 "background-size"_ostr, "border");
1761 assertXPath(pXmlDoc,
1762 "/office:document-styles/office:automatic-styles/"
1763 "style:style[@style:family='drawing-page' and @style:name = "
1764 "/office:document-styles/office:master-styles/"
1765 "style:master-page[@style:name='Default_20_3']/attribute::draw:style-name"
1766 "]/style:drawing-page-properties"_ostr,
1767 "background-size"_ostr, "full");
1768 assertXPath(pXmlDoc,
1769 "/office:document-styles/office:automatic-styles/"
1770 "style:style[@style:family='drawing-page' and @style:name = "
1771 "/office:document-styles/office:master-styles/"
1772 "style:master-page[@style:name='Default_20_2']/attribute::draw:style-name"
1773 "]/style:drawing-page-properties"_ostr,
1774 "background-size"_ostr, "border");
1775 assertXPath(pXmlDoc,
1776 "/office:document-styles/office:automatic-styles/"
1777 "style:style[@style:family='drawing-page' and @style:name = "
1778 "/office:document-styles/office:master-styles/"
1779 "style:master-page[@style:name='Default_20_1']/attribute::draw:style-name"
1780 "]/style:drawing-page-properties"_ostr,
1781 "background-size"_ostr, "full");
1784 CPPUNIT_TEST_FIXTURE(SdExportTest, testColumnsODG)
1786 createSdDrawDoc("odg/two_columns.odg");
1789 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
1790 uno::UNO_QUERY_THROW);
1791 uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages();
1792 uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW);
1793 uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW);
1794 uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
1795 uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW);
1796 uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"),
1797 uno::UNO_QUERY_THROW);
1798 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCols->getColumnCount());
1799 uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW);
1800 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(700)),
1801 xColProps->getPropertyValue("AutomaticDistance"));
1803 auto pTextObj = DynCastSdrTextObj(SdrObject::getSdrObjectFromXShape(xShape));
1804 CPPUNIT_ASSERT(pTextObj);
1806 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pTextObj->GetTextColumnsNumber());
1807 CPPUNIT_ASSERT_EQUAL(sal_Int32(700), pTextObj->GetTextColumnsSpacing());
1810 saveAndReload("draw8");
1813 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
1814 uno::UNO_QUERY_THROW);
1815 uno::Reference<drawing::XDrawPages> xPages = xDrawPagesSupplier->getDrawPages();
1816 uno::Reference<drawing::XDrawPage> xPage(xPages->getByIndex(0), uno::UNO_QUERY_THROW);
1817 uno::Reference<container::XIndexAccess> xIndexAccess(xPage, uno::UNO_QUERY_THROW);
1818 uno::Reference<drawing::XShape> xShape(xIndexAccess->getByIndex(0), uno::UNO_QUERY_THROW);
1819 uno::Reference<beans::XPropertySet> xProps(xShape, uno::UNO_QUERY_THROW);
1820 uno::Reference<text::XTextColumns> xCols(xProps->getPropertyValue("TextColumns"),
1821 uno::UNO_QUERY_THROW);
1822 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCols->getColumnCount());
1823 uno::Reference<beans::XPropertySet> xColProps(xCols, uno::UNO_QUERY_THROW);
1824 CPPUNIT_ASSERT_EQUAL(uno::Any(sal_Int32(700)),
1825 xColProps->getPropertyValue("AutomaticDistance"));
1827 auto pTextObj = DynCastSdrTextObj(SdrObject::getSdrObjectFromXShape(xShape));
1828 CPPUNIT_ASSERT(pTextObj);
1830 CPPUNIT_ASSERT_EQUAL(sal_Int16(2), pTextObj->GetTextColumnsNumber());
1831 CPPUNIT_ASSERT_EQUAL(sal_Int32(700), pTextObj->GetTextColumnsSpacing());
1834 xmlDocUniquePtr pXmlDoc = parseExport("content.xml");
1835 assertXPath(pXmlDoc,
1836 "/office:document-content/office:automatic-styles/style:style/"
1837 "style:graphic-properties/style:columns"_ostr,
1838 "column-count"_ostr, "2");
1839 assertXPath(pXmlDoc,
1840 "/office:document-content/office:automatic-styles/style:style/"
1841 "style:graphic-properties/style:columns"_ostr,
1842 "column-gap"_ostr, "0.7cm");
1845 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf112126)
1847 createSdDrawDoc("tdf112126.odg");
1848 saveAndReload("draw8");
1849 uno::Reference<drawing::XDrawPage> xPage(getPage(0));
1850 uno::Reference<beans::XPropertySet> xPropertySet(xPage, uno::UNO_QUERY);
1852 OUString xPageName;
1853 xPropertySet->getPropertyValue("LinkDisplayName") >>= xPageName;
1855 // without the fix in place, it fails with
1856 // - Expected: Page 1
1857 // - Actual : Slide 1
1858 CPPUNIT_ASSERT_EQUAL(OUString("Page 1"), xPageName);
1861 CPPUNIT_TEST_FIXTURE(SdExportTest, testCellProperties)
1863 // Silence unrelated failure:
1864 // Error: element "table:table-template" is missing "first-row-start-column" attribute
1865 // Looks like an oversight in the schema, as the docs claim this attribute is deprecated.
1866 skipValidation();
1868 createSdDrawDoc("odg/tablestyles.fodg");
1869 saveAndReload("draw8");
1871 const SdrPage* pPage = GetPage(1);
1872 auto pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
1873 CPPUNIT_ASSERT(pTableObj != nullptr);
1874 uno::Reference<beans::XPropertySet> xCell(pTableObj->getTable()->getCellByPosition(0, 0),
1875 uno::UNO_QUERY_THROW);
1877 Color nColor;
1878 table::BorderLine2 aBorderLine;
1879 drawing::TextVerticalAdjust aTextAdjust;
1880 sal_Int32 nPadding;
1882 xCell->getPropertyValue("FillColor") >>= nColor;
1883 CPPUNIT_ASSERT_EQUAL(Color(0xffcc99), nColor);
1884 xCell->getPropertyValue("RightBorder") >>= aBorderLine;
1885 CPPUNIT_ASSERT_EQUAL(Color(0x99ccff), Color(ColorTransparency, aBorderLine.Color));
1886 CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aBorderLine.LineWidth);
1887 xCell->getPropertyValue("TextRightDistance") >>= nPadding;
1888 CPPUNIT_ASSERT_EQUAL(sal_Int32(300), nPadding);
1889 xCell->getPropertyValue("TextVerticalAdjust") >>= aTextAdjust;
1890 CPPUNIT_ASSERT_EQUAL(drawing::TextVerticalAdjust::TextVerticalAdjust_CENTER, aTextAdjust);
1893 CPPUNIT_TEST_FIXTURE(SdExportTest, testUserTableStyles)
1895 // Silence unrelated failure:
1896 // Error: element "table:table-template" is missing "first-row-start-column" attribute
1897 // Looks like an oversight in the schema, as the docs claim this attribute is deprecated.
1898 skipValidation();
1900 createSdDrawDoc("odg/tablestyles.fodg");
1901 saveAndReload("draw8");
1903 uno::Reference<style::XStyleFamiliesSupplier> xStyleFamiliesSupplier(mxComponent,
1904 uno::UNO_QUERY);
1905 uno::Reference<container::XNameAccess> xStyleFamily(
1906 xStyleFamiliesSupplier->getStyleFamilies()->getByName("table"), uno::UNO_QUERY);
1908 uno::Reference<style::XStyle> xTableStyle(xStyleFamily->getByName("default"), uno::UNO_QUERY);
1909 CPPUNIT_ASSERT(!xTableStyle->isUserDefined());
1911 uno::Reference<container::XNameAccess> xNameAccess(xTableStyle, uno::UNO_QUERY);
1912 uno::Reference<style::XStyle> xCellStyle(xNameAccess->getByName("first-row"), uno::UNO_QUERY);
1913 CPPUNIT_ASSERT(xCellStyle);
1914 CPPUNIT_ASSERT_EQUAL(OUString("userdefined"), xCellStyle->getName());
1916 CPPUNIT_ASSERT(xStyleFamily->hasByName("userdefined"));
1917 xTableStyle.set(xStyleFamily->getByName("userdefined"), uno::UNO_QUERY);
1918 CPPUNIT_ASSERT(xTableStyle->isUserDefined());
1921 CPPUNIT_TEST_FIXTURE(SdExportTest, testTdf153179)
1923 createSdImpressDoc("pptx/ole-emf_min.pptx");
1924 saveAndReload("impress8");
1926 // Check number of shapes after export.
1927 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getPage(0)->getCount());
1930 CPPUNIT_TEST_FIXTURE(SdExportTest, testSvgImageSupport)
1932 for (OUString const& rFormat : { u"impress8"_ustr, u"Impress Office Open XML"_ustr })
1934 // Load the original file
1935 createSdImpressDoc("odp/SvgImageTest.odp");
1936 // Save into the target format
1937 saveAndReload(rFormat);
1939 const OString sFailedMessage = "Failed on filter: " + rFormat.toUtf8();
1941 // Check whether SVG graphic was exported as expected
1942 uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent,
1943 uno::UNO_QUERY_THROW);
1944 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(1),
1945 xDrawPagesSupplier->getDrawPages()->getCount());
1946 uno::Reference<drawing::XDrawPage> xDrawPage(
1947 xDrawPagesSupplier->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
1948 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xDrawPage.is());
1950 // Get the image
1951 uno::Reference<drawing::XShape> xImage(xDrawPage->getByIndex(0), uno::UNO_QUERY);
1952 uno::Reference<beans::XPropertySet> xPropertySet(xImage, uno::UNO_QUERY_THROW);
1954 // Convert to a XGraphic
1955 uno::Reference<graphic::XGraphic> xGraphic;
1956 xPropertySet->getPropertyValue("Graphic") >>= xGraphic;
1957 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), xGraphic.is());
1959 // Access the Graphic
1960 Graphic aGraphic(xGraphic);
1962 // Check if it contains a VectorGraphicData struct
1963 auto pVectorGraphic = aGraphic.getVectorGraphicData();
1964 CPPUNIT_ASSERT_MESSAGE(sFailedMessage.getStr(), pVectorGraphic);
1966 // Which should be of type SVG, which means we have a SVG file
1967 CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), VectorGraphicDataType::Svg,
1968 pVectorGraphic->getType());
1972 CPPUNIT_PLUGIN_IMPLEMENT();
1974 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */