Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : */
9 :
10 : #include "sdmodeltestbase.hxx"
11 :
12 : #include <svl/stritem.hxx>
13 : #include <editeng/editobj.hxx>
14 : #include <editeng/outlobj.hxx>
15 : #include <editeng/ulspitem.hxx>
16 : #include <editeng/fhgtitem.hxx>
17 : #include <editeng/escapementitem.hxx>
18 : #include <editeng/colritem.hxx>
19 : #include <editeng/fontitem.hxx>
20 : #include <editeng/wghtitem.hxx>
21 : #include <editeng/numitem.hxx>
22 : #include <editeng/lrspitem.hxx>
23 : #include <rsc/rscsfx.hxx>
24 :
25 : #include <svx/svdotext.hxx>
26 : #include <svx/svdoashp.hxx>
27 : #include <svx/svdogrp.hxx>
28 : #include <svx/svdomedia.hxx>
29 : #include <animations/animationnodehelper.hxx>
30 :
31 : #include <com/sun/star/drawing/XDrawPage.hpp>
32 : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
33 : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
34 : #include <com/sun/star/animations/XAnimationNode.hpp>
35 : #include <com/sun/star/animations/XAnimate.hpp>
36 : #include <com/sun/star/beans/XPropertySet.hpp>
37 : #include <com/sun/star/chart/XChartDocument.hpp>
38 : #include <com/sun/star/chart2/XChartDocument.hpp>
39 : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
40 : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
41 : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
42 : #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
43 : #include <com/sun/star/chart2/data/XDataSequence.hpp>
44 : #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
45 :
46 : using namespace ::com::sun::star;
47 :
48 : /// Impress import filters tests.
49 63 : class SdFiltersTest : public SdModelTestBase
50 : {
51 : public:
52 : void testDocumentLayout();
53 : void testSmoketest();
54 : void testN759180();
55 : void testN778859();
56 : void testFdo64512();
57 : void testFdo71075();
58 : void testN828390();
59 : void testN828390_2();
60 : void testN828390_3();
61 : void testN828390_4();
62 : void testN828390_5();
63 : void testN821567();
64 : void testFdo68594();
65 : void testFdo72998();
66 : void testStrictOOXML();
67 : void testN862510_1();
68 : void testN862510_2();
69 : void testN862510_3();
70 : void testN862510_4();
71 : void testFdo71961();
72 : void testMediaEmbedding();
73 :
74 2 : CPPUNIT_TEST_SUITE(SdFiltersTest);
75 1 : CPPUNIT_TEST(testDocumentLayout);
76 1 : CPPUNIT_TEST(testSmoketest);
77 1 : CPPUNIT_TEST(testN759180);
78 1 : CPPUNIT_TEST(testN778859);
79 1 : CPPUNIT_TEST(testFdo64512);
80 1 : CPPUNIT_TEST(testFdo71075);
81 1 : CPPUNIT_TEST(testN828390);
82 1 : CPPUNIT_TEST(testN828390_2);
83 1 : CPPUNIT_TEST(testN828390_3);
84 1 : CPPUNIT_TEST(testN828390_4);
85 1 : CPPUNIT_TEST(testN828390_5);
86 1 : CPPUNIT_TEST(testN821567);
87 1 : CPPUNIT_TEST(testFdo68594);
88 1 : CPPUNIT_TEST(testFdo72998);
89 1 : CPPUNIT_TEST(testStrictOOXML);
90 1 : CPPUNIT_TEST(testN862510_1);
91 1 : CPPUNIT_TEST(testN862510_2);
92 1 : CPPUNIT_TEST(testN862510_3);
93 1 : CPPUNIT_TEST(testN862510_4);
94 1 : CPPUNIT_TEST(testFdo71961);
95 1 : CPPUNIT_TEST(testMediaEmbedding);
96 :
97 2 : CPPUNIT_TEST_SUITE_END();
98 : };
99 :
100 : /** Test document against a reference XML dump of shapes.
101 :
102 : If you want to update one of these tests, or add a new one, set the nUpdateMe
103 : to the index of the test, and the dump XML's will be created (or rewritten)
104 : instead of checking. Use with care - when the test is failing, first find out
105 : why, instead of just updating .xml's blindly.
106 :
107 : Example: Let's say you are adding a test called fdoABCD.pptx. You'll place it
108 : to the data/ subdirectory, and will add an entry to aFilesToCompare below,
109 : the 3rd parameter is for export test - can be -1 (don't export), ODP, PPT or PPTX
110 : like:
111 :
112 : { "fdoABCD.pptx", "xml/fdoABCD_", PPTX },
113 :
114 : and will count the index in the aFilesToCompare structure (1st is 0, 2nd is 1,
115 : etc.) Temporarily you'll set nUpdateMe to this index (instead of -1), and run
116 :
117 : make sd
118 :
119 : This will generate the sd/qa/unit/data/xml/fdoABCD_*.xml for you. Now you
120 : will change nUpdateMe back to -1, and commit your fdoABCD.pptx test, the
121 : xml/fdoABCD_*.xml dumps, and the aFilesToCompare addition in one commit.
122 :
123 : As the last step, you will revert your fix and do 'make sd' again, to check
124 : that without your fix, the unit test breaks. Then clean up, and push :-)
125 :
126 : NOTE: This approach is suitable only for tests of fixes that actually change
127 : the layout - best to check by reverting your fix locally after having added
128 : the test, and re-running; it should break.
129 : */
130 1 : void SdFiltersTest::testDocumentLayout()
131 : {
132 : struct { const char *pInput, *pDump; sal_Int32 nExportType; } aFilesToCompare[] =
133 : {
134 : { "odp/shapes-test.odp", "xml/shapes-test_page", -1 },
135 : { "fdo47434.pptx", "xml/fdo47434_", -1 },
136 : { "n758621.ppt", "xml/n758621_", -1 },
137 : { "fdo64586.ppt", "xml/fdo64586_", -1 },
138 : { "n819614.pptx", "xml/n819614_", -1 },
139 : { "n820786.pptx", "xml/n820786_", -1 },
140 : { "n762695.pptx", "xml/n762695_", -1 },
141 : { "n593612.pptx", "xml/n593612_", -1 },
142 : { "fdo71434.pptx", "xml/fdo71434_", -1 },
143 : // { "pptx/n828390.pptx", "pptx/xml/n828390_", PPTX }, // Example
144 1 : };
145 :
146 10 : for ( int i = 0; i < static_cast< int >( SAL_N_ELEMENTS( aFilesToCompare ) ); ++i )
147 : {
148 9 : int nUpdateMe = -1; // index of test we want to update; supposedly only when the test is created
149 :
150 9 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pInput ) );
151 9 : if( aFilesToCompare[i].nExportType >= 0 )
152 0 : xDocShRef = saveAndReload( xDocShRef, aFilesToCompare[i].nExportType );
153 : compareWithShapesDump( xDocShRef,
154 18 : getPathFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pDump ),
155 18 : i == nUpdateMe );
156 9 : }
157 1 : }
158 :
159 1 : void SdFiltersTest::testSmoketest()
160 : {
161 1 : ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/smoketest.pptx"));
162 :
163 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
164 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
165 :
166 : // cf. SdrModel svx/svdmodel.hxx ...
167 :
168 1 : CPPUNIT_ASSERT_MESSAGE( "wrong page count", pDoc->GetPageCount() == 3);
169 :
170 1 : const SdrPage *pPage = pDoc->GetPage (1);
171 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
172 :
173 1 : sal_uIntPtr nObjs = pPage->GetObjCount();
174 4 : for (sal_uIntPtr i = 0; i < nObjs; i++)
175 : {
176 3 : SdrObject *pObj = pPage->GetObj(i);
177 3 : SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
178 3 : SdrTextObj *pTxt = dynamic_cast<SdrTextObj *>( pObj );
179 : (void)pTxt; (void)eKind;
180 : }
181 :
182 1 : CPPUNIT_ASSERT_MESSAGE( "changed", !pDoc->IsChanged() );
183 :
184 1 : xDocShRef->DoClose();
185 1 : }
186 :
187 1 : void SdFiltersTest::testN759180()
188 : {
189 1 : ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/n759180.pptx"));
190 :
191 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
192 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
193 1 : const SdrPage *pPage = pDoc->GetPage (1);
194 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
195 :
196 : //sal_uIntPtr nObjs = pPage->GetObjCount();
197 : //for (sal_uIntPtr i = 0; i < nObjs; i++)
198 : {
199 : // Get the object
200 1 : SdrObject *pObj = pPage->GetObj(0);
201 1 : SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
202 1 : CPPUNIT_ASSERT(pTxtObj);
203 1 : std::vector<EECharAttrib> rLst;
204 1 : const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
205 1 : const SvxULSpaceItem *pULSpace = dynamic_cast<const SvxULSpaceItem *>(aEdit.GetParaAttribs(0).GetItem(EE_PARA_ULSPACE));
206 1 : CPPUNIT_ASSERT(pULSpace);
207 1 : CPPUNIT_ASSERT_MESSAGE( "Para bottom spacing is wrong!", pULSpace->GetLower() == 0 );
208 1 : aEdit.GetCharAttribs(1, rLst);
209 2 : for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
210 : {
211 2 : const SvxFontHeightItem * pFontHeight = dynamic_cast<const SvxFontHeightItem *>((*it).pAttr);
212 2 : if(pFontHeight)
213 : {
214 : // nStart == 9
215 : // font height = 5 => 5*2540/72
216 1 : CPPUNIT_ASSERT_MESSAGE( "Font height is wrong", pFontHeight->GetHeight() == 176 );
217 1 : break;
218 : }
219 1 : }
220 : }
221 :
222 1 : xDocShRef->DoClose();
223 1 : }
224 :
225 1 : void SdFiltersTest::testN821567()
226 : {
227 1 : OUString bgImage;
228 2 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n821567.pptx") );
229 :
230 1 : xDocShRef = saveAndReload( xDocShRef, ODP );
231 : uno::Reference< drawing::XDrawPagesSupplier > xDoc(
232 2 : xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
233 1 : CPPUNIT_ASSERT_MESSAGE( "not exactly one page", xDoc->getDrawPages()->getCount() == 1 );
234 : uno::Reference< drawing::XDrawPage > xPage(
235 2 : xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
236 :
237 2 : uno::Reference< beans::XPropertySet > xPropSet( xPage, uno::UNO_QUERY );
238 2 : uno::Any aAny = xPropSet->getPropertyValue( OUString("Background") );
239 1 : if(aAny.hasValue())
240 : {
241 1 : uno::Reference< beans::XPropertySet > aXBackgroundPropSet;
242 1 : aAny >>= aXBackgroundPropSet;
243 1 : aAny = aXBackgroundPropSet->getPropertyValue( OUString("FillBitmapName"));
244 1 : aAny >>= bgImage;
245 : }
246 1 : CPPUNIT_ASSERT_MESSAGE("Slide Background is not exported properly", !bgImage.isEmpty());
247 :
248 2 : xDocShRef->DoClose();
249 1 : }
250 :
251 1 : void SdFiltersTest::testN862510_1()
252 : {
253 1 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_1.pptx") );
254 :
255 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
256 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
257 1 : const SdrPage *pPage = pDoc->GetPage(1);
258 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
259 : {
260 1 : std::vector<EECharAttrib> rLst;
261 1 : SdrObject *pObj = pPage->GetObj( 0 );
262 1 : SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
263 1 : CPPUNIT_ASSERT( pTxtObj );
264 1 : const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
265 1 : aEdit.GetCharAttribs( 0, rLst );
266 17 : for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
267 : {
268 16 : const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>( (*it).pAttr );
269 16 : CPPUNIT_ASSERT_MESSAGE( "Baseline attribute not handled properly", !( pFontEscapement && pFontEscapement->GetProp() != 100 ) );
270 1 : }
271 : }
272 :
273 1 : xDocShRef->DoClose();
274 1 : }
275 :
276 1 : void SdFiltersTest::testN862510_2()
277 : {
278 1 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_2.pptx") );
279 :
280 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
281 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
282 1 : const SdrPage *pPage = pDoc->GetPage(1);
283 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
284 : {
285 1 : SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 1 ) );
286 1 : CPPUNIT_ASSERT( pGrpObj );
287 1 : SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( pGrpObj->GetSubList()->GetObj( 0 ) );
288 1 : CPPUNIT_ASSERT( pObj );
289 1 : CPPUNIT_ASSERT_MESSAGE( "Wrong Text Rotation!", pObj->GetExtraTextRotation( true ) == 90 );
290 : }
291 :
292 1 : xDocShRef->DoClose();
293 1 : }
294 :
295 1 : void SdFiltersTest::testN862510_3()
296 : {
297 1 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_3.pptx") );
298 :
299 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
300 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
301 1 : const SdrPage *pPage = pDoc->GetPage( 1 );
302 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
303 : {
304 1 : SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 1 ) );
305 1 : CPPUNIT_ASSERT( pGrpObj );
306 1 : SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( pGrpObj->GetSubList()->GetObj( 0 ) );
307 1 : CPPUNIT_ASSERT( pObj );
308 1 : CPPUNIT_ASSERT_MESSAGE( "Left Spacing is wrong! check attribute anchorCtr", pObj->GetTextLeftDistance() < 30);
309 : }
310 :
311 1 : xDocShRef->DoClose();
312 1 : }
313 :
314 1 : void SdFiltersTest::testN862510_4()
315 : {
316 1 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_4.pptx") );
317 :
318 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
319 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
320 1 : const SdrPage *pPage = pDoc->GetPage( 1 );
321 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
322 : {
323 1 : std::vector<EECharAttrib> rLst;
324 1 : SdrObject *pObj = pPage->GetObj( 0 );
325 1 : SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
326 1 : CPPUNIT_ASSERT( pTxtObj );
327 1 : const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
328 1 : aEdit.GetCharAttribs( 0, rLst );
329 17 : for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it != rLst.rend(); ++it )
330 : {
331 16 : const SvxColorItem *pC = dynamic_cast<const SvxColorItem *>( (*it).pAttr );
332 16 : CPPUNIT_ASSERT_MESSAGE( "gradfill for text color not handled!", !( pC && pC->GetValue().GetColor() == 0 ) );
333 1 : }
334 : }
335 :
336 1 : xDocShRef->DoClose();
337 1 : }
338 :
339 1 : void SdFiltersTest::testN828390()
340 : {
341 1 : bool bPassed = false;
342 1 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390.pptx") );
343 :
344 1 : xDocShRef = saveAndReload( xDocShRef, PPTX );
345 :
346 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
347 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
348 1 : const SdrPage *pPage = pDoc->GetPage(1);
349 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
350 : {
351 1 : std::vector<EECharAttrib> rLst;
352 : // Get the object
353 1 : SdrObject *pObj = pPage->GetObj(0);
354 1 : SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
355 1 : CPPUNIT_ASSERT( pTxtObj );
356 1 : const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
357 1 : aEdit.GetCharAttribs(0, rLst);
358 7 : for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
359 : {
360 7 : const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>((*it).pAttr);
361 7 : if(pFontEscapement)
362 : {
363 2 : if( pFontEscapement->GetEsc() == -25 )
364 : {
365 1 : bPassed = true;
366 1 : break;
367 : }
368 : }
369 1 : }
370 : }
371 1 : CPPUNIT_ASSERT_MESSAGE("Subscript not exported properly", bPassed);
372 :
373 1 : xDocShRef->DoClose();
374 1 : }
375 :
376 1 : void SdFiltersTest::testN828390_2()
377 : {
378 1 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_2.pptx") );
379 :
380 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
381 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
382 1 : const SdrPage *pPage = pDoc->GetPage(1);
383 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
384 :
385 1 : SdrObject *pObj = pPage->GetObj(0);
386 1 : SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
387 1 : CPPUNIT_ASSERT( pTxtObj );
388 1 : const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
389 1 : CPPUNIT_ASSERT(aEdit.GetText(0) == OUString("Linux "));
390 1 : CPPUNIT_ASSERT(aEdit.GetText(1) == OUString("Standard Platform"));
391 :
392 1 : xDocShRef->DoClose();
393 1 : }
394 :
395 1 : void SdFiltersTest::testN828390_3()
396 : {
397 1 : bool bPassed = true;
398 1 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_3.pptx") );
399 :
400 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
401 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
402 1 : const SdrPage *pPage = pDoc->GetPage(1);
403 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
404 :
405 1 : SdrObject *pObj = pPage->GetObj(0);
406 1 : SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
407 1 : CPPUNIT_ASSERT( pTxtObj );
408 1 : const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
409 2 : std::vector<EECharAttrib> rLst;
410 1 : aEdit.GetCharAttribs(1, rLst);
411 17 : for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
412 : {
413 16 : const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>((*it).pAttr);
414 16 : if(pFontEscapement)
415 : {
416 1 : if( pFontEscapement->GetEsc() != 0 )
417 : {
418 0 : bPassed = false;
419 0 : break;
420 : }
421 : }
422 : }
423 1 : CPPUNIT_ASSERT_MESSAGE("CharEscapment not imported properly", bPassed);
424 :
425 2 : xDocShRef->DoClose();
426 1 : }
427 :
428 1 : void SdFiltersTest::testN828390_4()
429 : {
430 1 : bool bPassed = false;
431 1 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/n828390_4.odp") );
432 :
433 1 : xDocShRef = saveAndReload( xDocShRef, PPTX );
434 :
435 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
436 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
437 1 : const SdrPage *pPage = pDoc->GetPage(1);
438 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
439 : {
440 1 : std::vector<EECharAttrib> rLst;
441 1 : SdrObject *pObj = pPage->GetObj(0);
442 1 : SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
443 1 : CPPUNIT_ASSERT( pTxtObj );
444 1 : const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
445 1 : aEdit.GetCharAttribs(1, rLst);
446 16 : for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
447 : {
448 15 : const SvxFontHeightItem * pFontHeight = dynamic_cast<const SvxFontHeightItem *>((*it).pAttr);
449 15 : if( pFontHeight )
450 3 : CPPUNIT_ASSERT_MESSAGE( "Font height is wrong", pFontHeight->GetHeight() == 1129 );
451 15 : const SvxFontItem *pFont = dynamic_cast<const SvxFontItem *>((*it).pAttr);
452 15 : if( pFont )
453 : {
454 1 : CPPUNIT_ASSERT_MESSAGE( "Font is wrong", pFont->GetFamilyName().equalsAscii("Arial"));
455 1 : bPassed = true;
456 : }
457 15 : const SvxWeightItem *pWeight = dynamic_cast<const SvxWeightItem *>((*it).pAttr);
458 15 : if( pWeight )
459 3 : CPPUNIT_ASSERT_MESSAGE( "Font Weight is wrong", pWeight->GetWeight() == WEIGHT_BOLD);
460 1 : }
461 : }
462 1 : CPPUNIT_ASSERT(bPassed);
463 :
464 1 : xDocShRef->DoClose();
465 1 : }
466 :
467 1 : void SdFiltersTest::testN828390_5()
468 : {
469 1 : ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/n828390_5.odp") );
470 :
471 1 : xDocShRef = saveAndReload( xDocShRef, PPTX );
472 :
473 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
474 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
475 1 : const SdrPage *pPage = pDoc->GetPage(1);
476 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
477 : {
478 1 : SdrObject *pObj = pPage->GetObj(0);
479 1 : SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
480 1 : CPPUNIT_ASSERT( pTxtObj );
481 1 : const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
482 1 : const SvxNumBulletItem *pNumFmt = dynamic_cast<const SvxNumBulletItem *>(aEdit.GetPool()->GetItem2(EE_PARA_NUMBULLET, 5));
483 1 : CPPUNIT_ASSERT( pNumFmt );
484 1 : CPPUNIT_ASSERT_EQUAL_MESSAGE( "Bullet's relative size is wrong!", pNumFmt->GetNumRule()->GetLevel(1).GetBulletRelSize(), sal_uInt16(75) ); // != 25
485 : }
486 :
487 1 : xDocShRef->DoClose();
488 1 : }
489 :
490 1 : void SdFiltersTest::testN778859()
491 : {
492 1 : ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"));
493 :
494 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
495 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
496 1 : const SdrPage *pPage = pDoc->GetPage(1);
497 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
498 : {
499 : // Get the object
500 1 : SdrObject *pObj = pPage->GetObj(1);
501 1 : SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
502 1 : CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
503 1 : CPPUNIT_ASSERT(!pTxtObj->IsAutoFit());
504 : }
505 :
506 1 : xDocShRef->DoClose();
507 1 : }
508 :
509 1 : void SdFiltersTest::testFdo68594()
510 : {
511 1 : ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/ppt/fdo68594.ppt"));
512 :
513 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
514 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
515 1 : const SdrPage *pPage = &(pDoc->GetPage (1)->TRG_GetMasterPage());
516 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
517 1 : SdrObject *pObj = pPage->GetObj(1);
518 1 : SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
519 1 : CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
520 1 : const SvxColorItem *pC = dynamic_cast<const SvxColorItem *>(&pTxtObj->GetMergedItem(EE_CHAR_COLOR));
521 1 : CPPUNIT_ASSERT_MESSAGE( "no color item", pC != NULL);
522 : // Color should be black
523 1 : CPPUNIT_ASSERT_MESSAGE( "Placeholder color mismatch", pC->GetValue().GetColor() == 0);
524 :
525 1 : xDocShRef->DoClose();
526 1 : }
527 :
528 1 : void SdFiltersTest::testFdo72998()
529 : {
530 1 : ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/cshapes.pptx"));
531 :
532 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
533 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
534 1 : const SdrPage *pPage = pDoc->GetPage(1);
535 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
536 : {
537 1 : SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>(pPage->GetObj(2));
538 1 : CPPUNIT_ASSERT( pObj );
539 1 : const SdrCustomShapeGeometryItem& rGeometryItem = (const SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
540 1 : CPPUNIT_ASSERT_MESSAGE( "not a custom shape", pObj );
541 1 : const ::com::sun::star::uno::Any* pViewBox = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( OUString( "ViewBox" ) );
542 1 : CPPUNIT_ASSERT_MESSAGE( "Missing ViewBox", pViewBox );
543 1 : com::sun::star::awt::Rectangle aViewBox;
544 1 : CPPUNIT_ASSERT( (*pViewBox >>= aViewBox ) );
545 1 : CPPUNIT_ASSERT_MESSAGE( "Width should be zero - for forcing scale to 1", !aViewBox.Width );
546 1 : CPPUNIT_ASSERT_MESSAGE( "Height should be zero - for forcing scale to 1", !aViewBox.Height );
547 : }
548 :
549 1 : xDocShRef->DoClose();
550 1 : }
551 :
552 1 : void SdFiltersTest::testFdo64512()
553 : {
554 1 : ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo64512.odp"));
555 :
556 : uno::Reference< drawing::XDrawPagesSupplier > xDoc(
557 2 : xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
558 1 : CPPUNIT_ASSERT_MESSAGE( "not exactly one page", xDoc->getDrawPages()->getCount() == 1 );
559 :
560 : uno::Reference< drawing::XDrawPage > xPage(
561 2 : xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
562 1 : CPPUNIT_ASSERT_MESSAGE( "no exactly three shapes", xPage->getCount() == 3 );
563 :
564 : uno::Reference< beans::XPropertySet > xConnectorShape(
565 2 : xPage->getByIndex(2), uno::UNO_QUERY );
566 1 : CPPUNIT_ASSERT_MESSAGE( "no connector shape", xConnectorShape.is() );
567 :
568 : uno::Reference< beans::XPropertySet > xSvgShape(
569 2 : xConnectorShape->getPropertyValue("StartShape"), uno::UNO_QUERY );
570 1 : CPPUNIT_ASSERT_MESSAGE( "no start shape", xSvgShape.is() );
571 :
572 : uno::Reference< beans::XPropertySet > xCustomShape(
573 2 : xConnectorShape->getPropertyValue("EndShape"), uno::UNO_QUERY );
574 1 : CPPUNIT_ASSERT_MESSAGE( "no end shape", xCustomShape.is() );
575 :
576 : uno::Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier(
577 2 : xPage, uno::UNO_QUERY_THROW );
578 : uno::Reference< animations::XAnimationNode > xRootNode(
579 2 : xAnimNodeSupplier->getAnimationNode() );
580 2 : std::vector< uno::Reference< animations::XAnimationNode > > aAnimVector;
581 1 : anim::create_deep_vector(xRootNode, aAnimVector);
582 1 : CPPUNIT_ASSERT_MESSAGE( "not 8 animation nodes", aAnimVector.size() == 8 );
583 :
584 : uno::Reference< animations::XAnimate > xNode(
585 2 : aAnimVector[7], uno::UNO_QUERY_THROW );
586 : uno::Reference< drawing::XShape > xTargetShape(
587 2 : xNode->getTarget(), uno::UNO_QUERY_THROW );
588 2 : CPPUNIT_ASSERT_MESSAGE( "inner node not referencing svg shape",
589 1 : xTargetShape != xSvgShape );
590 :
591 2 : xDocShRef->DoClose();
592 1 : }
593 :
594 : // Unit test for importing charts
595 1 : void SdFiltersTest::testFdo71075()
596 : {
597 1 : double values[] = { 12.0, 13.0, 14.0 };
598 1 : ::com::sun::star::uno::Any aAny;
599 2 : ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71075.odp"));
600 :
601 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
602 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
603 2 : uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
604 2 : uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
605 2 : uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
606 1 : CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape.is() );
607 :
608 2 : uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
609 1 : aAny = xPropSet->getPropertyValue( OUString("Model") );
610 1 : CPPUNIT_ASSERT_MESSAGE( "failed to load shape", aAny.hasValue() );
611 :
612 2 : uno::Reference< chart::XChartDocument > xChartDoc;
613 1 : aAny >>= xChartDoc;
614 1 : CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc.is() );
615 2 : uno::Reference< chart2::XChartDocument > xChart2Doc( xChartDoc, uno::UNO_QUERY );
616 1 : CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc.is() );
617 :
618 2 : uno::Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xChart2Doc->getFirstDiagram(), uno::UNO_QUERY );
619 2 : uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
620 2 : uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[0], uno::UNO_QUERY );
621 :
622 2 : uno::Reference< chart2::XDataSeriesContainer > xDSCnt( xCTCnt->getChartTypes()[0], uno::UNO_QUERY );
623 1 : CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt.is() );
624 2 : uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
625 1 : CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aSeriesSeq.getLength() == 1);
626 2 : uno::Reference< chart2::data::XDataSource > xSource( aSeriesSeq[0], uno::UNO_QUERY );
627 2 : uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(xSource->getDataSequences());
628 1 : CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aSeqCnt.getLength() == 1);
629 2 : uno::Reference< chart2::data::XDataSequence > xValueSeq( aSeqCnt[0]->getValues() );
630 1 : CPPUNIT_ASSERT_MESSAGE( "Invalid Data count", xValueSeq->getData().getLength() == sizeof(values)/(sizeof(double)));
631 2 : uno::Reference< chart2::data::XNumericalDataSequence > xNumSeq( xValueSeq, uno::UNO_QUERY );
632 2 : uno::Sequence< double > aValues( xNumSeq->getNumericalData());
633 4 : for(sal_Int32 i=0;i<xValueSeq->getData().getLength();i++)
634 3 : CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aValues.getConstArray()[i] == values[i]);
635 :
636 2 : xDocShRef->DoClose();
637 1 : }
638 :
639 1 : void SdFiltersTest::testStrictOOXML()
640 : {
641 1 : ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/strict_ooxml.pptx"));
642 :
643 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
644 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
645 2 : uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
646 2 : uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
647 2 : uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
648 1 : CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape.is() );
649 :
650 2 : xDocShRef->DoClose();
651 1 : }
652 :
653 1 : void SdFiltersTest::testFdo71961()
654 : {
655 1 : ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71961.odp"));
656 :
657 1 : xDocShRef = saveAndReload( xDocShRef, PPTX );
658 :
659 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
660 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
661 1 : const SdrPage *pPage = pDoc->GetPage (1);
662 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
663 :
664 : // Export to .pptx changes all text frames to custom shape objects, which obey TextWordWrap property
665 : // (which is false for text frames otherwise and is ignored). Check that frames that should wrap still do.
666 1 : SdrObjCustomShape *pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 1 ));
667 1 : CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
668 1 : CPPUNIT_ASSERT_EQUAL( OUString( "Text to be always wrapped" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
669 1 : CPPUNIT_ASSERT_EQUAL( true, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue());
670 :
671 1 : pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 2 ));
672 1 : CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
673 1 : CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape non-wrapped text" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
674 1 : CPPUNIT_ASSERT_EQUAL( false, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue());
675 :
676 1 : pTxtObj = dynamic_cast<SdrObjCustomShape *>( pPage->GetObj( 3 ));
677 1 : CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
678 1 : CPPUNIT_ASSERT_EQUAL( OUString( "Custom shape wrapped text" ), pTxtObj->GetOutlinerParaObject()->GetTextObject().GetText(0));
679 1 : CPPUNIT_ASSERT_EQUAL( true, (static_cast<const SdrTextWordWrapItem&>(pTxtObj->GetMergedItem(SDRATTR_TEXT_WORDWRAP))).GetValue());
680 :
681 1 : xDocShRef->DoClose();
682 1 : }
683 :
684 1 : void SdFiltersTest::testMediaEmbedding()
685 : {
686 1 : ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/media_embedding.odp"));
687 1 : xDocShRef = saveAndReload( xDocShRef, ODP );
688 :
689 1 : SdDrawDocument *pDoc = xDocShRef->GetDoc();
690 1 : CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
691 1 : const SdrPage *pPage = pDoc->GetPage (1);
692 1 : CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
693 :
694 : // First object is a glTF model
695 1 : SdrMediaObj *pModelObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 1 ));
696 1 : CPPUNIT_ASSERT_MESSAGE( "missing model", pModelObj != NULL);
697 1 : CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Model/duck/duck.json" ), pModelObj->getMediaProperties().getURL());
698 1 : CPPUNIT_ASSERT_EQUAL( OUString( "application/vnd.gltf+json" ), pModelObj->getMediaProperties().getMimeType());
699 :
700 : // Second object is a sound
701 1 : SdrMediaObj *pMediaObj = dynamic_cast<SdrMediaObj*>( pPage->GetObj( 2 ));
702 1 : CPPUNIT_ASSERT_MESSAGE( "missing media object", pMediaObj != NULL);
703 1 : CPPUNIT_ASSERT_EQUAL( OUString( "vnd.sun.star.Package:Media/button-1.wav" ), pMediaObj->getMediaProperties().getURL());
704 1 : CPPUNIT_ASSERT_EQUAL( OUString( "application/vnd.sun.star.media" ), pMediaObj->getMediaProperties().getMimeType());
705 1 : }
706 :
707 1 : CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
708 :
709 4 : CPPUNIT_PLUGIN_IMPLEMENT();
710 :
711 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|