LCOV - code coverage report
Current view: top level - sw/qa/extras/rtfexport - rtfexport.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 548 549 99.8 %
Date: 2015-06-13 12:38:46 Functions: 1004 1089 92.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 <swmodeltestbase.hxx>
      11             : 
      12             : #include <com/sun/star/awt/Gradient.hpp>
      13             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      14             : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
      15             : #include <com/sun/star/drawing/FillStyle.hpp>
      16             : #include <com/sun/star/drawing/PointSequenceSequence.hpp>
      17             : #include <com/sun/star/frame/XStorable.hpp>
      18             : #include <com/sun/star/style/PageStyleLayout.hpp>
      19             : #include <com/sun/star/table/BorderLine2.hpp>
      20             : #include <com/sun/star/table/ShadowFormat.hpp>
      21             : #include <com/sun/star/text/FontEmphasis.hpp>
      22             : #include <com/sun/star/text/RelOrientation.hpp>
      23             : #include <com/sun/star/text/TableColumnSeparator.hpp>
      24             : #include <com/sun/star/text/TextContentAnchorType.hpp>
      25             : #include <com/sun/star/text/XFootnotesSupplier.hpp>
      26             : #include <com/sun/star/text/XPageCursor.hpp>
      27             : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
      28             : #include <com/sun/star/text/WritingMode2.hpp>
      29             : #include <com/sun/star/view/XViewSettingsSupplier.hpp>
      30             : 
      31             : #include <vcl/svapp.hxx>
      32             : 
      33         166 : class Test : public SwModelTestBase
      34             : {
      35             : public:
      36         166 :     Test() : SwModelTestBase("/sw/qa/extras/rtfexport/data/", "Rich Text Format") {}
      37             : 
      38          83 :     bool mustTestImportOf(const char* filename) const SAL_OVERRIDE
      39             :     {
      40             :         // Don't test the first import of these, for some reason those tests fail
      41             :         const char* aBlacklist[] =
      42             :         {
      43             :             "math-eqarray.rtf",
      44             :             "math-escaping.rtf",
      45             :             "math-lim.rtf",
      46             :             "math-mso2007.rtf",
      47             :             "math-nary.rtf",
      48             :             "math-rad.rtf",
      49             :             "math-vertical-stacks.rtf",
      50             :             "math-runs.rtf",
      51          83 :         };
      52          83 :         std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist));
      53             : 
      54             :         // If the testcase is stored in some other format, it's pointless to test.
      55          83 :         return (OString(filename).endsWith(".rtf") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end());
      56             :     }
      57             : 
      58          22 :     bool CjkNumberedListTestHelper(sal_Int16& rValue)
      59             :     {
      60          22 :         sal_Bool isNumber = false;
      61          22 :         uno::Reference<text::XTextRange> xPara(getParagraph(1));
      62          44 :         uno::Reference<beans::XPropertySet> properties(xPara, uno::UNO_QUERY);
      63          22 :         properties->getPropertyValue("NumberingIsNumber") >>= isNumber;
      64          22 :         if (!isNumber)
      65           0 :             return false;
      66          44 :         uno::Reference<container::XIndexAccess> xLevels(properties->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
      67          44 :         uno::Sequence< beans::PropertyValue > aPropertyValue;
      68          22 :         xLevels->getByIndex(0) >>= aPropertyValue;
      69         264 :         for (int j = 0; j < aPropertyValue.getLength(); ++j)
      70             :         {
      71         264 :             beans::PropertyValue aProp= aPropertyValue[j];
      72         264 :             if (aProp.Name == "NumberingType")
      73             :             {
      74          22 :                 rValue = aProp.Value.get<sal_Int16>();
      75          22 :                 return true;
      76             :             }
      77         242 :         }
      78          22 :         return false;
      79             : 
      80             :     }
      81             : 
      82          83 :     virtual void postLoad(const char* pFilename) SAL_OVERRIDE
      83             :     {
      84          83 :         if (OString(pFilename) == "tdf90421.fodt")
      85             :         {
      86             :             // Change the hyperlink, so its URL is empty.
      87           1 :             uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1), 2), uno::UNO_QUERY);
      88           1 :             xRun->setPropertyValue("HyperLinkURL", uno::makeAny(OUString()));
      89             :         }
      90          83 :     }
      91             : };
      92             : 
      93          17 : DECLARE_RTFEXPORT_TEST(testZoom, "zoom.rtf")
      94             : {
      95           2 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
      96           4 :     uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
      97           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings());
      98           2 :     sal_Int16 nValue = 0;
      99           2 :     xPropertySet->getPropertyValue("ZoomValue") >>= nValue;
     100           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue);
     101           2 : }
     102             : 
     103          17 : DECLARE_RTFEXPORT_TEST(testFdo38176, "fdo38176.rtf")
     104             : {
     105           2 :     CPPUNIT_ASSERT_EQUAL(9, getLength());
     106           2 : }
     107             : 
     108          17 : DECLARE_RTFEXPORT_TEST(testFdo49683, "fdo49683.rtf")
     109             : {
     110           2 :     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
     111           4 :     uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
     112           4 :     uno::Sequence<OUString> aKeywords(xDocumentProperties->getKeywords());
     113           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aKeywords.getLength());
     114           2 :     CPPUNIT_ASSERT_EQUAL(OUString("one"), aKeywords[0]);
     115           4 :     CPPUNIT_ASSERT_EQUAL(OUString("two"), aKeywords[1]);
     116           2 : }
     117             : 
     118          17 : DECLARE_RTFEXPORT_TEST(testFdo44174, "fdo44174.rtf")
     119             : {
     120           2 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
     121           4 :     uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
     122           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
     123           4 :     OUString aValue;
     124           2 :     xPropertySet->getPropertyValue("PageStyleName") >>= aValue;
     125           4 :     CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aValue);
     126           2 : }
     127             : 
     128          17 : DECLARE_RTFEXPORT_TEST(testFdo50087, "fdo50087.rtf")
     129             : {
     130           2 :     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
     131           4 :     uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
     132           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Title"), xDocumentProperties->getTitle());
     133           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Subject"), xDocumentProperties->getSubject());
     134           4 :     CPPUNIT_ASSERT_EQUAL(OUString("First line.\nSecond line."), xDocumentProperties->getDescription());
     135           2 : }
     136             : 
     137          17 : DECLARE_RTFEXPORT_TEST(testFdo50831, "fdo50831.rtf")
     138             : {
     139           2 :     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
     140           4 :     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
     141           4 :     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
     142           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
     143           2 :     float fValue = 0;
     144           2 :     xPropertySet->getPropertyValue("CharHeight") >>= fValue;
     145           4 :     CPPUNIT_ASSERT_EQUAL(10.f, fValue);
     146           2 : }
     147             : 
     148          16 : DECLARE_RTFEXPORT_TEST(testFdo48335, "fdo48335.odt")
     149             : {
     150             :     /*
     151             :      * The problem was that we exported a fake pagebreak, make sure it's just a soft one now.
     152             :      *
     153             :      * oParas = ThisComponent.Text.createEnumeration
     154             :      * oPara = oParas.nextElement
     155             :      * oPara = oParas.nextElement
     156             :      * oPara = oParas.nextElement
     157             :      * oRuns = oPara.createEnumeration
     158             :      * oRun = oRuns.nextElement
     159             :      * xray oRun.TextPortionType 'was Text, should be SoftPageBreak
     160             :      */
     161           1 :     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
     162           2 :     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
     163           2 :     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
     164           3 :     for (int i = 0; i < 2; i++)
     165           2 :         xParaEnum->nextElement();
     166           2 :     uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
     167           2 :     uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
     168           2 :     uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
     169           2 :     OUString aValue;
     170           1 :     xPropertySet->getPropertyValue("TextPortionType") >>= aValue;
     171           2 :     CPPUNIT_ASSERT_EQUAL(OUString("SoftPageBreak"), aValue);
     172           1 : }
     173             : 
     174          17 : DECLARE_RTFEXPORT_TEST(testFdo38244, "fdo38244.rtf")
     175             : {
     176             :     // See ooxmlexport's testFdo38244().
     177             :     // Test comment range feature.
     178           2 :     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
     179           4 :     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
     180           4 :     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
     181           4 :     uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
     182           4 :     uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
     183           2 :     xRunEnum->nextElement();
     184           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
     185           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(xPropertySet, "TextPortionType"));
     186           2 :     xRunEnum->nextElement();
     187           2 :     xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
     188           2 :     CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
     189             : 
     190             :     // Test initials.
     191           4 :     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
     192           4 :     uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
     193           4 :     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
     194           2 :     xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
     195           4 :     CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
     196           2 : }
     197             : 
     198          16 : DECLARE_RTFEXPORT_TEST(testCommentsNested, "comments-nested.odt")
     199             : {
     200           1 :     uno::Reference<beans::XPropertySet> xOuter(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField"), uno::UNO_QUERY);
     201           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Outer"), getProperty<OUString>(xOuter, "Content").trim());
     202             : 
     203           2 :     uno::Reference<beans::XPropertySet> xInner(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 4), "TextField"), uno::UNO_QUERY);
     204           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content").trim());
     205           1 : }
     206             : 
     207          17 : DECLARE_RTFEXPORT_TEST(testMathAccents, "math-accents.rtf")
     208             : {
     209           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     210           4 :     OUString aExpected("acute {a} grave {a} check {a} breve {a} circle {a} widevec {a} widetilde {a} widehat {a} dot {a} widevec {a} widevec {a} widetilde {a} underline {a}");
     211           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     212           2 : }
     213             : 
     214          16 : DECLARE_RTFEXPORT_TEST(testMathEqarray, "math-eqarray.rtf")
     215             : {
     216           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     217           2 :     OUString aExpected("y = left lbrace stack { 0, x < 0 # 1, x = 0 # {x} ^ {2} , x > 0 } right none");
     218           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     219           1 : }
     220             : 
     221          17 : DECLARE_RTFEXPORT_TEST(testMathD, "math-d.rtf")
     222             : {
     223           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     224           4 :     OUString aExpected("left (x mline y mline z right ) left (1 right ) left [2 right ] left ldbracket 3 right rdbracket left lline 4 right rline left ldline 5 right rdline left langle 6 right rangle left langle a mline b right rangle left ({x} over {y} right )");
     225           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     226           2 : }
     227             : 
     228          16 : DECLARE_RTFEXPORT_TEST(testMathEscaping, "math-escaping.rtf")
     229             : {
     230           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     231           2 :     OUString aExpected("\xc3\xa1 \\{", 5, RTL_TEXTENCODING_UTF8);
     232           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     233           1 : }
     234             : 
     235          16 : DECLARE_RTFEXPORT_TEST(testMathLim, "math-lim.rtf")
     236             : {
     237           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     238           2 :     OUString aExpected("lim from {x \xe2\x86\x92 1} {x}", 22, RTL_TEXTENCODING_UTF8);
     239           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     240           1 : }
     241             : 
     242          17 : DECLARE_RTFEXPORT_TEST(testMathMatrix, "math-matrix.rtf")
     243             : {
     244           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     245           4 :     OUString aExpected("left [matrix {1 # 2 ## 3 # 4} right ]");
     246           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     247           2 : }
     248             : 
     249          17 : DECLARE_RTFEXPORT_TEST(testMathBox, "math-mbox.rtf")
     250             : {
     251           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     252           4 :     OUString aExpected("a");
     253           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     254           2 : }
     255             : 
     256          16 : DECLARE_RTFEXPORT_TEST(testMathMso2007, "math-mso2007.rtf")
     257             : {
     258           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     259           2 :     OUString aExpected("A = \xcf\x80 {r} ^ {2}", 16, RTL_TEXTENCODING_UTF8);
     260           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     261             : 
     262           1 :     aActual = getFormula(getRun(getParagraph(2), 1));
     263           1 :     aExpected = OUString("{left (x + a right )} ^ {n} = sum from {k = 0} to {n} {left (stack { n # k } right ) {x} ^ {k} {a} ^ {n \xe2\x88\x92 k}}", 111, RTL_TEXTENCODING_UTF8);
     264           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     265             : 
     266           1 :     aActual = getFormula(getRun(getParagraph(3), 1));
     267           1 :     aExpected = OUString("{left (1 + x right )} ^ {n} = 1 + {nx} over {1 !} + {n left (n \xe2\x88\x92 1 right ) {x} ^ {2}} over {2 !} + \xe2\x80\xa6", 104, RTL_TEXTENCODING_UTF8);
     268           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     269             : 
     270           1 :     aActual = getFormula(getRun(getParagraph(4), 1));
     271           2 :     aExpected = OUString("f left (x right ) = {a} rsub {0} + sum from {n = 1} to {\xe2\x88\x9e} {left ({a} rsub {n} cos {n\xcf\x80x} over {L} + {b} rsub {n} sin {n\xcf\x80x} over {L} right )}", 144,
     272           1 :                          RTL_TEXTENCODING_UTF8);
     273           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     274             : 
     275           1 :     aActual = getFormula(getRun(getParagraph(5), 1));
     276           1 :     aExpected = "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}";
     277           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     278             : 
     279           1 :     aActual = getFormula(getRun(getParagraph(6), 1));
     280           1 :     aExpected = OUString("x = {\xe2\x88\x92 b \xc2\xb1 sqrt {{b} ^ {2} \xe2\x88\x92 4 ac}} over {2 a}", 51, RTL_TEXTENCODING_UTF8);
     281           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     282             : 
     283           1 :     aActual = getFormula(getRun(getParagraph(7), 1));
     284           1 :     aExpected = OUString("{e} ^ {x} = 1 + {x} over {1 !} + {{x} ^ {2}} over {2 !} + {{x} ^ {3}} over {3 !} + \xe2\x80\xa6 , \xe2\x88\x92 \xe2\x88\x9e < x < \xe2\x88\x9e", 106, RTL_TEXTENCODING_UTF8);
     285           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     286             : 
     287           1 :     aActual = getFormula(getRun(getParagraph(8), 1));
     288           1 :     aExpected = OUString("sin \xce\xb1 \xc2\xb1 sin \xce\xb2 = 2 sin {1} over {2} left (\xce\xb1 \xc2\xb1 \xce\xb2 right ) cos {1} over {2} left (\xce\xb1 \xe2\x88\x93 \xce\xb2 right )", 101, RTL_TEXTENCODING_UTF8);
     289           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     290             : 
     291           1 :     aActual = getFormula(getRun(getParagraph(9), 1));
     292           1 :     aExpected = OUString("cos \xce\xb1 + cos \xce\xb2 = 2 cos {1} over {2} left (\xce\xb1 + \xce\xb2 right ) cos {1} over {2} left (\xce\xb1 \xe2\x88\x92 \xce\xb2 right )", 99, RTL_TEXTENCODING_UTF8);
     293           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     294           1 : }
     295             : 
     296          16 : DECLARE_RTFEXPORT_TEST(testMathNary, "math-nary.rtf")
     297             : {
     298           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     299           2 :     OUString aExpected("lllint from {1} to {2} {x + 1} prod from {a} {b} sum to {2} {x}");
     300           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     301           1 : }
     302             : 
     303          17 : DECLARE_RTFEXPORT_TEST(testMathLimupp, "math-limupp.rtf")
     304             : {
     305           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     306           2 :     CPPUNIT_ASSERT_EQUAL(OUString("{abcd} overbrace {4}"), aActual);
     307             : 
     308           2 :     aActual = getFormula(getRun(getParagraph(2), 1));
     309           2 :     CPPUNIT_ASSERT_EQUAL(OUString("{xyz} underbrace {3}"), aActual);
     310           2 : }
     311             : 
     312          17 : DECLARE_RTFEXPORT_TEST(testMathStrikeh, "math-strikeh.rtf")
     313             : {
     314           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     315           2 :     CPPUNIT_ASSERT_EQUAL(OUString("overstrike {abc}"), aActual);
     316           2 : }
     317             : 
     318          17 : DECLARE_RTFEXPORT_TEST(testMathPlaceholders, "math-placeholders.rtf")
     319             : {
     320           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     321           2 :     CPPUNIT_ASSERT_EQUAL(OUString("sum from <?> to <?> <?>"), aActual);
     322           2 : }
     323             : 
     324          16 : DECLARE_RTFEXPORT_TEST(testMathRad, "math-rad.rtf")
     325             : {
     326           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     327           1 :     CPPUNIT_ASSERT_EQUAL(OUString("sqrt {4} nroot {3} {x + 1}"), aActual);
     328           1 : }
     329             : 
     330          17 : DECLARE_RTFEXPORT_TEST(testMathSepchr, "math-sepchr.rtf")
     331             : {
     332           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     333           2 :     CPPUNIT_ASSERT_EQUAL(OUString("AxByBzC"), aActual);
     334           2 : }
     335             : 
     336          17 : DECLARE_RTFEXPORT_TEST(testMathSubscripts, "math-subscripts.rtf")
     337             : {
     338           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     339           4 :     OUString aExpected("{x} ^ {y} + {e} ^ {x} {x} ^ {b} {x} rsub {b} {a} rsub {c} rsup {b} {x} lsub {2} lsup {1} {{x csup {6} csub {3}} lsub {4} lsup {5}} rsub {2} rsup {1}");
     340           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     341           2 : }
     342             : 
     343          16 : DECLARE_RTFEXPORT_TEST(testMathVerticalstacks, "math-vertical-stacks.rtf")
     344             : {
     345           1 :     CPPUNIT_ASSERT_EQUAL(OUString("{a} over {b}"), getFormula(getRun(getParagraph(1), 1)));
     346           1 :     CPPUNIT_ASSERT_EQUAL(OUString("{a} / {b}"), getFormula(getRun(getParagraph(2), 1)));
     347           1 :     CPPUNIT_ASSERT_EQUAL(OUString("stack { a # b }"), getFormula(getRun(getParagraph(3), 1)));
     348           1 :     CPPUNIT_ASSERT_EQUAL(OUString("stack { a # stack { b # c } }"), getFormula(getRun(getParagraph(4), 1)));
     349           1 : }
     350             : 
     351          16 : DECLARE_RTFEXPORT_TEST(testMathRuns, "math-runs.rtf")
     352             : {
     353             :     // was [](){}, i.e. first curly bracket had an incorrect position
     354           1 :     CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"), getFormula(getRun(getParagraph(1), 1)));
     355           1 : }
     356             : 
     357          16 : DECLARE_RTFEXPORT_TEST(testFdo77979, "fdo77979.odt")
     358             : {
     359             :     // font name is encoded with \fcharset of font
     360           1 :     OUString aExpected("\xE5\xBE\xAE\xE8\xBD\xAF\xE9\x9B\x85\xE9\xBB\x91", 12, RTL_TEXTENCODING_UTF8);
     361           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, getProperty<OUString>(getRun(getParagraph(1), 1), "CharFontName"));
     362           1 : }
     363             : 
     364          16 : DECLARE_RTFEXPORT_TEST(testFdo53113, "fdo53113.odt")
     365             : {
     366             :     /*
     367             :      * The problem was that a custom shape was missings its second (and all the other remaining) coordinates.
     368             :      *
     369             :      * oShape = ThisComponent.DrawPage(0)
     370             :      * oPathPropVec = oShape.CustomShapeGeometry(1).Value
     371             :      * oCoordinates = oPathPropVec(0).Value
     372             :      * xray oCoordinates(1).First.Value ' 535
     373             :      * xray oCoordinates(1).Second.Value ' 102
     374             :      */
     375             : 
     376           1 :     uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(getShape(1), "CustomShapeGeometry");
     377           2 :     uno::Sequence<beans::PropertyValue> aPathProps;
     378           4 :     for (int i = 0; i < aProps.getLength(); ++i)
     379             :     {
     380           3 :         const beans::PropertyValue& rProp = aProps[i];
     381           3 :         if (rProp.Name == "Path")
     382           1 :             rProp.Value >>= aPathProps;
     383             :     }
     384           2 :     uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aPairs;
     385           3 :     for (int i = 0; i < aPathProps.getLength(); ++i)
     386             :     {
     387           2 :         const beans::PropertyValue& rProp = aPathProps[i];
     388           2 :         if (rProp.Name == "Coordinates")
     389           1 :             rProp.Value >>= aPairs;
     390             :     }
     391           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aPairs.getLength());
     392           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(535), aPairs[1].First.Value.get<sal_Int32>());
     393           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(102), aPairs[1].Second.Value.get<sal_Int32>());
     394           1 : }
     395             : 
     396          16 : DECLARE_RTFEXPORT_TEST(testFdo55939, "fdo55939.odt")
     397             : {
     398             :     // The problem was that the exported RTF was invalid.
     399             :     // Also, the 'Footnote text.' had an additional newline at its end.
     400           1 :     uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
     401           1 :     getRun(xParagraph, 1, "Main text before footnote.");
     402             :     // Why the tab has to be removed here?
     403           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Footnote text."),
     404           1 :                          getProperty< uno::Reference<text::XTextRange> >(getRun(xParagraph, 2), "Footnote")->getText()->getString().replaceAll("\t", ""));
     405           1 :     getRun(xParagraph, 3, " Text after the footnote."); // However, this leading space is intentional and OK.
     406           1 : }
     407             : 
     408          16 : DECLARE_RTFEXPORT_TEST(testTextFrames, "textframes.odt")
     409             : {
     410             :     // The output was simply invalid, so let's check if all 3 frames were imported back.
     411           1 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     412           2 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     413           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount());
     414           1 : }
     415             : 
     416          16 : DECLARE_RTFEXPORT_TEST(testFdo53604, "fdo53604.odt")
     417             : {
     418             :     // Invalid output on empty footnote.
     419           1 :     uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
     420           2 :     uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
     421           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
     422           1 : }
     423             : 
     424          16 : DECLARE_RTFEXPORT_TEST(testFdo52286, "fdo52286.odt")
     425             : {
     426             :     // The problem was that font size wasn't reduced in sub/super script.
     427           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapementHeight"));
     428           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(2), 2), "CharEscapementHeight"));
     429           1 : }
     430             : 
     431          17 : DECLARE_RTFEXPORT_TEST(testFdo61507, "fdo61507.rtf")
     432             : {
     433             :     /*
     434             :      * Unicode-only characters in \title confused Wordpad. Once the exporter
     435             :      * was fixed to guard the problematic characters with \upr and \ud, the
     436             :      * importer didn't cope with these new keywords.
     437             :      */
     438             : 
     439           2 :     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
     440           4 :     uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
     441           4 :     OUString aExpected = OUString("\xc3\x89\xc3\x81\xc5\x90\xc5\xb0\xe2\x88\xad", 11, RTL_TEXTENCODING_UTF8);
     442           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, xDocumentProperties->getTitle());
     443             : 
     444             :     // Only "Hello.", no additional characters.
     445           4 :     CPPUNIT_ASSERT_EQUAL(6, getLength());
     446           2 : }
     447             : 
     448          17 : DECLARE_RTFEXPORT_TEST(testFdo30983, "fdo30983.rtf")
     449             : {
     450             :     // These were 'page text area', not 'entire page', i.e. both the horizontal
     451             :     // and vertical positions were incorrect.
     452           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), "HoriOrientRelation"));
     453           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), "VertOrientRelation"));
     454           2 : }
     455             : 
     456          16 : DECLARE_RTFEXPORT_TEST(testPlaceholder, "placeholder.odt")
     457             : {
     458             :     // Only the field text was exported, make sure we still have a field with the correct Hint text.
     459           1 :     uno::Reference<text::XTextRange> xRun(getRun(getParagraph(1), 2));
     460           1 :     CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(xRun, "TextPortionType"));
     461           2 :     uno::Reference<beans::XPropertySet> xField = getProperty< uno::Reference<beans::XPropertySet> >(xRun, "TextField");
     462           2 :     CPPUNIT_ASSERT_EQUAL(OUString("place holder"), getProperty<OUString>(xField, "Hint"));
     463           1 : }
     464             : 
     465          17 : DECLARE_RTFEXPORT_TEST(testMnor, "mnor.rtf")
     466             : {
     467             :     // \mnor wasn't handled, leading to missing quotes around "divF" and so on.
     468           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     469           4 :     OUString aExpected("iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\" \xe2\x88\x99 \"n\" dS}", 74, RTL_TEXTENCODING_UTF8);
     470           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     471           2 : }
     472             : 
     473          17 : DECLARE_RTFEXPORT_TEST(testI120928, "i120928.rtf")
     474             : {
     475             :     // \listpicture and \levelpicture0 was ignored, leading to missing graphic bullet in numbering.
     476           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
     477           4 :     uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
     478           4 :     uno::Sequence<beans::PropertyValue> aProps;
     479           2 :     xLevels->getByIndex(0) >>= aProps; // 1st level
     480             : 
     481           2 :     bool bIsGraphic = false;
     482          32 :     for (int i = 0; i < aProps.getLength(); ++i)
     483             :     {
     484          30 :         const beans::PropertyValue& rProp = aProps[i];
     485             : 
     486          30 :         if (rProp.Name == "NumberingType")
     487           2 :             CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>());
     488          28 :         else if (rProp.Name == "GraphicURL")
     489           2 :             bIsGraphic = true;
     490             :     }
     491           4 :     CPPUNIT_ASSERT_EQUAL(true, bIsGraphic);
     492           2 : }
     493             : 
     494          17 : DECLARE_RTFEXPORT_TEST(testBookmark, "bookmark.rtf")
     495             : {
     496           2 :     uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
     497           4 :     uno::Reference<text::XTextContent> xBookmark(xBookmarksSupplier->getBookmarks()->getByName("firstword"), uno::UNO_QUERY);
     498           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xBookmark->getAnchor()->getString());
     499           2 : }
     500             : 
     501          17 : DECLARE_RTFEXPORT_TEST(testHyperlink, "hyperlink.rtf")
     502             : {
     503           2 :     CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 1, "Hello"), "HyperLinkURL"));
     504           2 :     CPPUNIT_ASSERT_EQUAL(OUString("http://en.wikipedia.org/wiki/World"), getProperty<OUString>(getRun(getParagraph(1), 2, "world"), "HyperLinkURL"));
     505           2 :     CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 3, "!"), "HyperLinkURL"));
     506           2 : }
     507             : 
     508          17 : DECLARE_RTFEXPORT_TEST(test78758, "fdo78758.rtf")
     509             : {
     510           4 :     CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
     511           2 :                          getProperty<OUString>(getRun(getParagraph(2), 1, "EE5E EeEEE5EE"), "HyperLinkURL"));
     512           4 :     CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
     513           2 :                          getProperty<OUString>(getRun(getParagraph(2), 2, "e"), "HyperLinkURL"));
     514           4 :     CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"),
     515           2 :                          getProperty<OUString>(getRun(getParagraph(2), 3, "\t46"), "HyperLinkURL"));
     516           2 : }
     517             : 
     518          17 : DECLARE_RTFEXPORT_TEST(testTextFrameBorders, "textframe-borders.rtf")
     519             : {
     520           2 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     521           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     522           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
     523           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xFrame, "BackColor"));
     524             : 
     525           2 :     table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder");
     526           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aBorder.Color);
     527           2 :     CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth);
     528             : 
     529           2 :     table::ShadowFormat aShadowFormat = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat");
     530           2 :     CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location);
     531           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth);
     532           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aShadowFormat.Color);
     533           2 : }
     534             : 
     535          17 : DECLARE_RTFEXPORT_TEST(testTextframeGradient, "textframe-gradient.rtf")
     536             : {
     537           2 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     538           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     539           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
     540             : 
     541           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
     542           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
     543           2 :     awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
     544           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor);
     545           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor);
     546           2 :     CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
     547             : 
     548           2 :     xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
     549           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
     550           2 :     aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
     551           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor);
     552           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor);
     553           4 :     CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
     554           2 : }
     555             : 
     556          17 : DECLARE_RTFEXPORT_TEST(testRecordChanges, "record-changes.rtf")
     557             : {
     558             :     // \revisions wasn't imported/exported.
     559           2 :     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(mxComponent, "RecordChanges"));
     560           2 : }
     561             : 
     562          17 : DECLARE_RTFEXPORT_TEST(testTextframeTable, "textframe-table.rtf")
     563             : {
     564           2 :     uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY);
     565           4 :     uno::Reference<text::XText> xText = xTextRange->getText();
     566           2 :     CPPUNIT_ASSERT_EQUAL(OUString("First para."), getParagraphOfText(1, xText)->getString());
     567           4 :     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
     568           2 :     CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString());
     569           2 :     CPPUNIT_ASSERT_EQUAL(OUString("B"), uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY)->getString());
     570           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Last para."), getParagraphOfText(3, xText)->getString());
     571           2 : }
     572             : 
     573          17 : DECLARE_RTFEXPORT_TEST(testFdo66682, "fdo66682.rtf")
     574             : {
     575           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
     576           4 :     uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
     577           4 :     uno::Sequence<beans::PropertyValue> aProps;
     578           2 :     xLevels->getByIndex(0) >>= aProps; // 1st level
     579             : 
     580           4 :     OUString aSuffix;
     581          26 :     for (int i = 0; i < aProps.getLength(); ++i)
     582             :     {
     583          24 :         const beans::PropertyValue& rProp = aProps[i];
     584             : 
     585          24 :         if (rProp.Name == "Suffix")
     586           2 :             aSuffix = rProp.Value.get<OUString>();
     587             :     }
     588             :     // Suffix was '\0' instead of ' '.
     589           4 :     CPPUNIT_ASSERT_EQUAL(OUString(" "), aSuffix);
     590           2 : }
     591             : 
     592          17 : DECLARE_RTFEXPORT_TEST(testParaShadow, "para-shadow.rtf")
     593             : {
     594             :     // The problem was that \brdrsh was ignored.
     595           2 :     table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getParagraph(2), "ParaShadowFormat");
     596           2 :     CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
     597           2 :     CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
     598           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(convertTwipToMm100(60)), aShadow.ShadowWidth);
     599           2 : }
     600             : 
     601          16 : DECLARE_RTFEXPORT_TEST(testCharacterBorder, "charborder.odt")
     602             : {
     603           1 :     uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
     604             :     // RTF has just one border attribute (chbrdr) for text border so all side has
     605             :     // the same border with the same padding
     606             :     // Border
     607             :     {
     608           1 :         const table::BorderLine2 aTopBorder = getProperty<table::BorderLine2>(xRun,"CharTopBorder");
     609           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF6600,0,318,0,0,318), aTopBorder);
     610           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharLeftBorder"));
     611           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharBottomBorder"));
     612           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharRightBorder"));
     613             :     }
     614             : 
     615             :     // Padding (brsp)
     616             :     {
     617           1 :         const sal_Int32 nTopPadding = getProperty<sal_Int32>(xRun,"CharTopBorderDistance");
     618             :         // In the original ODT file the padding is 150, but the unit conversion round it down.
     619           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(141), nTopPadding);
     620           1 :         CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharLeftBorderDistance"));
     621           1 :         CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharBottomBorderDistance"));
     622           1 :         CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharRightBorderDistance"));
     623             :     }
     624             : 
     625             :     // Shadow (brdrsh)
     626             :     /* RTF use just one bool value for shadow so the next conversions
     627             :        are made during an export-import round
     628             :        color: any -> black
     629             :        location: any -> bottom-right
     630             :        width: any -> border width */
     631             :     {
     632           1 :         const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
     633           1 :         CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
     634           1 :         CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
     635           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth);
     636           1 :     }
     637           1 : }
     638             : 
     639          17 : DECLARE_RTFEXPORT_TEST(testFdo66743, "fdo66743.rtf")
     640             : {
     641           2 :     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
     642           4 :     uno::Reference<table::XCell> xCell = xTable->getCellByName("A1");
     643             :     // This was too dark, 0x7f7f7f.
     644           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xd8d8d8), getProperty<sal_Int32>(xCell, "BackColor"));
     645           2 : }
     646             : 
     647          17 : DECLARE_RTFEXPORT_TEST(testFdo68787, "fdo68787.rtf")
     648             : {
     649           2 :     uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
     650             :     // This was 0, the 'lack of \chftnsep' <-> '0 line width' mapping was missing in the RTF tokenizer / exporter.
     651           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth"));
     652           2 : }
     653             : 
     654          17 : DECLARE_RTFEXPORT_TEST(testFdo74709, "fdo74709.rtf")
     655             : {
     656           2 :     uno::Reference<table::XCell> xCell = getCell(getParagraphOrTable(1), "B1");
     657             :     // This was 0, as top/bottom/left/right padding wasn't imported.
     658           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(360)), getProperty<sal_Int32>(xCell, "RightBorderDistance"));
     659           2 : }
     660             : 
     661          17 : DECLARE_RTFEXPORT_TEST(testRelsize, "relsize.rtf")
     662             : {
     663           2 :     uno::Reference<drawing::XShape> xShape = getShape(1);
     664           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(xShape, "RelativeWidth"));
     665           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation"));
     666           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(xShape, "RelativeHeight"));
     667           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation"));
     668           2 : }
     669             : 
     670          17 : DECLARE_RTFEXPORT_TEST(testLineNumbering, "linenumbering.rtf")
     671             : {
     672           2 :     uno::Reference<text::XLineNumberingProperties> xLineNumberingProperties(mxComponent, uno::UNO_QUERY_THROW);
     673           4 :     uno::Reference<beans::XPropertySet> xPropertySet = xLineNumberingProperties->getLineNumberingProperties();
     674           2 :     CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xPropertySet, "IsOn")));
     675           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(5), getProperty<sal_Int32>(xPropertySet, "Interval"));
     676           2 : }
     677             : 
     678          17 : DECLARE_RTFEXPORT_TEST(testFdo77600, "fdo77600.rtf")
     679             : {
     680             :     // This was 'Liberation Serif'.
     681           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Arial"), getProperty<OUString>(getRun(getParagraph(1), 3), "CharFontName"));
     682           2 : }
     683             : 
     684          17 : DECLARE_RTFEXPORT_TEST(testFdo80167, "fdo80167.rtf")
     685             : {
     686             :     // Problem was that after export, the page break was missing, so this was 1.
     687           2 :     CPPUNIT_ASSERT_EQUAL(2, getPages());
     688           2 : }
     689             : 
     690          16 : DECLARE_RTFEXPORT_TEST(testFdo32613, "fdo32613.odt")
     691             : {
     692             :     // This was AS_CHARACTER, RTF export did not support writing anchored pictures.
     693           1 :     CPPUNIT_ASSERT_EQUAL(text::TextContentAnchorType_AT_CHARACTER, getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
     694           1 : }
     695             : 
     696          17 : DECLARE_RTFEXPORT_TEST(testPictureWrapPolygon, "picture-wrap-polygon.rtf")
     697             : {
     698             :     // The problem was that the wrap polygon was ignored during import.
     699           2 :     drawing::PointSequenceSequence aSeqSeq = getProperty<drawing::PointSequenceSequence>(getShape(1), "ContourPolyPolygon");
     700             :     // This was 0: the polygon list was empty.
     701           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), aSeqSeq.getLength());
     702             : 
     703           4 :     drawing::PointSequence aSeq = aSeqSeq[0];
     704           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(11), aSeq.getLength());
     705             : 
     706             :     // The shape also didn't have negative top / left coordinates.
     707           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-1177)), getProperty<sal_Int32>(getShape(1), "HoriOrientPosition"));
     708           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(-67)), getProperty<sal_Int32>(getShape(1), "VertOrientPosition"));
     709           2 : }
     710             : 
     711          16 : DECLARE_RTFEXPORT_TEST(testAbi10039, "abi10039.odt")
     712             : {
     713             :     // Make sure we don't just crash on export, and additionally the shape should not be inline (as it's at-page anchored originally).
     714           1 :     CPPUNIT_ASSERT(text::TextContentAnchorType_AS_CHARACTER != getProperty<text::TextContentAnchorType>(getShape(1), "AnchorType"));
     715           1 : }
     716             : 
     717          16 : DECLARE_RTFEXPORT_TEST(testAbi10076, "abi10076.odt")
     718             : {
     719             :     // Just make sure that we don't crash after exporting a fully calculated layout.
     720           1 : }
     721             : 
     722          17 : DECLARE_RTFEXPORT_TEST(testEm, "em.rtf")
     723             : {
     724             :     // Test all possible \acc* control words.
     725           2 :     CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::NONE, getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharEmphasis"));
     726           2 :     CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_ABOVE, getProperty<sal_Int16>(getRun(getParagraph(1), 2), "CharEmphasis"));
     727           2 :     CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::ACCENT_ABOVE, getProperty<sal_Int16>(getRun(getParagraph(1), 3), "CharEmphasis"));
     728             :     // This was missing.
     729           2 :     CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::CIRCLE_ABOVE, getProperty<sal_Int16>(getRun(getParagraph(1), 4), "CharEmphasis"));
     730             :     // This one, too.
     731           2 :     CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_BELOW, getProperty<sal_Int16>(getRun(getParagraph(1), 5), "CharEmphasis"));
     732           2 : }
     733             : 
     734          17 : DECLARE_RTFEXPORT_TEST(testNumberingFont, "numbering-font.rtf")
     735             : {
     736           2 :     uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName("ListLabel 1"), uno::UNO_QUERY);
     737             :     // This was Liberation Serif, i.e. custom font of the numbering itself ("1.\t") was lost on import.
     738           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(xStyle, "CharFontName"));
     739           2 : }
     740             : 
     741          16 : DECLARE_RTFEXPORT_TEST(testFdo82860, "fdo82860.odt")
     742             : {
     743             :     // The problem was that:
     744             :     // 1) The import tried to use fieldmarks for SHAPE fields
     745             :     // 2) The exporter did not handle "shape with textbox" text.
     746           1 :     uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY);
     747           2 :     uno::Reference<text::XText> xText = xTextRange->getText();
     748           2 :     CPPUNIT_ASSERT_EQUAL(OUString("hello"), getParagraphOfText(1, xText)->getString());
     749           1 : }
     750             : 
     751          16 : DECLARE_RTFEXPORT_TEST(testFdo82858, "fdo82858.docx")
     752             : {
     753             :     // This was table::BorderLineStyle::SOLID, exporter failed to write explicit no line when line color was written.
     754           1 :     CPPUNIT_ASSERT_EQUAL(table::BorderLineStyle::NONE, getProperty<table::BorderLine2>(getShape(1), "TopBorder").LineStyle);
     755           1 : }
     756             : 
     757          17 : DECLARE_RTFEXPORT_TEST(testCjklist12, "cjklist12.rtf")
     758             : {
     759             :     sal_Int16   numFormat;
     760           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     761           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::AIU_HALFWIDTH_JA, numFormat);
     762           2 : }
     763             : 
     764          17 : DECLARE_RTFEXPORT_TEST(testCjklist13, "cjklist13.rtf")
     765             : {
     766             :     sal_Int16   numFormat;
     767           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     768           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::IROHA_HALFWIDTH_JA, numFormat);
     769           2 : }
     770             : 
     771          17 : DECLARE_RTFEXPORT_TEST(testCjklist16, "cjklist16.rtf")
     772             : {
     773             :     sal_Int16   numFormat;
     774           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     775           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_TRADITIONAL_JA, numFormat);
     776           2 : }
     777             : 
     778          17 : DECLARE_RTFEXPORT_TEST(testCjklist20, "cjklist20.rtf")
     779             : {
     780             :     sal_Int16   numFormat;
     781           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     782           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::AIU_FULLWIDTH_JA, numFormat);
     783           2 : }
     784             : 
     785          17 : DECLARE_RTFEXPORT_TEST(testCjklist21, "cjklist21.rtf")
     786             : {
     787             :     sal_Int16   numFormat;
     788           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     789           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::IROHA_FULLWIDTH_JA, numFormat);
     790           2 : }
     791             : 
     792          17 : DECLARE_RTFEXPORT_TEST(testCjklist24, "cjklist24.rtf")
     793             : {
     794             :     sal_Int16   numFormat;
     795           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     796           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::HANGUL_SYLLABLE_KO, numFormat);
     797           2 : }
     798             : 
     799          17 : DECLARE_RTFEXPORT_TEST(testCjklist25, "cjklist25.rtf")
     800             : {
     801             :     sal_Int16   numFormat;
     802           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     803           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::HANGUL_JAMO_KO, numFormat);
     804           2 : }
     805             : 
     806          17 : DECLARE_RTFEXPORT_TEST(testCjklist30, "cjklist30.rtf")
     807             : {
     808             :     sal_Int16   numFormat;
     809           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     810           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::TIAN_GAN_ZH, numFormat);
     811           2 : }
     812             : 
     813          17 : DECLARE_RTFEXPORT_TEST(testCjklist31, "cjklist31.rtf")
     814             : {
     815             :     sal_Int16   numFormat;
     816           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     817           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::DI_ZI_ZH, numFormat);
     818           2 : }
     819             : 
     820          17 : DECLARE_RTFEXPORT_TEST(testCjklist34, "cjklist34.rtf")
     821             : {
     822             :     sal_Int16   numFormat;
     823           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     824           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH_TW, numFormat);
     825           2 : }
     826             : 
     827          17 : DECLARE_RTFEXPORT_TEST(testCjklist38, "cjklist38.rtf")
     828             : {
     829             :     sal_Int16   numFormat;
     830           2 :     CPPUNIT_ASSERT(CjkNumberedListTestHelper(numFormat));
     831           2 :     CPPUNIT_ASSERT_EQUAL(style::NumberingType::NUMBER_UPPER_ZH, numFormat);
     832           2 : }
     833             : 
     834          17 : DECLARE_RTFEXPORT_TEST(testTableRtl, "table-rtl.rtf")
     835             : {
     836           2 :     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
     837           4 :     uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
     838           4 :     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
     839             :     // This was text::WritingMode2::LR_TB, i.e. direction of the table was ignored.
     840           4 :     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, getProperty<sal_Int16>(xTable, "WritingMode"));
     841           2 : }
     842             : 
     843          17 : DECLARE_RTFEXPORT_TEST(testNumOverrideStart, "num-override-start.rtf")
     844             : {
     845             :     // The numbering on the second level was "3.1", not "1.3".
     846           2 :     uno::Reference<container::XIndexAccess> xRules = getProperty< uno::Reference<container::XIndexAccess> >(getStyles("NumberingStyles")->getByName("WWNum1"), "NumberingRules");
     847           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(1), comphelper::SequenceAsHashMap(xRules->getByIndex(0))["StartWith"].get<sal_Int16>());
     848           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(3), comphelper::SequenceAsHashMap(xRules->getByIndex(1))["StartWith"].get<sal_Int16>());
     849           2 : }
     850             : 
     851          17 : DECLARE_RTFEXPORT_TEST(testFdo82006, "fdo82006.rtf")
     852             : {
     853             :     // These were 176 (100 twips), as \sbauto and \sbbefore were ignored.
     854           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), getProperty<sal_Int32>(getParagraph(0), "ParaTopMargin"));
     855           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(convertTwipToMm100(280)), getProperty<sal_Int32>(getParagraph(0), "ParaBottomMargin"));
     856           2 : }
     857             : 
     858          16 : DECLARE_RTFEXPORT_TEST(testTdf88583, "tdf88583.odt")
     859             : {
     860             :     // This was FillStyle_NONE, as background color was missing from the color table during export.
     861           1 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_SOLID, getProperty<drawing::FillStyle>(getParagraph(1), "FillStyle"));
     862           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0x00cc00), getProperty<sal_Int32>(getParagraph(1), "FillColor"));
     863           1 : }
     864             : 
     865          17 : DECLARE_RTFEXPORT_TEST(testMargmirror, "margmirror.rtf")
     866             : {
     867             :     // \margmirror was not handled, this was PageStyleLayout_ALL.
     868           2 :     uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
     869           2 :     CPPUNIT_ASSERT_EQUAL(style::PageStyleLayout_MIRRORED, getProperty<style::PageStyleLayout>(xPageStyle, "PageStyleLayout"));
     870           2 : }
     871             : 
     872          17 : DECLARE_RTFEXPORT_TEST(testSautoupd, "sautoupd.rtf")
     873             : {
     874             :     // \sautoupd was ignored during import and export.
     875           2 :     uno::Reference<beans::XPropertySet> xHeading1(getStyles("ParagraphStyles")->getByName("Heading 1"), uno::UNO_QUERY);
     876           2 :     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xHeading1, "IsAutoUpdate"));
     877           4 :     uno::Reference<beans::XPropertySet> xHeading2(getStyles("ParagraphStyles")->getByName("Heading 2"), uno::UNO_QUERY);
     878           4 :     CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(xHeading2, "IsAutoUpdate"));
     879           2 : }
     880             : 
     881          17 : DECLARE_RTFEXPORT_TEST(testHyphauto, "hyphauto.rtf")
     882             : {
     883           2 :     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(getParagraph(1), "ParaIsHyphenation"));
     884           2 : }
     885             : 
     886          17 : DECLARE_RTFEXPORT_TEST(testHyphpar, "hyphpar.rtf")
     887             : {
     888             :     // Hyphenation was enabled for all 3 paragraphs, but it should be disabled for the 2nd one.
     889           2 :     CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(getParagraph(2), "ParaIsHyphenation"));
     890           2 : }
     891             : 
     892          17 : DECLARE_RTFEXPORT_TEST(testTdf80708, "tdf80708.rtf")
     893             : {
     894           2 :     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
     895           4 :     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
     896           4 :     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(1), uno::UNO_QUERY);
     897           4 :     uno::Reference<table::XTableRows> xTableRows(xTable->getRows(), uno::UNO_QUERY);
     898             :     // This was 2, i.e. the second table had 3 cols, now 2 as expected.
     899           4 :     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), getProperty< uno::Sequence<text::TableColumnSeparator> >(xTableRows->getByIndex(0), "TableColumnSeparators").getLength());
     900           2 : }
     901             : 
     902          16 : DECLARE_RTFEXPORT_TEST(testTdf90421, "tdf90421.fodt")
     903             : {
     904           1 :     if (mbExported)
     905             :     {
     906           1 :         SvMemoryStream aMemoryStream;
     907           2 :         SvFileStream aStream(maTempFile.GetURL(), StreamMode::READ);
     908           1 :         aStream.ReadStream(aMemoryStream);
     909           2 :         OString aData(static_cast<const char*>(aMemoryStream.GetData()), aMemoryStream.GetSize());
     910             :         // This was some positive number, i.e. we exported a hyperlink with an empty URL.
     911           2 :         CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(-1), aData.indexOf("HYPERLINK"));
     912             :     }
     913           1 : }
     914             : 
     915           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     916             : 
     917             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11