Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / sd / qa / unit / export-tests-ooxml1.cxx
blob05d7d3aff31b0a14bd6b6b2049bb3fec5443d735
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 */
9 #include <officecfg/Office/Common.hxx>
10 #include "sdmodeltestbase.hxx"
11 #include <Outliner.hxx>
12 #include <editeng/eeitem.hxx>
13 #include <editeng/editobj.hxx>
14 #include <editeng/outlobj.hxx>
15 #include <editeng/fhgtitem.hxx>
16 #include <editeng/escapementitem.hxx>
17 #include <editeng/colritem.hxx>
18 #include <editeng/fontitem.hxx>
19 #include <editeng/wghtitem.hxx>
20 #include <editeng/numitem.hxx>
21 #include <editeng/postitem.hxx>
23 #include <oox/drawingml/drawingmltypes.hxx>
25 #include <svx/svdoutl.hxx>
26 #include <svx/svdotext.hxx>
27 #include <svx/svdoashp.hxx>
28 #include <svx/svdogrp.hxx>
29 #include <svx/xflclit.hxx>
30 #include <svx/xlineit0.hxx>
31 #include <svx/sdooitm.hxx>
32 #include <svx/sdmetitm.hxx>
33 #include <unotools/mediadescriptor.hxx>
34 #include <rtl/ustring.hxx>
36 #include <com/sun/star/drawing/XDrawPage.hpp>
37 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/awt/Gradient.hpp>
40 #include <com/sun/star/awt/FontDescriptor.hpp>
41 #include <com/sun/star/frame/XStorable.hpp>
42 #include <com/sun/star/drawing/FillStyle.hpp>
43 #include <com/sun/star/drawing/LineDash.hpp>
44 #include <com/sun/star/text/WritingMode2.hpp>
45 #include <com/sun/star/table/BorderLine2.hpp>
46 #include <com/sun/star/table/XTable.hpp>
47 #include <com/sun/star/table/XMergeableCell.hpp>
49 #include <svx/svdotable.hxx>
50 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
52 using namespace css;
54 class SdOOXMLExportTest1 : public SdModelTestBaseXML
56 public:
57 void testFdo90607();
58 void testBnc870233_1();
59 void testBnc870233_2();
60 void testN828390_4();
61 void testN828390_5();
62 void testFdo71961();
63 void testN828390();
64 void testBnc880763();
65 void testBnc862510_5();
66 void testBnc822347_EmptyBullet();
67 void testFdo83751();
68 void testFdo79731();
69 void testTableCellFillProperties();
70 void testBulletStartNumber();
71 void testLineStyle();
72 void testCellLeftAndRightMargin();
73 void testRightToLeftParaghraph();
74 void testTextboxWithHyperlink();
75 void testMergedCells();
76 void testTableCellBorder();
77 void testBulletColor();
78 void testBulletCharAndFont();
79 void testBulletMarginAndIndentation();
80 void testParaMarginAndindentation();
81 void testTdf111884();
82 void testTdf112633();
83 void testCustomXml();
84 void testTdf94238();
85 void testPictureTransparency();
86 void testTdf125554();
87 void testRoundtripOwnLineStyles();
88 void testRoundtripPrstDash();
89 void testDashOnHairline();
91 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1);
93 CPPUNIT_TEST(testFdo90607);
94 CPPUNIT_TEST(testBnc870233_1);
95 CPPUNIT_TEST(testBnc870233_2);
96 CPPUNIT_TEST(testN828390_4);
97 CPPUNIT_TEST(testN828390_5);
98 CPPUNIT_TEST(testFdo71961);
99 CPPUNIT_TEST(testN828390);
100 CPPUNIT_TEST(testBnc880763);
101 CPPUNIT_TEST(testBnc862510_5);
102 CPPUNIT_TEST(testBnc822347_EmptyBullet);
103 CPPUNIT_TEST(testFdo83751);
104 CPPUNIT_TEST(testFdo79731);
105 CPPUNIT_TEST(testTableCellFillProperties);
106 CPPUNIT_TEST(testBulletStartNumber);
107 CPPUNIT_TEST(testLineStyle);
108 CPPUNIT_TEST(testCellLeftAndRightMargin);
109 CPPUNIT_TEST(testRightToLeftParaghraph);
110 CPPUNIT_TEST(testTextboxWithHyperlink);
111 CPPUNIT_TEST(testMergedCells);
112 CPPUNIT_TEST(testTableCellBorder);
113 CPPUNIT_TEST(testBulletColor);
114 CPPUNIT_TEST(testBulletCharAndFont);
115 CPPUNIT_TEST(testBulletMarginAndIndentation);
116 CPPUNIT_TEST(testParaMarginAndindentation);
117 CPPUNIT_TEST(testTdf111884);
118 CPPUNIT_TEST(testTdf112633);
119 CPPUNIT_TEST(testCustomXml);
120 CPPUNIT_TEST(testTdf94238);
121 CPPUNIT_TEST(testTdf125554);
122 CPPUNIT_TEST(testPictureTransparency);
123 CPPUNIT_TEST(testRoundtripOwnLineStyles);
124 CPPUNIT_TEST(testRoundtripPrstDash);
125 CPPUNIT_TEST(testDashOnHairline);
127 CPPUNIT_TEST_SUITE_END();
129 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
131 static const struct { char const * pPrefix; char const * pURI; } namespaces[] =
133 // OOXML
134 { "ContentType", "http://schemas.openxmlformats.org/package/2006/content-types" },
135 { "rels", "http://schemas.openxmlformats.org/package/2006/relationships" },
136 { "mc", "http://schemas.openxmlformats.org/markup-compatibility/2006" },
137 { "v", "urn:schemas-microsoft-com:vml" },
138 { "a", "http://schemas.openxmlformats.org/drawingml/2006/main" },
139 { "c", "http://schemas.openxmlformats.org/drawingml/2006/chart" },
140 { "m", "http://schemas.openxmlformats.org/officeDocument/2006/math" },
141 { "pic", "http://schemas.openxmlformats.org/drawingml/2006/picture" },
142 { "wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" },
143 { "p", "http://schemas.openxmlformats.org/presentationml/2006/main" },
144 { "w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main" },
145 { "a14", "http://schemas.microsoft.com/office/drawing/2010/main" },
146 { "wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" },
147 { "wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" },
149 for (size_t i = 0; i < SAL_N_ELEMENTS(namespaces); ++i)
151 xmlXPathRegisterNs(pXmlXPathCtx,
152 reinterpret_cast<xmlChar const *>(namespaces[i].pPrefix),
153 reinterpret_cast<xmlChar const *>(namespaces[i].pURI));
158 namespace {
160 template< typename ItemValue, typename ItemType >
161 void checkFontAttributes( const SdrTextObj* pObj, ItemValue nVal)
163 CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
164 const EditTextObject& aEdit = pObj->GetOutlinerParaObject()->GetTextObject();
165 std::vector<EECharAttrib> rLst;
166 aEdit.GetCharAttribs(0, rLst);
167 for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
169 const ItemType* pAttrib = dynamic_cast<const ItemType *>((*it).pAttr);
170 if (pAttrib)
172 CPPUNIT_ASSERT_EQUAL( nVal, static_cast<ItemValue>(pAttrib->GetValue()));
179 void SdOOXMLExportTest1::testBnc870233_1()
181 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_1.pptx"), PPTX);
182 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
184 const SdrPage *pPage = GetPage( 1, xDocShRef );
186 // The problem was all shapes had the same font (the last parsed font attributes overwrote all previous ones)
188 // First shape has red, bold font
190 const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 0 ) );
191 checkFontAttributes<Color, SvxColorItem>( pObj, Color(0xff0000) );
192 checkFontAttributes<FontWeight, SvxWeightItem>( pObj, WEIGHT_BOLD );
195 // Second shape has blue, italic font
197 const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>( pPage->GetObj( 1 ) );
198 checkFontAttributes<Color, SvxColorItem>( pObj, Color(0x0000ff) );
199 checkFontAttributes<FontItalic, SvxPostureItem>( pObj, ITALIC_NORMAL );
202 xDocShRef->DoClose();
205 void SdOOXMLExportTest1::testBnc870233_2()
207 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_2.pptx"), PPTX);
208 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
210 const SdrPage *pPage = GetPage( 1, xDocShRef );
212 // The problem was in some SmartArts font color was wrong
214 // First smart art has blue font color (direct formatting)
216 const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(0));
217 CPPUNIT_ASSERT(pObjGroup);
218 const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>(pObjGroup->GetSubList()->GetObj(0));
219 checkFontAttributes<Color, SvxColorItem>(pObj, Color(0x0000ff));
222 // Second smart art has "dk2" font color (style)
224 const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(1));
225 CPPUNIT_ASSERT(pObjGroup);
226 const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>(pObjGroup->GetSubList()->GetObj(0));
227 checkFontAttributes<Color, SvxColorItem>( pObj, Color(0x1F497D) );
230 // Third smart art has white font color (style)
232 const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(2));
233 CPPUNIT_ASSERT(pObjGroup);
234 const SdrTextObj *pObj = dynamic_cast<SdrTextObj *>(pObjGroup->GetSubList()->GetObj(0));
235 checkFontAttributes<Color, SvxColorItem>(pObj, Color(0xffffff));
238 xDocShRef->DoClose();
241 void SdOOXMLExportTest1::testN828390_4()
243 bool bPassed = false;
244 ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/n828390_4.odp"), ODP );
246 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
248 const SdrPage *pPage = GetPage( 1, xDocShRef );
250 std::vector<EECharAttrib> rLst;
251 SdrObject *pObj = pPage->GetObj(0);
252 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
253 CPPUNIT_ASSERT( pTxtObj );
254 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
255 aEdit.GetCharAttribs(0, rLst);
256 for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
258 const SvxFontHeightItem * pFontHeight = dynamic_cast<const SvxFontHeightItem *>((*it).pAttr);
259 if( pFontHeight && (*it).nStart == 18 )
260 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font height is wrong", static_cast<sal_uInt32>(1129), pFontHeight->GetHeight() );
261 const SvxFontItem *pFont = dynamic_cast<const SvxFontItem *>((*it).pAttr);
262 if( pFont )
264 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font is wrong", OUString("Arial"), pFont->GetFamilyName() );
265 bPassed = true;
267 const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr);
268 if( pWeight && (*it).nStart == 18 )
269 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font Weight is wrong", WEIGHT_BOLD, pWeight->GetWeight() );
272 CPPUNIT_ASSERT(bPassed);
274 xDocShRef->DoClose();
277 void SdOOXMLExportTest1::testN828390_5()
279 ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/n828390_5.odp"), ODP );
281 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
283 const SdrPage *pPage = GetPage( 1, xDocShRef );
285 SdrObject *pObj = pPage->GetObj(0);
286 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
287 CPPUNIT_ASSERT( pTxtObj );
288 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
289 const SvxNumBulletItem& rNumFmt = aEdit.GetParaAttribs(3).Get(EE_PARA_NUMBULLET);
290 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's relative size is wrong!", sal_uInt16(75), rNumFmt.GetNumRule()->GetLevel(1).GetBulletRelSize() ); // != 25
293 xDocShRef->DoClose();
296 void SdOOXMLExportTest1::testFdo71961()
298 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/fdo71961.odp"), ODP);
300 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
301 const SdrPage *pPage = GetPage( 1, xDocShRef );
303 // Export to .pptx changes all text frames to custom shape objects, which obey TextWordWrap property
304 // (which is false for text frames otherwise and is ignored). Check that frames that should wrap still do.
305 SdrObjCustomShape *pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 1 ));
306 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
307 CPPUNIT_ASSERT_EQUAL( OUString( "Text to be always wrapped" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
308 CPPUNIT_ASSERT_EQUAL( true, pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP).GetValue());
310 pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 2 ));
311 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
312 CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape non-wrapped text" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
313 CPPUNIT_ASSERT_EQUAL( false, pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP).GetValue());
315 pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 3 ));
316 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
317 CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape wrapped text" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
318 CPPUNIT_ASSERT_EQUAL( true, pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP).GetValue());
320 xDocShRef->DoClose();
323 void SdOOXMLExportTest1::testN828390()
325 bool bPassed = false;
326 ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n828390.pptx"), PPTX );
328 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
330 const SdrPage *pPage = GetPage( 1, xDocShRef );
332 std::vector<EECharAttrib> rLst;
333 // Get the object
334 SdrObject *pObj = pPage->GetObj(0);
335 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
336 CPPUNIT_ASSERT( pTxtObj );
337 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
338 aEdit.GetCharAttribs(0, rLst);
339 bPassed = std::any_of(rLst.rbegin(), rLst.rend(),
340 [](const EECharAttrib& rCharAttr) {
341 const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>(rCharAttr.pAttr);
342 return pFontEscapement && (pFontEscapement->GetEsc() == -25);
345 CPPUNIT_ASSERT_MESSAGE("Subscript not exported properly", bPassed);
347 xDocShRef->DoClose();
350 void SdOOXMLExportTest1::testBnc880763()
352 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc880763.pptx"), PPTX);
353 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
355 const SdrPage *pPage = GetPage( 1, xDocShRef );
357 // Check z-order of the two shapes, use background color to identify them
358 // First object in the background has blue background color
359 const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(0));
360 CPPUNIT_ASSERT(pObjGroup);
361 const SdrObject *pObj = pObjGroup->GetSubList()->GetObj(1);
362 CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
363 CPPUNIT_ASSERT_EQUAL( Color(0x0000ff),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue());
365 // Second object at the front has green background color
366 pObj = pPage->GetObj(1);
367 CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
368 CPPUNIT_ASSERT_EQUAL( Color(0x00ff00),(static_cast< const XColorItem& >(pObj->GetMergedItem(XATTR_FILLCOLOR))).GetColorValue());
370 xDocShRef->DoClose();
373 void SdOOXMLExportTest1::testBnc862510_5()
375 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_5.pptx"), PPTX);
376 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
378 const SdrPage *pPage = GetPage( 1, xDocShRef );
380 // Same as testBnc870237, but here we check the horizontal spacing
381 const SdrObjGroup *pObjGroup = dynamic_cast<SdrObjGroup *>(pPage->GetObj(0));
382 CPPUNIT_ASSERT(pObjGroup);
383 const SdrObject* pObj = pObjGroup->GetSubList()->GetObj(2);
384 CPPUNIT_ASSERT_MESSAGE( "no object", pObj != nullptr);
385 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST).GetValue());
386 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST).GetValue());
387 CPPUNIT_ASSERT_EQUAL( sal_Int32(7510), pObj->GetMergedItem(SDRATTR_TEXT_RIGHTDIST).GetValue());
388 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj->GetMergedItem(SDRATTR_TEXT_LEFTDIST).GetValue());
390 xDocShRef->DoClose();
393 // In numbering a bullet could be defined as empty (no character).
394 // When exporting to OOXML make sure that the bullet is ignored and
395 // not written into the file.
396 void SdOOXMLExportTest1::testBnc822347_EmptyBullet()
398 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/bnc822347_EmptyBullet.odp"), ODP);
399 xDocShRef = saveAndReload( xDocShRef.get(), PPTX);
401 SdDrawDocument* pDoc = xDocShRef->GetDoc();
402 SdrOutliner* pOutliner = pDoc->GetInternalOutliner();
403 const SdrPage* pPage = pDoc->GetPage(1);
404 SdrObject* pObject = pPage->GetObj(0);
405 SdrTextObj* pTextObject = dynamic_cast<SdrTextObj*>(pObject);
406 CPPUNIT_ASSERT(pTextObject);
408 OutlinerParaObject* pOutlinerParagraphObject = pTextObject->GetOutlinerParaObject();
409 const EditTextObject& aEdit = pOutlinerParagraphObject->GetTextObject();
411 OUString sText = aEdit.GetText(0);
412 CPPUNIT_ASSERT_EQUAL(OUString("M3 Feature Test"), sText);
414 pOutliner->SetText(*pOutlinerParagraphObject);
415 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pOutliner->GetParagraphCount());
417 const sal_Int16 nDepth = pOutliner->GetDepth(0);
419 CPPUNIT_ASSERT_EQUAL(sal_Int16(-1), nDepth); // depth >= 0 means that the paragraph has bullets enabled
421 xDocShRef->DoClose();
424 //Bullets not having any text following them are not getting exported to pptx correctly.
425 void SdOOXMLExportTest1::testFdo90607()
427 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/fdo90607.pptx"), PPTX);
428 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
430 const SdrPage *pPage = GetPage( 1, xDocShRef );
431 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(1) );
432 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
433 OutlinerParaObject* pOutlinerParagraphObject = pTxtObj->GetOutlinerParaObject();
434 const sal_Int16 nDepth = pOutlinerParagraphObject->GetDepth(0);
435 CPPUNIT_ASSERT_MESSAGE("not equal", nDepth != -1);
436 xDocShRef->DoClose();
439 void SdOOXMLExportTest1::testFdo83751()
441 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/fdo83751.pptx"), PPTX);
442 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
444 SdDrawDocument *pDoc = xDocShRef->GetDoc();
445 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
447 uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier( xDocShRef->GetModel(), uno::UNO_QUERY );
448 uno::Reference<document::XDocumentProperties> xProps = xDocumentPropertiesSupplier->getDocumentProperties();
449 uno::Reference<beans::XPropertySet> xUDProps( xProps->getUserDefinedProperties(), uno::UNO_QUERY );
450 OUString propValue;
451 xUDProps->getPropertyValue("Testing") >>= propValue;
452 CPPUNIT_ASSERT_EQUAL(OUString("Document"), propValue);
453 xDocShRef->DoClose();
456 void SdOOXMLExportTest1::testFdo79731()
458 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/fdo79731.odp"), ODP);
459 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
460 SdDrawDocument *pDoc = xDocShRef->GetDoc();
461 CPPUNIT_ASSERT(pDoc);
462 xDocShRef->DoClose();
465 void SdOOXMLExportTest1::testTableCellFillProperties()
467 std::shared_ptr< comphelper::ConfigurationChanges > batch(comphelper::ConfigurationChanges::create());
468 officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), batch);
469 batch->commit();
471 // Load the original file
472 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/odp/Table_with_Cell_Fill.odp"), ODP);
474 // Export the document and import again for a check
475 uno::Reference< lang::XComponent > xComponent = xDocShRef->GetModel();
476 uno::Reference<frame::XStorable> xStorable(xComponent, uno::UNO_QUERY);
477 utl::MediaDescriptor aMediaDescriptor;
478 aMediaDescriptor["FilterName"] <<= OStringToOUString(OString(aFileFormats[PPTX].pFilterName), RTL_TEXTENCODING_UTF8);
480 utl::TempFile aTempFile;
481 aTempFile.EnableKillingFile();
482 xStorable->storeToURL(aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
483 xComponent.set(xStorable, uno::UNO_QUERY);
484 xComponent->dispose();
485 xDocShRef = loadURL(aTempFile.GetURL(), PPTX);
487 const SdrPage *pPage = GetPage( 1, xDocShRef );
489 sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
490 CPPUNIT_ASSERT( pTableObj );
491 uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
492 uno::Reference< beans::XPropertySet > xCell;
494 // Test Solid fill color
495 sal_Int32 nColor;
496 xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
497 xCell->getPropertyValue("FillColor") >>= nColor;
498 CPPUNIT_ASSERT_EQUAL(sal_Int32(6750207), nColor);
500 // Test Picture fill type for cell
501 drawing::FillStyle aFillStyle( drawing::FillStyle_NONE );
502 xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
503 xCell->getPropertyValue("FillStyle") >>= aFillStyle;
504 CPPUNIT_ASSERT_EQUAL(int(drawing::FillStyle_BITMAP), static_cast<int>(aFillStyle));
506 // Test Gradient fill type for cell
507 xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
508 xCell->getPropertyValue("FillStyle") >>= aFillStyle;
509 CPPUNIT_ASSERT_EQUAL(int(drawing::FillStyle_GRADIENT), static_cast<int>(aFillStyle));
511 xDocShRef->DoClose();
514 void SdOOXMLExportTest1::testBulletStartNumber()
516 ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/n90255.pptx"), PPTX );
517 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
519 const SdrPage *pPage = GetPage( 1, xDocShRef );
520 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(0) );
521 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
522 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
523 const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
524 CPPUNIT_ASSERT(pNumFmt);
525 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's start number is wrong!", sal_Int16(3), sal_Int16(pNumFmt->GetNumRule()->GetLevel(0).GetStart()) );
526 xDocShRef->DoClose();
529 void SdOOXMLExportTest1::testLineStyle()
531 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/lineStyle.pptx"), PPTX);
532 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
534 const SdrPage *pPage = GetPage( 1, xDocShRef );
535 SdrObject const* pShape = pPage->GetObj(0);
536 CPPUNIT_ASSERT_MESSAGE("no shape", pShape != nullptr);
538 const XLineStyleItem& rStyleItem = dynamic_cast<const XLineStyleItem&>(
539 pShape->GetMergedItem(XATTR_LINESTYLE));
540 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong style", int(drawing::LineStyle_SOLID), static_cast<int>(rStyleItem.GetValue()));
542 xDocShRef->DoClose();
545 void SdOOXMLExportTest1::testRightToLeftParaghraph()
547 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/rightToLeftParagraph.pptx"), PPTX);
549 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
550 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
552 // Get first paragraph
553 uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
554 uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
556 sal_Int16 nWritingMode = 0;
557 xPropSet->getPropertyValue( "WritingMode" ) >>= nWritingMode;
558 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong paragraph WritingMode", text::WritingMode2::RL_TB, nWritingMode);
560 xDocShRef->DoClose();
563 void SdOOXMLExportTest1::testTextboxWithHyperlink()
565 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/hyperlinktest.pptx"), PPTX);
567 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
568 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
570 // Get first paragraph
571 uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
573 // first chunk of text
574 uno::Reference<text::XTextRange> xRun( getRunFromParagraph( 0, xParagraph ) );
575 uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
577 uno::Reference<text::XTextField> xField;
578 xPropSet->getPropertyValue("TextField") >>= xField;
579 CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField.is() );
581 xPropSet.set(xField, uno::UNO_QUERY);
582 OUString aURL;
583 xPropSet->getPropertyValue("URL") >>= aURL;
584 CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("http://www.xkcd.com/"), aURL);
586 xDocShRef->DoClose();
589 void SdOOXMLExportTest1::testBulletColor()
591 ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bulletColor.pptx"), PPTX );
593 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
595 const SdrPage *pPage = GetPage( 1, xDocShRef );
597 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(0) );
598 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
600 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
601 const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
602 CPPUNIT_ASSERT(pNumFmt);
603 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", Color(0xff0000),pNumFmt->GetNumRule()->GetLevel(0).GetBulletColor());
605 xDocShRef->DoClose();
608 void SdOOXMLExportTest1::testBulletCharAndFont()
610 ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/odp/bulletCharAndFont.odp"), ODP);
611 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
613 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
614 uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
615 uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
617 uno::Reference<container::XIndexAccess> xLevels(xPropSet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
618 uno::Sequence<beans::PropertyValue> aProps;
619 xLevels->getByIndex(0) >>= aProps; // 1st level
620 OUString sBulletChar(u'\xf06c');
621 for (int i = 0; i < aProps.getLength(); ++i)
623 const beans::PropertyValue& rProp = aProps[i];
624 if (rProp.Name == "BulletChar")
625 CPPUNIT_ASSERT_EQUAL_MESSAGE( "BulletChar incorrect.", sBulletChar ,rProp.Value.get<OUString>());
626 if (rProp.Name == "BulletFont")
628 awt::FontDescriptor aFontDescriptor;
629 rProp.Value >>= aFontDescriptor;
630 CPPUNIT_ASSERT_EQUAL_MESSAGE( "BulletFont incorrect.", OUString("Wingdings"),aFontDescriptor.Name);
633 xDocShRef->DoClose();
636 void SdOOXMLExportTest1::testBulletMarginAndIndentation()
638 ::sd::DrawDocShellRef xDocShRef = loadURL( m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx"), PPTX );
639 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
641 const SdrPage *pPage = GetPage( 1, xDocShRef );
643 SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(0) );
644 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != nullptr);
646 const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
647 const SvxNumBulletItem *pNumFmt = aEdit.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET);
648 CPPUNIT_ASSERT(pNumFmt);
650 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's left margin is wrong!", sal_Int32(1000),pNumFmt->GetNumRule()->GetLevel(0).GetAbsLSpace() ); // left margin is 0.79 cm
651 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's indentation is wrong!", sal_Int32(-998),pNumFmt->GetNumRule()->GetLevel(0). GetFirstLineOffset());
653 xDocShRef->DoClose();
656 void SdOOXMLExportTest1::testParaMarginAndindentation()
658 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx"), PPTX);
660 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
661 uno::Reference< beans::XPropertySet > xShape( getShapeFromPage( 0, 0, xDocShRef ) );
663 // Get first paragraph
664 uno::Reference<text::XTextRange> const xParagraph( getParagraphFromShape( 0, xShape ) );
665 uno::Reference< beans::XPropertySet > xPropSet( xParagraph, uno::UNO_QUERY_THROW );
667 sal_Int32 nParaLeftMargin = 0;
668 xPropSet->getPropertyValue( "ParaLeftMargin" ) >>= nParaLeftMargin;
669 CPPUNIT_ASSERT_EQUAL(sal_uInt32(1000), sal_uInt32(nParaLeftMargin));
671 sal_Int32 nParaFirstLineIndent = 0;
672 xPropSet->getPropertyValue( "ParaFirstLineIndent" ) >>= nParaFirstLineIndent;
673 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1268), nParaFirstLineIndent);
675 xDocShRef->DoClose();
678 void SdOOXMLExportTest1::testCellLeftAndRightMargin()
680 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/n90223.pptx"), PPTX);
681 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
682 sal_Int32 nLeftMargin, nRightMargin;
684 const SdrPage *pPage = GetPage( 1, xDocShRef );
686 sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
687 CPPUNIT_ASSERT( pTableObj );
689 uno::Reference< css::table::XTable > xTable (pTableObj->getTable(), uno::UNO_SET_THROW);
690 uno::Reference< css::table::XMergeableCell > xCell( xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW );
691 uno::Reference< beans::XPropertySet > xCellPropSet(xCell, uno::UNO_QUERY_THROW);
693 uno::Any aLeftMargin = xCellPropSet->getPropertyValue("TextLeftDistance");
694 aLeftMargin >>= nLeftMargin ;
696 uno::Any aRightMargin = xCellPropSet->getPropertyValue("TextRightDistance");
697 aRightMargin >>= nRightMargin ;
699 // Convert values to EMU
700 nLeftMargin = oox::drawingml::convertHmmToEmu( nLeftMargin );
701 nRightMargin = oox::drawingml::convertHmmToEmu( nRightMargin );
703 CPPUNIT_ASSERT_EQUAL(sal_Int32(45720), nLeftMargin);
704 CPPUNIT_ASSERT_EQUAL(sal_Int32(45720), nRightMargin);
706 xDocShRef->DoClose();
709 void SdOOXMLExportTest1::testMergedCells()
711 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/cellspan.odp"), ODP);
712 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
713 const SdrPage *pPage = GetPage( 1, xDocShRef );
715 sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
717 CPPUNIT_ASSERT( pTableObj );
718 uno::Reference< table::XTable > xTable(pTableObj->getTable(), uno::UNO_SET_THROW);
719 uno::Reference< text::XTextRange > xText1(xTable->getCellByPosition(3, 0), uno::UNO_QUERY_THROW);
720 CPPUNIT_ASSERT_EQUAL( OUString("0,3"), xText1->getString() );
722 uno::Reference< text::XTextRange > xText2(xTable->getCellByPosition(3, 2), uno::UNO_QUERY_THROW);
723 CPPUNIT_ASSERT_EQUAL( OUString("2,3"), xText2->getString() );
726 void SdOOXMLExportTest1::testTableCellBorder()
728 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/n90190.pptx"), PPTX);
729 xDocShRef = saveAndReload( xDocShRef.get(), PPTX );
731 const SdrPage *pPage = GetPage( 1, xDocShRef );
733 sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
734 CPPUNIT_ASSERT( pTableObj );
736 table::BorderLine2 aBorderLine;
738 uno::Reference< table::XTable > xTable(pTableObj->getTable(), uno::UNO_SET_THROW);
739 uno::Reference< css::table::XMergeableCell > xCell(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
740 uno::Reference< beans::XPropertySet > xCellPropSet (xCell, uno::UNO_QUERY_THROW);
742 xCellPropSet->getPropertyValue("LeftBorder") >>= aBorderLine;
743 // While importing the table cell border line width, it converts EMU->Hmm then divided result by 2.
744 // To get original value of LineWidth need to multiple by 2.
745 sal_Int32 nLeftBorder = aBorderLine.LineWidth * 2;
746 nLeftBorder = oox::drawingml::convertHmmToEmu( nLeftBorder );
747 CPPUNIT_ASSERT(nLeftBorder);
748 CPPUNIT_ASSERT_EQUAL(util::Color(45296), aBorderLine.Color);
750 xCellPropSet->getPropertyValue("RightBorder") >>= aBorderLine;
751 sal_Int32 nRightBorder = aBorderLine.LineWidth * 2;
752 nRightBorder = oox::drawingml::convertHmmToEmu( nRightBorder );
753 CPPUNIT_ASSERT(nRightBorder);
754 CPPUNIT_ASSERT_EQUAL(util::Color(16777215), aBorderLine.Color);
756 xCellPropSet->getPropertyValue("TopBorder") >>= aBorderLine;
757 sal_Int32 nTopBorder = aBorderLine.LineWidth * 2;
758 nTopBorder = oox::drawingml::convertHmmToEmu( nTopBorder );
759 CPPUNIT_ASSERT(nTopBorder);
760 CPPUNIT_ASSERT_EQUAL(util::Color(45296), aBorderLine.Color);
763 xCellPropSet->getPropertyValue("BottomBorder") >>= aBorderLine;
764 sal_Int32 nBottomBorder = aBorderLine.LineWidth * 2;
765 nBottomBorder = oox::drawingml::convertHmmToEmu( nBottomBorder );
766 CPPUNIT_ASSERT(nBottomBorder);
767 CPPUNIT_ASSERT_EQUAL(util::Color(45296), aBorderLine.Color);
769 xDocShRef->DoClose();
772 void SdOOXMLExportTest1::testTdf111884()
774 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf111884.pptx"), PPTX);
775 xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
777 const SdrPage *pPage = GetPage(1, xDocShRef);
778 SdrObject const* pShape = pPage->GetObj(2);
779 CPPUNIT_ASSERT_MESSAGE("no shape", pShape != nullptr);
781 // must be a group shape
782 CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(OBJ_GRUP), pShape->GetObjIdentifier());
784 xDocShRef->DoClose();
787 void SdOOXMLExportTest1::testTdf112633()
789 // Load document and export it to a temporary file
790 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf112633.pptx"), PPTX);
791 utl::TempFile tempFile;
792 xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
793 xDocShRef->DoClose();
795 xmlDocPtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
796 xmlDocPtr pRelsDoc = parseExport(tempFile, "ppt/slides/_rels/slide1.xml.rels");
798 // Check image with artistic effect exists in the slide
799 assertXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/"
800 "a14:imgLayer/a14:imgEffect/a14:artisticPencilGrayscale",
801 "pencilSize", "80");
803 // Check there is a relation with the .wdp file that contains the backed up image
804 OUString sEmbedId1 = getXPath(pXmlDoc, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:extLst/"
805 "a:ext/a14:imgProps/a14:imgLayer", "embed");
806 OUString sXmlPath = "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId1 + "']";
807 assertXPath(pRelsDoc, OUStringToOString( sXmlPath, RTL_TEXTENCODING_UTF8 ), "Target", "../media/hdphoto1.wdp");
809 // Check the .wdp file exists
810 uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(
811 comphelper::getComponentContext(m_xSFactory), tempFile.GetURL());
812 CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess->hasByName("ppt/media/hdphoto1.wdp")));
815 void SdOOXMLExportTest1::testCustomXml()
817 // Load document and export it to a temporary file
818 ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/customxml.pptx"), PPTX);
819 utl::TempFile tempFile;
820 xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
821 xDocShRef->DoClose();
823 xmlDocPtr pXmlDoc = parseExport(tempFile, "customXml/item1.xml");
824 CPPUNIT_ASSERT(pXmlDoc);
825 xmlDocPtr pRelsDoc = parseExport(tempFile, "customXml/_rels/item1.xml.rels");
826 CPPUNIT_ASSERT(pRelsDoc);
828 // Check there is a relation to itemProps1.xml.
829 assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship", 1);
830 assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship[@Id='rId1']", "Target", "itemProps1.xml");
832 std::shared_ptr<SvStream> pStream = parseExportStream(tempFile, "ddp/ddpfile.xen");
833 CPPUNIT_ASSERT(pStream);
836 void SdOOXMLExportTest1::testTdf94238()
838 // Load document and export it to a temporary file.
839 ::sd::DrawDocShellRef xDocShRef
840 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf94238.pptx"), PPTX);
841 utl::TempFile tempFile;
842 xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
843 uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(),
844 uno::UNO_QUERY);
845 CPPUNIT_ASSERT(xDoc.is());
847 uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
848 CPPUNIT_ASSERT(xPage.is());
850 uno::Reference<beans::XPropertySet> xShape(getShape(0, xPage));
851 CPPUNIT_ASSERT(xShape.is());
853 awt::Gradient aGradient;
854 CPPUNIT_ASSERT(xShape->getPropertyValue("FillGradient") >>= aGradient);
856 // Without the accompanying fix in place, this test would have failed with
857 // the following details:
858 // - aGradient.Style was awt::GradientStyle_ELLIPTICAL
859 // - aGradient.YOffset was 70
860 // - aGradient.Border was 0
861 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL, aGradient.Style);
862 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(100), aGradient.YOffset);
863 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(39), aGradient.Border);
865 // Without the accompanying fix in place, this test would have failed with
866 // 'Expected: 0, Actual : 10592673', i.e. the start color of the gradient
867 // was incorrect.
868 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aGradient.StartColor);
869 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x8B8B8B), aGradient.EndColor);
871 xDocShRef->DoClose();
874 void SdOOXMLExportTest1::testPictureTransparency()
876 // Load document and export it to a temporary file.
877 ::sd::DrawDocShellRef xDocShRef
878 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/image_transparency.odp"), ODP);
879 utl::TempFile tempFile;
880 xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
881 uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(),
882 uno::UNO_QUERY);
883 CPPUNIT_ASSERT(xDoc.is());
885 uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
886 CPPUNIT_ASSERT(xPage.is());
888 uno::Reference<beans::XPropertySet> xGraphicShape(getShape(0, xPage));
889 CPPUNIT_ASSERT(xGraphicShape.is());
891 sal_Int16 nTransparency = 0;
892 CPPUNIT_ASSERT(xGraphicShape->getPropertyValue("Transparency") >>= nTransparency);
893 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(51), nTransparency);
895 xDocShRef->DoClose();
898 void SdOOXMLExportTest1::testTdf125554()
900 ::sd::DrawDocShellRef xDocShRef
901 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/tdf125554.pptx"), PPTX);
902 xDocShRef = saveAndReload(xDocShRef.get(), PPTX);
904 uno::Reference<beans::XPropertySet> xShape = getShapeFromPage(0, 0, xDocShRef);
905 uno::Any aFillTransparenceGradientName
906 = xShape->getPropertyValue("FillTransparenceGradientName");
907 CPPUNIT_ASSERT(aFillTransparenceGradientName.has<OUString>());
908 // Without the accompanying fix in place, this test would have failed, i.e. the transparency of
909 // the shape has no gradient, so it looked like a solid fill instead of a gradient fill.
910 CPPUNIT_ASSERT(!aFillTransparenceGradientName.get<OUString>().isEmpty());
912 xDocShRef->DoClose();
915 void SdOOXMLExportTest1::testRoundtripOwnLineStyles()
917 // Load odp document and read the LineDash values.
918 ::sd::DrawDocShellRef xDocShRef
919 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/LineStylesOwn.odp"), ODP);
920 uno::Reference<drawing::XDrawPagesSupplier> xDocodp(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
921 CPPUNIT_ASSERT(xDocodp.is());
922 uno::Reference<drawing::XDrawPage> xPageodp(xDocodp->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
923 CPPUNIT_ASSERT(xPageodp.is());
924 drawing::LineDash aLineDashodp[10];
925 for (sal_uInt16 i= 0; i < 10; i++)
927 uno::Reference<beans::XPropertySet> xShapeodp(getShape(i, xPageodp));
928 CPPUNIT_ASSERT(xShapeodp.is());
929 xShapeodp->getPropertyValue("LineDash") >>= aLineDashodp[i];
932 // Save to pptx, reload and compare the LineDash values
933 utl::TempFile tempFile;
934 xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
935 uno::Reference<drawing::XDrawPagesSupplier> xDocpptx(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
936 CPPUNIT_ASSERT(xDocpptx.is());
937 uno::Reference<drawing::XDrawPage> xPagepptx(xDocpptx->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
938 CPPUNIT_ASSERT(xPagepptx.is());
940 for (sal_uInt16 i = 0; i < 10; i++)
942 drawing::LineDash aLineDashpptx;
943 uno::Reference<beans::XPropertySet> xShapepptx(getShape(i, xPagepptx));
944 CPPUNIT_ASSERT(xShapepptx.is());
945 xShapepptx->getPropertyValue("LineDash") >>= aLineDashpptx;
946 bool bIsSameLineDash = (aLineDashodp[i].Style == aLineDashpptx.Style
947 && aLineDashodp[i].Dots == aLineDashpptx.Dots
948 && aLineDashodp[i].DotLen == aLineDashpptx.DotLen
949 && aLineDashodp[i].Dashes == aLineDashpptx.Dashes
950 && aLineDashodp[i].DashLen == aLineDashpptx.DashLen
951 && aLineDashodp[i].Distance == aLineDashpptx.Distance);
952 CPPUNIT_ASSERT_MESSAGE("LineDash differ", bIsSameLineDash);
954 xDocShRef->DoClose();
957 void SdOOXMLExportTest1::testRoundtripPrstDash()
959 // load and save document, compare prstDash values in saved document with original.
960 ::sd::DrawDocShellRef xDocShRef
961 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/presetDashDot.pptx"), PPTX);
962 utl::TempFile tempFile;
963 xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
965 const OUString sOriginal[] = {
966 "dash",
967 "dashDot",
968 "dot",
969 "lgDash",
970 "lgDashDot",
971 "lgDashDotDot",
972 "sysDash",
973 "sysDashDot",
974 "sysDashDotDot",
975 "sysDot"
977 xmlDocPtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
978 const OString sStart = "/p:sld/p:cSld/p:spTree/p:sp[";
979 const OString sEnd = "]/p:spPr/a:ln/a:prstDash";
980 for (sal_uInt16 i = 0; i < 10; i++)
982 OString sXmlPath = sStart + OString::number(i+1) + sEnd;
983 OUString sResaved = getXPath(pXmlDoc, sXmlPath, "val");
984 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong prstDash", sOriginal[i], sResaved);
987 // tdf#126746: Make sure that dash-dot pattern starts with the longer dash, as defined in OOXML
988 // Make sure Style is drawing::DashStyle_RECTRELATIVE
989 uno::Reference<drawing::XDrawPagesSupplier> xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY);
990 CPPUNIT_ASSERT(xDoc.is());
991 uno::Reference<drawing::XDrawPage> xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY);
992 CPPUNIT_ASSERT(xPage.is());
993 for (sal_uInt16 i = 0; i < 10; i++)
995 drawing::LineDash aLineDash;
996 uno::Reference<beans::XPropertySet> xShape(getShape(i, xPage));
997 CPPUNIT_ASSERT(xShape.is());
998 xShape->getPropertyValue("LineDash") >>= aLineDash;
999 CPPUNIT_ASSERT_MESSAGE("First dash is short", aLineDash.DotLen >= aLineDash.DashLen);
1000 bool bIsRectRelative = aLineDash.Style == drawing::DashStyle_RECTRELATIVE;
1001 CPPUNIT_ASSERT_MESSAGE("not RECTRELATIVE", bIsRectRelative);
1004 xDocShRef->DoClose();
1007 void SdOOXMLExportTest1::testDashOnHairline()
1009 // load and save document, make sure the custDash has 11 child elements.
1010 ::sd::DrawDocShellRef xDocShRef
1011 = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/odp/tdf127267DashOnHairline.odp"), ODP);
1012 utl::TempFile tempFile;
1013 xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile);
1014 xDocShRef->DoClose();
1016 xmlDocPtr pXmlDoc = parseExport(tempFile, "ppt/slides/slide1.xml");
1017 const OString sXmlPath = "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:ln/a:custDash/a:ds";
1018 assertXPath(pXmlDoc, sXmlPath, 11);
1021 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest1);
1023 CPPUNIT_PLUGIN_IMPLEMENT();
1025 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */