LCOV - code coverage report
Current view: top level - sd/qa/unit - import-tests.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 487 493 98.8 %
Date: 2014-11-03 Functions: 34 36 94.4 %
Legend: Lines: hit not hit

          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 <editeng/postitem.hxx>
      24             : #include <rsc/rscsfx.hxx>
      25             : 
      26             : #include <svx/svdotext.hxx>
      27             : #include <svx/svdoashp.hxx>
      28             : #include <svx/svdograf.hxx>
      29             : #include <svx/svdogrp.hxx>
      30             : #include <svx/svdomedia.hxx>
      31             : #include <svx/svdoole2.hxx>
      32             : #include <svx/svdotable.hxx>
      33             : #include <svx/xflclit.hxx>
      34             : #include <animations/animationnodehelper.hxx>
      35             : #include <sax/tools/converter.hxx>
      36             : 
      37             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      38             : #include <com/sun/star/drawing/XDrawPage.hpp>
      39             : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      40             : #include <com/sun/star/animations/XAnimationNodeSupplier.hpp>
      41             : #include <com/sun/star/animations/XAnimationNode.hpp>
      42             : #include <com/sun/star/animations/XAnimate.hpp>
      43             : #include <com/sun/star/beans/XPropertySet.hpp>
      44             : #include <com/sun/star/chart/XChartDocument.hpp>
      45             : #include <com/sun/star/chart2/XChartDocument.hpp>
      46             : #include <com/sun/star/chart2/XDataSeriesContainer.hpp>
      47             : #include <com/sun/star/chart2/XCoordinateSystemContainer.hpp>
      48             : #include <com/sun/star/chart2/XChartTypeContainer.hpp>
      49             : #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp>
      50             : #include <com/sun/star/chart2/data/XDataSequence.hpp>
      51             : #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp>
      52             : #include <com/sun/star/table/BorderLine2.hpp>
      53             : 
      54             : #include <stlpool.hxx>
      55             : 
      56             : using namespace ::com::sun::star;
      57             : 
      58             : /// Impress import filters tests.
      59         150 : class SdImportTest : public SdModelTestBase
      60             : {
      61             : public:
      62             :     void testDocumentLayout();
      63             :     void testSmoketest();
      64             :     void testN759180();
      65             :     void testN778859();
      66             :     void testMasterPageStyleParent();
      67             :     void testFdo64512();
      68             :     void testFdo71075();
      69             :     void testN828390_2();
      70             :     void testN828390_3();
      71             :     void testFdo68594();
      72             :     void testFdo72998();
      73             :     void testFdo77027();
      74             :     void testStrictOOXML();
      75             :     void testN862510_1();
      76             :     void testN862510_2();
      77             :     void testN862510_4();
      78             :     void testBnc870237();
      79             :     void testBnc887225();
      80             :     void testBnc480256();
      81             :     void testBnc591147();
      82             :     void testCreationDate();
      83             :     void testBnc584721_1();
      84             :     void testBnc584721_2();
      85             :     void testBnc584721_3();
      86             :     void testBnc584721_4();
      87             : 
      88           4 :     CPPUNIT_TEST_SUITE(SdImportTest);
      89           2 :     CPPUNIT_TEST(testDocumentLayout);
      90           2 :     CPPUNIT_TEST(testSmoketest);
      91           2 :     CPPUNIT_TEST(testN759180);
      92           2 :     CPPUNIT_TEST(testN778859);
      93           2 :     CPPUNIT_TEST(testMasterPageStyleParent);
      94           2 :     CPPUNIT_TEST(testFdo64512);
      95           2 :     CPPUNIT_TEST(testFdo71075);
      96           2 :     CPPUNIT_TEST(testN828390_2);
      97           2 :     CPPUNIT_TEST(testN828390_3);
      98           2 :     CPPUNIT_TEST(testFdo68594);
      99           2 :     CPPUNIT_TEST(testFdo72998);
     100           2 :     CPPUNIT_TEST(testFdo77027);
     101           2 :     CPPUNIT_TEST(testStrictOOXML);
     102           2 :     CPPUNIT_TEST(testN862510_1);
     103           2 :     CPPUNIT_TEST(testN862510_2);
     104           2 :     CPPUNIT_TEST(testN862510_4);
     105           2 :     CPPUNIT_TEST(testBnc870237);
     106           2 :     CPPUNIT_TEST(testBnc887225);
     107           2 :     CPPUNIT_TEST(testBnc480256);
     108           2 :     CPPUNIT_TEST(testBnc591147);
     109           2 :     CPPUNIT_TEST(testCreationDate);
     110           2 :     CPPUNIT_TEST(testBnc584721_1);
     111           2 :     CPPUNIT_TEST(testBnc584721_2);
     112           2 :     CPPUNIT_TEST(testBnc584721_3);
     113           2 :     CPPUNIT_TEST(testBnc584721_4);
     114             : 
     115           4 :     CPPUNIT_TEST_SUITE_END();
     116             : };
     117             : 
     118             : /** Test document against a reference XML dump of shapes.
     119             : 
     120             : If you want to update one of these tests, or add a new one, set the nUpdateMe
     121             : to the index of the test, and the dump XML's will be created (or rewritten)
     122             : instead of checking. Use with care - when the test is failing, first find out
     123             : why, instead of just updating .xml's blindly.
     124             : 
     125             : Example: Let's say you are adding a test called fdoABCD.pptx.  You'll place it
     126             : to the data/ subdirectory, and will add an entry to aFilesToCompare below,
     127             : the 3rd parameter is for export test - can be -1 (don't export), ODP, PPT or PPTX
     128             : like:
     129             : 
     130             :         { "fdoABCD.pptx", "xml/fdoABCD_", PPTX },
     131             : 
     132             : and will count the index in the aFilesToCompare structure (1st is 0, 2nd is 1,
     133             : etc.)  Temporarily you'll set nUpdateMe to this index (instead of -1), and run
     134             : 
     135             : make sd
     136             : 
     137             : This will generate the sd/qa/unit/data/xml/fdoABCD_*.xml for you.  Now you
     138             : will change nUpdateMe back to -1, and commit your fdoABCD.pptx test, the
     139             : xml/fdoABCD_*.xml dumps, and the aFilesToCompare addition in one commit.
     140             : 
     141             : As the last step, you will revert your fix and do 'make sd' again, to check
     142             : that without your fix, the unit test breaks.  Then clean up, and push :-)
     143             : 
     144             : NOTE: This approach is suitable only for tests of fixes that actually change
     145             : the layout - best to check by reverting your fix locally after having added
     146             : the test, and re-running; it should break.
     147             : */
     148           2 : void SdImportTest::testDocumentLayout()
     149             : {
     150             :     struct { const char *pInput, *pDump; sal_Int32 nFormat; sal_Int32 nExportType; } aFilesToCompare[] =
     151             :     {
     152             :         { "odp/shapes-test.odp", "xml/shapes-test_page", ODP, -1 },
     153             :         { "fdo47434.pptx", "xml/fdo47434_", PPTX, -1 },
     154             :         { "n758621.ppt", "xml/n758621_", PPT, -1 },
     155             :         { "fdo64586.ppt", "xml/fdo64586_", PPT, -1 },
     156             :         { "n819614.pptx", "xml/n819614_", PPTX, -1 },
     157             :         { "n820786.pptx", "xml/n820786_", PPTX, -1 },
     158             :         { "n762695.pptx", "xml/n762695_", PPTX, -1 },
     159             :         { "n593612.pptx", "xml/n593612_", PPTX, -1 },
     160             :         { "fdo71434.pptx", "xml/fdo71434_", PPTX, -1 },
     161             :         // { "pptx/n828390.pptx", "pptx/xml/n828390_", PPTX, PPTX }, // Example
     162           2 :     };
     163             : 
     164          20 :     for ( int i = 0; i < static_cast< int >( SAL_N_ELEMENTS( aFilesToCompare ) ); ++i )
     165             :     {
     166          18 :         int nUpdateMe = -1; // index of test we want to update; supposedly only when the test is created
     167             : 
     168          18 :         ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pInput ), aFilesToCompare[i].nFormat );
     169          18 :         if( aFilesToCompare[i].nExportType >= 0 )
     170           0 :             xDocShRef = saveAndReload( xDocShRef, aFilesToCompare[i].nExportType );
     171             :         compareWithShapesDump( xDocShRef,
     172          36 :                 getPathFromSrc( "/sd/qa/unit/data/" ) + OUString::createFromAscii( aFilesToCompare[i].pDump ),
     173          36 :                 i == nUpdateMe );
     174          18 :     }
     175           2 : }
     176             : 
     177           2 : void SdImportTest::testSmoketest()
     178             : {
     179           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/smoketest.pptx"), PPTX);
     180             : 
     181           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     182           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     183             : 
     184             :     // cf. SdrModel svx/svdmodel.hxx ...
     185             : 
     186           2 :     CPPUNIT_ASSERT_MESSAGE( "wrong page count", pDoc->GetPageCount() == 3);
     187             : 
     188           2 :     const SdrPage *pPage = pDoc->GetPage (1);
     189           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     190             : 
     191           2 :     const size_t nObjs = pPage->GetObjCount();
     192           8 :     for (size_t i = 0; i < nObjs; i++)
     193             :     {
     194           6 :         SdrObject *pObj = pPage->GetObj(i);
     195           6 :         SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
     196           6 :         SdrTextObj *pTxt = dynamic_cast<SdrTextObj *>( pObj );
     197             :         (void)pTxt; (void)eKind;
     198             :     }
     199             : 
     200           2 :     CPPUNIT_ASSERT_MESSAGE( "changed", !pDoc->IsChanged() );
     201             : 
     202           2 :     xDocShRef->DoClose();
     203           2 : }
     204             : 
     205           2 : void SdImportTest::testN759180()
     206             : {
     207           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/n759180.pptx"), PPTX);
     208             : 
     209           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     210           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     211           2 :     const SdrPage *pPage = pDoc->GetPage (1);
     212           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     213             : 
     214             :     //sal_uIntPtr nObjs = pPage->GetObjCount();
     215             :     //for (sal_uIntPtr i = 0; i < nObjs; i++)
     216             :     {
     217             :         // Get the object
     218           2 :         SdrObject *pObj = pPage->GetObj(0);
     219           2 :         SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
     220           2 :         CPPUNIT_ASSERT(pTxtObj);
     221           2 :         std::vector<EECharAttrib> rLst;
     222           2 :         const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
     223           2 :         const SvxULSpaceItem *pULSpace = dynamic_cast<const SvxULSpaceItem *>(aEdit.GetParaAttribs(0).GetItem(EE_PARA_ULSPACE));
     224           2 :         CPPUNIT_ASSERT(pULSpace);
     225           2 :         CPPUNIT_ASSERT_MESSAGE( "Para bottom spacing is wrong!", pULSpace->GetLower() == 0 );
     226           2 :         aEdit.GetCharAttribs(1, rLst);
     227           4 :         for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
     228             :         {
     229           4 :             const SvxFontHeightItem * pFontHeight = dynamic_cast<const SvxFontHeightItem *>((*it).pAttr);
     230           4 :             if(pFontHeight)
     231             :             {
     232             :                 // nStart == 9
     233             :                 // font height = 5 => 5*2540/72
     234           2 :                 CPPUNIT_ASSERT_MESSAGE( "Font height is wrong", pFontHeight->GetHeight() == 176 );
     235           2 :                 break;
     236             :             }
     237           2 :         }
     238             :     }
     239             : 
     240           2 :     xDocShRef->DoClose();
     241           2 : }
     242             : 
     243           2 : void SdImportTest::testN862510_1()
     244             : {
     245           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_1.pptx"), PPTX );
     246             : 
     247           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     248           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     249           2 :     const SdrPage *pPage = pDoc->GetPage(1);
     250           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     251             :     {
     252           2 :         std::vector<EECharAttrib> rLst;
     253           2 :         SdrObject *pObj = pPage->GetObj( 0 );
     254           2 :         SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
     255           2 :         CPPUNIT_ASSERT( pTxtObj );
     256           2 :         const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
     257           2 :         aEdit.GetCharAttribs( 0, rLst );
     258          34 :         for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
     259             :         {
     260          32 :             const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>( (*it).pAttr );
     261          32 :             CPPUNIT_ASSERT_MESSAGE( "Baseline attribute not handled properly", !( pFontEscapement && pFontEscapement->GetProp() != 100 ) );
     262           2 :         }
     263             :     }
     264             : 
     265           2 :     xDocShRef->DoClose();
     266           2 : }
     267             : 
     268           2 : void SdImportTest::testN862510_2()
     269             : {
     270           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_2.pptx"), PPTX );
     271             : 
     272           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     273           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     274           2 :     const SdrPage *pPage = pDoc->GetPage(1);
     275           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     276             :     {
     277           2 :         SdrObjGroup *pGrpObj = dynamic_cast<SdrObjGroup *>( pPage->GetObj( 0 ) );
     278           2 :         CPPUNIT_ASSERT( pGrpObj );
     279           2 :         SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>( pGrpObj->GetSubList()->GetObj( 0 ) );
     280           2 :         CPPUNIT_ASSERT( pObj );
     281           2 :         CPPUNIT_ASSERT_MESSAGE( "Wrong Text Rotation!", pObj->GetExtraTextRotation( true ) == 90 );
     282             :     }
     283             : 
     284           2 :     xDocShRef->DoClose();
     285           2 : }
     286             : 
     287           2 : void SdImportTest::testN862510_4()
     288             : {
     289           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n862510_4.pptx"), PPTX );
     290             : 
     291           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     292           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     293           2 :     const SdrPage *pPage = pDoc->GetPage( 1 );
     294           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     295             :     {
     296           2 :         std::vector<EECharAttrib> rLst;
     297           2 :         SdrObject *pObj = pPage->GetObj( 0 );
     298           2 :         SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
     299           2 :         CPPUNIT_ASSERT( pTxtObj );
     300           2 :         const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
     301           2 :         aEdit.GetCharAttribs( 0, rLst );
     302          34 :         for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it != rLst.rend(); ++it )
     303             :         {
     304          32 :             const SvxColorItem *pC = dynamic_cast<const SvxColorItem *>( (*it).pAttr );
     305          32 :             CPPUNIT_ASSERT_MESSAGE( "gradfill for text color not handled!", !( pC && pC->GetValue().GetColor() == 0 ) );
     306           2 :         }
     307             :     }
     308             : 
     309           2 :     xDocShRef->DoClose();
     310           2 : }
     311             : 
     312           2 : void SdImportTest::testN828390_2()
     313             : {
     314           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_2.pptx"), PPTX );
     315             : 
     316           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     317           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     318           2 :     const SdrPage *pPage = pDoc->GetPage(1);
     319           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     320             : 
     321           2 :     SdrObject *pObj = pPage->GetObj(0);
     322           2 :     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
     323           2 :     CPPUNIT_ASSERT( pTxtObj );
     324           2 :     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
     325           2 :     CPPUNIT_ASSERT(aEdit.GetText(0) == OUString("Linux  "));
     326           2 :     CPPUNIT_ASSERT(aEdit.GetText(1) == OUString("Standard Platform"));
     327             : 
     328           2 :     xDocShRef->DoClose();
     329           2 : }
     330             : 
     331           2 : void SdImportTest::testN828390_3()
     332             : {
     333           2 :     bool bPassed = true;
     334           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/n828390_3.pptx"), PPTX );
     335             : 
     336           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     337           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     338           2 :     const SdrPage *pPage = pDoc->GetPage(1);
     339           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     340             : 
     341           2 :     SdrObject *pObj = pPage->GetObj(0);
     342           2 :     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
     343           2 :     CPPUNIT_ASSERT( pTxtObj );
     344           2 :     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
     345           4 :     std::vector<EECharAttrib> rLst;
     346           2 :     aEdit.GetCharAttribs(1, rLst);
     347          34 :     for( std::vector<EECharAttrib>::reverse_iterator it = rLst.rbegin(); it!=rLst.rend(); ++it)
     348             :     {
     349          32 :         const SvxEscapementItem *pFontEscapement = dynamic_cast<const SvxEscapementItem *>((*it).pAttr);
     350          32 :         if(pFontEscapement)
     351             :         {
     352           2 :             if( pFontEscapement->GetEsc() != 0 )
     353             :             {
     354           0 :                 bPassed = false;
     355           0 :                 break;
     356             :             }
     357             :         }
     358             :     }
     359           2 :     CPPUNIT_ASSERT_MESSAGE("CharEscapment not imported properly", bPassed);
     360             : 
     361           4 :     xDocShRef->DoClose();
     362           2 : }
     363             : 
     364           2 : void SdImportTest::testMasterPageStyleParent()
     365             : {
     366           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/odp/masterpage_style_parent.odp"), ODP );
     367             : 
     368           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     369           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     370           2 :     const SdrPage *pPage = pDoc->GetPage(1);
     371           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     372             : 
     373           2 :     SdStyleSheetPool *const pPool(pDoc->GetSdStyleSheetPool());
     374             : 
     375           2 :     int parents(0);
     376           4 :     SfxStyleSheetIterator iter(pPool, SD_STYLE_FAMILY_MASTERPAGE);
     377          58 :     for (SfxStyleSheetBase * pStyle = iter.First(); pStyle; pStyle = iter.Next())
     378             :     {
     379          56 :         OUString const name(pStyle->GetName());
     380         112 :         OUString const parent(pStyle->GetParent());
     381          56 :         if (!parent.isEmpty())
     382             :         {
     383          32 :             ++parents;
     384             :             // check that parent exists
     385             :             SfxStyleSheetBase *const pParentStyle(
     386          32 :                     pPool->Find(parent, SD_STYLE_FAMILY_MASTERPAGE));
     387          32 :             CPPUNIT_ASSERT(pParentStyle);
     388          32 :             CPPUNIT_ASSERT_EQUAL(pParentStyle->GetName(), parent);
     389             :             // check that parent has the same master page as pStyle
     390          32 :             CPPUNIT_ASSERT(parent.indexOf(SD_LT_SEPARATOR) != -1);
     391          32 :             CPPUNIT_ASSERT(name.indexOf(SD_LT_SEPARATOR) != -1);
     392          64 :             CPPUNIT_ASSERT_EQUAL(
     393             :                     parent.copy(0, parent.indexOf(SD_LT_SEPARATOR)),
     394          32 :                     name.copy(0, name.indexOf(SD_LT_SEPARATOR)));
     395             :         }
     396          56 :     }
     397             :     // check that there are actually parents...
     398           2 :     CPPUNIT_ASSERT_EQUAL(16, parents);
     399             : 
     400           4 :     xDocShRef->DoClose();
     401           2 : }
     402             : 
     403           2 : void SdImportTest::testN778859()
     404             : {
     405           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/n778859.pptx"), PPTX);
     406             : 
     407           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     408           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     409           2 :     const SdrPage *pPage = pDoc->GetPage(1);
     410           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     411             :     {
     412             :         // Get the object
     413           2 :         SdrObject *pObj = pPage->GetObj(1);
     414           2 :         SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
     415           2 :         CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
     416           2 :         CPPUNIT_ASSERT(!pTxtObj->IsAutoFit());
     417             :     }
     418             : 
     419           2 :     xDocShRef->DoClose();
     420           2 : }
     421             : 
     422           2 : void SdImportTest::testFdo68594()
     423             : {
     424           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/ppt/fdo68594.ppt"), PPT);
     425             : 
     426           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     427           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     428           2 :     const SdrPage *pPage = &(pDoc->GetPage (1)->TRG_GetMasterPage());
     429           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     430           2 :     SdrObject *pObj = pPage->GetObj(1);
     431           2 :     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
     432           2 :     CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
     433           2 :     const SvxColorItem *pC = dynamic_cast<const SvxColorItem *>(&pTxtObj->GetMergedItem(EE_CHAR_COLOR));
     434           2 :     CPPUNIT_ASSERT_MESSAGE( "no color item", pC != NULL);
     435             :     // Color should be black
     436           2 :     CPPUNIT_ASSERT_MESSAGE( "Placeholder color mismatch", pC->GetValue().GetColor() == 0);
     437             : 
     438           2 :     xDocShRef->DoClose();
     439           2 : }
     440             : 
     441           2 : void SdImportTest::testFdo72998()
     442             : {
     443           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/cshapes.pptx"), PPTX);
     444             : 
     445           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     446           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     447           2 :     const SdrPage *pPage = pDoc->GetPage(1);
     448           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     449             :     {
     450           2 :         SdrObjCustomShape *pObj = dynamic_cast<SdrObjCustomShape *>(pPage->GetObj(2));
     451           2 :         CPPUNIT_ASSERT( pObj );
     452           2 :         const SdrCustomShapeGeometryItem& rGeometryItem = (const SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY );
     453           2 :         const ::com::sun::star::uno::Any* pViewBox = ((SdrCustomShapeGeometryItem&)rGeometryItem).GetPropertyValueByName( OUString( "ViewBox" ) );
     454           2 :         CPPUNIT_ASSERT_MESSAGE( "Missing ViewBox", pViewBox );
     455           2 :         com::sun::star::awt::Rectangle aViewBox;
     456           2 :         CPPUNIT_ASSERT( (*pViewBox >>= aViewBox ) );
     457           2 :         CPPUNIT_ASSERT_MESSAGE( "Width should be zero - for forcing scale to 1", !aViewBox.Width );
     458           2 :         CPPUNIT_ASSERT_MESSAGE( "Height should be zero - for forcing scale to 1", !aViewBox.Height );
     459             :     }
     460             : 
     461           2 :     xDocShRef->DoClose();
     462           2 : }
     463             : 
     464             : // FIXME copypasta
     465           0 : std::ostream& operator<<(std::ostream& rStrm, const Color& rColor)
     466             : {
     467           0 :     rStrm << "Color: R:" << rColor.GetRed() << " G:" << rColor.GetGreen() << " B: " << rColor.GetBlue();
     468           0 :     return rStrm;
     469             : }
     470             : 
     471           2 : void SdImportTest::testFdo77027()
     472             : {
     473           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/odp/fdo77027.odp"), ODP);
     474             : 
     475           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     476           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     477           2 :     const SdrPage *pPage = pDoc->GetPage(1);
     478           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     479             :     {
     480           2 :         SdrOle2Obj *const pObj = dynamic_cast<SdrOle2Obj*>(pPage->GetObj(0));
     481           2 :         CPPUNIT_ASSERT(pObj);
     482             : 
     483             :         // check that the fill style/color was actually imported
     484             :         const XFillStyleItem& rStyleItem = dynamic_cast<const XFillStyleItem&>(
     485           2 :                 pObj->GetMergedItem(XATTR_FILLSTYLE));
     486           2 :         CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, rStyleItem.GetValue());
     487             :         const XFillColorItem& rColorItem = dynamic_cast<const XFillColorItem&>(
     488           2 :                 pObj->GetMergedItem(XATTR_FILLCOLOR));
     489           2 :         CPPUNIT_ASSERT_EQUAL(Color(0xff6600), rColorItem.GetColorValue());
     490             :     }
     491             : 
     492           2 :     xDocShRef->DoClose();
     493           2 : }
     494             : 
     495           2 : void SdImportTest::testFdo64512()
     496             : {
     497           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo64512.odp"), ODP);
     498             : 
     499             :     uno::Reference< drawing::XDrawPagesSupplier > xDoc(
     500           4 :         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
     501           2 :     CPPUNIT_ASSERT_MESSAGE( "not exactly one page", xDoc->getDrawPages()->getCount() == 1 );
     502             : 
     503             :     uno::Reference< drawing::XDrawPage > xPage(
     504           4 :         xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
     505           2 :     CPPUNIT_ASSERT_MESSAGE( "no exactly three shapes", xPage->getCount() == 3 );
     506             : 
     507             :     uno::Reference< beans::XPropertySet > xConnectorShape(
     508           4 :         xPage->getByIndex(2), uno::UNO_QUERY );
     509           2 :     CPPUNIT_ASSERT_MESSAGE( "no connector shape", xConnectorShape.is() );
     510             : 
     511             :     uno::Reference< beans::XPropertySet > xSvgShape(
     512           4 :         xConnectorShape->getPropertyValue("StartShape"), uno::UNO_QUERY );
     513           2 :     CPPUNIT_ASSERT_MESSAGE( "no start shape", xSvgShape.is() );
     514             : 
     515             :     uno::Reference< beans::XPropertySet > xCustomShape(
     516           4 :         xConnectorShape->getPropertyValue("EndShape"), uno::UNO_QUERY );
     517           2 :     CPPUNIT_ASSERT_MESSAGE( "no end shape", xCustomShape.is() );
     518             : 
     519             :     uno::Reference< animations::XAnimationNodeSupplier > xAnimNodeSupplier(
     520           4 :         xPage, uno::UNO_QUERY_THROW );
     521             :     uno::Reference< animations::XAnimationNode > xRootNode(
     522           4 :         xAnimNodeSupplier->getAnimationNode() );
     523           4 :     std::vector< uno::Reference< animations::XAnimationNode > > aAnimVector;
     524           2 :     anim::create_deep_vector(xRootNode, aAnimVector);
     525           2 :     CPPUNIT_ASSERT_MESSAGE( "not 8 animation nodes", aAnimVector.size() == 8 );
     526             : 
     527             :     uno::Reference< animations::XAnimate > xNode(
     528           4 :         aAnimVector[7], uno::UNO_QUERY_THROW );
     529             :     uno::Reference< drawing::XShape > xTargetShape(
     530           4 :         xNode->getTarget(), uno::UNO_QUERY_THROW );
     531           4 :     CPPUNIT_ASSERT_MESSAGE( "inner node not referencing svg shape",
     532           2 :                             xTargetShape != xSvgShape );
     533             : 
     534           4 :     xDocShRef->DoClose();
     535           2 : }
     536             : 
     537             : // Unit test for importing charts
     538           2 : void SdImportTest::testFdo71075()
     539             : {
     540           2 :     double values[] = { 12.0, 13.0, 14.0 };
     541           2 :     ::com::sun::star::uno::Any aAny;
     542           4 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71075.odp"), ODP);
     543             : 
     544           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     545           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     546           4 :     uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
     547           4 :     uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
     548           4 :     uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
     549           2 :     CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape.is() );
     550             : 
     551           4 :     uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY );
     552           2 :     aAny = xPropSet->getPropertyValue( OUString("Model") );
     553           2 :     CPPUNIT_ASSERT_MESSAGE( "failed to load shape", aAny.hasValue() );
     554             : 
     555           4 :     uno::Reference< chart::XChartDocument > xChartDoc;
     556           2 :     aAny >>= xChartDoc;
     557           2 :     CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChartDoc.is() );
     558           4 :     uno::Reference< chart2::XChartDocument > xChart2Doc( xChartDoc, uno::UNO_QUERY );
     559           2 :     CPPUNIT_ASSERT_MESSAGE( "failed to load chart", xChart2Doc.is() );
     560             : 
     561           4 :     uno::Reference< chart2::XCoordinateSystemContainer > xBCooSysCnt( xChart2Doc->getFirstDiagram(), uno::UNO_QUERY );
     562           4 :     uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xBCooSysCnt->getCoordinateSystems());
     563           4 :     uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[0], uno::UNO_QUERY );
     564             : 
     565           4 :     uno::Reference< chart2::XDataSeriesContainer > xDSCnt( xCTCnt->getChartTypes()[0], uno::UNO_QUERY );
     566           2 :     CPPUNIT_ASSERT_MESSAGE( "failed to load data series", xDSCnt.is() );
     567           4 :     uno::Sequence< uno::Reference< chart2::XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries());
     568           2 :     CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aSeriesSeq.getLength() == 1);
     569           4 :     uno::Reference< chart2::data::XDataSource > xSource( aSeriesSeq[0], uno::UNO_QUERY );
     570           4 :     uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aSeqCnt(xSource->getDataSequences());
     571           2 :     CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aSeqCnt.getLength() == 1);
     572           4 :     uno::Reference< chart2::data::XDataSequence > xValueSeq( aSeqCnt[0]->getValues() );
     573           2 :     CPPUNIT_ASSERT_MESSAGE( "Invalid Data count", xValueSeq->getData().getLength() == sizeof(values)/(sizeof(double)));
     574           4 :     uno::Reference< chart2::data::XNumericalDataSequence > xNumSeq( xValueSeq, uno::UNO_QUERY );
     575           4 :     uno::Sequence< double > aValues( xNumSeq->getNumericalData());
     576           8 :     for(sal_Int32 i=0;i<xValueSeq->getData().getLength();i++)
     577           6 :         CPPUNIT_ASSERT_MESSAGE( "Invalid Series count", aValues.getConstArray()[i] == values[i]);
     578             : 
     579           4 :     xDocShRef->DoClose();
     580           2 : }
     581             : 
     582           2 : void SdImportTest::testStrictOOXML()
     583             : {
     584           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/strict_ooxml.pptx"), PPTX);
     585             : 
     586           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     587           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     588           4 :     uno::Reference< drawing::XDrawPagesSupplier > xDoc(xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
     589           4 :     uno::Reference< drawing::XDrawPage > xPage(xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
     590           4 :     uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
     591           2 :     CPPUNIT_ASSERT_MESSAGE( "failed to load shape", xShape.is() );
     592             : 
     593           4 :     xDocShRef->DoClose();
     594           2 : }
     595             : 
     596           2 : void SdImportTest::testBnc870237()
     597             : {
     598           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc870237.pptx"), PPTX);
     599             : 
     600           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     601           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     602           2 :     const SdrPage *pPage = pDoc->GetPage (1);
     603           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     604             : 
     605             :     // Simulate a:ext inside dsp:txXfrm with changing the lower distance
     606           2 :     const SdrObjGroup* pObj = dynamic_cast<SdrObjGroup*>( pPage->GetObj( 0 ) );
     607           2 :     CPPUNIT_ASSERT_MESSAGE( "no object", pObj != NULL);
     608           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrMetricItem& >(pObj->GetMergedItem(SDRATTR_TEXT_UPPERDIST))).GetValue());
     609           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32(9919), (static_cast< const SdrMetricItem& >(pObj->GetMergedItem(SDRATTR_TEXT_LOWERDIST))).GetValue());
     610           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrMetricItem& >(pObj->GetMergedItem(SDRATTR_TEXT_RIGHTDIST))).GetValue());
     611           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32(0), (static_cast< const SdrMetricItem& >(pObj->GetMergedItem(SDRATTR_TEXT_LEFTDIST))).GetValue());
     612             : 
     613           2 :     xDocShRef->DoClose();
     614           2 : }
     615             : 
     616           2 : void SdImportTest::testCreationDate()
     617             : {
     618           2 :     sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/fdo71434.pptx"), PPTX);
     619           4 :     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(xDocShRef->GetModel(), uno::UNO_QUERY);
     620           4 :     uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
     621           2 :     util::DateTime aDate = xDocumentProperties->getCreationDate();
     622           4 :     OUStringBuffer aBuffer;
     623           2 :     sax::Converter::convertDateTime(aBuffer, aDate, 0);
     624             :     // Metadata wasn't imported, this was 0000-00-00.
     625           2 :     CPPUNIT_ASSERT_EQUAL(OUString("2013-11-09T10:37:56"), aBuffer.makeStringAndClear());
     626           4 :     xDocShRef->DoClose();
     627           2 : }
     628             : 
     629           2 : void SdImportTest::testBnc887225()
     630             : {
     631           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/bnc887225.pptx"), PPTX );
     632             :     // In the document, lastRow and lastCol table properties are used.
     633             :     // Make sure styles are set properly for individual cells.
     634             : 
     635           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     636           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     637           2 :     const SdrPage *pPage = pDoc->GetPage(1);
     638           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     639             : 
     640           2 :     sdr::table::SdrTableObj *pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(2));
     641           2 :     CPPUNIT_ASSERT( pTableObj );
     642           4 :     uno::Reference< table::XCellRange > xTable(pTableObj->getTable(), uno::UNO_QUERY_THROW);
     643           4 :     uno::Reference< beans::XPropertySet > xCell;
     644             :     sal_Int32 nColor;
     645             : 
     646           2 :     xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
     647           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     648           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor);
     649             : 
     650           2 :     xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
     651           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     652           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor);
     653             : 
     654           2 :     xCell.set(xTable->getCellByPosition(1, 1), uno::UNO_QUERY_THROW);
     655           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     656           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(13754095), nColor);
     657             : 
     658           2 :     xCell.set(xTable->getCellByPosition(1, 2), uno::UNO_QUERY_THROW);
     659           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     660           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(15331319), nColor);
     661             : 
     662           2 :     xCell.set(xTable->getCellByPosition(1, 4), uno::UNO_QUERY_THROW);
     663           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     664           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor);
     665             : 
     666           2 :     xCell.set(xTable->getCellByPosition(3, 2), uno::UNO_QUERY_THROW);
     667           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     668           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor);
     669             : 
     670           2 :     xCell.set(xTable->getCellByPosition(3, 4), uno::UNO_QUERY_THROW);
     671           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     672           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(6003669), nColor);
     673             : 
     674           4 :     xDocShRef->DoClose();
     675           2 : }
     676             : 
     677           2 : void SdImportTest::testBnc480256()
     678             : {
     679           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc480256.pptx"), PPTX);
     680             :     // In the document, there are two tables with table background properties.
     681             :     // Make sure colors are set properly for individual cells.
     682             : 
     683             :     // TODO: If you are working on improving table background support, expect
     684             :     // this unit test to fail. In that case, feel free to change the numbers.
     685             : 
     686           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     687           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     688           2 :     const SdrPage *pPage = pDoc->GetPage(1);
     689           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     690             : 
     691             :     sdr::table::SdrTableObj *pTableObj;
     692           4 :     uno::Reference< table::XCellRange > xTable;
     693           4 :     uno::Reference< beans::XPropertySet > xCell;
     694             :     sal_Int32 nColor;
     695           2 :     table::BorderLine2 aBorderLine;
     696             : 
     697           2 :     pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(0));
     698           2 :     CPPUNIT_ASSERT( pTableObj );
     699           2 :     xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
     700             : 
     701           2 :     xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
     702           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     703           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(10208238), nColor);
     704           2 :     xCell->getPropertyValue("LeftBorder") >>= aBorderLine;
     705           2 :     CPPUNIT_ASSERT_EQUAL(util::Color(5609427), aBorderLine.Color);
     706             : 
     707           2 :     xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
     708           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     709           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(13032959), nColor);
     710           2 :     xCell->getPropertyValue("TopBorder") >>= aBorderLine;
     711           2 :     CPPUNIT_ASSERT_EQUAL(util::Color(5609427), aBorderLine.Color);
     712             : 
     713           2 :     pTableObj = dynamic_cast<sdr::table::SdrTableObj*>(pPage->GetObj(1));
     714           2 :     CPPUNIT_ASSERT( pTableObj );
     715           2 :     xTable.set(pTableObj->getTable(), uno::UNO_QUERY_THROW);
     716             : 
     717           2 :     xCell.set(xTable->getCellByPosition(0, 0), uno::UNO_QUERY_THROW);
     718           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     719           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(7056614), nColor);
     720           2 :     xCell->getPropertyValue("LeftBorder") >>= aBorderLine;
     721           2 :     CPPUNIT_ASSERT_EQUAL(util::Color(12505062), aBorderLine.Color);
     722             : 
     723           2 :     xCell.set(xTable->getCellByPosition(0, 1), uno::UNO_QUERY_THROW);
     724           2 :     xCell->getPropertyValue("FillColor") >>= nColor;
     725           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(4626400), nColor);
     726             : 
     727           2 :     xCell.set(xTable->getCellByPosition(1, 0), uno::UNO_QUERY_THROW);
     728           2 :     xCell->getPropertyValue("BottomBorder") >>= aBorderLine;
     729           2 :     CPPUNIT_ASSERT_EQUAL(util::Color(0), aBorderLine.Color);
     730             : 
     731           4 :     xDocShRef->DoClose();
     732           2 : }
     733             : 
     734           2 : void SdImportTest::testBnc584721_1()
     735             : {
     736             :     // Title text shape on the master page contained wrong text.
     737             : 
     738           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX);
     739             : 
     740           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     741           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     742           2 :     const SdrPage *pPage = &(pDoc->GetPage (1)->TRG_GetMasterPage());
     743           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     744           2 :     SdrObject *pObj = pPage->GetObj(0);
     745           2 :     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pObj );
     746           2 :     CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
     747           2 :     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
     748           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Click to edit Master title style"), aEdit.GetText(0));
     749           2 :     xDocShRef->DoClose();
     750           2 : }
     751             : 
     752           2 : void SdImportTest::testBnc584721_2()
     753             : {
     754             :     // Import created an extra/unneeded outliner shape on the master slide next to the imported title shape.
     755             : 
     756           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_1_2.pptx"), PPTX);
     757             : 
     758           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     759           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     760           2 :     const SdrPage *pPage = &(pDoc->GetPage(1)->TRG_GetMasterPage());
     761           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     762           2 :     CPPUNIT_ASSERT_EQUAL(size_t(1), pPage->GetObjCount());
     763             : 
     764           2 :     xDocShRef->DoClose();
     765           2 : }
     766             : 
     767           2 : void SdImportTest::testBnc584721_3()
     768             : {
     769             :     // Subtitle was simply skipped on master slides.
     770             :     // Check whether the second shape is a subtitle shape with the right text.
     771             : 
     772           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_3.pptx"), PPTX);
     773             : 
     774           2 :     SdDrawDocument *pDoc = xDocShRef->GetDoc();
     775           2 :     CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
     776           2 :     const SdrPage *pPage = &(pDoc->GetPage(1)->TRG_GetMasterPage());
     777           2 :     CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
     778           2 :     SdrTextObj *pTxtObj = dynamic_cast<SdrTextObj *>( pPage->GetObj(1) );
     779           2 :     CPPUNIT_ASSERT_MESSAGE( "no text object", pTxtObj != NULL);
     780             : 
     781             :     // Check the shape type
     782           4 :     uno::Reference< drawing::XShape > xShape( pTxtObj->getUnoShape(), uno::UNO_QUERY );
     783           2 :     CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.presentation.SubtitleShape"), xShape->getShapeType());
     784             : 
     785             :     // Check the text
     786           2 :     const EditTextObject& aEdit = pTxtObj->GetOutlinerParaObject()->GetTextObject();
     787           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Click to edit Master subtitle style"), aEdit.GetText(0));
     788             : 
     789           4 :     xDocShRef->DoClose();
     790           2 : }
     791             : 
     792           2 : void SdImportTest::testBnc591147()
     793             : {
     794           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc591147.pptx"), PPTX);
     795             : 
     796             :     // In the document, there are two slides with media files.
     797             :     uno::Reference< drawing::XDrawPagesSupplier > xDoc(
     798           4 :         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
     799           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32(2), xDoc->getDrawPages()->getCount() );
     800             : 
     801             :     // First page has video file inserted
     802             :     uno::Reference< drawing::XDrawPage > xPage(
     803           4 :         xDoc->getDrawPages()->getByIndex(0), uno::UNO_QUERY_THROW );
     804           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage->getCount() );
     805             : 
     806           4 :     uno::Reference< drawing::XShape > xShape(xPage->getByIndex(0), uno::UNO_QUERY_THROW );
     807           4 :     uno::Reference< beans::XPropertySet > xPropSet( xShape, uno::UNO_QUERY_THROW );
     808           4 :     OUString sVideoURL("emptyURL");
     809           2 :     bool bSucess = xPropSet->getPropertyValue("MediaURL") >>= sVideoURL;
     810           2 :     CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSucess );
     811           2 :     CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sVideoURL.isEmpty());
     812             : 
     813             :     // Second page has audio file inserted
     814           2 :     xPage.set( xDoc->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
     815           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32(1), xPage->getCount() );
     816             : 
     817           2 :     xShape.set( xPage->getByIndex(0), uno::UNO_QUERY_THROW );
     818           2 :     xPropSet.set( xShape, uno::UNO_QUERY_THROW );
     819           4 :     OUString sAudioURL("emptyURL");
     820           2 :     bSucess = xPropSet->getPropertyValue("MediaURL") >>= sAudioURL;
     821           2 :     CPPUNIT_ASSERT_MESSAGE( "MediaURL property is not set", bSucess );
     822           2 :     CPPUNIT_ASSERT_MESSAGE("MediaURL is empty", !sAudioURL.isEmpty());
     823             : 
     824           2 :     CPPUNIT_ASSERT_MESSAGE( "sAudioURL and sVideoURL should not be equal", sAudioURL != sVideoURL );
     825             : 
     826           4 :     xDocShRef->DoClose();
     827           2 : }
     828             : 
     829           2 : void SdImportTest::testBnc584721_4()
     830             : {
     831             :     // Black text was imported as white because of wrong caching mechanism
     832             : 
     833           2 :     ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/pptx/bnc584721_4.pptx"), PPTX);
     834             : 
     835             :     uno::Reference< drawing::XDrawPagesSupplier > xDoc(
     836           4 :         xDocShRef->GetDoc()->getUnoModel(), uno::UNO_QUERY_THROW );
     837             : 
     838             :     uno::Reference< drawing::XDrawPage > xPage(
     839           4 :         xDoc->getDrawPages()->getByIndex(1), uno::UNO_QUERY_THROW );
     840             : 
     841             :     uno::Reference< beans::XPropertySet > xShape(
     842           4 :         xPage->getByIndex(1), uno::UNO_QUERY );
     843           2 :     CPPUNIT_ASSERT_MESSAGE( "no text shape", xShape.is() );
     844             : 
     845             :     // Get first paragraph of the text
     846           4 :     uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
     847           2 :     CPPUNIT_ASSERT_MESSAGE( "no text shape", xText.is() );
     848           4 :     uno::Reference<container::XEnumerationAccess> paraEnumAccess;
     849           2 :     paraEnumAccess.set(xText, uno::UNO_QUERY);
     850           4 :     uno::Reference<container::XEnumeration> paraEnum = paraEnumAccess->createEnumeration();
     851           2 :     uno::Reference<text::XTextRange> const xParagraph(paraEnum->nextElement(),
     852           4 :                 uno::UNO_QUERY_THROW);
     853             : 
     854             :     // Get first run of the paragraph
     855           4 :     uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParagraph, uno::UNO_QUERY);
     856           4 :     uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
     857           4 :     uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
     858           4 :     uno::Reference< beans::XPropertySet > xPropSet( xRun, uno::UNO_QUERY_THROW );
     859             :     sal_Int32 nCharColor;
     860           2 :     xPropSet->getPropertyValue( "CharColor" ) >>= nCharColor;
     861             : 
     862             :     // Color should be black
     863           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32(COL_BLACK), nCharColor );
     864             : 
     865           4 :     xDocShRef->DoClose();
     866           2 : }
     867             : 
     868           2 : CPPUNIT_TEST_SUITE_REGISTRATION(SdImportTest);
     869             : 
     870           8 : CPPUNIT_PLUGIN_IMPLEMENT();
     871             : 
     872             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10