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/.
10 #include <config_poppler.h>
12 #include "sdmodeltestbase.hxx"
14 #include <svl/stritem.hxx>
15 #include <editeng/editobj.hxx>
16 #include <editeng/outlobj.hxx>
17 #include <editeng/ulspitem.hxx>
18 #include <editeng/fhgtitem.hxx>
19 #include <editeng/escapementitem.hxx>
20 #include <editeng/colritem.hxx>
21 #include <editeng/fontitem.hxx>
22 #include <editeng/wghtitem.hxx>
23 #include <editeng/numitem.hxx>
24 #include <editeng/lrspitem.hxx>
25 #include <editeng/postitem.hxx>
26 #include <rsc/rscsfx.hxx>
28 #include <sfx2/sfxsids.hrc>
29 #include <svl/stritem.hxx>
30 #include <svx/svdotext.hxx>
31 #include <svx/svdoashp.hxx>
32 #include <svx/svdograf.hxx>
33 #include <svx/svdogrp.hxx>
34 #include <svx/svdomedia.hxx>
35 #include <svx/svdoole2.hxx>
36 #include <svx/svdotable.hxx>
37 #include <svx/xflclit.hxx>
38 #include <svx/xlineit0.hxx>
39 #include <svx/xlnclit.hxx>
40 #include <svx/xlnwtit.hxx>
41 #include <animations/animationnodehelper.hxx>
42 #include <sax/tools/converter.hxx>
44 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
45 #include <com/sun/star/drawing/XDrawPage.hpp>
46 #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
47 #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
48 #include <com/sun/star/animations/XAnimationNode.hpp>
49 #include <com/sun/star/animations/XAnimate.hpp>
50 #include <com/sun/star/beans/XPropertySet.hpp>
51 #include <com/sun/star/chart/XChartDocument.hpp>
52 #include <com/sun/star/chart2/XChartDocument.hpp>
53 #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
54 #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
55 #include <com/sun/star/chart2/XChartTypeContainer.hpp>
56 #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
57 #include <com/sun/star/chart2/data/XDataSequence.hpp>
58 #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
59 #include <com/sun/star/table/BorderLine2.hpp>
60 #include <com/sun/star/style/ParagraphAdjust.hpp>
61 #include <com/sun/star/table/XTableRows.hpp>
63 #include <stlpool.hxx>
65 using namespace ::com::sun::star
;
67 /// Impress import filters tests.
68 class SdImportTest
: public SdModelTestBase
71 void testDocumentLayout();
75 void testMasterPageStyleParent();
83 void testStrictOOXML();
91 void testCreationDate();
92 void testBnc584721_1();
93 void testBnc584721_2();
94 void testBnc584721_3();
95 void testBnc584721_4();
97 void testShapeLineStyle();
98 void testBnc862510_6();
99 void testBnc862510_7();
101 void testPDFImport();
102 void testPDFImportSkipImages();
104 void testBulletSuffix();
105 void testBnc910045();
106 void testRowHeight();
108 CPPUNIT_TEST_SUITE(SdImportTest
);
110 CPPUNIT_TEST(testDocumentLayout
);
111 CPPUNIT_TEST(testSmoketest
);
112 CPPUNIT_TEST(testN759180
);
113 CPPUNIT_TEST(testN778859
);
114 CPPUNIT_TEST(testMasterPageStyleParent
);
115 CPPUNIT_TEST(testFdo64512
);
116 CPPUNIT_TEST(testFdo71075
);
117 CPPUNIT_TEST(testN828390_2
);
118 CPPUNIT_TEST(testN828390_3
);
119 CPPUNIT_TEST(testFdo68594
);
120 CPPUNIT_TEST(testFdo72998
);
121 CPPUNIT_TEST(testFdo77027
);
122 CPPUNIT_TEST(testStrictOOXML
);
123 CPPUNIT_TEST(testN862510_1
);
124 CPPUNIT_TEST(testN862510_2
);
125 CPPUNIT_TEST(testN862510_4
);
126 CPPUNIT_TEST(testBnc870237
);
127 CPPUNIT_TEST(testBnc887225
);
128 CPPUNIT_TEST(testBnc480256
);
129 CPPUNIT_TEST(testBnc591147
);
130 CPPUNIT_TEST(testCreationDate
);
131 CPPUNIT_TEST(testBnc584721_1
);
132 CPPUNIT_TEST(testBnc584721_2
);
133 CPPUNIT_TEST(testBnc584721_3
);
134 CPPUNIT_TEST(testBnc584721_4
);
135 CPPUNIT_TEST(testBnc904423
);
136 CPPUNIT_TEST(testShapeLineStyle
);
137 CPPUNIT_TEST(testBnc862510_6
);
138 CPPUNIT_TEST(testBnc862510_7
);
140 CPPUNIT_TEST(testPDFImport
);
141 CPPUNIT_TEST(testPDFImportSkipImages
);
143 CPPUNIT_TEST(testBulletSuffix
);
144 CPPUNIT_TEST(testBnc910045
);
145 CPPUNIT_TEST(testRowHeight
);
147 CPPUNIT_TEST_SUITE_END();
150 /** Test document against a reference XML dump of shapes.
152 If you want to update one of these tests, or add a new one, set the nUpdateMe
153 to the index of the test, and the dump XML's will be created (or rewritten)
154 instead of checking. Use with care - when the test is failing, first find out
155 why, instead of just updating .xml's blindly.
157 Example: Let's say you are adding a test called fdoABCD.pptx. You'll place it
158 to the data/ subdirectory, and will add an entry to aFilesToCompare below,
159 the 3rd parameter is for export test - can be -1 (don't export), ODP, PPT or PPTX
162 { "fdoABCD.pptx", "xml/fdoABCD_", PPTX },
164 and will count the index in the aFilesToCompare structure (1st is 0, 2nd is 1,
165 etc.) Temporarily you'll set nUpdateMe to this index (instead of -1), and run
169 This will generate the sd/qa/unit/data/xml/fdoABCD_*.xml for you. Now you
170 will change nUpdateMe back to -1, and commit your fdoABCD.pptx test, the
171 xml/fdoABCD_*.xml dumps, and the aFilesToCompare addition in one commit.
173 As the last step, you will revert your fix and do 'make sd' again, to check
174 that without your fix, the unit test breaks. Then clean up, and push :-)
176 NOTE: This approach is suitable only for tests of fixes that actually change
177 the layout - best to check by reverting your fix locally after having added
178 the test, and re-running; it should break.
180 void SdImportTest::testDocumentLayout()
182 struct { const char *pInput
, *pDump
; sal_Int32 nFormat
; sal_Int32 nExportType
; } aFilesToCompare
[] =
184 { "odp/shapes-test.odp", "xml/shapes-test_page", ODP
, -1 },
185 { "fdo47434.pptx", "xml/fdo47434_", PPTX
, -1 },
186 { "n758621.ppt", "xml/n758621_", PPT
, -1 },
187 { "fdo64586.ppt", "xml/fdo64586_", PPT
, -1 },
188 { "n819614.pptx", "xml/n819614_", PPTX
, -1 },
189 { "n820786.pptx", "xml/n820786_", PPTX
, -1 },
190 { "n762695.pptx", "xml/n762695_", PPTX
, -1 },
191 { "n593612.pptx", "xml/n593612_", PPTX
, -1 },
192 { "fdo71434.pptx", "xml/fdo71434_", PPTX
, -1 },
193 { "n902652.pptx", "xml/n902652_", PPTX
, -1 },
194 { "tdf90403.pptx", "xml/tdf90403_", PPTX
, -1 },
195 { "tdf90338.odp", "xml/tdf90338_", ODP
, PPTX
},
196 // { "pptx/n828390.pptx", "pptx/xml/n828390_", PPTX, PPTX }, // Example
199 for ( int i
= 0; i
< static_cast< int >( SAL_N_ELEMENTS( aFilesToCompare
) ); ++i
)
201 int nUpdateMe
= -1; // index of test we want to update; supposedly only when the test is created
203 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare
[i
].pInput
), aFilesToCompare
[i
].nFormat
);
204 if( aFilesToCompare
[i
].nExportType
>= 0 )
205 xDocShRef
= saveAndReload( xDocShRef
, aFilesToCompare
[i
].nExportType
);
206 compareWithShapesDump( xDocShRef
,
207 getPathFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare
[i
].pDump
),
212 void SdImportTest::testSmoketest()
214 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/smoketest.pptx"), PPTX
);
216 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
217 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
219 // cf. SdrModel svx/svdmodel.hxx ...
221 CPPUNIT_ASSERT_MESSAGE( "wrong page count", pDoc
->GetPageCount() == 3);
223 const SdrPage
*pPage
= pDoc
->GetPage (1);
224 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
226 const size_t nObjs
= pPage
->GetObjCount();
227 for (size_t i
= 0; i
< nObjs
; i
++)
229 SdrObject
*pObj
= pPage
->GetObj(i
);
230 SdrObjKind eKind
= (SdrObjKind
) pObj
->GetObjIdentifier();
231 SdrTextObj
*pTxt
= dynamic_cast<SdrTextObj
*>( pObj
);
232 (void)pTxt
; (void)eKind
;
235 CPPUNIT_ASSERT_MESSAGE( "changed", !pDoc
->IsChanged() );
237 xDocShRef
->DoClose();
240 void SdImportTest::testN759180()
242 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/n759180.pptx"), PPTX
);
244 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
245 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
246 const SdrPage
*pPage
= pDoc
->GetPage (1);
247 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
249 //sal_uIntPtr nObjs = pPage->GetObjCount();
250 //for (sal_uIntPtr i = 0; i < nObjs; i++)
253 SdrObject
*pObj
= pPage
->GetObj(0);
254 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
255 CPPUNIT_ASSERT(pTxtObj
);
256 std::vector
<EECharAttrib
> rLst
;
257 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
258 const SvxULSpaceItem
*pULSpace
= dynamic_cast<const SvxULSpaceItem
*>(aEdit
.GetParaAttribs(0).GetItem(EE_PARA_ULSPACE
));
259 CPPUNIT_ASSERT(pULSpace
);
260 CPPUNIT_ASSERT_MESSAGE( "Para bottom spacing is wrong!", pULSpace
->GetLower() == 0 );
261 aEdit
.GetCharAttribs(1, rLst
);
262 for( std::vector
<EECharAttrib
>::reverse_iterator it
= rLst
.rbegin(); it
!=rLst
.rend(); ++it
)
264 const SvxFontHeightItem
* pFontHeight
= dynamic_cast<const SvxFontHeightItem
*>((*it
).pAttr
);
268 // font height = 5 => 5*2540/72
269 CPPUNIT_ASSERT_MESSAGE( "Font height is wrong", pFontHeight
->GetHeight() == 176 );
275 xDocShRef
->DoClose();
278 void SdImportTest::testN862510_1()
280 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_1.pptx"), PPTX
);
282 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
283 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
284 const SdrPage
*pPage
= pDoc
->GetPage(1);
285 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
287 std::vector
<EECharAttrib
> rLst
;
288 SdrObject
*pObj
= pPage
->GetObj( 0 );
289 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
290 CPPUNIT_ASSERT( pTxtObj
);
291 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
292 aEdit
.GetCharAttribs( 0, rLst
);
293 for( std::vector
<EECharAttrib
>::reverse_iterator it
= rLst
.rbegin(); it
!=rLst
.rend(); ++it
)
295 const SvxEscapementItem
*pFontEscapement
= dynamic_cast<const SvxEscapementItem
*>( (*it
).pAttr
);
296 CPPUNIT_ASSERT_MESSAGE( "Baseline attribute not handled properly", !( pFontEscapement
&& pFontEscapement
->GetProp() != 100 ) );
300 xDocShRef
->DoClose();
303 void SdImportTest::testN862510_2()
305 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_2.pptx"), PPTX
);
307 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
308 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
309 const SdrPage
*pPage
= pDoc
->GetPage(1);
310 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
312 SdrObjGroup
*pGrpObj
= dynamic_cast<SdrObjGroup
*>( pPage
->GetObj( 0 ) );
313 CPPUNIT_ASSERT( pGrpObj
);
314 SdrObjCustomShape
*pObj
= dynamic_cast<SdrObjCustomShape
*>( pGrpObj
->GetSubList()->GetObj( 0 ) );
315 CPPUNIT_ASSERT( pObj
);
316 CPPUNIT_ASSERT_MESSAGE( "Wrong Text Rotation!", pObj
->GetExtraTextRotation( true ) == 90 );
319 xDocShRef
->DoClose();
322 void SdImportTest::testN862510_4()
324 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_4.pptx"), PPTX
);
326 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
327 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
328 const SdrPage
*pPage
= pDoc
->GetPage( 1 );
329 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
331 std::vector
<EECharAttrib
> rLst
;
332 SdrObject
*pObj
= pPage
->GetObj( 0 );
333 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
334 CPPUNIT_ASSERT( pTxtObj
);
335 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
336 aEdit
.GetCharAttribs( 0, rLst
);
337 for( std::vector
<EECharAttrib
>::reverse_iterator it
= rLst
.rbegin(); it
!= rLst
.rend(); ++it
)
339 const SvxColorItem
*pC
= dynamic_cast<const SvxColorItem
*>( (*it
).pAttr
);
340 CPPUNIT_ASSERT_MESSAGE( "gradfill for text color not handled!", !( pC
&& pC
->GetValue().GetColor() == 0 ) );
344 xDocShRef
->DoClose();
347 void SdImportTest::testN828390_2()
349 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_2.pptx"), PPTX
);
351 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
352 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
353 const SdrPage
*pPage
= pDoc
->GetPage(1);
354 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
356 SdrObject
*pObj
= pPage
->GetObj(0);
357 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
358 CPPUNIT_ASSERT( pTxtObj
);
359 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
360 CPPUNIT_ASSERT(aEdit
.GetText(0) == "Linux ");
361 CPPUNIT_ASSERT(aEdit
.GetText(1) == "Standard Platform");
363 xDocShRef
->DoClose();
366 void SdImportTest::testN828390_3()
369 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_3.pptx"), PPTX
);
371 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
372 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
373 const SdrPage
*pPage
= pDoc
->GetPage(1);
374 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
376 SdrObject
*pObj
= pPage
->GetObj(0);
377 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
378 CPPUNIT_ASSERT( pTxtObj
);
379 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
380 std::vector
<EECharAttrib
> rLst
;
381 aEdit
.GetCharAttribs(1, rLst
);
382 for( std::vector
<EECharAttrib
>::reverse_iterator it
= rLst
.rbegin(); it
!=rLst
.rend(); ++it
)
384 const SvxEscapementItem
*pFontEscapement
= dynamic_cast<const SvxEscapementItem
*>((*it
).pAttr
);
387 if( pFontEscapement
->GetEsc() != 0 )
394 CPPUNIT_ASSERT_MESSAGE("CharEscapment not imported properly", bPassed
);
396 xDocShRef
->DoClose();
399 void SdImportTest::testMasterPageStyleParent()
401 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc("/sd/qa/unit/data/odp/masterpage_style_parent.odp"), ODP
);
403 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
404 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
405 const SdrPage
*pPage
= pDoc
->GetPage(1);
406 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
408 SdStyleSheetPool
*const pPool(pDoc
->GetSdStyleSheetPool());
411 SfxStyleSheetIterator
iter(pPool
, SD_STYLE_FAMILY_MASTERPAGE
);
412 for (SfxStyleSheetBase
* pStyle
= iter
.First(); pStyle
; pStyle
= iter
.Next())
414 OUString
const name(pStyle
->GetName());
415 OUString
const parent(pStyle
->GetParent());
416 if (!parent
.isEmpty())
419 // check that parent exists
420 SfxStyleSheetBase
*const pParentStyle(
421 pPool
->Find(parent
, SD_STYLE_FAMILY_MASTERPAGE
));
422 CPPUNIT_ASSERT(pParentStyle
);
423 CPPUNIT_ASSERT_EQUAL(pParentStyle
->GetName(), parent
);
424 // check that parent has the same master page as pStyle
425 CPPUNIT_ASSERT(parent
.indexOf(SD_LT_SEPARATOR
) != -1);
426 CPPUNIT_ASSERT(name
.indexOf(SD_LT_SEPARATOR
) != -1);
427 CPPUNIT_ASSERT_EQUAL(
428 parent
.copy(0, parent
.indexOf(SD_LT_SEPARATOR
)),
429 name
.copy(0, name
.indexOf(SD_LT_SEPARATOR
)));
432 // check that there are actually parents...
433 CPPUNIT_ASSERT_EQUAL(16, parents
);
435 xDocShRef
->DoClose();
438 void SdImportTest::testN778859()
440 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"), PPTX
);
442 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
443 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
444 const SdrPage
*pPage
= pDoc
->GetPage(1);
445 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
448 SdrObject
*pObj
= pPage
->GetObj(1);
449 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
450 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= NULL
);
451 CPPUNIT_ASSERT(!pTxtObj
->IsAutoFit());
454 xDocShRef
->DoClose();
457 void SdImportTest::testFdo68594()
459 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/ppt/fdo68594.ppt"), PPT
);
461 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
462 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
463 const SdrPage
*pPage
= &(pDoc
->GetPage (1)->TRG_GetMasterPage());
464 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
465 SdrObject
*pObj
= pPage
->GetObj(1);
466 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
467 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= NULL
);
468 const SvxColorItem
*pC
= dynamic_cast<const SvxColorItem
*>(&pTxtObj
->GetMergedItem(EE_CHAR_COLOR
));
469 CPPUNIT_ASSERT_MESSAGE( "no color item", pC
!= NULL
);
470 // Color should be black
471 CPPUNIT_ASSERT_MESSAGE( "Placeholder color mismatch", pC
->GetValue().GetColor() == 0);
473 xDocShRef
->DoClose();
476 void SdImportTest::testFdo72998()
478 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/cshapes.pptx"), PPTX
);
480 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
481 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
482 const SdrPage
*pPage
= pDoc
->GetPage(1);
483 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
485 SdrObjCustomShape
*pObj
= dynamic_cast<SdrObjCustomShape
*>(pPage
->GetObj(2));
486 CPPUNIT_ASSERT( pObj
);
487 const SdrCustomShapeGeometryItem
& rGeometryItem
= static_cast<const SdrCustomShapeGeometryItem
&>(pObj
->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY
));
488 const ::com::sun::star::uno::Any
* pViewBox
= ((SdrCustomShapeGeometryItem
&)rGeometryItem
).GetPropertyValueByName( OUString( "ViewBox" ) );
489 CPPUNIT_ASSERT_MESSAGE( "Missing ViewBox", pViewBox
);
490 com::sun::star::awt::Rectangle aViewBox
;
491 CPPUNIT_ASSERT( (*pViewBox
>>= aViewBox
) );
492 CPPUNIT_ASSERT_MESSAGE( "Width should be zero - for forcing scale to 1", !aViewBox
.Width
);
493 CPPUNIT_ASSERT_MESSAGE( "Height should be zero - for forcing scale to 1", !aViewBox
.Height
);
496 xDocShRef
->DoClose();
500 std::ostream
& operator<<(std::ostream
& rStrm
, const Color
& rColor
)
502 rStrm
<< "Color: R:" << rColor
.GetRed() << " G:" << rColor
.GetGreen() << " B: " << rColor
.GetBlue();
506 void SdImportTest::testFdo77027()
508 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/odp/fdo77027.odp"), ODP
);
510 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
511 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
512 const SdrPage
*pPage
= pDoc
->GetPage(1);
513 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
515 SdrOle2Obj
*const pObj
= dynamic_cast<SdrOle2Obj
*>(pPage
->GetObj(0));
516 CPPUNIT_ASSERT(pObj
);
518 // check that the fill style/color was actually imported
519 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
520 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
521 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
522 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
523 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
524 CPPUNIT_ASSERT_EQUAL(Color(0xff6600), rColorItem
.GetColorValue());
527 xDocShRef
->DoClose();
530 void SdImportTest::testFdo64512()
532 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/fdo64512.odp"), ODP
);
534 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(
535 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
536 CPPUNIT_ASSERT_MESSAGE( "not exactly one page", xDoc
->getDrawPages()->getCount() == 1 );
538 uno::Reference
< drawing::XDrawPage
> xPage(
539 xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
540 CPPUNIT_ASSERT_MESSAGE( "no exactly three shapes", xPage
->getCount() == 3 );
542 uno::Reference
< beans::XPropertySet
> xConnectorShape(
543 xPage
->getByIndex(2), uno::UNO_QUERY
);
544 CPPUNIT_ASSERT_MESSAGE( "no connector shape", xConnectorShape
.is() );
546 uno::Reference
< beans::XPropertySet
> xSvgShape(
547 xConnectorShape
->getPropertyValue("StartShape"), uno::UNO_QUERY
);
548 CPPUNIT_ASSERT_MESSAGE( "no start shape", xSvgShape
.is() );
550 uno::Reference
< beans::XPropertySet
> xCustomShape(
551 xConnectorShape
->getPropertyValue("EndShape"), uno::UNO_QUERY
);
552 CPPUNIT_ASSERT_MESSAGE( "no end shape", xCustomShape
.is() );
554 uno::Reference
< animations::XAnimationNodeSupplier
> xAnimNodeSupplier(
555 xPage
, uno::UNO_QUERY_THROW
);
556 uno::Reference
< animations::XAnimationNode
> xRootNode(
557 xAnimNodeSupplier
->getAnimationNode() );
558 std::vector
< uno::Reference
< animations::XAnimationNode
> > aAnimVector
;
559 anim::create_deep_vector(xRootNode
, aAnimVector
);
560 CPPUNIT_ASSERT_MESSAGE( "not 8 animation nodes", aAnimVector
.size() == 8 );
562 uno::Reference
< animations::XAnimate
> xNode(
563 aAnimVector
[7], uno::UNO_QUERY_THROW
);
564 uno::Reference
< drawing::XShape
> xTargetShape(
565 xNode
->getTarget(), uno::UNO_QUERY_THROW
);
566 CPPUNIT_ASSERT_MESSAGE( "inner node not referencing svg shape",
567 xTargetShape
!= xSvgShape
);
569 xDocShRef
->DoClose();
572 // Unit test for importing charts
573 void SdImportTest::testFdo71075()
575 double values
[] = { 12.0, 13.0, 14.0 };
576 ::com::sun::star::uno::Any aAny
;
577 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71075.odp"), ODP
);
579 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
580 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
581 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
582 uno::Reference
< drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
583 uno::Reference
< drawing::XShape
> xShape(xPage
->getByIndex(0), uno::UNO_QUERY_THROW
);
584 CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape
.is() );
586 uno::Reference
< beans::XPropertySet
> xPropSet( xShape
, uno::UNO_QUERY
);
587 aAny
= xPropSet
->getPropertyValue( OUString("Model") );
588 CPPUNIT_ASSERT_MESSAGE( "failed to load shape", aAny
.hasValue() );
590 uno::Reference
< chart::XChartDocument
> xChartDoc
;
592 CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc
.is() );
593 uno::Reference
< chart2::XChartDocument
> xChart2Doc( xChartDoc
, uno::UNO_QUERY
);
594 CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc
.is() );
596 uno::Reference
< chart2::XCoordinateSystemContainer
> xBCooSysCnt( xChart2Doc
->getFirstDiagram(), uno::UNO_QUERY
);
597 uno::Sequence
< uno::Reference
< chart2::XCoordinateSystem
> > aCooSysSeq( xBCooSysCnt
->getCoordinateSystems());
598 uno::Reference
< chart2::XChartTypeContainer
> xCTCnt( aCooSysSeq
[0], uno::UNO_QUERY
);
600 uno::Reference
< chart2::XDataSeriesContainer
> xDSCnt( xCTCnt
->getChartTypes()[0], uno::UNO_QUERY
);
601 CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt
.is() );
602 uno::Sequence
< uno::Reference
< chart2::XDataSeries
> > aSeriesSeq( xDSCnt
->getDataSeries());
603 CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aSeriesSeq
.getLength() == 1);
604 uno::Reference
< chart2::data::XDataSource
> xSource( aSeriesSeq
[0], uno::UNO_QUERY
);
605 uno::Sequence
< uno::Reference
< chart2::data::XLabeledDataSequence
> > aSeqCnt(xSource
->getDataSequences());
606 CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aSeqCnt
.getLength() == 1);
607 uno::Reference
< chart2::data::XDataSequence
> xValueSeq( aSeqCnt
[0]->getValues() );
608 CPPUNIT_ASSERT_MESSAGE( "Invalid Data count", xValueSeq
->getData().getLength() == sizeof(values
)/(sizeof(double)));
609 uno::Reference
< chart2::data::XNumericalDataSequence
> xNumSeq( xValueSeq
, uno::UNO_QUERY
);
610 uno::Sequence
< double > aValues( xNumSeq
->getNumericalData());
611 for(sal_Int32 i
=0;i
<xValueSeq
->getData().getLength();i
++)
612 CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aValues
.getConstArray()[i
] == values
[i
]);
614 xDocShRef
->DoClose();
617 void SdImportTest::testStrictOOXML()
619 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/strict_ooxml.pptx"), PPTX
);
621 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
622 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
623 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
624 uno::Reference
< drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
625 uno::Reference
< drawing::XShape
> xShape(xPage
->getByIndex(0), uno::UNO_QUERY_THROW
);
626 CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape
.is() );
628 xDocShRef
->DoClose();
631 void SdImportTest::testBnc870237()
633 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870237.pptx"), PPTX
);
635 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
636 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
637 const SdrPage
*pPage
= pDoc
->GetPage (1);
638 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
640 // Simulate a:ext inside dsp:txXfrm with changing the lower distance
641 const SdrObjGroup
* pObj
= dynamic_cast<SdrObjGroup
*>( pPage
->GetObj( 0 ) );
642 CPPUNIT_ASSERT_MESSAGE( "no object", pObj
!= NULL
);
643 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrMetricItem
& >(pObj
->GetMergedItem(SDRATTR_TEXT_UPPERDIST
))).GetValue());
644 CPPUNIT_ASSERT_EQUAL( sal_Int32(9919), (static_cast< const SdrMetricItem
& >(pObj
->GetMergedItem(SDRATTR_TEXT_LOWERDIST
))).GetValue());
645 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrMetricItem
& >(pObj
->GetMergedItem(SDRATTR_TEXT_RIGHTDIST
))).GetValue());
646 CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrMetricItem
& >(pObj
->GetMergedItem(SDRATTR_TEXT_LEFTDIST
))).GetValue());
648 xDocShRef
->DoClose();
651 void SdImportTest::testCreationDate()
653 sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71434.pptx"), PPTX
);
654 uno::Reference
<document::XDocumentPropertiesSupplier
> xDocumentPropertiesSupplier(xDocShRef
->GetModel(), uno::UNO_QUERY
);
655 uno::Reference
<document::XDocumentProperties
> xDocumentProperties
= xDocumentPropertiesSupplier
->getDocumentProperties();
656 util::DateTime aDate
= xDocumentProperties
->getCreationDate();
657 OUStringBuffer aBuffer
;
658 sax::Converter::convertDateTime(aBuffer
, aDate
, 0);
659 // Metadata wasn't imported, this was 0000-00-00.
660 CPPUNIT_ASSERT_EQUAL(OUString("2013-11-09T10:37:56"), aBuffer
.makeStringAndClear());
661 xDocShRef
->DoClose();
664 void SdImportTest::testBnc887225()
666 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/bnc887225.pptx"), PPTX
);
667 // In the document, lastRow and lastCol table properties are used.
668 // Make sure styles are set properly for individual cells.
670 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
671 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
672 const SdrPage
*pPage
= pDoc
->GetPage(1);
673 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
675 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(2));
676 CPPUNIT_ASSERT( pTableObj
);
677 uno::Reference
< table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
678 uno::Reference
< beans::XPropertySet
> xCell
;
681 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
682 xCell
->getPropertyValue("FillColor") >>= nColor
;
683 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor
);
685 xCell
.set(xTable
->getCellByPosition(0, 1), uno::UNO_QUERY_THROW
);
686 xCell
->getPropertyValue("FillColor") >>= nColor
;
687 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor
);
689 xCell
.set(xTable
->getCellByPosition(1, 1), uno::UNO_QUERY_THROW
);
690 xCell
->getPropertyValue("FillColor") >>= nColor
;
691 CPPUNIT_ASSERT_EQUAL(sal_Int32(13754095), nColor
);
693 xCell
.set(xTable
->getCellByPosition(1, 2), uno::UNO_QUERY_THROW
);
694 xCell
->getPropertyValue("FillColor") >>= nColor
;
695 CPPUNIT_ASSERT_EQUAL(sal_Int32(15331319), nColor
);
697 xCell
.set(xTable
->getCellByPosition(1, 4), uno::UNO_QUERY_THROW
);
698 xCell
->getPropertyValue("FillColor") >>= nColor
;
699 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor
);
701 xCell
.set(xTable
->getCellByPosition(3, 2), uno::UNO_QUERY_THROW
);
702 xCell
->getPropertyValue("FillColor") >>= nColor
;
703 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor
);
705 xCell
.set(xTable
->getCellByPosition(3, 4), uno::UNO_QUERY_THROW
);
706 xCell
->getPropertyValue("FillColor") >>= nColor
;
707 CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor
);
709 xDocShRef
->DoClose();
712 void SdImportTest::testBnc480256()
714 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc480256.pptx"), PPTX
);
715 // In the document, there are two tables with table background properties.
716 // Make sure colors are set properly for individual cells.
718 // TODO: If you are working on improving table background support, expect
719 // this unit test to fail. In that case, feel free to change the numbers.
721 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
722 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
723 const SdrPage
*pPage
= pDoc
->GetPage(1);
724 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
726 sdr::table::SdrTableObj
*pTableObj
;
727 uno::Reference
< table::XCellRange
> xTable
;
728 uno::Reference
< beans::XPropertySet
> xCell
;
730 table::BorderLine2 aBorderLine
;
732 pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
733 CPPUNIT_ASSERT( pTableObj
);
734 xTable
.set(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
736 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
737 xCell
->getPropertyValue("FillColor") >>= nColor
;
738 CPPUNIT_ASSERT_EQUAL(sal_Int32(10208238), nColor
);
739 xCell
->getPropertyValue("LeftBorder") >>= aBorderLine
;
740 CPPUNIT_ASSERT_EQUAL(util::Color(5609427), aBorderLine
.Color
);
742 xCell
.set(xTable
->getCellByPosition(0, 1), uno::UNO_QUERY_THROW
);
743 xCell
->getPropertyValue("FillColor") >>= nColor
;
744 CPPUNIT_ASSERT_EQUAL(sal_Int32(13032959), nColor
);
745 xCell
->getPropertyValue("TopBorder") >>= aBorderLine
;
746 CPPUNIT_ASSERT_EQUAL(util::Color(5609427), aBorderLine
.Color
);
748 pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(1));
749 CPPUNIT_ASSERT( pTableObj
);
750 xTable
.set(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
752 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
753 xCell
->getPropertyValue("FillColor") >>= nColor
;
754 CPPUNIT_ASSERT_EQUAL(sal_Int32(7056614), nColor
);
755 xCell
->getPropertyValue("LeftBorder") >>= aBorderLine
;
756 CPPUNIT_ASSERT_EQUAL(util::Color(12505062), aBorderLine
.Color
);
758 xCell
.set(xTable
->getCellByPosition(0, 1), uno::UNO_QUERY_THROW
);
759 xCell
->getPropertyValue("FillColor") >>= nColor
;
760 CPPUNIT_ASSERT_EQUAL(sal_Int32(4626400), nColor
);
762 xCell
.set(xTable
->getCellByPosition(1, 0), uno::UNO_QUERY_THROW
);
763 xCell
->getPropertyValue("BottomBorder") >>= aBorderLine
;
764 CPPUNIT_ASSERT_EQUAL(util::Color(0), aBorderLine
.Color
);
766 xDocShRef
->DoClose();
769 void SdImportTest::testBnc584721_1()
771 // Title text shape on the master page contained wrong text.
773 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX
);
775 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
776 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
777 const SdrPage
*pPage
= &(pDoc
->GetPage (1)->TRG_GetMasterPage());
778 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
779 SdrObject
*pObj
= pPage
->GetObj(0);
780 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pObj
);
781 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= NULL
);
782 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
783 CPPUNIT_ASSERT_EQUAL(OUString("Click to edit Master title style"), aEdit
.GetText(0));
784 xDocShRef
->DoClose();
787 void SdImportTest::testBnc584721_2()
789 // Import created an extra/unneeded outliner shape on the master slide next to the imported title shape.
791 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX
);
793 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
794 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
795 const SdrPage
*pPage
= &(pDoc
->GetPage(1)->TRG_GetMasterPage());
796 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
797 CPPUNIT_ASSERT_EQUAL(size_t(1), pPage
->GetObjCount());
799 xDocShRef
->DoClose();
802 void SdImportTest::testBnc584721_3()
804 // Subtitle was simply skipped on master slides.
805 // Check whether the second shape is a subtitle shape with the right text.
807 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_3.pptx"), PPTX
);
809 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
810 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
811 const SdrPage
*pPage
= &(pDoc
->GetPage(1)->TRG_GetMasterPage());
812 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
813 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj(1) );
814 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= NULL
);
816 // Check the shape type
817 uno::Reference
< drawing::XShape
> xShape( pTxtObj
->getUnoShape(), uno::UNO_QUERY
);
818 CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.presentation.SubtitleShape"), xShape
->getShapeType());
821 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
822 CPPUNIT_ASSERT_EQUAL(OUString("Click to edit Master subtitle style"), aEdit
.GetText(0));
824 xDocShRef
->DoClose();
827 void SdImportTest::testBnc591147()
829 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc591147.pptx"), PPTX
);
831 // In the document, there are two slides with media files.
832 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(
833 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
834 CPPUNIT_ASSERT_EQUAL( sal_Int32(2), xDoc
->getDrawPages()->getCount() );
836 // First page has video file inserted
837 uno::Reference
< drawing::XDrawPage
> xPage(
838 xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
839 CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage
->getCount() );
841 uno::Reference
< drawing::XShape
> xShape(xPage
->getByIndex(0), uno::UNO_QUERY_THROW
);
842 uno::Reference
< beans::XPropertySet
> xPropSet( xShape
, uno::UNO_QUERY_THROW
);
843 OUString
sVideoURL("emptyURL");
844 bool bSucess
= xPropSet
->getPropertyValue("MediaURL") >>= sVideoURL
;
845 CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSucess
);
846 CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sVideoURL
.isEmpty());
848 // Second page has audio file inserted
849 xPage
.set( xDoc
->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW
);
850 CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage
->getCount() );
852 xShape
.set( xPage
->getByIndex(0), uno::UNO_QUERY_THROW
);
853 xPropSet
.set( xShape
, uno::UNO_QUERY_THROW
);
854 OUString
sAudioURL("emptyURL");
855 bSucess
= xPropSet
->getPropertyValue("MediaURL") >>= sAudioURL
;
856 CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSucess
);
857 CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sAudioURL
.isEmpty());
859 CPPUNIT_ASSERT_MESSAGE( "sAudioURL and sVideoURL should not be equal", sAudioURL
!= sVideoURL
);
861 xDocShRef
->DoClose();
864 void SdImportTest::testBnc584721_4()
866 // Black text was imported as white because of wrong caching mechanism
868 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_4.pptx"), PPTX
);
870 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(
871 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
873 uno::Reference
< drawing::XDrawPage
> xPage(
874 xDoc
->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW
);
876 uno::Reference
< beans::XPropertySet
> xShape(
877 xPage
->getByIndex(1), uno::UNO_QUERY
);
878 CPPUNIT_ASSERT_MESSAGE( "no text shape", xShape
.is() );
880 // Get first paragraph of the text
881 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY
)->getText();
882 CPPUNIT_ASSERT_MESSAGE( "no text shape", xText
.is() );
883 uno::Reference
<container::XEnumerationAccess
> paraEnumAccess
;
884 paraEnumAccess
.set(xText
, uno::UNO_QUERY
);
885 uno::Reference
<container::XEnumeration
> paraEnum
= paraEnumAccess
->createEnumeration();
886 uno::Reference
<text::XTextRange
> const xParagraph(paraEnum
->nextElement(),
887 uno::UNO_QUERY_THROW
);
889 // Get first run of the paragraph
890 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xParagraph
, uno::UNO_QUERY
);
891 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
892 uno::Reference
<text::XTextRange
> xRun(xRunEnum
->nextElement(), uno::UNO_QUERY
);
893 uno::Reference
< beans::XPropertySet
> xPropSet( xRun
, uno::UNO_QUERY_THROW
);
894 sal_Int32 nCharColor
;
895 xPropSet
->getPropertyValue( "CharColor" ) >>= nCharColor
;
897 // Color should be black
898 CPPUNIT_ASSERT_EQUAL( sal_Int32(COL_BLACK
), nCharColor
);
900 xDocShRef
->DoClose();
903 void SdImportTest::testBnc904423()
905 // Here the problem was that different fill properties were applied in wrong order on the shape
906 // Right order: 1) master slide fill style, 2) theme, 3) direct formatting
907 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("sd/qa/unit/data/pptx/bnc904423.pptx"), PPTX
);
909 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
910 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
911 const SdrPage
*pPage
= pDoc
->GetPage(1);
912 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
914 // First shape's background color is defined on master slide
916 SdrObject
*const pObj
= pPage
->GetObj(0);
917 CPPUNIT_ASSERT(pObj
);
919 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
920 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
921 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
922 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
923 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
924 CPPUNIT_ASSERT_EQUAL(ColorData(0x00CC99), rColorItem
.GetColorValue().GetColor());
927 // Second shape's background color is defined by theme
929 SdrObject
*const pObj
= pPage
->GetObj(1);
930 CPPUNIT_ASSERT(pObj
);
932 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
933 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
934 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
935 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
936 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
937 CPPUNIT_ASSERT_EQUAL(ColorData(0x3333CC), rColorItem
.GetColorValue().GetColor());
940 // Third shape's background color is defined by direct formatting
942 SdrObject
*const pObj
= pPage
->GetObj(2);
943 CPPUNIT_ASSERT(pObj
);
945 const XFillStyleItem
& rStyleItem
= dynamic_cast<const XFillStyleItem
&>(
946 pObj
->GetMergedItem(XATTR_FILLSTYLE
));
947 CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID
, rStyleItem
.GetValue());
948 const XFillColorItem
& rColorItem
= dynamic_cast<const XFillColorItem
&>(
949 pObj
->GetMergedItem(XATTR_FILLCOLOR
));
950 CPPUNIT_ASSERT_EQUAL(ColorData(0xFF0000), rColorItem
.GetColorValue().GetColor());
953 xDocShRef
->DoClose();
956 void SdImportTest::testShapeLineStyle()
958 // Here the problem was that different line properties were applied in wrong order on the shape
959 // Right order: 1) master slide line style, 2) theme, 3) direct formatting
960 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("sd/qa/unit/data/pptx/ShapeLineProperties.pptx"), PPTX
);
962 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
963 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
964 const SdrPage
*pPage
= pDoc
->GetPage(1);
965 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
967 // First shape's line style is defined on master slide
969 SdrObject
*const pObj
= pPage
->GetObj(0);
970 CPPUNIT_ASSERT(pObj
);
972 const XLineStyleItem
& rStyleItem
= dynamic_cast<const XLineStyleItem
&>(
973 pObj
->GetMergedItem(XATTR_LINESTYLE
));
974 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_DASH
, rStyleItem
.GetValue());
976 const XLineColorItem
& rColorItem
= dynamic_cast<const XLineColorItem
&>(
977 pObj
->GetMergedItem(XATTR_LINECOLOR
));
978 CPPUNIT_ASSERT_EQUAL(ColorData(0xFF0000), rColorItem
.GetColorValue().GetColor());
980 const XLineWidthItem
& rWidthItem
= dynamic_cast<const XLineWidthItem
&>(
981 pObj
->GetMergedItem(XATTR_LINEWIDTH
));
982 CPPUNIT_ASSERT_EQUAL(sal_Int32(132), rWidthItem
.GetValue());
985 // Second shape's line style is defined by theme
987 SdrObject
*const pObj
= pPage
->GetObj(1);
988 CPPUNIT_ASSERT(pObj
);
990 const XLineStyleItem
& rStyleItem
= dynamic_cast<const XLineStyleItem
&>(
991 pObj
->GetMergedItem(XATTR_LINESTYLE
));
992 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, rStyleItem
.GetValue());
994 const XLineColorItem
& rColorItem
= dynamic_cast<const XLineColorItem
&>(
995 pObj
->GetMergedItem(XATTR_LINECOLOR
));
996 CPPUNIT_ASSERT_EQUAL(ColorData(0x3333CC), rColorItem
.GetColorValue().GetColor());
998 const XLineWidthItem
& rWidthItem
= dynamic_cast<const XLineWidthItem
&>(
999 pObj
->GetMergedItem(XATTR_LINEWIDTH
));
1000 CPPUNIT_ASSERT_EQUAL(sal_Int32(35), rWidthItem
.GetValue());
1003 // Third shape's line style is defined by direct formatting
1005 SdrObject
*const pObj
= pPage
->GetObj(2);
1006 CPPUNIT_ASSERT(pObj
);
1008 const XLineStyleItem
& rStyleItem
= dynamic_cast<const XLineStyleItem
&>(
1009 pObj
->GetMergedItem(XATTR_LINESTYLE
));
1010 CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_SOLID
, rStyleItem
.GetValue());
1012 const XLineColorItem
& rColorItem
= dynamic_cast<const XLineColorItem
&>(
1013 pObj
->GetMergedItem(XATTR_LINECOLOR
));
1014 CPPUNIT_ASSERT_EQUAL(ColorData(0x7030A0), rColorItem
.GetColorValue().GetColor());
1016 const XLineWidthItem
& rWidthItem
= dynamic_cast<const XLineWidthItem
&>(
1017 pObj
->GetMergedItem(XATTR_LINEWIDTH
));
1018 CPPUNIT_ASSERT_EQUAL(sal_Int32(176), rWidthItem
.GetValue());
1021 xDocShRef
->DoClose();
1024 void SdImportTest::testBnc862510_6()
1026 // Black text was imported instead of gray
1027 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_6.pptx"), PPTX
);
1029 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(
1030 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
1032 uno::Reference
< drawing::XDrawPage
> xPage(
1033 xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
1035 uno::Reference
< beans::XPropertySet
> xShape(
1036 xPage
->getByIndex(0), uno::UNO_QUERY
);
1037 CPPUNIT_ASSERT_MESSAGE( "no shape", xShape
.is() );
1039 // Get first paragraph of the text
1040 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY
)->getText();
1041 CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText
.is() );
1042 uno::Reference
<container::XEnumerationAccess
> paraEnumAccess
;
1043 paraEnumAccess
.set(xText
, uno::UNO_QUERY
);
1044 uno::Reference
<container::XEnumeration
> paraEnum
= paraEnumAccess
->createEnumeration();
1045 uno::Reference
<text::XTextRange
> const xParagraph(paraEnum
->nextElement(),
1046 uno::UNO_QUERY_THROW
);
1048 // Get first run of the paragraph
1049 uno::Reference
<container::XEnumerationAccess
> xRunEnumAccess(xParagraph
, uno::UNO_QUERY
);
1050 uno::Reference
<container::XEnumeration
> xRunEnum
= xRunEnumAccess
->createEnumeration();
1051 uno::Reference
<text::XTextRange
> xRun(xRunEnum
->nextElement(), uno::UNO_QUERY
);
1052 uno::Reference
< beans::XPropertySet
> xPropSet( xRun
, uno::UNO_QUERY_THROW
);
1053 sal_Int32 nCharColor
;
1054 xPropSet
->getPropertyValue( "CharColor" ) >>= nCharColor
;
1056 // Color should be gray
1057 CPPUNIT_ASSERT_EQUAL( sal_Int32(0x8B8B8B), nCharColor
);
1059 xDocShRef
->DoClose();
1062 void SdImportTest::testBnc862510_7()
1064 // Title shape's text was aligned to left instead of center.
1065 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc862510_7.pptx"), PPTX
);
1067 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(
1068 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
1070 uno::Reference
< drawing::XDrawPage
> xPage(
1071 xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
1073 uno::Reference
< beans::XPropertySet
> xShape(
1074 xPage
->getByIndex(0), uno::UNO_QUERY
);
1075 CPPUNIT_ASSERT_MESSAGE( "no shape", xShape
.is() );
1077 // Get first paragraph
1078 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY
)->getText();
1079 CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText
.is() );
1080 uno::Reference
<container::XEnumerationAccess
> paraEnumAccess
;
1081 paraEnumAccess
.set(xText
, uno::UNO_QUERY
);
1082 uno::Reference
<container::XEnumeration
> paraEnum
= paraEnumAccess
->createEnumeration();
1083 uno::Reference
<text::XTextRange
> const xParagraph(paraEnum
->nextElement(),
1084 uno::UNO_QUERY_THROW
);
1085 uno::Reference
< beans::XPropertySet
> xPropSet( xParagraph
, uno::UNO_QUERY_THROW
);
1087 sal_Int16 nParaAdjust
= 0;
1088 xPropSet
->getPropertyValue( "ParaAdjust" ) >>= nParaAdjust
;
1089 CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER
, static_cast<style::ParagraphAdjust
>(nParaAdjust
));
1091 xDocShRef
->DoClose();
1094 #if ENABLE_PDFIMPORT
1096 void SdImportTest::testPDFImport()
1098 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pdf/txtpic.pdf"), PDF
);
1099 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
1100 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
1101 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
1102 uno::Reference
< drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
1103 CPPUNIT_ASSERT_MESSAGE( "no exactly two shapes", xPage
->getCount() == 2 );
1105 uno::Reference
< drawing::XShape
> xShape(xPage
->getByIndex(0), uno::UNO_QUERY_THROW
);
1106 CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape
.is() );
1107 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY
)->getText();
1108 CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText
.is() );
1110 xDocShRef
->DoClose();
1113 void SdImportTest::testPDFImportSkipImages()
1115 SfxAllItemSet
*pParams
= new SfxAllItemSet( SfxGetpApp()->GetPool() );
1116 pParams
->Put( SfxStringItem ( SID_FILE_FILTEROPTIONS
, OUString("SkipImages") ) );
1118 ::sd::DrawDocShellRef xDocShRef
= loadURL(getURLFromSrc("/sd/qa/unit/data/pdf/txtpic.pdf"), PDF
, pParams
);
1119 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
1120 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
1121 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
1122 uno::Reference
< drawing::XDrawPage
> xPage(xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
1123 CPPUNIT_ASSERT_MESSAGE( "no exactly one shape", xPage
->getCount() == 1 );
1125 uno::Reference
< drawing::XShape
> xShape(xPage
->getByIndex(0), uno::UNO_QUERY_THROW
);
1126 CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape
.is() );
1127 uno::Reference
<text::XText
> xText
= uno::Reference
<text::XTextRange
>(xShape
, uno::UNO_QUERY
)->getText();
1128 CPPUNIT_ASSERT_MESSAGE( "not a text shape", xText
.is() );
1130 xDocShRef
->DoClose();
1135 void SdImportTest::testBulletSuffix()
1137 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n83889.pptx"), PPTX
);
1139 uno::Reference
< drawing::XDrawPagesSupplier
> xDoc(
1140 xDocShRef
->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW
);
1142 uno::Reference
< drawing::XDrawPage
> xPage(
1143 xDoc
->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW
);
1144 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
1145 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
1147 // check suffix of the char bullet
1148 const SdrPage
*pPage
= pDoc
->GetPage(1);
1149 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
1150 SdrTextObj
*pTxtObj
= dynamic_cast<SdrTextObj
*>( pPage
->GetObj(0) );
1151 CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj
!= NULL
);
1152 const EditTextObject
& aEdit
= pTxtObj
->GetOutlinerParaObject()->GetTextObject();
1153 const SvxNumBulletItem
*pNumFmt
= dynamic_cast<const SvxNumBulletItem
*>(aEdit
.GetParaAttribs(1).GetItem(EE_PARA_NUMBULLET
));
1154 CPPUNIT_ASSERT(pNumFmt
);
1155 CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's suffix is wrong!", OUString(pNumFmt
->GetNumRule()->GetLevel(0).GetSuffix()), OUString("") );
1156 xDocShRef
->DoClose();
1159 void SdImportTest::testBnc910045()
1161 // Problem with table style which defines cell color with fill style
1162 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/bnc910045.pptx"), PPTX
);
1164 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
1165 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
1166 const SdrPage
*pPage
= pDoc
->GetPage(1);
1167 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
1169 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1170 CPPUNIT_ASSERT( pTableObj
);
1171 uno::Reference
< table::XCellRange
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1172 uno::Reference
< beans::XPropertySet
> xCell
;
1175 xCell
.set(xTable
->getCellByPosition(0, 0), uno::UNO_QUERY_THROW
);
1176 xCell
->getPropertyValue("FillColor") >>= nColor
;
1177 CPPUNIT_ASSERT_EQUAL(sal_Int32(5210557), nColor
);
1180 void SdImportTest::testRowHeight()
1182 ::sd::DrawDocShellRef xDocShRef
= loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n80340.pptx"), PPTX
);
1184 SdDrawDocument
*pDoc
= xDocShRef
->GetDoc();
1185 CPPUNIT_ASSERT_MESSAGE( "no document", pDoc
!= NULL
);
1187 const SdrPage
*pPage
= pDoc
->GetPage(1);
1188 CPPUNIT_ASSERT_MESSAGE( "no page", pPage
!= NULL
);
1190 sdr::table::SdrTableObj
*pTableObj
= dynamic_cast<sdr::table::SdrTableObj
*>(pPage
->GetObj(0));
1191 CPPUNIT_ASSERT( pTableObj
);
1194 const OUString
sHeight("Height");
1195 uno::Reference
< com::sun::star::table::XTable
> xTable(pTableObj
->getTable(), uno::UNO_QUERY_THROW
);
1196 uno::Reference
< com::sun::star::table::XTableRows
> xRows( xTable
->getRows(), uno::UNO_QUERY_THROW
);
1197 uno::Reference
< beans::XPropertySet
> xRefRow( xRows
->getByIndex(0), uno::UNO_QUERY_THROW
);
1198 xRefRow
->getPropertyValue( sHeight
) >>= nHeight
;
1199 CPPUNIT_ASSERT_EQUAL( sal_Int32(508), nHeight
);
1202 CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest
);
1204 CPPUNIT_PLUGIN_IMPLEMENT();
1206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */