LCOV - code coverage report
Current view: top level - sw/qa/extras/odfimport - odfimport.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 363 365 99.5 %
Date: 2014-11-03 Functions: 190 215 88.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * This file is part of the LibreOffice project.
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  */
       8             : 
       9             : #include <swmodeltestbase.hxx>
      10             : 
      11             : #if !defined(WNT)
      12             : 
      13             : #include <com/sun/star/awt/FontWeight.hpp>
      14             : #include <com/sun/star/style/PageStyleLayout.hpp>
      15             : #include <com/sun/star/table/XCell.hpp>
      16             : #include <com/sun/star/table/BorderLine.hpp>
      17             : #include <com/sun/star/text/XTextSection.hpp>
      18             : #include <com/sun/star/text/XTextTable.hpp>
      19             : 
      20             : #include <wrtsh.hxx>
      21             : #include <ndtxt.hxx>
      22             : #include <swdtflvr.hxx>
      23             : #include <view.hxx>
      24             : #include <edtwin.hxx>
      25             : #include <olmenu.hxx>
      26             : #include <cmdid.h>
      27             : 
      28             : typedef std::map<OUString, com::sun::star::uno::Sequence< com::sun::star::table::BorderLine> > AllBordersMap;
      29             : typedef std::pair<OUString, com::sun::star::uno::Sequence< com::sun::star::table::BorderLine> > StringSequencePair;
      30             : 
      31          46 : class Test : public SwModelTestBase
      32             : {
      33             :     public:
      34          46 :         Test() : SwModelTestBase("/sw/qa/extras/odfimport/data/", "writer8") {}
      35             : };
      36             : 
      37          18 : DECLARE_ODFIMPORT_TEST(testEmptySvgFamilyName, "empty-svg-family-name.odt")
      38             : {
      39             :     // .odt import did crash on the empty font list (which I think is valid according SVG spec)
      40           2 : }
      41             : 
      42          18 : DECLARE_ODFIMPORT_TEST(testHideAllSections, "fdo53210.odt")
      43             : {
      44             :     // This document has a section that is conditionally hidden, but has no empty paragraph after it.
      45           2 :     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
      46           4 :     uno::Reference<container::XNameAccess> xMasters = xTextFieldsSupplier->getTextFieldMasters();
      47             :     // Set _CS_Allgemein to 0
      48           4 :     uno::Reference<beans::XPropertySet> xMaster(xMasters->getByName("com.sun.star.text.fieldmaster.User._CS_Allgemein"), uno::UNO_QUERY);
      49           2 :     xMaster->setPropertyValue("Content", uno::makeAny(OUString("0")));
      50             :     // This used to crash
      51           4 :     uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh();
      52           2 : }
      53             : 
      54          18 : DECLARE_ODFIMPORT_TEST(testOdtBorders, "borders_ooo33.odt")
      55             : {
      56           2 :     AllBordersMap map;
      57           4 :     uno::Sequence< table::BorderLine > tempSequence(4);
      58             : 
      59           2 :     tempSequence[0] = table::BorderLine(0, 2, 2, 35);   // left
      60           2 :     tempSequence[1] = table::BorderLine(0, 2, 2, 35);   // right
      61           2 :     tempSequence[2] = table::BorderLine(0, 2, 2, 35);   // top
      62           2 :     tempSequence[3] = table::BorderLine(0, 2, 2, 35);   // bottom
      63           2 :     map.insert(StringSequencePair(OUString("B2"), tempSequence));
      64           2 :     tempSequence[0] = table::BorderLine(0, 0, 2, 0);
      65           2 :     tempSequence[1] = table::BorderLine(0, 0, 2, 0);
      66           2 :     tempSequence[2] = table::BorderLine(0, 0, 2, 0);
      67           2 :     tempSequence[3] = table::BorderLine(0, 0, 2, 0);
      68           2 :     map.insert(StringSequencePair(OUString("D2"), tempSequence));
      69           2 :     tempSequence[0] = table::BorderLine(0, 2, 2, 88);
      70           2 :     tempSequence[1] = table::BorderLine(0, 2, 2, 88);
      71           2 :     tempSequence[2] = table::BorderLine(0, 2, 2, 88);
      72           2 :     tempSequence[3] = table::BorderLine(0, 2, 2, 88);
      73           2 :     map.insert(StringSequencePair(OUString("B4"), tempSequence));
      74           2 :     tempSequence[0] = table::BorderLine(0, 0, 18, 0);
      75           2 :     tempSequence[1] = table::BorderLine(0, 0, 18, 0);
      76           2 :     tempSequence[2] = table::BorderLine(0, 0, 18, 0);
      77           2 :     tempSequence[3] = table::BorderLine(0, 0, 18, 0);
      78           2 :     map.insert(StringSequencePair(OUString("D4"), tempSequence));
      79           2 :     tempSequence[0] = table::BorderLine(0, 35, 35, 35);
      80           2 :     tempSequence[1] = table::BorderLine(0, 35, 35, 35);
      81           2 :     tempSequence[2] = table::BorderLine(0, 35, 35, 35);
      82           2 :     tempSequence[3] = table::BorderLine(0, 35, 35, 35);
      83           2 :     map.insert(StringSequencePair(OUString("B6"), tempSequence));
      84           2 :     tempSequence[0] = table::BorderLine(0, 0, 35, 0);
      85           2 :     tempSequence[1] = table::BorderLine(0, 0, 35, 0);
      86           2 :     tempSequence[2] = table::BorderLine(0, 0, 35, 0);
      87           2 :     tempSequence[3] = table::BorderLine(0, 0, 35, 0);
      88           2 :     map.insert(StringSequencePair(OUString("D6"), tempSequence));
      89           2 :     tempSequence[0] = table::BorderLine(0, 88, 88, 88);
      90           2 :     tempSequence[1] = table::BorderLine(0, 88, 88, 88);
      91           2 :     tempSequence[2] = table::BorderLine(0, 88, 88, 88);
      92           2 :     tempSequence[3] = table::BorderLine(0, 88, 88, 88);
      93           2 :     map.insert(StringSequencePair(OUString("B8"), tempSequence));
      94           2 :     tempSequence[0] = table::BorderLine(0, 0, 88, 0);
      95           2 :     tempSequence[1] = table::BorderLine(0, 0, 88, 0);
      96           2 :     tempSequence[2] = table::BorderLine(0, 0, 88, 0);
      97           2 :     tempSequence[3] = table::BorderLine(0, 0, 88, 0);
      98           2 :     map.insert(StringSequencePair(OUString("D8"), tempSequence));
      99           2 :     tempSequence[0] = table::BorderLine(0, 2, 35, 88);
     100           2 :     tempSequence[1] = table::BorderLine(0, 2, 35, 88);
     101           2 :     tempSequence[2] = table::BorderLine(0, 2, 35, 88);
     102           2 :     tempSequence[3] = table::BorderLine(0, 2, 35, 88);
     103           2 :     map.insert(StringSequencePair(OUString("B10"), tempSequence));
     104           2 :     tempSequence[0] = table::BorderLine(0, 0, 141, 0);
     105           2 :     tempSequence[1] = table::BorderLine(0, 0, 141, 0);
     106           2 :     tempSequence[2] = table::BorderLine(0, 0, 141, 0);
     107           2 :     tempSequence[3] = table::BorderLine(0, 0, 141, 0);
     108           2 :     map.insert(StringSequencePair(OUString("D10"), tempSequence));
     109           2 :     tempSequence[0] = table::BorderLine(0, 2, 88, 88);
     110           2 :     tempSequence[1] = table::BorderLine(0, 2, 88, 88);
     111           2 :     tempSequence[2] = table::BorderLine(0, 2, 88, 88);
     112           2 :     tempSequence[3] = table::BorderLine(0, 2, 88, 88);
     113           2 :     map.insert(StringSequencePair(OUString("B12"), tempSequence));
     114           2 :     tempSequence[0] = table::BorderLine(0, 0, 176, 0);
     115           2 :     tempSequence[1] = table::BorderLine(0, 0, 176, 0);
     116           2 :     tempSequence[2] = table::BorderLine(0, 0, 176, 0);
     117           2 :     tempSequence[3] = table::BorderLine(0, 0, 176, 0);
     118           2 :     map.insert(StringSequencePair(OUString("D12"), tempSequence));
     119           2 :     tempSequence[0] = table::BorderLine(0, 2, 141, 88);
     120           2 :     tempSequence[1] = table::BorderLine(0, 2, 141, 88);
     121           2 :     tempSequence[2] = table::BorderLine(0, 2, 141, 88);
     122           2 :     tempSequence[3] = table::BorderLine(0, 2, 141, 88);
     123           2 :     map.insert(StringSequencePair(OUString("B14"), tempSequence));
     124           2 :     tempSequence[0] = table::BorderLine(0, 35, 88, 88);
     125           2 :     tempSequence[1] = table::BorderLine(0, 35, 88, 88);
     126           2 :     tempSequence[2] = table::BorderLine(0, 35, 88, 88);
     127           2 :     tempSequence[3] = table::BorderLine(0, 35, 88, 88);
     128           2 :     map.insert(StringSequencePair(OUString("B16"), tempSequence));
     129           2 :     tempSequence[0] = table::BorderLine(0, 88, 35, 35);
     130           2 :     tempSequence[1] = table::BorderLine(0, 88, 35, 35);
     131           2 :     tempSequence[2] = table::BorderLine(0, 88, 35, 35);
     132           2 :     tempSequence[3] = table::BorderLine(0, 88, 35, 35);
     133           2 :     map.insert(StringSequencePair(OUString("B18"), tempSequence));
     134           2 :     tempSequence[0] = table::BorderLine(0, 88, 141, 88);
     135           2 :     tempSequence[1] = table::BorderLine(0, 88, 141, 88);
     136           2 :     tempSequence[2] = table::BorderLine(0, 88, 141, 88);
     137           2 :     tempSequence[3] = table::BorderLine(0, 88, 141, 88);
     138           2 :     map.insert(StringSequencePair(OUString("B20"), tempSequence));
     139           2 :     tempSequence[0] = table::BorderLine(0, 141, 88, 88);
     140           2 :     tempSequence[1] = table::BorderLine(0, 141, 88, 88);
     141           2 :     tempSequence[2] = table::BorderLine(0, 141, 88, 88);
     142           2 :     tempSequence[3] = table::BorderLine(0, 141, 88, 88);
     143           2 :     map.insert(StringSequencePair(OUString("B22"), tempSequence));
     144             : 
     145           4 :     uno::Reference<text::XTextDocument> textDocument(mxComponent, uno::UNO_QUERY);
     146           4 :     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(textDocument->getText(), uno::UNO_QUERY);
     147             :     // list of paragraphs
     148           4 :     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
     149           4 :     do
     150             :     {
     151           4 :         uno::Reference<lang::XServiceInfo> xServiceInfo;
     152           4 :         if (xParaEnum->nextElement() >>= xServiceInfo)
     153             :         {
     154           4 :             if (xServiceInfo->supportsService("com.sun.star.text.TextTable"))
     155             :             {
     156           2 :                 uno::Reference<text::XTextTable> const xTextTable(xServiceInfo, uno::UNO_QUERY_THROW);
     157           4 :                 uno::Sequence<OUString> const cells = xTextTable->getCellNames();
     158           2 :                 sal_Int32 nLength = cells.getLength();
     159             : 
     160           2 :                 AllBordersMap::iterator it;
     161           2 :                 it = map.begin();
     162             : 
     163         232 :                 for (sal_Int32 i = 0; i < nLength; ++i)
     164             :                 {
     165         230 :                     if(i%10==6 || (i%10==8 && i<60))    // only B and D cells have borders, every 2 rows
     166             :                     {
     167          34 :                         uno::Reference<table::XCell> xCell = xTextTable->getCellByName(cells[i]);
     168          68 :                         uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW);
     169          34 :                         it = map.find(cells[i]);
     170             : 
     171          68 :                         uno::Any aLeftBorder = xPropSet->getPropertyValue("LeftBorder");
     172          34 :                         table::BorderLine aLeftBorderLine;
     173          34 :                         if (aLeftBorder >>= aLeftBorderLine)
     174             :                         {
     175          34 :                             sal_Int32 innerLineWidth = aLeftBorderLine.InnerLineWidth;
     176          34 :                             sal_Int32 outerLineWidth = aLeftBorderLine.OuterLineWidth;
     177          34 :                             sal_Int32 lineDistance = aLeftBorderLine.LineDistance;
     178             : 
     179          34 :                             sal_Int32 perfectInner = it->second[0].InnerLineWidth;
     180          34 :                             sal_Int32 perfectOuter = it->second[0].OuterLineWidth;
     181          34 :                             sal_Int32 perfectDistance = it->second[0].LineDistance;
     182          34 :                             CPPUNIT_ASSERT_EQUAL(perfectInner, innerLineWidth);
     183          34 :                             CPPUNIT_ASSERT_EQUAL(perfectOuter, outerLineWidth);
     184          34 :                             CPPUNIT_ASSERT_EQUAL(perfectDistance, lineDistance);
     185             :                         }
     186             : 
     187          68 :                         uno::Any aRightBorder = xPropSet->getPropertyValue("RightBorder");
     188          34 :                         table::BorderLine aRightBorderLine;
     189          34 :                         if (aRightBorder >>= aRightBorderLine)
     190             :                         {
     191          34 :                             sal_Int32 innerLineWidth = aRightBorderLine.InnerLineWidth;
     192          34 :                             sal_Int32 outerLineWidth = aRightBorderLine.OuterLineWidth;
     193          34 :                             sal_Int32 lineDistance = aRightBorderLine.LineDistance;
     194             : 
     195          34 :                             sal_Int32 perfectInner = it->second[1].InnerLineWidth;
     196          34 :                             sal_Int32 perfectOuter = it->second[1].OuterLineWidth;
     197          34 :                             sal_Int32 perfectDistance = it->second[1].LineDistance;
     198          34 :                             CPPUNIT_ASSERT_EQUAL(perfectInner, innerLineWidth);
     199          34 :                             CPPUNIT_ASSERT_EQUAL(perfectOuter, outerLineWidth);
     200          34 :                             CPPUNIT_ASSERT_EQUAL(perfectDistance, lineDistance);
     201             :                         }
     202             : 
     203          68 :                         uno::Any aTopBorder = xPropSet->getPropertyValue("TopBorder");
     204          34 :                         table::BorderLine aTopBorderLine;
     205          34 :                         if (aTopBorder >>= aTopBorderLine)
     206             :                         {
     207          34 :                             sal_Int32 innerLineWidth = aTopBorderLine.InnerLineWidth;
     208          34 :                             sal_Int32 outerLineWidth = aTopBorderLine.OuterLineWidth;
     209          34 :                             sal_Int32 lineDistance = aTopBorderLine.LineDistance;
     210             : 
     211          34 :                             sal_Int32 perfectInner = it->second[2].InnerLineWidth;
     212          34 :                             sal_Int32 perfectOuter = it->second[2].OuterLineWidth;
     213          34 :                             sal_Int32 perfectDistance = it->second[2].LineDistance;
     214          34 :                             CPPUNIT_ASSERT_EQUAL(perfectInner, innerLineWidth);
     215          34 :                             CPPUNIT_ASSERT_EQUAL(perfectOuter, outerLineWidth);
     216          34 :                             CPPUNIT_ASSERT_EQUAL(perfectDistance, lineDistance);
     217             :                         }
     218             : 
     219          68 :                         uno::Any aBottomBorder = xPropSet->getPropertyValue("BottomBorder");
     220          34 :                         table::BorderLine aBottomBorderLine;
     221          34 :                         if (aBottomBorder >>= aBottomBorderLine)
     222             :                         {
     223          34 :                             sal_Int32 innerLineWidth = aBottomBorderLine.InnerLineWidth;
     224          34 :                             sal_Int32 outerLineWidth = aBottomBorderLine.OuterLineWidth;
     225          34 :                             sal_Int32 lineDistance = aBottomBorderLine.LineDistance;
     226             : 
     227          34 :                             sal_Int32 perfectInner = it->second[3].InnerLineWidth;
     228          34 :                             sal_Int32 perfectOuter = it->second[3].OuterLineWidth;
     229          34 :                             sal_Int32 perfectDistance = it->second[3].LineDistance;
     230          34 :                             CPPUNIT_ASSERT_EQUAL(perfectInner, innerLineWidth);
     231          34 :                             CPPUNIT_ASSERT_EQUAL(perfectOuter, outerLineWidth);
     232          34 :                             CPPUNIT_ASSERT_EQUAL(perfectDistance, lineDistance);
     233          34 :                         }
     234             :                     }
     235           2 :                 }   //end of the 'for' loop
     236             :             }
     237           4 :         }
     238           6 :     } while(xParaEnum->hasMoreElements());
     239           2 : }
     240             : 
     241          18 : DECLARE_ODFIMPORT_TEST(testPageStyleLayoutDefault, "hello.odt")
     242             : {
     243           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Default Style"), uno::UNO_QUERY);
     244             :     // This was style::PageStyleLayout_MIRRORED.
     245           2 :     CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_ALL, getProperty<style::PageStyleLayout>(xPropertySet, "PageStyleLayout"));
     246           2 : }
     247             : 
     248          18 : DECLARE_ODFIMPORT_TEST(testPageStyleLayoutRight, "hello.odt")
     249             : {
     250           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("Default Style"), uno::UNO_QUERY);
     251             :     // This caused a crash.
     252           2 :     xPropertySet->setPropertyValue("PageStyleLayout", uno::makeAny(style::PageStyleLayout_RIGHT));
     253           2 : }
     254             : 
     255          18 : DECLARE_ODFIMPORT_TEST(testFdo61952, "hello.odt")
     256             : {
     257           2 :     uno::Reference<beans::XPropertySet> xPara(getParagraph(0), uno::UNO_QUERY);
     258           2 :     xPara->setPropertyValue("PageDescName", uno::makeAny(OUString("Left Page")));
     259           2 :     xPara->setPropertyValue("PageDescName", uno::makeAny(OUString("Right Page")));
     260           2 :     xPara->setPropertyValue("PageDescName", uno::makeAny(OUString("Left Page")));
     261           2 :     xPara->setPropertyValue("PageDescName", uno::makeAny(OUString("Right Page")));
     262           2 : }
     263             : 
     264          18 : DECLARE_ODFIMPORT_TEST(testFdo60842, "fdo60842.odt")
     265             : {
     266           2 :     uno::Reference<text::XTextContent> const xTable(getParagraphOrTable(0));
     267           2 :     getCell(xTable, "A1", "");
     268           2 :     getCell(xTable, "B1", "18/02/2012");
     269           2 :     getCell(xTable, "C1", "USD"); // this is the cell with office:string-value
     270           2 :     getCell(xTable, "D1", "");
     271           2 :     getCell(xTable, "E1", "01/04/2012");
     272           2 : }
     273             : 
     274          18 : DECLARE_ODFIMPORT_TEST(testFdo79269, "fdo79269.odt")
     275             : {
     276           2 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
     277           4 :     uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
     278           4 :     uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
     279           2 :     xCursor->jumpToLastPage();
     280           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
     281             : 
     282             :     // The problem was that the first-footer was shared.
     283           4 :     uno::Reference<beans::XPropertySet> xPropSet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
     284           2 :     CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPropSet, "FirstIsShared"));
     285             : 
     286           4 :     uno::Reference<text::XTextRange> xFooter1 = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "FooterTextFirst");
     287           2 :     CPPUNIT_ASSERT_EQUAL(OUString("forst"), xFooter1->getString());
     288           4 :     uno::Reference<text::XTextRange> xFooter = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "FooterText");
     289           4 :     CPPUNIT_ASSERT_EQUAL(OUString("second"), xFooter->getString());
     290           2 : }
     291             : 
     292          18 : DECLARE_ODFIMPORT_TEST(testFdo79269_header, "fdo79269_header.odt")
     293             : {
     294           2 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
     295           4 :     uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
     296           4 :     uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
     297           2 :     xCursor->jumpToLastPage();
     298           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
     299             : 
     300           4 :     uno::Reference<beans::XPropertySet> xPropSet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
     301           2 :     CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xPropSet, "FirstIsShared"));
     302             : 
     303           4 :     uno::Reference<text::XTextRange> xFooter1 = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "HeaderTextFirst");
     304           2 :     CPPUNIT_ASSERT_EQUAL(OUString("forst"), xFooter1->getString());
     305           4 :     uno::Reference<text::XTextRange> xFooter = getProperty< uno::Reference<text::XTextRange> >(xPropSet, "HeaderText");
     306           4 :     CPPUNIT_ASSERT_EQUAL(OUString("second"), xFooter->getString());
     307           2 : }
     308             : 
     309          18 : DECLARE_ODFIMPORT_TEST(testFdo56272, "fdo56272.odt")
     310             : {
     311           2 :     uno::Reference<drawing::XShape> xShape = getShape(1);
     312             :     // Vertical position was incorrect.
     313           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(422), xShape->getPosition().Y); // Was -2371
     314           2 : }
     315             : 
     316          18 : DECLARE_ODFIMPORT_TEST(testFdo75872_ooo33, "fdo75872_ooo33.odt")
     317             : {
     318             :     // graphics default style: line color and fill color changed
     319           2 :     uno::Reference<drawing::XShape> xShape = getShape(1);
     320           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_BLACK),
     321           2 :            getProperty<sal_Int32>(xShape, "LineColor"));
     322           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(RGB_COLORDATA(153, 204, 255)),
     323           4 :            getProperty<sal_Int32>(xShape, "FillColor"));
     324           2 : }
     325             : 
     326          18 : DECLARE_ODFIMPORT_TEST(testFdo75872_aoo40, "fdo75872_aoo40.odt")
     327             : {
     328             :     // graphics default style: line color and fill color changed
     329           2 :     uno::Reference<drawing::XShape> xShape = getShape(1);
     330           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(RGB_COLORDATA(128, 128, 128)),
     331           2 :            getProperty<sal_Int32>(xShape, "LineColor"));
     332           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(RGB_COLORDATA(0xCF, 0xE7, 0xF5)),
     333           4 :            getProperty<sal_Int32>(xShape, "FillColor"));
     334           2 : }
     335             : 
     336          18 : DECLARE_ODFIMPORT_TEST(testFdo55814, "fdo55814.odt")
     337             : {
     338           2 :     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
     339           4 :     uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
     340           4 :     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
     341           4 :     uno::Reference<beans::XPropertySet> xField(xFields->nextElement(), uno::UNO_QUERY);
     342           2 :     xField->setPropertyValue("Content", uno::makeAny(OUString("Yes")));
     343           2 :     uno::Reference<util::XRefreshable>(xTextFieldsSupplier->getTextFields(), uno::UNO_QUERY)->refresh();
     344           4 :     uno::Reference<text::XTextSectionsSupplier> xTextSectionsSupplier(mxComponent, uno::UNO_QUERY);
     345           4 :     uno::Reference<container::XIndexAccess> xSections(xTextSectionsSupplier->getTextSections(), uno::UNO_QUERY);
     346             :     // This was "0".
     347           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Hide==\"Yes\""), getProperty<OUString>(xSections->getByIndex(0), "Condition"));
     348           2 : }
     349             : 
     350          10 : void lcl_CheckShape(
     351             :     uno::Reference<drawing::XShape> const& xShape, OUString const& rExpected)
     352             : {
     353          10 :     uno::Reference<container::XNamed> const xNamed(xShape, uno::UNO_QUERY);
     354          10 :     CPPUNIT_ASSERT(xNamed.is());
     355          10 :     CPPUNIT_ASSERT_EQUAL(rExpected, xNamed->getName());
     356          10 : }
     357             : 
     358          18 : DECLARE_ODFIMPORT_TEST(testFdo68839, "fdo68839.odt")
     359             : {
     360             :     // check names
     361           2 :     lcl_CheckShape(getShape(1), "FrameXXX");
     362           2 :     lcl_CheckShape(getShape(2), "ObjectXXX");
     363           2 :     lcl_CheckShape(getShape(3), "FrameY");
     364           2 :     lcl_CheckShape(getShape(4), "graphicsXXX");
     365             :     try {
     366           2 :         uno::Reference<drawing::XShape> xShape = getShape(5);
     367           0 :         CPPUNIT_FAIL("IndexOutOfBoundsException expected");
     368           2 :     } catch (lang::IndexOutOfBoundsException const&) { }
     369             :     // check prev/next chain
     370           2 :     uno::Reference<beans::XPropertySet> xFrame1(getShape(1), uno::UNO_QUERY);
     371           4 :     uno::Reference<beans::XPropertySet> xFrame2(getShape(3), uno::UNO_QUERY);
     372           4 :     CPPUNIT_ASSERT_EQUAL(OUString(),
     373           2 :             getProperty<OUString>(xFrame1, "ChainPrevName"));
     374           4 :     CPPUNIT_ASSERT_EQUAL(OUString("FrameY"),
     375           2 :             getProperty<OUString>(xFrame1, "ChainNextName"));
     376           4 :     CPPUNIT_ASSERT_EQUAL(OUString("FrameXXX"),
     377           2 :             getProperty<OUString>(xFrame2, "ChainPrevName"));
     378           4 :     CPPUNIT_ASSERT_EQUAL(OUString(),
     379           4 :             getProperty<OUString>(xFrame2, "ChainNextName"));
     380           2 : }
     381             : 
     382          18 : DECLARE_ODFIMPORT_TEST(testFdo82165, "fdo82165.odt")
     383             : {
     384             :     // there was a duplicate shape in the left header
     385           2 :     lcl_CheckShape(getShape(1), "Picture 9");
     386             :     try {
     387           2 :         uno::Reference<drawing::XShape> xShape = getShape(2);
     388           0 :         CPPUNIT_FAIL("IndexOutOfBoundsException expected");
     389           2 :     } catch (lang::IndexOutOfBoundsException const&) { }
     390           2 : }
     391             : 
     392          18 : DECLARE_ODFIMPORT_TEST(testFdo37606, "fdo37606.odt")
     393             : {
     394           2 :     SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
     395           2 :     CPPUNIT_ASSERT(pTxtDoc);
     396           2 :     SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
     397           2 :     SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
     398             : 
     399             :     {
     400           2 :         pWrtShell->SelAll();
     401           2 :         SwTxtNode& rStart = dynamic_cast<SwTxtNode&>(pShellCrsr->Start()->nNode.GetNode());
     402           2 :         CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetTxt());
     403             : 
     404           2 :         SwTxtNode& rEnd = dynamic_cast<SwTxtNode&>(pShellCrsr->End()->nNode.GetNode());
     405             :         // This was "A1", i.e. Ctrl-A only selected the A1 cell of the table, not the whole document.
     406           2 :         CPPUNIT_ASSERT_EQUAL(OUString("Hello."), rEnd.GetTxt());
     407             :     }
     408             : 
     409             :     {
     410           2 :         pWrtShell->SttEndDoc(false); // Go to the end of the doc.
     411           2 :         pWrtShell->SelAll(); // And now that we're outside of the table, try Ctrl-A again.
     412           2 :         SwTxtNode& rStart = dynamic_cast<SwTxtNode&>(pShellCrsr->Start()->nNode.GetNode());
     413             :         // This was "Hello", i.e. Ctrl-A did not select the starting table.
     414           2 :         CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetTxt());
     415             : 
     416           2 :         SwTxtNode& rEnd = dynamic_cast<SwTxtNode&>(pShellCrsr->End()->nNode.GetNode());
     417           2 :         CPPUNIT_ASSERT_EQUAL(OUString("Hello."), rEnd.GetTxt());
     418             :     }
     419             : 
     420             :     {
     421           2 :         pWrtShell->Delete(); // Delete the selection
     422             :         // And make sure the table got deleted as well.
     423           2 :         SwNodes& rNodes = pWrtShell->GetDoc()->GetNodes();
     424           2 :         SwNodeIndex nNode(rNodes.GetEndOfExtras());
     425           2 :         SwCntntNode* pCntntNode = rNodes.GoNext(&nNode);
     426             :         // First content node was in a table -> table wasn't deleted.
     427           2 :         CPPUNIT_ASSERT(!pCntntNode->FindTableNode());
     428             :     }
     429           2 : }
     430             : 
     431          18 : DECLARE_ODFIMPORT_TEST(testFdo37606Copy, "fdo37606.odt")
     432             : {
     433           2 :     SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
     434           2 :     CPPUNIT_ASSERT(pTxtDoc);
     435           2 :     SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
     436             :     // Ctrl-A
     437           2 :     pWrtShell->SelAll();
     438             : 
     439             :     // Ctrl-C
     440           2 :     SwTransferable* pTransferable = new SwTransferable(*pWrtShell);
     441           2 :     uno::Reference<datatransfer::XTransferable> xTransferable(pTransferable);
     442           2 :     pTransferable->Copy();
     443             : 
     444           2 :     pWrtShell->SttEndDoc(false); // Go to the end of the doc.
     445             : 
     446             :     // Ctrl-V
     447           4 :     TransferableDataHelper aDataHelper(TransferableDataHelper::CreateFromSystemClipboard(&pWrtShell->GetView().GetEditWin()));
     448           2 :     SwTransferable::Paste( *pWrtShell, aDataHelper );
     449             : 
     450             :     // Previously copy&paste failed to copy the table in case it was the document-starting one.
     451           4 :     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
     452           4 :     uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
     453             : #ifndef MACOSX // FIXME
     454           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
     455             : #endif
     456           2 : }
     457             : 
     458          18 : DECLARE_ODFIMPORT_TEST(testFdo69862, "fdo69862.odt")
     459             : {
     460             :     // The test doc is special in that it starts with a table and it also has a footnote.
     461           2 :     SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
     462           2 :     CPPUNIT_ASSERT(pTxtDoc);
     463           2 :     SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
     464           2 :     SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
     465             : 
     466           2 :     pWrtShell->SelAll();
     467           2 :     SwTxtNode& rStart = dynamic_cast<SwTxtNode&>(pShellCrsr->Start()->nNode.GetNode());
     468             :     // This was "Footnote.", as Ctrl-A also selected footnotes, but it should not.
     469           2 :     CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetTxt());
     470             : 
     471           2 :     SwTxtNode& rEnd = dynamic_cast<SwTxtNode&>(pShellCrsr->End()->nNode.GetNode());
     472           2 :     CPPUNIT_ASSERT_EQUAL(OUString("H" "\x01" "ello."), rEnd.GetTxt());
     473           2 : }
     474             : 
     475          18 : DECLARE_ODFIMPORT_TEST(testFdo69979, "fdo69979.odt")
     476             : {
     477             :     // The test doc is special in that it starts with a table and it also has a header.
     478           2 :     SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
     479           2 :     CPPUNIT_ASSERT(pTxtDoc);
     480           2 :     SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
     481           2 :     SwShellCrsr* pShellCrsr = pWrtShell->getShellCrsr(false);
     482             : 
     483           2 :     pWrtShell->SelAll();
     484           2 :     SwTxtNode& rStart = dynamic_cast<SwTxtNode&>(pShellCrsr->Start()->nNode.GetNode());
     485             :     // This was "", as Ctrl-A also selected headers, but it should not.
     486           2 :     CPPUNIT_ASSERT_EQUAL(OUString("A1"), rStart.GetTxt());
     487             : 
     488           2 :     SwTxtNode& rEnd = dynamic_cast<SwTxtNode&>(pShellCrsr->End()->nNode.GetNode());
     489           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Hello."), rEnd.GetTxt());
     490           2 : }
     491             : 
     492          18 : DECLARE_ODFIMPORT_TEST(testSpellmenuRedline, "spellmenu-redline.odt")
     493             : {
     494           2 :     SwXTextDocument* pTxtDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
     495           2 :     CPPUNIT_ASSERT(pTxtDoc);
     496           2 :     SwWrtShell* pWrtShell = pTxtDoc->GetDocShell()->GetWrtShell();
     497           2 :     OUString aParaText;
     498           4 :     uno::Reference<linguistic2::XSpellAlternatives> xAlt;
     499           4 :     SwSpellPopup aPopup(pWrtShell, xAlt, aParaText);
     500             :     // Make sure that if we show the spellcheck popup menu (for the current
     501             :     // document, which contains redlines), then the last two entries will be
     502             :     // always 'go to next/previous change'.
     503           2 :     CPPUNIT_ASSERT_EQUAL(sal_uInt16(FN_REDLINE_NEXT_CHANGE), aPopup.GetItemId(aPopup.GetItemCount() - 2));
     504           4 :     CPPUNIT_ASSERT_EQUAL(sal_uInt16(FN_REDLINE_PREV_CHANGE), aPopup.GetItemId(aPopup.GetItemCount() - 1));
     505           2 : }
     506             : 
     507          18 : DECLARE_ODFIMPORT_TEST(testAnnotationFormatting, "annotation-formatting.odt")
     508             : {
     509           2 :     uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 1), "TextField");
     510           4 :     uno::Reference<text::XText> xText = getProperty< uno::Reference<text::XText> >(xTextField, "TextRange");
     511             :     // Make sure we test the right annotation.
     512           4 :     uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText, "Looses: bold");
     513             :     // Formatting was lost: the second text portion was NORMAL, not BOLD.
     514           4 :     CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xParagraph, 2), "CharWeight"));
     515           2 : }
     516             : 
     517          18 : DECLARE_ODFIMPORT_TEST(fdo81223, "fdo81223.odt")
     518             : {
     519           2 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     520           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     521           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
     522           2 :     sal_Int32 nValue(0);
     523           2 :     xFrame->getPropertyValue("BackColor") >>= nValue;
     524           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xfeffffff), nValue);
     525           2 : }
     526             : 
     527          18 : DECLARE_ODFIMPORT_TEST(testBnc800714, "bnc800714.fodt")
     528             : {
     529             :     // Document's second paragraph wants to be together with the third one, but:
     530             :     // - it's in a section with multiple columns
     531             :     // - contains a single as-char anchored frame
     532             :     // This was a layout loop.
     533           2 :     CPPUNIT_ASSERT(getProperty< uno::Reference<text::XTextSection> >(getParagraph(2), "TextSection").is());
     534           2 :     CPPUNIT_ASSERT(getProperty<bool>(getParagraph(2), "ParaKeepTogether"));
     535           2 : }
     536             : 
     537             : #endif
     538             : 
     539           8 : CPPUNIT_PLUGIN_IMPLEMENT();
     540             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10