LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/qa/unit - filters-test.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 223 223 100.0 %
Date: 2013-07-09 Functions: 25 26 96.2 %
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 <sal/config.h>
      11             : #include <unotest/filters-test.hxx>
      12             : #include <test/bootstrapfixture.hxx>
      13             : #include <rtl/strbuf.hxx>
      14             : #include <osl/file.hxx>
      15             : 
      16             : #include "scdll.hxx"
      17             : #include <sfx2/app.hxx>
      18             : #include <sfx2/docfilt.hxx>
      19             : #include <sfx2/docfile.hxx>
      20             : #include <sfx2/sfxmodelfactory.hxx>
      21             : #include <svl/stritem.hxx>
      22             : 
      23             : #define CALC_DEBUG_OUTPUT 0
      24             : #define TEST_BUG_FILES 0
      25             : 
      26             : #include "helper/qahelper.hxx"
      27             : 
      28             : #include "docsh.hxx"
      29             : #include "postit.hxx"
      30             : #include "patattr.hxx"
      31             : #include "scitems.hxx"
      32             : #include "document.hxx"
      33             : #include "cellform.hxx"
      34             : #include "drwlayer.hxx"
      35             : #include "userdat.hxx"
      36             : #include <svx/svdpage.hxx>
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using namespace ::com::sun::star::uno;
      40             : 
      41             : /* Implementation of Filters test */
      42             : 
      43          20 : class ScFiltersTest
      44             :     : public test::FiltersTest
      45             :     , public ScBootstrapFixture
      46             : {
      47             : public:
      48             :     ScFiltersTest();
      49             : 
      50             :     virtual void setUp();
      51             :     virtual void tearDown();
      52             : 
      53             :     virtual bool load( const OUString &rFilter, const OUString &rURL,
      54             :         const OUString &rUserData, unsigned int nFilterFlags,
      55             :         unsigned int nClipboardID, unsigned int nFilterVersion);
      56             :     /**
      57             :      * Ensure CVEs remain unbroken
      58             :      */
      59             :     void testCVEs();
      60             : 
      61             :     //ods, xls, xlsx filter tests
      62             :     void testRangeNameODS(); // only test ods here, xls and xlsx in subsequent_filters-test
      63             :     void testContentODS();
      64             :     void testContentXLS();
      65             :     void testContentXLSX();
      66             :     void testContentLotus123();
      67             :     void testContentDIF();
      68             :     void testSharedFormulaXLS();
      69             :     void testSharedFormulaXLSX();
      70             : #if TEST_BUG_FILES
      71             :     //goes recursively through all files in this dir and tries to open them
      72             :     void testDir(osl::Directory& rDir, sal_Int32 nType);
      73             :     //test Bug Files and search for files that crash LibO
      74             :     void testBugFiles();
      75             :     void testBugFilesXLS();
      76             :     void testBugFilesXLSX();
      77             : #endif
      78             :     void testLegacyCellAnchoredRotatedShape();
      79             : 
      80           2 :     CPPUNIT_TEST_SUITE(ScFiltersTest);
      81           1 :     CPPUNIT_TEST(testCVEs);
      82           1 :     CPPUNIT_TEST(testRangeNameODS);
      83           1 :     CPPUNIT_TEST(testContentODS);
      84           1 :     CPPUNIT_TEST(testContentXLS);
      85           1 :     CPPUNIT_TEST(testContentXLSX);
      86           1 :     CPPUNIT_TEST(testContentLotus123);
      87           1 :     CPPUNIT_TEST(testContentDIF);
      88           1 :     CPPUNIT_TEST(testSharedFormulaXLS);
      89           1 :     CPPUNIT_TEST(testSharedFormulaXLSX);
      90           1 :     CPPUNIT_TEST(testLegacyCellAnchoredRotatedShape);
      91             : 
      92             : #if TEST_BUG_FILES
      93             :     CPPUNIT_TEST(testBugFiles);
      94             :     CPPUNIT_TEST(testBugFilesXLS);
      95             :     CPPUNIT_TEST(testBugFilesXLSX);
      96             : #endif
      97           2 :     CPPUNIT_TEST_SUITE_END();
      98             : 
      99             : private:
     100             :     uno::Reference<uno::XInterface> m_xCalcComponent;
     101             : };
     102             : 
     103          21 : bool ScFiltersTest::load(const OUString &rFilter, const OUString &rURL,
     104             :     const OUString &rUserData, unsigned int nFilterFlags,
     105             :         unsigned int nClipboardID, unsigned int nFilterVersion)
     106             : {
     107             :     ScDocShellRef xDocShRef = ScBootstrapFixture::load(rURL, rFilter, rUserData,
     108          21 :         OUString(), nFilterFlags, nClipboardID, nFilterVersion );
     109          21 :     bool bLoaded = xDocShRef.Is();
     110             :     //reference counting of ScDocShellRef is very confused.
     111          21 :     if (bLoaded)
     112          18 :         xDocShRef->DoClose();
     113          21 :     return bLoaded;
     114             : }
     115             : 
     116           1 : void ScFiltersTest::testCVEs()
     117             : {
     118             : #ifndef DISABLE_CVE_TESTS
     119             :     testDir(OUString("Quattro Pro 6.0"),
     120           1 :         getURLFromSrc("/sc/qa/unit/data/qpro/"), OUString());
     121             : 
     122             :     //warning, the current "sylk filter" in sc (docsh.cxx) automatically
     123             :     //chains on failure on trying as csv, rtf, etc. so "success" may
     124             :     //not indicate that it imported as .slk.
     125             :     testDir(OUString("SYLK"),
     126           1 :         getURLFromSrc("/sc/qa/unit/data/slk/"), OUString());
     127             : 
     128             :     testDir(OUString("MS Excel 97"),
     129           1 :         getURLFromSrc("/sc/qa/unit/data/xls/"), OUString());
     130             : #endif
     131           1 : }
     132             : 
     133             : #if TEST_BUG_FILES
     134             : 
     135             : void ScFiltersTest::testDir(osl::Directory& rDir, sal_uInt32 nType)
     136             : {
     137             :     OUString aFilterName(aFileFormats[nType].pFilterName, strlen(aFileFormats[nType].pFilterName), RTL_TEXTENCODING_UTF8) ;
     138             :     OUString aFilterType(aFileFormats[nType].pTypeName, strlen(aFileFormats[nType].pTypeName), RTL_TEXTENCODING_UTF8);
     139             : 
     140             :     osl::DirectoryItem aItem;
     141             :     osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
     142             :     while (rDir.getNextItem(aItem) == osl::FileBase::E_None)
     143             :     {
     144             :         aItem.getFileStatus(aFileStatus);
     145             :         OUString sURL = aFileStatus.getFileURL();
     146             :         std::cout << "File: " << OUStringToOString(sURL, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
     147             :         //OStringBuffer aMessage("Failed loading: ");
     148             :         //aMessage.append(OUStringToOString(sURL, RTL_TEXTENCODING_UTF8));
     149             : 
     150             :         unsigned int nFormatType = aFileFormats[nType].nFormatType;
     151             :         unsigned int nClipboardId = nFormatType ? SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS : 0;
     152             :         ScDocShellRef xDocSh = load(sURL, aFilterName, OUString(),
     153             :             aFilterType, nFormatType, nClipboardId );
     154             :         // use this only if you're sure that all files can be loaded
     155             :         // pay attention to lock files
     156             :         //CPPUNIT_ASSERT_MESSAGE(aMessage.getStr(), xDocSh.Is());
     157             :         if (xDocSh.Is())
     158             :             xDocSh->DoClose();
     159             :     }
     160             : }
     161             : 
     162             : void ScFiltersTest::testBugFiles()
     163             : {
     164             :     OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugODS/");
     165             :     osl::Directory aDir(aDirName);
     166             : 
     167             :     CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open());
     168             :     testDir(aDir, 0);
     169             : }
     170             : 
     171             : void ScFiltersTest::testBugFilesXLS()
     172             : {
     173             :     OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLS/");
     174             :     osl::Directory aDir(aDirName);
     175             : 
     176             :     CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open());
     177             :     testDir(aDir, 1);
     178             : }
     179             : 
     180             : void ScFiltersTest::testBugFilesXLSX()
     181             : {
     182             :     OUString aDirName = getURLFromSrc("/sc/qa/unit/data/bugXLSX/");
     183             :     osl::Directory aDir(aDirName);
     184             : 
     185             :     CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open());
     186             :     testDir(aDir, 2);
     187             : }
     188             : 
     189             : #endif
     190             : 
     191             : namespace {
     192             : 
     193           1 : void testRangeNameImpl(ScDocument* pDoc)
     194             : {
     195             :     //check one range data per sheet and one global more detailed
     196             :     //add some more checks here
     197           1 :     ScRangeData* pRangeData = pDoc->GetRangeName()->findByUpperName(OUString("GLOBAL1"));
     198           1 :     CPPUNIT_ASSERT_MESSAGE("range name Global1 not found", pRangeData);
     199             :     double aValue;
     200           1 :     pDoc->GetValue(1,0,0,aValue);
     201           1 :     CPPUNIT_ASSERT_MESSAGE("range name Global1 should reference Sheet1.A1", aValue == 1);
     202           1 :     pRangeData = pDoc->GetRangeName(0)->findByUpperName(OUString("LOCAL1"));
     203           1 :     CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 not found", pRangeData);
     204           1 :     pDoc->GetValue(1,2,0,aValue);
     205           1 :     CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 should reference Sheet1.A3", aValue == 3);
     206           1 :     pRangeData = pDoc->GetRangeName(1)->findByUpperName(OUString("LOCAL2"));
     207           1 :     CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 not found", pRangeData);
     208             :     //check for correct results for the remaining formulas
     209           1 :     pDoc->GetValue(1,1,0, aValue);
     210           1 :     CPPUNIT_ASSERT_MESSAGE("=global2 should be 2", aValue == 2);
     211           1 :     pDoc->GetValue(1,3,0, aValue);
     212           1 :     CPPUNIT_ASSERT_MESSAGE("=local2 should be 4", aValue == 4);
     213           1 :     pDoc->GetValue(2,0,0, aValue);
     214           1 :     CPPUNIT_ASSERT_MESSAGE("=SUM(global3) should be 10", aValue == 10);
     215           1 : }
     216             : 
     217             : }
     218             : 
     219           1 : void ScFiltersTest::testRangeNameODS()
     220             : {
     221           1 :     ScDocShellRef xDocSh = loadDoc("named-ranges-global.", ODS);
     222             : 
     223           1 :     CPPUNIT_ASSERT_MESSAGE("Failed to load named-ranges-globals.*", xDocSh.Is());
     224             : 
     225           1 :     xDocSh->DoHardRecalc(true);
     226             : 
     227           1 :     ScDocument* pDoc = xDocSh->GetDocument();
     228           1 :     testRangeNameImpl(pDoc);
     229             : 
     230           2 :     OUString aSheet2CSV("rangeExp_Sheet2.");
     231           2 :     OUString aCSVPath;
     232           1 :     createCSVPath( aSheet2CSV, aCSVPath );
     233           1 :     testFile( aCSVPath, pDoc, 1);
     234           2 :     xDocSh->DoClose();
     235           1 : }
     236             : 
     237             : namespace {
     238             : 
     239           4 : void testContentImpl(ScDocument* pDoc, sal_Int32 nFormat ) //same code for ods, xls, xlsx
     240             : {
     241             :     double fValue;
     242             :     //check value import
     243           4 :     pDoc->GetValue(0,0,0,fValue);
     244           4 :     CPPUNIT_ASSERT_MESSAGE("value not imported correctly", fValue == 1);
     245           4 :     pDoc->GetValue(0,1,0,fValue);
     246           4 :     CPPUNIT_ASSERT_MESSAGE("value not imported correctly", fValue == 2);
     247           4 :     OUString aString = pDoc->GetString(1, 0, 0);
     248             : 
     249             :     //check string import
     250           4 :     CPPUNIT_ASSERT_MESSAGE("string imported not correctly", aString == OUString("String1"));
     251           4 :     aString = pDoc->GetString(1, 1, 0);
     252           4 :     CPPUNIT_ASSERT_MESSAGE("string not imported correctly", aString == OUString("String2"));
     253             : 
     254             :     //check basic formula import
     255             :     // in case of DIF it just contains values
     256           4 :     pDoc->GetValue(2,0,0,fValue);
     257           4 :     CPPUNIT_ASSERT_MESSAGE("=2*3", fValue == 6);
     258           4 :     pDoc->GetValue(2,1,0,fValue);
     259           4 :     CPPUNIT_ASSERT_MESSAGE("=2+3", fValue == 5);
     260           4 :     pDoc->GetValue(2,2,0,fValue);
     261           4 :     CPPUNIT_ASSERT_MESSAGE("=2-3", fValue == -1);
     262           4 :     pDoc->GetValue(2,3,0,fValue);
     263           4 :     CPPUNIT_ASSERT_MESSAGE("=C1+C2", fValue == 11);
     264             : 
     265             :     //check merged cells import
     266           4 :     if(nFormat != LOTUS123 && nFormat != DIF)
     267             :     {
     268           3 :         SCCOL nCol = 4;
     269           3 :         SCROW nRow = 1;
     270           3 :         pDoc->ExtendMerge(4, 1, nCol, nRow, 0, false);
     271           3 :         CPPUNIT_ASSERT_MESSAGE("merged cells are not imported", nCol == 5 && nRow == 2);
     272             : 
     273             :         //check notes import
     274           3 :         ScAddress aAddress(7, 2, 0);
     275           3 :         ScPostIt* pNote = pDoc->GetNotes(aAddress.Tab())->findByAddress(aAddress);
     276           3 :         CPPUNIT_ASSERT_MESSAGE("note not imported", pNote);
     277           3 :         CPPUNIT_ASSERT_EQUAL_MESSAGE("note text not imported correctly", pNote->GetText(), OUString("Test"));
     278           4 :     }
     279             : 
     280             :     //add additional checks here
     281           4 : }
     282             : 
     283             : }
     284             : 
     285           1 : void ScFiltersTest::testContentODS()
     286             : {
     287           1 :     ScDocShellRef xDocSh = loadDoc("universal-content.", ODS);
     288           1 :     xDocSh->DoHardRecalc(true);
     289             : 
     290           1 :     ScDocument* pDoc = xDocSh->GetDocument();
     291           1 :     testContentImpl(pDoc, ODS);
     292           1 :     xDocSh->DoClose();
     293           1 : }
     294             : 
     295           1 : void ScFiltersTest::testContentXLS()
     296             : {
     297           1 :     ScDocShellRef xDocSh = loadDoc("universal-content.", XLS);
     298           1 :     xDocSh->DoHardRecalc(true);
     299             : 
     300           1 :     ScDocument* pDoc = xDocSh->GetDocument();
     301           1 :     testContentImpl(pDoc, XLS);
     302           1 :     xDocSh->DoClose();
     303           1 : }
     304             : 
     305           1 : void ScFiltersTest::testContentXLSX()
     306             : {
     307           1 :     ScDocShellRef xDocSh = loadDoc("universal-content.", XLSX);
     308           1 :     xDocSh->DoHardRecalc(true);
     309             : 
     310           1 :     ScDocument* pDoc = xDocSh->GetDocument();
     311           1 :     testContentImpl(pDoc, XLSX);
     312           1 :     xDocSh->DoClose();
     313           1 : }
     314             : 
     315           1 : void ScFiltersTest::testContentLotus123()
     316             : {
     317           1 :     ScDocShellRef xDocSh = loadDoc("universal-content.", LOTUS123);
     318           1 :     xDocSh->DoHardRecalc(true);
     319             : 
     320           1 :     ScDocument* pDoc = xDocSh->GetDocument();
     321           1 :     CPPUNIT_ASSERT(pDoc);
     322           1 :     testContentImpl(pDoc, LOTUS123);
     323           1 :     xDocSh->DoClose();
     324           1 : }
     325             : 
     326           1 : void ScFiltersTest::testContentDIF()
     327             : {
     328           1 :     ScDocShellRef xDocSh = loadDoc("universal-content.", DIF);
     329             : 
     330           1 :     ScDocument* pDoc = xDocSh->GetDocument();
     331           1 :     CPPUNIT_ASSERT(pDoc);
     332           1 :     xDocSh->DoClose();
     333           1 : }
     334             : 
     335           1 : void ScFiltersTest::testSharedFormulaXLS()
     336             : {
     337           1 :     ScDocShellRef xDocSh = loadDoc("shared-formula.", XLS);
     338           1 :     ScDocument* pDoc = xDocSh->GetDocument();
     339           1 :     CPPUNIT_ASSERT(pDoc);
     340           1 :     xDocSh->DoHardRecalc(true);
     341             :     // Check the results of formula cells in the shared formula range.
     342          19 :     for (SCROW i = 1; i <= 18; ++i)
     343             :     {
     344          18 :         double fVal = pDoc->GetValue(ScAddress(1,i,0));
     345          18 :         double fCheck = i*10.0;
     346          18 :         CPPUNIT_ASSERT_EQUAL(fCheck, fVal);
     347             :     }
     348           1 :     xDocSh->DoClose();
     349           1 : }
     350             : 
     351           1 : void ScFiltersTest::testSharedFormulaXLSX()
     352             : {
     353           1 :     ScDocShellRef xDocSh = loadDoc("shared-formula.", XLSX);
     354           1 :     ScDocument* pDoc = xDocSh->GetDocument();
     355           1 :     CPPUNIT_ASSERT(pDoc);
     356           1 :     xDocSh->DoHardRecalc(true);
     357             :     // Check the results of formula cells in the shared formula range.
     358          19 :     for (SCROW i = 1; i <= 18; ++i)
     359             :     {
     360          18 :         double fVal = pDoc->GetValue(ScAddress(1,i,0));
     361          18 :         double fCheck = i*10.0;
     362          18 :         CPPUNIT_ASSERT_EQUAL(fCheck, fVal);
     363             :     }
     364           1 :     xDocSh->DoClose();
     365           1 : }
     366             : 
     367           5 : void impl_testLegacyCellAnchoredRotatedShape( ScDocument* pDoc, Rectangle& aRect, ScDrawObjData& aAnchor, long TOLERANCE = 30 /* 30 hmm */ )
     368             : {
     369           5 :     ScDrawLayer* pDrawLayer = pDoc->GetDrawLayer();
     370           5 :     CPPUNIT_ASSERT_MESSAGE("No drawing layer.", pDrawLayer);
     371           5 :     SdrPage* pPage = pDrawLayer->GetPage(0);
     372           5 :     CPPUNIT_ASSERT_MESSAGE("No page instance for the 1st sheet.", pPage);
     373           5 :     CPPUNIT_ASSERT_EQUAL( sal_uIntPtr(1), pPage->GetObjCount() );
     374             : 
     375           5 :     SdrObject* pObj = pPage->GetObj(0);
     376           5 :     const Rectangle& aSnap = pObj->GetSnapRect();
     377           5 :     printf("expected height %ld actual %ld\n", aRect.GetHeight(), aSnap.GetHeight() );
     378           5 :     CPPUNIT_ASSERT_EQUAL( true, testEqualsWithTolerance( aRect.GetHeight(), aSnap.GetHeight(), TOLERANCE ) );
     379           5 :     printf("expected width %ld actual %ld\n", aRect.GetWidth(), aSnap.GetWidth() );
     380           5 :     CPPUNIT_ASSERT_EQUAL( true, testEqualsWithTolerance( aRect.GetWidth(), aSnap.GetWidth(), TOLERANCE ) );
     381           5 :     printf("expected left %ld actual %ld\n", aRect.Left(), aSnap.Left() );
     382           5 :     CPPUNIT_ASSERT_EQUAL( true, testEqualsWithTolerance( aRect.Left(), aSnap.Left(), TOLERANCE ) );
     383           5 :     printf("expected right %ld actual %ld\n", aRect.Top(), aSnap.Top() );
     384           5 :     CPPUNIT_ASSERT_EQUAL( true, testEqualsWithTolerance( aRect.Top(), aSnap.Top(), TOLERANCE ) );
     385             : 
     386             : 
     387           5 :     ScDrawObjData* pData = ScDrawLayer::GetObjData( pObj );
     388           5 :     printf("expected startrow %" SAL_PRIdINT32 " actual %" SAL_PRIdINT32 "\n", aAnchor.maStart.Row(), pData->maStart.Row()  );
     389           5 :     CPPUNIT_ASSERT_EQUAL( aAnchor.maStart.Row(), pData->maStart.Row() );
     390           5 :     printf("expected startcol %d actual %d\n", aAnchor.maStart.Col(), pData->maStart.Col()  );
     391           5 :     CPPUNIT_ASSERT_EQUAL( aAnchor.maStart.Col(), pData->maStart.Col() );
     392           5 :     printf("expected endrow %" SAL_PRIdINT32 " actual %" SAL_PRIdINT32 "\n", aAnchor.maEnd.Row(), pData->maEnd.Row()  );
     393           5 :     CPPUNIT_ASSERT_EQUAL( aAnchor.maEnd.Row(), pData->maEnd.Row() );
     394           5 :     printf("expected endcol %d actual %d\n", aAnchor.maEnd.Col(), pData->maEnd.Col()  );
     395           5 :     CPPUNIT_ASSERT_EQUAL( aAnchor.maEnd.Col(), pData->maEnd.Col() );
     396           5 : }
     397             : 
     398           1 : void ScFiltersTest::testLegacyCellAnchoredRotatedShape()
     399             : {
     400             :     {
     401             :         // This example doc contains cell anchored shape that is rotated, the
     402             :         // rotated shape is in fact cliped by the sheet boundries ( and thus
     403             :         // is a good edge case test to see if we import it still correctly )
     404           1 :         ScDocShellRef xDocSh = loadDoc("legacycellanchoredrotatedclippedshape.", ODS);
     405             : 
     406           1 :         ScDocument* pDoc = xDocSh->GetDocument();
     407           1 :         CPPUNIT_ASSERT(pDoc);
     408             :         // ensure the imported legacy rotated shape is in the expected position
     409           1 :         Rectangle aRect( 6000, -2000, 8000, 4000 );
     410             :         // ensure the imported ( and converted ) anchor ( note we internally now store the anchor in
     411             :         // terms of the rotated shape ) is more or less contains the correct info
     412           2 :         ScDrawObjData aAnchor;
     413           1 :         aAnchor.maStart.SetRow( 0 );
     414           1 :         aAnchor.maStart.SetCol( 5 );
     415           1 :         aAnchor.maEnd.SetRow( 3 );
     416           1 :         aAnchor.maEnd.SetCol( 7 );
     417           1 :         impl_testLegacyCellAnchoredRotatedShape( pDoc, aRect, aAnchor );
     418             :         // test save and reload
     419             :         // for some reason having this test in subsequent_export-test.cxx causes
     420             :         // a core dump in editeng ( so moved to here )
     421           1 :         xDocSh = saveAndReload( &(*xDocSh), ODS);
     422           1 :         pDoc = xDocSh->GetDocument();
     423           1 :         CPPUNIT_ASSERT(pDoc);
     424           2 :         impl_testLegacyCellAnchoredRotatedShape( pDoc, aRect, aAnchor );
     425             :     }
     426             :     {
     427             :         // This example doc contains cell anchored shape that is rotated, the
     428             :         // rotated shape is in fact clipped by the sheet boundries, additionally
     429             :         // the shape is completely hidden because the rows the shape occupies
     430             :         // are hidden
     431           1 :         ScDocShellRef xDocSh = loadDoc("legacycellanchoredrotatedhiddenshape.", ODS, true);
     432           1 :         ScDocument* pDoc = xDocSh->GetDocument();
     433           1 :         CPPUNIT_ASSERT(pDoc);
     434             :         // ensure the imported legacy rotated shape is in the expected position
     435             :         // when a shape is fully hidden reloading seems to result is in some errors, usually
     436             :         // ( same but different error happens pre-patch ) - we should do better here, I regard it
     437             :         // as a pre-existing bug though ( #FIXME )
     438             :         //Rectangle aRect( 6000, -2000, 8000, 4000 ); // proper dimensions
     439           1 :         Rectangle aRect( 6000, -2000, 7430, 4000 );
     440             :         // ensure the imported ( and converted ) anchor ( note we internally now store the anchor in
     441             :         // terms of the rotated shape ) is more or less contains the correct info
     442           2 :         ScDrawObjData aAnchor;
     443           1 :         aAnchor.maStart.SetRow( 0 );
     444           1 :         aAnchor.maStart.SetCol( 5 );
     445           1 :         aAnchor.maEnd.SetRow( 3 );
     446           1 :         aAnchor.maEnd.SetCol( 7 );
     447           1 :         pDoc->ShowRows(0, 9, 0, true); // show relavent rows
     448           1 :         pDoc->SetDrawPageSize(0); // trigger recalcpos
     449             : 
     450             :         // apply hefty ( 1 mm ) tolerence here, as some opensuse tinderbox
     451             :         // failing
     452           1 :         impl_testLegacyCellAnchoredRotatedShape( pDoc, aRect, aAnchor, 100 );
     453           2 :         xDocSh->DoClose();
     454             :     }
     455             :     {
     456             :         // This example doc contains cell anchored shape that is rotated
     457           1 :         ScDocShellRef xDocSh = loadDoc("legacycellanchoredrotatedshape.", ODS);
     458             : 
     459           1 :         ScDocument* pDoc = xDocSh->GetDocument();
     460           1 :         CPPUNIT_ASSERT(pDoc);
     461             :         // ensure the imported legacy rotated shape is in the expected position
     462           1 :         Rectangle aRect( 6000, 3000, 8000, 9000 );
     463             :         // ensure the imported ( and converted ) anchor ( note we internally now store the anchor in
     464             :         // terms of the rotated shape ) is more or less contains the correct info
     465             : 
     466           2 :         ScDrawObjData aAnchor;
     467           1 :         aAnchor.maStart.SetRow( 3 );
     468           1 :         aAnchor.maStart.SetCol( 6 );
     469           1 :         aAnchor.maEnd.SetRow( 9 );
     470           1 :         aAnchor.maEnd.SetCol( 7 );
     471             :         // test import
     472           1 :         impl_testLegacyCellAnchoredRotatedShape( pDoc, aRect, aAnchor );
     473             :         // test save and reload
     474           1 :         xDocSh = saveAndReload( &(*xDocSh), ODS);
     475           1 :         pDoc = xDocSh->GetDocument();
     476           1 :         CPPUNIT_ASSERT(pDoc);
     477           2 :         impl_testLegacyCellAnchoredRotatedShape( pDoc, aRect, aAnchor );
     478             :     }
     479           1 : }
     480             : 
     481          10 : ScFiltersTest::ScFiltersTest()
     482          10 :       : ScBootstrapFixture( "/sc/qa/unit/data" )
     483             : {
     484          10 : }
     485             : 
     486          10 : void ScFiltersTest::setUp()
     487             : {
     488          10 :     test::BootstrapFixture::setUp();
     489             : 
     490             :     // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
     491             :     // which is a private symbol to us, gets called
     492          20 :     m_xCalcComponent =
     493          30 :         getMultiServiceFactory()->createInstance("com.sun.star.comp.Calc.SpreadsheetDocument");
     494          10 :     CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xCalcComponent.is());
     495          10 : }
     496             : 
     497          10 : void ScFiltersTest::tearDown()
     498             : {
     499          10 :     uno::Reference< lang::XComponent >( m_xCalcComponent, UNO_QUERY_THROW )->dispose();
     500          10 :     test::BootstrapFixture::tearDown();
     501          10 : }
     502             : 
     503           1 : CPPUNIT_TEST_SUITE_REGISTRATION(ScFiltersTest);
     504             : 
     505           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     506             : 
     507             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10