1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
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>
54 class SdOOXMLExportTest1
: public SdModelTestBaseXML
60 void testBnc870233_1();
61 void testBnc870233_2();
67 void testBnc862510_5();
68 void testBnc822347_EmptyBullet();
71 void testTableCellFillProperties();
72 void testBulletStartNumber();
74 void testCellLeftAndRightMargin();
75 void testRightToLeftParaghraph();
76 void testTextboxWithHyperlink();
77 void testMergedCells();
78 void testTableCellBorder();
79 void testBulletColor();
80 void testBulletCharAndFont();
81 void testBulletMarginAndIndentation();
82 void testParaMarginAndindentation();
89 void testPictureTransparency();
91 void testRoundtripOwnLineStyles();
92 void testRoundtripPrstDash();
93 void testDashOnHairline();
94 void testCustomshapeBitmapfillSrcrect();
95 void testTdf100348FontworkBitmapFill();
96 void testTdf100348FontworkGradientGlow();
97 void testTdf128345FullTransparentGradient();
98 void testTdf128345GradientLinear();
99 void testTdf128345GradientRadial();
100 void testTdf128345GradientAxial();
101 void testTdf134969TransparencyOnColorGradient();
102 void testTdf136911();
104 void testNarrationMimeType();
105 void testTdf140865Wordart3D();
107 CPPUNIT_TEST_SUITE(SdOOXMLExportTest1
);
109 CPPUNIT_TEST(testFdo90607
);
110 CPPUNIT_TEST(testTdf127237
);
111 CPPUNIT_TEST(testBnc887230
);
112 CPPUNIT_TEST(testBnc870233_1
);
113 CPPUNIT_TEST(testBnc870233_2
);
114 CPPUNIT_TEST(testN828390_4
);
115 CPPUNIT_TEST(testN828390_5
);
116 CPPUNIT_TEST(testFdo71961
);
117 CPPUNIT_TEST(testN828390
);
118 CPPUNIT_TEST(testBnc880763
);
119 CPPUNIT_TEST(testBnc862510_5
);
120 CPPUNIT_TEST(testBnc822347_EmptyBullet
);
121 CPPUNIT_TEST(testFdo83751
);
122 CPPUNIT_TEST(testFdo79731
);
123 CPPUNIT_TEST(testTableCellFillProperties
);
124 CPPUNIT_TEST(testBulletStartNumber
);
125 CPPUNIT_TEST(testLineStyle
);
126 CPPUNIT_TEST(testCellLeftAndRightMargin
);
127 CPPUNIT_TEST(testRightToLeftParaghraph
);
128 CPPUNIT_TEST(testTextboxWithHyperlink
);
129 CPPUNIT_TEST(testMergedCells
);
130 CPPUNIT_TEST(testTableCellBorder
);
131 CPPUNIT_TEST(testBulletColor
);
132 CPPUNIT_TEST(testBulletCharAndFont
);
133 CPPUNIT_TEST(testBulletMarginAndIndentation
);
134 CPPUNIT_TEST(testParaMarginAndindentation
);
135 CPPUNIT_TEST(testTdf111884
);
136 CPPUNIT_TEST(testTdf112633
);
137 CPPUNIT_TEST(testTdf128952
);
138 CPPUNIT_TEST(testTdf127090
);
139 CPPUNIT_TEST(testCustomXml
);
140 CPPUNIT_TEST(testTdf94238
);
141 CPPUNIT_TEST(testTdf125554
);
142 CPPUNIT_TEST(testPictureTransparency
);
143 CPPUNIT_TEST(testRoundtripOwnLineStyles
);
144 CPPUNIT_TEST(testRoundtripPrstDash
);
145 CPPUNIT_TEST(testDashOnHairline
);
146 CPPUNIT_TEST(testCustomshapeBitmapfillSrcrect
);
147 CPPUNIT_TEST(testTdf100348FontworkBitmapFill
);
148 CPPUNIT_TEST(testTdf100348FontworkGradientGlow
);
149 CPPUNIT_TEST(testTdf128345FullTransparentGradient
);
150 CPPUNIT_TEST(testTdf128345GradientLinear
);
151 CPPUNIT_TEST(testTdf128345GradientRadial
);
152 CPPUNIT_TEST(testTdf128345GradientAxial
);
153 CPPUNIT_TEST(testTdf134969TransparencyOnColorGradient
);
154 CPPUNIT_TEST(testTdf136911
);
155 CPPUNIT_TEST(testArcTo
);
156 CPPUNIT_TEST(testNarrationMimeType
);
157 CPPUNIT_TEST(testTdf140865Wordart3D
);
159 CPPUNIT_TEST_SUITE_END();
161 virtual void registerNamespaces(xmlXPathContextPtr
& pXmlXPathCtx
) override
163 static const struct { char const * pPrefix
; char const * pURI
; } namespaces
[] =
166 { "ContentType", "http://schemas.openxmlformats.org/package/2006/content-types" },
167 { "rels", "http://schemas.openxmlformats.org/package/2006/relationships" },
168 { "mc", "http://schemas.openxmlformats.org/markup-compatibility/2006" },
169 { "v", "urn:schemas-microsoft-com:vml" },
170 { "a", "http://schemas.openxmlformats.org/drawingml/2006/main" },
171 { "c", "http://schemas.openxmlformats.org/drawingml/2006/chart" },
172 { "m", "http://schemas.openxmlformats.org/officeDocument/2006/math" },
173 { "pic", "http://schemas.openxmlformats.org/drawingml/2006/picture" },
174 { "wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" },
175 { "p", "http://schemas.openxmlformats.org/presentationml/2006/main" },
176 { "w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main" },
177 { "a14", "http://schemas.microsoft.com/office/drawing/2010/main" },
178 { "wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" },
179 { "wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" },
181 for (size_t i
= 0; i
< SAL_N_ELEMENTS(namespaces
); ++i
)
183 xmlXPathRegisterNs(pXmlXPathCtx
,
184 reinterpret_cast<xmlChar
const *>(namespaces
[i
].pPrefix
),
185 reinterpret_cast<xmlChar
const *>(namespaces
[i
].pURI
));
192 template< typename ItemValue
, typename ItemType
>
193 void checkFontAttributes( const SdrTextObj
* pObj
, ItemValue nVal
)
195 CPPUNIT_ASSERT_MESSAGE( "no object", pObj
!= nullptr);
196 const EditTextObject
& aEdit
= pObj
->GetOutlinerParaObject()->GetTextObject();
197 std::vector
<EECharAttrib
> rLst
;
198 aEdit
.GetCharAttribs(0, rLst
);
199 for( std::vector
<EECharAttrib
>::reverse_iterator it
= rLst
.rbegin(); it
!=rLst
.rend(); ++it
)
201 const ItemType
* pAttrib
= dynamic_cast<const ItemType
*>((*it
).pAttr
);
204 CPPUNIT_ASSERT_EQUAL( nVal
, static_cast<ItemValue
>(pAttrib
->GetValue()));
211 void SdOOXMLExportTest1::testTdf127237()
213 sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/tdf127237.pptx"), PPTX
);
214 xDocShRef
= saveAndReload(xDocShRef
.get(), ODP
);
216 const SdrPage
* pPage
= GetPage(1, xDocShRef
);
217 CPPUNIT_ASSERT(pPage
!= nullptr);
219 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
220 CPPUNIT_ASSERT(pTableObj
!= nullptr);
221 uno::Reference
< table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
223 sal_Int32 nFillColor
= 0;
224 uno::Reference
< beans::XPropertySet
> xCell(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
225 xCell
->getPropertyValue("FillColor") >>= nFillColor
;
226 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0070C0), nFillColor
);
228 xDocShRef
->DoClose();
231 void SdOOXMLExportTest1::testBnc887230()
233 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc887230.pptx"), PPTX
);
234 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
236 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
238 const SdrTextObj
*pObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj( 0 ) );
239 // Without the fix in place, this test would have failed with
241 //- Actual : 13421823
242 checkFontAttributes
<Color
, SvxColorItem
>( pObj
, Color(0x0000ff) );
244 xDocShRef
->DoClose();
247 void SdOOXMLExportTest1::testBnc870233_1()
249 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_1.pptx"), PPTX
);
250 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
252 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
254 // The problem was all shapes had the same font (the last parsed font attributes overwrote all previous ones)
256 // First shape has red, bold font
258 const SdrTextObj
*pObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj( 0 ) );
259 checkFontAttributes
<Color
, SvxColorItem
>( pObj
, Color(0xff0000) );
260 checkFontAttributes
<FontWeight
, SvxWeightItem
>( pObj
, WEIGHT_BOLD
);
263 // Second shape has blue, italic font
265 const SdrTextObj
*pObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj( 1 ) );
266 checkFontAttributes
<Color
, SvxColorItem
>( pObj
, Color(0x0000ff) );
267 checkFontAttributes
<FontItalic
, SvxPostureItem
>( pObj
, ITALIC_NORMAL
);
270 xDocShRef
->DoClose();
273 void SdOOXMLExportTest1::testBnc870233_2()
275 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc870233_2.pptx"), PPTX
);
276 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
278 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
280 // The problem was in some SmartArts font color was wrong
282 // First smart art has blue font color (direct formatting)
284 const SdrObjGroup
*pObjGroup
= dynamic_cast<SdrObjGroup
*>(pPage
->GetObj(0));
285 CPPUNIT_ASSERT(pObjGroup
);
286 const SdrTextObj
*pObj
= dynamic_cast<SdrTextObj
*>(pObjGroup
->GetSubList()->GetObj(0));
287 checkFontAttributes
<Color
, SvxColorItem
>(pObj
, Color(0x0000ff));
290 // Second smart art has "dk2" font color (style)
292 const SdrObjGroup
*pObjGroup
= dynamic_cast<SdrObjGroup
*>(pPage
->GetObj(1));
293 CPPUNIT_ASSERT(pObjGroup
);
294 const SdrTextObj
*pObj
= dynamic_cast<SdrTextObj
*>(pObjGroup
->GetSubList()->GetObj(0));
295 checkFontAttributes
<Color
, SvxColorItem
>( pObj
, Color(0x1F497D) );
298 // Third smart art has white font color (style)
300 const SdrObjGroup
*pObjGroup
= dynamic_cast<SdrObjGroup
*>(pPage
->GetObj(2));
301 CPPUNIT_ASSERT(pObjGroup
);
302 const SdrTextObj
*pObj
= dynamic_cast<SdrTextObj
*>(pObjGroup
->GetSubList()->GetObj(0));
303 checkFontAttributes
<Color
, SvxColorItem
>(pObj
, Color(0xffffff));
306 xDocShRef
->DoClose();
309 void SdOOXMLExportTest1::testN828390_4()
311 bool bPassed
= false;
312 ::sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/n828390_4.odp"), ODP
);
314 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
316 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
318 std::vector
<EECharAttrib
> rLst
;
319 SdrObject
*pObj
= pPage
->GetObj(0);
320 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
321 CPPUNIT_ASSERT( pTxtObj
);
322 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
323 aEdit
.GetCharAttribs(0, rLst
);
324 for( std::vector
<EECharAttrib
>::reverse_iterator it
= rLst
.rbegin(); it
!=rLst
.rend(); ++it
)
326 const SvxFontHeightItem
* pFontHeight
= dynamic_cast<const SvxFontHeightItem
*>((*it
).pAttr
);
327 if( pFontHeight
&& (*it
).nStart
== 18 )
328 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font height is wrong", static_cast<sal_uInt32
>(1129), pFontHeight
->GetHeight() );
329 const SvxFontItem
*pFont
= dynamic_cast<const SvxFontItem
*>((*it
).pAttr
);
332 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font is wrong", OUString("Arial"), pFont
->GetFamilyName() );
335 const SvxWeightItem
*pWeight
= dynamic_cast<const SvxWeightItem
*>((*it
).pAttr
);
336 if( pWeight
&& (*it
).nStart
== 18 )
337 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Font Weight is wrong", WEIGHT_BOLD
, pWeight
->GetWeight() );
340 CPPUNIT_ASSERT(bPassed
);
342 xDocShRef
->DoClose();
345 void SdOOXMLExportTest1::testN828390_5()
347 ::sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/n828390_5.odp"), ODP
);
349 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
351 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
353 SdrObject
*pObj
= pPage
->GetObj(0);
354 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
355 CPPUNIT_ASSERT( pTxtObj
);
356 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
357 const SvxNumBulletItem
& rNumFmt
= aEdit
.GetParaAttribs(3).Get(EE_PARA_NUMBULLET
);
358 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's relative size is wrong!", sal_uInt16(75), rNumFmt
.GetNumRule()->GetLevel(1).GetBulletRelSize() ); // != 25
361 xDocShRef
->DoClose();
364 void SdOOXMLExportTest1::testFdo71961()
366 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/fdo71961.odp"), ODP
);
368 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
369 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
371 // Export to .pptx changes all text frames to custom shape objects, which obey TextWordWrap property
372 // (which is false for text frames otherwise and is ignored). Check that frames that should wrap still do.
373 SdrObjCustomShape
*pTxtObj
= dynamic_cast<SdrObjCustomShape
*>( pPage
->GetObj( 1 ));
374 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
375 CPPUNIT_ASSERT_EQUAL( OUString( "Text to be always wrapped" ), pTxtObj
->GetOutlinerParaObject()->GetTextObject().GetText(0));
376 CPPUNIT_ASSERT_EQUAL( true, pTxtObj
->GetMergedItem(SDRATTR_TEXT_WORDWRAP
).GetValue());
378 pTxtObj
= dynamic_cast<SdrObjCustomShape
*>( pPage
->GetObj( 2 ));
379 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
380 CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape non-wrapped text" ), pTxtObj
->GetOutlinerParaObject()->GetTextObject().GetText(0));
381 CPPUNIT_ASSERT_EQUAL( false, pTxtObj
->GetMergedItem(SDRATTR_TEXT_WORDWRAP
).GetValue());
383 pTxtObj
= dynamic_cast<SdrObjCustomShape
*>( pPage
->GetObj( 3 ));
384 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
385 CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape wrapped text" ), pTxtObj
->GetOutlinerParaObject()->GetTextObject().GetText(0));
386 CPPUNIT_ASSERT_EQUAL( true, pTxtObj
->GetMergedItem(SDRATTR_TEXT_WORDWRAP
).GetValue());
388 xDocShRef
->DoClose();
391 void SdOOXMLExportTest1::testN828390()
393 bool bPassed
= false;
394 ::sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/n828390.pptx"), PPTX
);
396 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
398 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
400 std::vector
<EECharAttrib
> rLst
;
402 SdrObject
*pObj
= pPage
->GetObj(0);
403 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
404 CPPUNIT_ASSERT( pTxtObj
);
405 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
406 aEdit
.GetCharAttribs(0, rLst
);
407 bPassed
= std::any_of(rLst
.rbegin(), rLst
.rend(),
408 [](const EECharAttrib
& rCharAttr
) {
409 const SvxEscapementItem
*pFontEscapement
= dynamic_cast<const SvxEscapementItem
*>(rCharAttr
.pAttr
);
410 return pFontEscapement
&& (pFontEscapement
->GetEsc() == -25);
413 CPPUNIT_ASSERT_MESSAGE("Subscript not exported properly", bPassed
);
415 xDocShRef
->DoClose();
418 void SdOOXMLExportTest1::testBnc880763()
420 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc880763.pptx"), PPTX
);
421 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
423 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
425 // Check z-order of the two shapes, use background color to identify them
426 // First object in the background has blue background color
427 const SdrObjGroup
*pObjGroup
= dynamic_cast<SdrObjGroup
*>(pPage
->GetObj(0));
428 CPPUNIT_ASSERT(pObjGroup
);
429 const SdrObject
*pObj
= pObjGroup
->GetSubList()->GetObj(1);
430 CPPUNIT_ASSERT_MESSAGE( "no object", pObj
!= nullptr);
431 CPPUNIT_ASSERT_EQUAL( Color(0x0000ff),(static_cast< const XColorItem
& >(pObj
->GetMergedItem(XATTR_FILLCOLOR
))).GetColorValue());
433 // Second object at the front has green background color
434 pObj
= pPage
->GetObj(1);
435 CPPUNIT_ASSERT_MESSAGE( "no object", pObj
!= nullptr);
436 CPPUNIT_ASSERT_EQUAL( Color(0x00ff00),(static_cast< const XColorItem
& >(pObj
->GetMergedItem(XATTR_FILLCOLOR
))).GetColorValue());
438 xDocShRef
->DoClose();
441 void SdOOXMLExportTest1::testBnc862510_5()
443 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_5.pptx"), PPTX
);
444 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
446 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
448 // Same as testBnc870237, but here we check the horizontal spacing
449 const SdrObjGroup
*pObjGroup
= dynamic_cast<SdrObjGroup
*>(pPage
->GetObj(0));
450 CPPUNIT_ASSERT(pObjGroup
);
451 const SdrObject
* pObj
= pObjGroup
->GetSubList()->GetObj(2);
452 CPPUNIT_ASSERT_MESSAGE( "no object", pObj
!= nullptr);
453 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj
->GetMergedItem(SDRATTR_TEXT_UPPERDIST
).GetValue());
454 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj
->GetMergedItem(SDRATTR_TEXT_LOWERDIST
).GetValue());
455 CPPUNIT_ASSERT_EQUAL( sal_Int32(7510), pObj
->GetMergedItem(SDRATTR_TEXT_RIGHTDIST
).GetValue());
456 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), pObj
->GetMergedItem(SDRATTR_TEXT_LEFTDIST
).GetValue());
458 xDocShRef
->DoClose();
461 // In numbering a bullet could be defined as empty (no character).
462 // When exporting to OOXML make sure that the bullet is ignored and
463 // not written into the file.
464 void SdOOXMLExportTest1::testBnc822347_EmptyBullet()
466 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/bnc822347_EmptyBullet.odp"), ODP
);
467 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
469 SdDrawDocument
* pDoc
= xDocShRef
->GetDoc();
470 SdrOutliner
* pOutliner
= pDoc
->GetInternalOutliner();
471 const SdrPage
* pPage
= pDoc
->GetPage(1);
472 SdrObject
* pObject
= pPage
->GetObj(0);
473 SdrTextObj
* pTextObject
= dynamic_cast<SdrTextObj
*>(pObject
);
474 CPPUNIT_ASSERT(pTextObject
);
476 OutlinerParaObject
* pOutlinerParagraphObject
= pTextObject
->GetOutlinerParaObject();
477 const EditTextObject
& aEdit
= pOutlinerParagraphObject
->GetTextObject();
479 OUString sText
= aEdit
.GetText(0);
480 CPPUNIT_ASSERT_EQUAL(OUString("M3 Feature Test"), sText
);
482 pOutliner
->SetText(*pOutlinerParagraphObject
);
483 CPPUNIT_ASSERT_EQUAL(sal_Int32(1), pOutliner
->GetParagraphCount());
485 const sal_Int16 nDepth
= pOutliner
->GetDepth(0);
487 CPPUNIT_ASSERT_EQUAL(sal_Int16(-1), nDepth
); // depth >= 0 means that the paragraph has bullets enabled
489 xDocShRef
->DoClose();
492 //Bullets not having any text following them are not getting exported to pptx correctly.
493 void SdOOXMLExportTest1::testFdo90607()
495 sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/fdo90607.pptx"), PPTX
);
496 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
498 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
499 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj(1) );
500 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
501 OutlinerParaObject
* pOutlinerParagraphObject
= pTxtObj
->GetOutlinerParaObject();
502 const sal_Int16 nDepth
= pOutlinerParagraphObject
->GetDepth(0);
503 CPPUNIT_ASSERT_MESSAGE("not equal", nDepth
!= -1);
504 xDocShRef
->DoClose();
507 void SdOOXMLExportTest1::testFdo83751()
509 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/fdo83751.pptx"), PPTX
);
510 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
512 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
513 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= nullptr );
515 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier( xDocShRef
->GetModel(), uno::UNO_QUERY
);
516 uno::Reference
<document::XDocumentProperties
> xProps
= xDocumentPropertiesSupplier
->getDocumentProperties();
517 uno::Reference
<beans::XPropertySet
> xUDProps( xProps
->getUserDefinedProperties(), uno::UNO_QUERY
);
519 xUDProps
->getPropertyValue("Testing") >>= propValue
;
520 CPPUNIT_ASSERT_EQUAL(OUString("Document"), propValue
);
521 xDocShRef
->DoClose();
524 void SdOOXMLExportTest1::testFdo79731()
526 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/fdo79731.odp"), ODP
);
527 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
528 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
529 CPPUNIT_ASSERT(pDoc
);
530 xDocShRef
->DoClose();
533 void SdOOXMLExportTest1::testTableCellFillProperties()
535 std::shared_ptr
< comphelper::ConfigurationChanges
> batch(comphelper::ConfigurationChanges::create());
536 officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(sal_Int32(1), batch
);
539 // Load the original file
540 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/odp/Table_with_Cell_Fill.odp"), ODP
);
542 // Export the document and import again for a check
543 uno::Reference
< lang::XComponent
> xComponent
= xDocShRef
->GetModel();
544 uno::Reference
<frame::XStorable
> xStorable(xComponent
, uno::UNO_QUERY
);
545 utl::MediaDescriptor aMediaDescriptor
;
546 aMediaDescriptor
["FilterName"] <<= OStringToOUString(OString(aFileFormats
[PPTX
].pFilterName
), RTL_TEXTENCODING_UTF8
);
548 utl::TempFile aTempFile
;
549 aTempFile
.EnableKillingFile();
550 xStorable
->storeToURL(aTempFile
.GetURL(), aMediaDescriptor
.getAsConstPropertyValueList());
551 xComponent
.set(xStorable
, uno::UNO_QUERY
);
552 xComponent
->dispose();
553 xDocShRef
= loadURL(aTempFile
.GetURL(), PPTX
);
555 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
557 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
558 CPPUNIT_ASSERT( pTableObj
);
559 uno::Reference
< table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
560 uno::Reference
< beans::XPropertySet
> xCell
;
562 // Test Solid fill color
564 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
565 xCell
->getPropertyValue("FillColor") >>= nColor
;
566 CPPUNIT_ASSERT_EQUAL(sal_Int32(6750207), nColor
);
568 // Test Picture fill type for cell
569 drawing::FillStyle
aFillStyle( drawing::FillStyle_NONE
);
570 xCell
.set(xTable
->getCellByPosition(0, 1), uno::UNO_QUERY_THROW
);
571 xCell
->getPropertyValue("FillStyle") >>= aFillStyle
;
572 CPPUNIT_ASSERT_EQUAL(int(drawing::FillStyle_BITMAP
), static_cast<int>(aFillStyle
));
574 // Test Gradient fill type for cell
575 xCell
.set(xTable
->getCellByPosition(1, 0), uno::UNO_QUERY_THROW
);
576 xCell
->getPropertyValue("FillStyle") >>= aFillStyle
;
577 CPPUNIT_ASSERT_EQUAL(int(drawing::FillStyle_GRADIENT
), static_cast<int>(aFillStyle
));
579 xDocShRef
->DoClose();
582 void SdOOXMLExportTest1::testBulletStartNumber()
584 ::sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/n90255.pptx"), PPTX
);
585 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
587 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
588 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj(0) );
589 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
590 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
591 const SvxNumBulletItem
*pNumFmt
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
592 CPPUNIT_ASSERT(pNumFmt
);
593 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's start number is wrong!", sal_Int16(3), sal_Int16(pNumFmt
->GetNumRule()->GetLevel(0).GetStart()) );
594 xDocShRef
->DoClose();
597 void SdOOXMLExportTest1::testLineStyle()
599 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/lineStyle.pptx"), PPTX
);
600 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
602 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
603 SdrObject
const* pShape
= pPage
->GetObj(0);
604 CPPUNIT_ASSERT_MESSAGE("no shape", pShape
!= nullptr);
606 const XLineStyleItem
& rStyleItem
= dynamic_cast<const XLineStyleItem
&>(
607 pShape
->GetMergedItem(XATTR_LINESTYLE
));
608 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong style", int(drawing::LineStyle_SOLID
), static_cast<int>(rStyleItem
.GetValue()));
610 xDocShRef
->DoClose();
613 void SdOOXMLExportTest1::testRightToLeftParaghraph()
615 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/rightToLeftParagraph.pptx"), PPTX
);
617 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
618 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
620 // Get first paragraph
621 uno::Reference
<text::XTextRange
> const xParagraph( getParagraphFromShape( 0, xShape
) );
622 uno::Reference
< beans::XPropertySet
> xPropSet( xParagraph
, uno::UNO_QUERY_THROW
);
624 sal_Int16 nWritingMode
= 0;
625 xPropSet
->getPropertyValue( "WritingMode" ) >>= nWritingMode
;
626 CPPUNIT_ASSERT_EQUAL_MESSAGE("Wrong paragraph WritingMode", text::WritingMode2::RL_TB
, nWritingMode
);
628 xDocShRef
->DoClose();
631 void SdOOXMLExportTest1::testTextboxWithHyperlink()
633 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/hyperlinktest.pptx"), PPTX
);
635 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
636 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
638 // Get first paragraph
639 uno::Reference
<text::XTextRange
> const xParagraph( getParagraphFromShape( 0, xShape
) );
641 // first chunk of text
642 uno::Reference
<text::XTextRange
> xRun( getRunFromParagraph( 0, xParagraph
) );
643 uno::Reference
< beans::XPropertySet
> xPropSet( xRun
, uno::UNO_QUERY_THROW
);
645 uno::Reference
<text::XTextField
> xField
;
646 xPropSet
->getPropertyValue("TextField") >>= xField
;
647 CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField
.is() );
649 xPropSet
.set(xField
, uno::UNO_QUERY
);
651 xPropSet
->getPropertyValue("URL") >>= aURL
;
652 CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("http://www.xkcd.com/"), aURL
);
654 xDocShRef
->DoClose();
657 void SdOOXMLExportTest1::testTdf136911()
659 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/ppt/tdf136911.ppt"), PPT
);
661 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
662 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
664 // Get second paragraph
665 uno::Reference
<text::XTextRange
> const xParagraph( getParagraphFromShape( 0, xShape
) );
667 // first chunk of text
668 uno::Reference
<text::XTextRange
> xRun( getRunFromParagraph( 0, xParagraph
) );
669 uno::Reference
< beans::XPropertySet
> xPropSet( xRun
, uno::UNO_QUERY_THROW
);
671 uno::Reference
<text::XTextField
> xField
;
672 xPropSet
->getPropertyValue("TextField") >>= xField
;
673 CPPUNIT_ASSERT_MESSAGE("Where is the text field?", xField
.is() );
675 xPropSet
.set(xField
, uno::UNO_QUERY
);
677 xPropSet
->getPropertyValue("URL") >>= aURL
;
678 CPPUNIT_ASSERT_EQUAL_MESSAGE("URLs don't match", OUString("http://google.com"), aURL
);
680 xDocShRef
->DoClose();
683 void SdOOXMLExportTest1::testBulletColor()
685 ::sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bulletColor.pptx"), PPTX
);
687 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
689 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
691 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj(0) );
692 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
694 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
695 const SvxNumBulletItem
*pNumFmt
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
696 CPPUNIT_ASSERT(pNumFmt
);
697 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's color is wrong!", Color(0xff0000),pNumFmt
->GetNumRule()->GetLevel(0).GetBulletColor());
699 xDocShRef
->DoClose();
702 void SdOOXMLExportTest1::testBulletCharAndFont()
704 ::sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/odp/bulletCharAndFont.odp"), ODP
);
705 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
707 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
708 uno::Reference
<text::XTextRange
> const xParagraph( getParagraphFromShape( 0, xShape
) );
709 uno::Reference
< beans::XPropertySet
> xPropSet( xParagraph
, uno::UNO_QUERY_THROW
);
711 uno::Reference
<container::XIndexAccess
> xLevels(xPropSet
->getPropertyValue("NumberingRules"), uno::UNO_QUERY
);
712 uno::Sequence
<beans::PropertyValue
> aProps
;
713 xLevels
->getByIndex(0) >>= aProps
; // 1st level
714 OUString
sBulletChar(u
'\xf06c');
715 for (beans::PropertyValue
const & rProp
: std::as_const(aProps
))
717 if (rProp
.Name
== "BulletChar")
718 CPPUNIT_ASSERT_EQUAL_MESSAGE( "BulletChar incorrect.", sBulletChar
,rProp
.Value
.get
<OUString
>());
719 if (rProp
.Name
== "BulletFont")
721 awt::FontDescriptor aFontDescriptor
;
722 rProp
.Value
>>= aFontDescriptor
;
723 CPPUNIT_ASSERT_EQUAL_MESSAGE( "BulletFont incorrect.", OUString("Wingdings"),aFontDescriptor
.Name
);
726 xDocShRef
->DoClose();
729 void SdOOXMLExportTest1::testBulletMarginAndIndentation()
731 ::sd::DrawDocShellRef xDocShRef
= loadURL( m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx"), PPTX
);
732 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
734 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
736 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj(0) );
737 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= nullptr);
739 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
740 const SvxNumBulletItem
*pNumFmt
= aEdit
.GetParaAttribs(0).GetItem(EE_PARA_NUMBULLET
);
741 CPPUNIT_ASSERT(pNumFmt
);
743 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's left margin is wrong!", sal_Int32(1000),pNumFmt
->GetNumRule()->GetLevel(0).GetAbsLSpace() ); // left margin is 0.79 cm
744 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's indentation is wrong!", sal_Int32(-998),pNumFmt
->GetNumRule()->GetLevel(0). GetFirstLineOffset());
746 xDocShRef
->DoClose();
749 void SdOOXMLExportTest1::testParaMarginAndindentation()
751 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("/sd/qa/unit/data/pptx/paraMarginAndIndentation.pptx"), PPTX
);
753 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
754 uno::Reference
< beans::XPropertySet
> xShape( getShapeFromPage( 0, 0, xDocShRef
) );
756 // Get first paragraph
757 uno::Reference
<text::XTextRange
> const xParagraph( getParagraphFromShape( 0, xShape
) );
758 uno::Reference
< beans::XPropertySet
> xPropSet( xParagraph
, uno::UNO_QUERY_THROW
);
760 sal_Int32 nParaLeftMargin
= 0;
761 xPropSet
->getPropertyValue( "ParaLeftMargin" ) >>= nParaLeftMargin
;
762 CPPUNIT_ASSERT_EQUAL(sal_uInt32(1000), sal_uInt32(nParaLeftMargin
));
764 sal_Int32 nParaFirstLineIndent
= 0;
765 xPropSet
->getPropertyValue( "ParaFirstLineIndent" ) >>= nParaFirstLineIndent
;
766 CPPUNIT_ASSERT_EQUAL(sal_Int32(-1268), nParaFirstLineIndent
);
768 xDocShRef
->DoClose();
771 void SdOOXMLExportTest1::testCellLeftAndRightMargin()
773 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/n90223.pptx"), PPTX
);
774 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
775 sal_Int32 nLeftMargin
, nRightMargin
;
777 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
779 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
780 CPPUNIT_ASSERT( pTableObj
);
782 uno::Reference
< css::table::XTable
> xTable (pTableObj
->getTable(), uno::UNO_SET_THROW
);
783 uno::Reference
< css::table::XMergeableCell
> xCell( xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
784 uno::Reference
< beans::XPropertySet
> xCellPropSet(xCell
, uno::UNO_QUERY_THROW
);
786 uno::Any aLeftMargin
= xCellPropSet
->getPropertyValue("TextLeftDistance");
787 aLeftMargin
>>= nLeftMargin
;
789 uno::Any aRightMargin
= xCellPropSet
->getPropertyValue("TextRightDistance");
790 aRightMargin
>>= nRightMargin
;
792 // Convert values to EMU
793 nLeftMargin
= oox::drawingml::convertHmmToEmu( nLeftMargin
);
794 nRightMargin
= oox::drawingml::convertHmmToEmu( nRightMargin
);
796 CPPUNIT_ASSERT_EQUAL(sal_Int32(45720), nLeftMargin
);
797 CPPUNIT_ASSERT_EQUAL(sal_Int32(45720), nRightMargin
);
799 xDocShRef
->DoClose();
802 void SdOOXMLExportTest1::testMergedCells()
804 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/cellspan.odp"), ODP
);
805 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
806 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
808 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
810 CPPUNIT_ASSERT( pTableObj
);
811 uno::Reference
< table::XTable
> xTable(pTableObj
->getTable(), uno::UNO_SET_THROW
);
812 uno::Reference
< text::XTextRange
> xText1(xTable
->getCellByPosition(3, 0), uno::UNO_QUERY_THROW
);
813 CPPUNIT_ASSERT_EQUAL( OUString("0,3"), xText1
->getString() );
815 uno::Reference
< text::XTextRange
> xText2(xTable
->getCellByPosition(3, 2), uno::UNO_QUERY_THROW
);
816 CPPUNIT_ASSERT_EQUAL( OUString("2,3"), xText2
->getString() );
819 void SdOOXMLExportTest1::testTableCellBorder()
821 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/n90190.pptx"), PPTX
);
822 xDocShRef
= saveAndReload( xDocShRef
.get(), PPTX
);
824 const SdrPage
*pPage
= GetPage( 1, xDocShRef
);
826 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
827 CPPUNIT_ASSERT( pTableObj
);
829 table::BorderLine2 aBorderLine
;
831 uno::Reference
< table::XTable
> xTable(pTableObj
->getTable(), uno::UNO_SET_THROW
);
832 uno::Reference
< css::table::XMergeableCell
> xCell(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
833 uno::Reference
< beans::XPropertySet
> xCellPropSet (xCell
, uno::UNO_QUERY_THROW
);
835 xCellPropSet
->getPropertyValue("LeftBorder") >>= aBorderLine
;
836 // While importing the table cell border line width, it converts EMU->Hmm then divided result by 2.
837 // To get original value of LineWidth need to multiple by 2.
838 sal_Int32 nLeftBorder
= aBorderLine
.LineWidth
* 2;
839 nLeftBorder
= oox::drawingml::convertHmmToEmu( nLeftBorder
);
840 CPPUNIT_ASSERT(nLeftBorder
);
841 CPPUNIT_ASSERT_EQUAL(util::Color(45296), aBorderLine
.Color
);
843 xCellPropSet
->getPropertyValue("RightBorder") >>= aBorderLine
;
844 sal_Int32 nRightBorder
= aBorderLine
.LineWidth
* 2;
845 nRightBorder
= oox::drawingml::convertHmmToEmu( nRightBorder
);
846 CPPUNIT_ASSERT(nRightBorder
);
847 CPPUNIT_ASSERT_EQUAL(util::Color(16777215), aBorderLine
.Color
);
849 xCellPropSet
->getPropertyValue("TopBorder") >>= aBorderLine
;
850 sal_Int32 nTopBorder
= aBorderLine
.LineWidth
* 2;
851 nTopBorder
= oox::drawingml::convertHmmToEmu( nTopBorder
);
852 CPPUNIT_ASSERT(nTopBorder
);
853 CPPUNIT_ASSERT_EQUAL(util::Color(45296), aBorderLine
.Color
);
856 xCellPropSet
->getPropertyValue("BottomBorder") >>= aBorderLine
;
857 sal_Int32 nBottomBorder
= aBorderLine
.LineWidth
* 2;
858 nBottomBorder
= oox::drawingml::convertHmmToEmu( nBottomBorder
);
859 CPPUNIT_ASSERT(nBottomBorder
);
860 CPPUNIT_ASSERT_EQUAL(util::Color(45296), aBorderLine
.Color
);
862 xDocShRef
->DoClose();
865 void SdOOXMLExportTest1::testTdf111884()
867 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf111884.pptx"), PPTX
);
868 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
);
870 const SdrPage
*pPage
= GetPage(1, xDocShRef
);
871 SdrObject
const* pShape
= pPage
->GetObj(2);
872 CPPUNIT_ASSERT_MESSAGE("no shape", pShape
!= nullptr);
874 // must be a group shape
875 CPPUNIT_ASSERT_EQUAL(OBJ_GRUP
, pShape
->GetObjIdentifier());
877 xDocShRef
->DoClose();
880 void SdOOXMLExportTest1::testTdf112633()
882 // Load document and export it to a temporary file
883 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf112633.pptx"), PPTX
);
884 utl::TempFile tempFile
;
885 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
886 xDocShRef
->DoClose();
888 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
889 xmlDocUniquePtr pRelsDoc
= parseExport(tempFile
, "ppt/slides/_rels/slide1.xml.rels");
891 // Check image with artistic effect exists in the slide
892 assertXPath(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:extLst/a:ext/a14:imgProps/"
893 "a14:imgLayer/a14:imgEffect/a14:artisticPencilGrayscale",
896 // Check there is a relation with the .wdp file that contains the backed up image
897 OUString sEmbedId1
= getXPath(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:pic/p:blipFill/a:blip/a:extLst/"
898 "a:ext/a14:imgProps/a14:imgLayer", "embed");
899 OUString sXmlPath
= "/rels:Relationships/rels:Relationship[@Id='" + sEmbedId1
+ "']";
900 assertXPath(pRelsDoc
, OUStringToOString( sXmlPath
, RTL_TEXTENCODING_UTF8
), "Target", "../media/hdphoto1.wdp");
902 // Check the .wdp file exists
903 uno::Reference
<packages::zip::XZipFileAccess2
> xNameAccess
= packages::zip::ZipFileAccess::createWithURL(
904 comphelper::getComponentContext(m_xSFactory
), tempFile
.GetURL());
905 CPPUNIT_ASSERT_EQUAL(true, bool(xNameAccess
->hasByName("ppt/media/hdphoto1.wdp")));
908 void SdOOXMLExportTest1::testTdf128952()
910 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf128952.pptx"), PPTX
);
911 utl::TempFile tempFile
;
912 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
913 xDocShRef
->DoClose();
915 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
917 assertXPath(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:off", "x", "360");
918 assertXPath(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:off", "y", "-360");
919 assertXPath(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:ext", "cx", "1919880");
920 assertXPath(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:xfrm/a:ext", "cy", "1462680");
923 void SdOOXMLExportTest1::testTdf127090()
925 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf127090.odp"), ODP
);
926 utl::TempFile tempFile
;
927 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
928 xDocShRef
->DoClose();
930 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
932 assertXPath(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:bodyPr", "rot", "-5400000");
935 void SdOOXMLExportTest1::testCustomXml()
937 // Load document and export it to a temporary file
938 ::sd::DrawDocShellRef xDocShRef
= loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/customxml.pptx"), PPTX
);
939 utl::TempFile tempFile
;
940 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
941 xDocShRef
->DoClose();
943 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "customXml/item1.xml");
944 CPPUNIT_ASSERT(pXmlDoc
);
945 xmlDocUniquePtr pRelsDoc
= parseExport(tempFile
, "customXml/_rels/item1.xml.rels");
946 CPPUNIT_ASSERT(pRelsDoc
);
948 // Check there is a relation to itemProps1.xml.
949 assertXPath(pRelsDoc
, "/rels:Relationships/rels:Relationship", 1);
950 assertXPath(pRelsDoc
, "/rels:Relationships/rels:Relationship[@Id='rId1']", "Target", "itemProps1.xml");
952 std::unique_ptr
<SvStream
> pStream
= parseExportStream(tempFile
, "ddp/ddpfile.xen");
953 CPPUNIT_ASSERT(pStream
);
956 void SdOOXMLExportTest1::testTdf94238()
958 // Load document and export it to a temporary file.
959 ::sd::DrawDocShellRef xDocShRef
960 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf94238.pptx"), PPTX
);
961 utl::TempFile tempFile
;
962 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
963 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(),
965 CPPUNIT_ASSERT(xDoc
.is());
967 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
968 CPPUNIT_ASSERT(xPage
.is());
970 uno::Reference
<beans::XPropertySet
> xShape(getShape(0, xPage
));
971 CPPUNIT_ASSERT(xShape
.is());
973 awt::Gradient aGradient
;
974 CPPUNIT_ASSERT(xShape
->getPropertyValue("FillGradient") >>= aGradient
);
976 // Without the accompanying fix in place, this test would have failed with
977 // the following details:
978 // - aGradient.Style was awt::GradientStyle_ELLIPTICAL
979 // - aGradient.YOffset was 70
980 // - aGradient.Border was 0
981 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_RADIAL
, aGradient
.Style
);
982 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(100), aGradient
.YOffset
);
983 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(39), aGradient
.Border
);
985 // Without the accompanying fix in place, this test would have failed with
986 // 'Expected: 0, Actual : 10592673', i.e. the start color of the gradient
988 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0), aGradient
.StartColor
);
989 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32
>(0x8B8B8B), aGradient
.EndColor
);
991 xDocShRef
->DoClose();
994 void SdOOXMLExportTest1::testPictureTransparency()
996 // Load document and export it to a temporary file.
997 ::sd::DrawDocShellRef xDocShRef
998 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/image_transparency.odp"), ODP
);
999 utl::TempFile tempFile
;
1000 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1001 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(),
1003 CPPUNIT_ASSERT(xDoc
.is());
1005 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
1006 CPPUNIT_ASSERT(xPage
.is());
1008 uno::Reference
<beans::XPropertySet
> xGraphicShape(getShape(0, xPage
));
1009 CPPUNIT_ASSERT(xGraphicShape
.is());
1011 sal_Int16 nTransparency
= 0;
1012 CPPUNIT_ASSERT(xGraphicShape
->getPropertyValue("Transparency") >>= nTransparency
);
1013 CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16
>(51), nTransparency
);
1015 xDocShRef
->DoClose();
1018 void SdOOXMLExportTest1::testTdf125554()
1020 ::sd::DrawDocShellRef xDocShRef
1021 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/tdf125554.pptx"), PPTX
);
1022 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
);
1024 uno::Reference
<beans::XPropertySet
> xShape
= getShapeFromPage(0, 0, xDocShRef
);
1025 uno::Any aFillTransparenceGradientName
1026 = xShape
->getPropertyValue("FillTransparenceGradientName");
1027 CPPUNIT_ASSERT(aFillTransparenceGradientName
.has
<OUString
>());
1028 // Without the accompanying fix in place, this test would have failed, i.e. the transparency of
1029 // the shape has no gradient, so it looked like a solid fill instead of a gradient fill.
1030 CPPUNIT_ASSERT(!aFillTransparenceGradientName
.get
<OUString
>().isEmpty());
1032 xDocShRef
->DoClose();
1035 void SdOOXMLExportTest1::testRoundtripOwnLineStyles()
1037 // Load odp document and read the LineDash values.
1038 ::sd::DrawDocShellRef xDocShRef
1039 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/LineStylesOwn.odp"), ODP
);
1040 uno::Reference
<drawing::XDrawPagesSupplier
> xDocodp(xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY
);
1041 CPPUNIT_ASSERT(xDocodp
.is());
1042 uno::Reference
<drawing::XDrawPage
> xPageodp(xDocodp
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
1043 CPPUNIT_ASSERT(xPageodp
.is());
1044 drawing::LineDash aLineDashodp
[10];
1045 for (sal_uInt16 i
= 0; i
< 10; i
++)
1047 uno::Reference
<beans::XPropertySet
> xShapeodp(getShape(i
, xPageodp
));
1048 CPPUNIT_ASSERT(xShapeodp
.is());
1049 xShapeodp
->getPropertyValue("LineDash") >>= aLineDashodp
[i
];
1052 // Save to pptx, reload and compare the LineDash values
1053 utl::TempFile tempFile
;
1054 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1055 uno::Reference
<drawing::XDrawPagesSupplier
> xDocpptx(xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY
);
1056 CPPUNIT_ASSERT(xDocpptx
.is());
1057 uno::Reference
<drawing::XDrawPage
> xPagepptx(xDocpptx
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
1058 CPPUNIT_ASSERT(xPagepptx
.is());
1060 for (sal_uInt16 i
= 0; i
< 10; i
++)
1062 drawing::LineDash aLineDashpptx
;
1063 uno::Reference
<beans::XPropertySet
> xShapepptx(getShape(i
, xPagepptx
));
1064 CPPUNIT_ASSERT(xShapepptx
.is());
1065 xShapepptx
->getPropertyValue("LineDash") >>= aLineDashpptx
;
1066 bool bIsSameLineDash
= (aLineDashodp
[i
].Style
== aLineDashpptx
.Style
1067 && aLineDashodp
[i
].Dots
== aLineDashpptx
.Dots
1068 && aLineDashodp
[i
].DotLen
== aLineDashpptx
.DotLen
1069 && aLineDashodp
[i
].Dashes
== aLineDashpptx
.Dashes
1070 && aLineDashodp
[i
].DashLen
== aLineDashpptx
.DashLen
1071 && aLineDashodp
[i
].Distance
== aLineDashpptx
.Distance
);
1072 CPPUNIT_ASSERT_MESSAGE("LineDash differ", bIsSameLineDash
);
1074 xDocShRef
->DoClose();
1077 void SdOOXMLExportTest1::testRoundtripPrstDash()
1079 // load and save document, compare prstDash values in saved document with original.
1080 ::sd::DrawDocShellRef xDocShRef
1081 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/presetDashDot.pptx"), PPTX
);
1082 utl::TempFile tempFile
;
1083 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1085 const OUString sOriginal
[] = {
1097 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
1098 const OString sStart
= "/p:sld/p:cSld/p:spTree/p:sp[";
1099 const OString sEnd
= "]/p:spPr/a:ln/a:prstDash";
1100 for (sal_uInt16 i
= 0; i
< 10; i
++)
1102 OString sXmlPath
= sStart
+ OString::number(i
+1) + sEnd
;
1103 OUString sResaved
= getXPath(pXmlDoc
, sXmlPath
, "val");
1104 CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong prstDash", sOriginal
[i
], sResaved
);
1107 // tdf#126746: Make sure that dash-dot pattern starts with the longer dash, as defined in OOXML
1108 // Make sure Style is drawing::DashStyle_RECTRELATIVE
1109 uno::Reference
<drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY
);
1110 CPPUNIT_ASSERT(xDoc
.is());
1111 uno::Reference
<drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY
);
1112 CPPUNIT_ASSERT(xPage
.is());
1113 for (sal_uInt16 i
= 0; i
< 10; i
++)
1115 drawing::LineDash aLineDash
;
1116 uno::Reference
<beans::XPropertySet
> xShape(getShape(i
, xPage
));
1117 CPPUNIT_ASSERT(xShape
.is());
1118 xShape
->getPropertyValue("LineDash") >>= aLineDash
;
1119 CPPUNIT_ASSERT_MESSAGE("First dash is short", aLineDash
.DotLen
>= aLineDash
.DashLen
);
1120 bool bIsRectRelative
= aLineDash
.Style
== drawing::DashStyle_RECTRELATIVE
;
1121 CPPUNIT_ASSERT_MESSAGE("not RECTRELATIVE", bIsRectRelative
);
1124 xDocShRef
->DoClose();
1127 void SdOOXMLExportTest1::testDashOnHairline()
1129 // load and save document, make sure the custDash has 11 child elements.
1130 ::sd::DrawDocShellRef xDocShRef
1131 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/tdf127267DashOnHairline.odp"), ODP
);
1132 utl::TempFile tempFile
;
1133 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1134 xDocShRef
->DoClose();
1136 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
1137 assertXPath(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:ln/a:custDash/a:ds", 11);
1140 void SdOOXMLExportTest1::testCustomshapeBitmapfillSrcrect()
1142 ::sd::DrawDocShellRef xDocShRef
= loadURL(
1143 m_directories
.getURLFromSrc("sd/qa/unit/data/pptx/customshape-bitmapfill-srcrect.pptx"),
1145 utl::TempFile tempFile
;
1146 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1147 xDocShRef
->DoClose();
1149 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
1152 // We are preventing the side effect of DOCX improvement to PPTX case.
1153 // Without the accompanying fix in place, this test would have failed with:
1156 // - XPath '/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:blipFill/a:srcRect' number of nodes is incorrect
1157 // i.e. <a:srcRect> was exported as <a:fillRect> in <a:stretch>, which made part of the image
1160 assertXPath(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:blipFill/a:srcRect");
1163 // Original values of attribute of l and r in xml files: <a:srcRect l="4393" r="4393"/>
1164 // No core feature for handling this. We add suuport to import filter. We crop the bitmap
1165 // physically during import and shouldn't export the l r t b attributes anymore. In the
1166 // future if we add core feature to LibreOffice, we should change the control value with
1169 assertXPathNoAttribute(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:blipFill/a:srcRect", "l");
1170 assertXPathNoAttribute(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:blipFill/a:srcRect", "r");
1171 assertXPathNoAttribute(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:blipFill/a:srcRect", "t");
1172 assertXPathNoAttribute(pXmlDoc
, "/p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:blipFill/a:srcRect", "b");
1177 void SdOOXMLExportTest1::testTdf100348FontworkBitmapFill()
1179 ::sd::DrawDocShellRef xDocShRef
1180 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/tdf100348_FontworkBitmapFill.odp"), ODP
);
1181 utl::TempFile tempFile
;
1182 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1183 xDocShRef
->DoClose();
1185 // Make sure the fontwork shape has a blip bitmap fill and a colored outline.
1186 // Without the patch, fill and outline were black.
1187 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
1188 const OString
sPathStart("//p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr");
1189 assertXPath(pXmlDoc
, sPathStart
+ "/a:blipFill/a:blip", 1);
1190 assertXPath(pXmlDoc
, sPathStart
+ "/a:ln/a:solidFill/a:srgbClr", "val", "ffbf00");
1193 void SdOOXMLExportTest1::testTdf100348FontworkGradientGlow()
1195 ::sd::DrawDocShellRef xDocShRef
1196 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/tdf100348_FontworkGradientGlow.odp"), ODP
);
1197 utl::TempFile tempFile
;
1198 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1199 xDocShRef
->DoClose();
1201 // Make sure the fontwork shape has a gradient fill and a colored glow.
1202 // Without the patch, fill was black and no glow applied.
1203 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
1204 const OString
sPathStart("//p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:p/a:r/a:rPr");
1205 assertXPath(pXmlDoc
, sPathStart
+ "/a:gradFill/a:gsLst/a:gs[1]/a:srgbClr", "val", "8d281e");
1206 assertXPath(pXmlDoc
, sPathStart
+ "/a:effectLst/a:glow", "rad", "63360");
1207 assertXPath(pXmlDoc
, sPathStart
+ "/a:effectLst/a:glow/a:srgbClr", "val", "ff4500");
1210 void SdOOXMLExportTest1::testTdf128345FullTransparentGradient()
1212 ::sd::DrawDocShellRef xDocShRef
1213 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/tdf128345_FullTransparentGradient.odp"), ODP
);
1214 utl::TempFile tempFile
;
1215 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1216 xDocShRef
->DoClose();
1218 // Make sure the shape has no fill. Without the patch, fill was solid red.
1219 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
1220 assertXPath(pXmlDoc
, "//p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:noFill");
1223 void SdOOXMLExportTest1::testTdf128345GradientLinear()
1225 ::sd::DrawDocShellRef xDocShRef
1226 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/tdf128345_GradientLinear.odp"), ODP
);
1227 utl::TempFile tempFile
;
1228 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1229 xDocShRef
->DoClose();
1231 // Make sure the shape has a lin fill. Without the patch, fill was solid red.
1232 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
1233 const OString
sPathStart("//p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill");
1234 assertXPath(pXmlDoc
, sPathStart
+ "/a:lin", "ang", "3600000");
1235 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs",2);
1236 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[1]", "pos", "25000");
1237 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[1]/a:srgbClr", "val", "ff0000");
1238 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "20000");
1239 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[2]", "pos", "100000");
1240 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[2]/a:srgbClr", "val", "ff0000");
1241 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "80000");
1244 void SdOOXMLExportTest1::testTdf128345GradientRadial()
1246 ::sd::DrawDocShellRef xDocShRef
1247 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/tdf128345_GradientRadial.odp"), ODP
);
1248 utl::TempFile tempFile
;
1249 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1250 xDocShRef
->DoClose();
1252 // Make sure the shape has transparency. In OOXML alpha means 'opacity' with default
1253 // 100000 for full opak, so only the full transparency with val 0 should be written.
1254 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
1255 const OString
sPathStart("//p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill");
1256 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs",2);
1257 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[1]/a:srgbClr", "val", "ff0000");
1258 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", 0);
1259 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[2]/a:srgbClr", "val", "ffffff");
1260 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "0");
1263 void SdOOXMLExportTest1::testTdf128345GradientAxial()
1265 // Without the patch, symmetric linear gradient with full transparence outside and
1266 // full opak in the middle were imported as full transparent.
1267 ::sd::DrawDocShellRef xDocShRef
1268 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/tdf128345_GradientAxial.odp"), ODP
);
1269 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
);
1270 uno::Reference
<beans::XPropertySet
> xShapePropSet(getShapeFromPage(0, 0, xDocShRef
));
1272 awt::Gradient aTransparenceGradient
;
1273 xShapePropSet
->getPropertyValue("FillTransparenceGradient") >>= aTransparenceGradient
;
1274 CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aTransparenceGradient
.StartColor
);
1275 CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), aTransparenceGradient
.EndColor
);
1276 CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL
, aTransparenceGradient
.Style
);
1278 xDocShRef
->DoClose();
1281 void SdOOXMLExportTest1::testTdf134969TransparencyOnColorGradient()
1283 ::sd::DrawDocShellRef xDocShRef
1284 = loadURL(m_directories
.getURLFromSrc("sd/qa/unit/data/odp/tdf134969_TransparencyOnColorGradient.odp"), ODP
);
1285 utl::TempFile tempFile
;
1286 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1287 xDocShRef
->DoClose();
1289 // Make sure the shape has a transparency in gradient stops.
1290 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
1291 const OString
sPathStart("//p:sld/p:cSld/p:spTree/p:sp/p:spPr/a:gradFill");
1292 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs",2);
1293 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[1]/a:srgbClr/a:alpha", "val", "60000");
1294 assertXPath(pXmlDoc
, sPathStart
+ "/a:gsLst/a:gs[2]/a:srgbClr/a:alpha", "val", "60000");
1297 void SdOOXMLExportTest1::testArcTo()
1299 ::sd::DrawDocShellRef xDocShRef
1300 = loadURL(m_directories
.getURLFromSrc(u
"sd/qa/unit/data/pptx/arc-validiert.pptx"), PPTX
);
1301 utl::TempFile tempFile
;
1302 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &tempFile
);
1303 xDocShRef
->DoClose();
1305 xmlDocUniquePtr pXmlDoc
= parseExport(tempFile
, "ppt/slides/slide1.xml");
1306 const OString
sPath("//a:custGeom/a:pathLst/a:path/a:arcTo");
1307 assertXPath(pXmlDoc
, sPath
, "wR", "3");
1308 assertXPath(pXmlDoc
, sPath
, "hR", "3");
1309 assertXPath(pXmlDoc
, sPath
, "stAng", "1800000");
1310 assertXPath(pXmlDoc
, sPath
, "swAng", "2700000");
1313 void SdOOXMLExportTest1::testNarrationMimeType()
1315 sd::DrawDocShellRef xDocShRef
1316 = loadURL(m_directories
.getURLFromSrc(u
"sd/qa/unit/data/pptx/narration.pptx"), PPTX
);
1317 utl::TempFile aTempFile
;
1318 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &aTempFile
);
1319 xmlDocUniquePtr pXmlDoc
= parseExport(aTempFile
, "[Content_Types].xml");
1320 // Without the accompanying fix in place, this test would have failed with:
1321 // - Expected: audio/mp4
1322 // - Actual : application/vnd.sun.star.media
1323 // i.e. the mime type of the narration was incorrect.
1324 assertXPath(pXmlDoc
,
1325 "/ContentType:Types/ContentType:Override[@PartName='/ppt/media/media1.m4a']",
1326 "ContentType", "audio/mp4");
1327 xDocShRef
->DoClose();
1330 void SdOOXMLExportTest1::testTdf140865Wordart3D()
1332 sd::DrawDocShellRef xDocShRef
1333 = loadURL(m_directories
.getURLFromSrc(u
"sd/qa/unit/data/pptx/tdf140865Wordart3D.pptx"), PPTX
);
1334 utl::TempFile aTempFile
;
1335 xDocShRef
= saveAndReload(xDocShRef
.get(), PPTX
, &aTempFile
);
1336 xmlDocUniquePtr pXmlDoc
= parseExport(aTempFile
, "ppt/slides/slide1.xml");
1338 // without the fix in place a:sp3d was lost on round trip, and so extrusion was lost.
1339 constexpr OStringLiteral
sPathStart("//p:sld/p:cSld/p:spTree/p:sp/p:txBody/a:bodyPr");
1340 assertXPath(pXmlDoc
, sPathStart
+ "/a:sp3d", "extrusionH", "342900");
1341 assertXPath(pXmlDoc
, sPathStart
+ "/a:sp3d", "contourW", "12700");
1342 assertXPath(pXmlDoc
, sPathStart
+ "/a:sp3d/a:bevelT", "w", "114300");
1343 assertXPath(pXmlDoc
, sPathStart
+ "/a:sp3d/a:bevelT", "h", "38100");
1344 assertXPath(pXmlDoc
, sPathStart
+ "/a:sp3d/a:bevelT", "prst", "softRound");
1345 assertXPath(pXmlDoc
, sPathStart
+ "/a:sp3d/a:bevelB", "h", "152400");
1346 assertXPath(pXmlDoc
, sPathStart
+ "/a:sp3d/a:extrusionClr/a:srgbClr", "val", "990000");
1347 assertXPath(pXmlDoc
, sPathStart
+ "/a:sp3d/a:contourClr/a:srgbClr", "val", "009876");
1349 xDocShRef
->DoClose();
1352 CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest1
);
1354 CPPUNIT_PLUGIN_IMPLEMENT();
1356 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */