LCOV - code coverage report
Current view: top level - sw/qa/extras/rtfexport - rtfexport.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 380 380 100.0 %
Date: 2014-04-11 Functions: 456 508 89.8 %
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/Gradient.hpp>
      14             : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      15             : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
      16             : #include <com/sun/star/drawing/FillStyle.hpp>
      17             : #include <com/sun/star/frame/XStorable.hpp>
      18             : #include <com/sun/star/table/BorderLine2.hpp>
      19             : #include <com/sun/star/table/ShadowFormat.hpp>
      20             : #include <com/sun/star/text/XFootnotesSupplier.hpp>
      21             : #include <com/sun/star/text/XPageCursor.hpp>
      22             : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
      23             : #include <com/sun/star/view/XViewSettingsSupplier.hpp>
      24             : #include <com/sun/star/text/RelOrientation.hpp>
      25             : 
      26             : #include <vcl/svapp.hxx>
      27             : 
      28         100 : class Test : public SwModelTestBase
      29             : {
      30             : public:
      31         100 :     Test() : SwModelTestBase("/sw/qa/extras/rtfexport/data/", "Rich Text Format") {}
      32             : 
      33          50 :     bool mustTestImportOf(const char* filename) const SAL_OVERRIDE {
      34             :         // Don't test the first import of these, for some reason those tests fail
      35             :         const char* aBlacklist[] = {
      36             :             "math-eqarray.rtf",
      37             :             "math-escaping.rtf",
      38             :             "math-lim.rtf",
      39             :             "math-mso2007.rtf",
      40             :             "math-nary.rtf",
      41             :             "math-rad.rtf",
      42             :             "math-vertical-stacks.rtf",
      43             :             "math-runs.rtf",
      44          50 :         };
      45          50 :         std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist));
      46             : 
      47             :         // If the testcase is stored in some other format, it's pointless to test.
      48          50 :         return (OString(filename).endsWith(".rtf") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end());
      49             :     }
      50             : };
      51             : 
      52             : #define DECLARE_RTFEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, Test)
      53             : 
      54          14 : DECLARE_RTFEXPORT_TEST(testZoom, "zoom.rtf")
      55             : {
      56           2 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
      57           4 :     uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
      58           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings());
      59           2 :     sal_Int16 nValue = 0;
      60           2 :     xPropertySet->getPropertyValue("ZoomValue") >>= nValue;
      61           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue);
      62           2 : }
      63             : 
      64          14 : DECLARE_RTFEXPORT_TEST(testFdo38176, "fdo38176.rtf")
      65             : {
      66           2 :     CPPUNIT_ASSERT_EQUAL(9, getLength());
      67           2 : }
      68             : 
      69          14 : DECLARE_RTFEXPORT_TEST(testFdo49683, "fdo49683.rtf")
      70             : {
      71           2 :     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
      72           4 :     uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
      73           4 :     uno::Sequence<OUString> aKeywords(xDocumentProperties->getKeywords());
      74           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aKeywords.getLength());
      75           2 :     CPPUNIT_ASSERT_EQUAL(OUString("one"), aKeywords[0]);
      76           4 :     CPPUNIT_ASSERT_EQUAL(OUString("two"), aKeywords[1]);
      77           2 : }
      78             : 
      79          14 : DECLARE_RTFEXPORT_TEST(testFdo44174, "fdo44174.rtf")
      80             : {
      81           2 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
      82           4 :     uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
      83           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
      84           4 :     OUString aValue;
      85           2 :     xPropertySet->getPropertyValue("PageStyleName") >>= aValue;
      86           4 :     CPPUNIT_ASSERT_EQUAL(OUString("First Page"), aValue);
      87           2 : }
      88             : 
      89          14 : DECLARE_RTFEXPORT_TEST(testFdo50087, "fdo50087.rtf")
      90             : {
      91           2 :     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
      92           4 :     uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
      93           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Title"), xDocumentProperties->getTitle());
      94           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Subject"), xDocumentProperties->getSubject());
      95           4 :     CPPUNIT_ASSERT_EQUAL(OUString("First line.\nSecond line."), xDocumentProperties->getDescription());
      96           2 : }
      97             : 
      98          14 : DECLARE_RTFEXPORT_TEST(testFdo50831, "fdo50831.rtf")
      99             : {
     100           2 :     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
     101           4 :     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
     102           4 :     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
     103           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
     104           2 :     float fValue = 0;
     105           2 :     xPropertySet->getPropertyValue("CharHeight") >>= fValue;
     106           4 :     CPPUNIT_ASSERT_EQUAL(10.f, fValue);
     107           2 : }
     108             : 
     109          13 : DECLARE_RTFEXPORT_TEST(testFdo48335, "fdo48335.odt")
     110             : {
     111             :     /*
     112             :      * The problem was that we exported a fake pagebreak, make sure it's just a soft one now.
     113             :      *
     114             :      * oParas = ThisComponent.Text.createEnumeration
     115             :      * oPara = oParas.nextElement
     116             :      * oPara = oParas.nextElement
     117             :      * oPara = oParas.nextElement
     118             :      * oRuns = oPara.createEnumeration
     119             :      * oRun = oRuns.nextElement
     120             :      * xray oRun.TextPortionType 'was Text, should be SoftPageBreak
     121             :      */
     122           1 :     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
     123           2 :     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
     124           2 :     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
     125           3 :     for (int i = 0; i < 2; i++)
     126           2 :         xParaEnum->nextElement();
     127           2 :     uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
     128           2 :     uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
     129           2 :     uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
     130           2 :     OUString aValue;
     131           1 :     xPropertySet->getPropertyValue("TextPortionType") >>= aValue;
     132           2 :     CPPUNIT_ASSERT_EQUAL(OUString("SoftPageBreak"), aValue);
     133           1 : }
     134             : 
     135          14 : DECLARE_RTFEXPORT_TEST(testFdo38244, "fdo38244.rtf")
     136             : {
     137             :     // See ooxmlexport's testFdo38244().
     138             :     // Test comment range feature.
     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<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
     143           4 :     uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
     144           2 :     xRunEnum->nextElement();
     145           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
     146           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(xPropertySet, "TextPortionType"));
     147           2 :     xRunEnum->nextElement();
     148           2 :     xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
     149           2 :     CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
     150             : 
     151             :     // Test initials.
     152           4 :     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
     153           4 :     uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
     154           4 :     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
     155           2 :     xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
     156           4 :     CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
     157           2 : }
     158             : 
     159          13 : DECLARE_RTFEXPORT_TEST(testCommentsNested, "comments-nested.odt")
     160             : {
     161           1 :     uno::Reference<beans::XPropertySet> xOuter(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField"), uno::UNO_QUERY);
     162           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Outer"), getProperty<OUString>(xOuter, "Content"));
     163             : 
     164           2 :     uno::Reference<beans::XPropertySet> xInner(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 4), "TextField"), uno::UNO_QUERY);
     165           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content"));
     166           1 : }
     167             : 
     168          14 : DECLARE_RTFEXPORT_TEST(testMathAccents, "math-accents.rtf")
     169             : {
     170           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     171           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}");
     172           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     173           2 : }
     174             : 
     175          13 : DECLARE_RTFEXPORT_TEST(testMathEqarray, "math-eqarray.rtf")
     176             : {
     177           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     178           2 :     OUString aExpected("y = left lbrace stack { 0, x < 0 # 1, x = 0 # {x} ^ {2} , x > 0 } right none");
     179           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     180           1 : }
     181             : 
     182          14 : DECLARE_RTFEXPORT_TEST(testMathD, "math-d.rtf")
     183             : {
     184           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     185           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 )");
     186           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     187           2 : }
     188             : 
     189          13 : DECLARE_RTFEXPORT_TEST(testMathEscaping, "math-escaping.rtf")
     190             : {
     191           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     192           2 :     OUString aExpected("\xc3\xa1 \\{", 5, RTL_TEXTENCODING_UTF8);
     193           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     194           1 : }
     195             : 
     196          13 : DECLARE_RTFEXPORT_TEST(testMathLim, "math-lim.rtf")
     197             : {
     198           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     199           2 :     OUString aExpected("lim from {x \xe2\x86\x92 1} {x}", 22, RTL_TEXTENCODING_UTF8);
     200           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     201           1 : }
     202             : 
     203          14 : DECLARE_RTFEXPORT_TEST(testMathMatrix, "math-matrix.rtf")
     204             : {
     205           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     206           4 :     OUString aExpected("left [matrix {1 # 2 ## 3 # 4} right ]");
     207           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     208           2 : }
     209             : 
     210          14 : DECLARE_RTFEXPORT_TEST(testMathBox, "math-mbox.rtf")
     211             : {
     212           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     213           4 :     OUString aExpected("a");
     214           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     215           2 : }
     216             : 
     217          13 : DECLARE_RTFEXPORT_TEST(testMathMso2007, "math-mso2007.rtf")
     218             : {
     219           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     220           2 :     OUString aExpected("A = \xcf\x80 {r} ^ {2}", 16, RTL_TEXTENCODING_UTF8);
     221           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     222             : 
     223           1 :     aActual = getFormula(getRun(getParagraph(2), 1));
     224           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);
     225           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     226             : 
     227           1 :     aActual = getFormula(getRun(getParagraph(3), 1));
     228           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);
     229           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     230             : 
     231           1 :     aActual = getFormula(getRun(getParagraph(4), 1));
     232           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,
     233           1 :             RTL_TEXTENCODING_UTF8);
     234           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     235             : 
     236           1 :     aActual = getFormula(getRun(getParagraph(5), 1));
     237           1 :     aExpected = "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}";
     238           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     239             : 
     240           1 :     aActual = getFormula(getRun(getParagraph(6), 1));
     241           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);
     242           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     243             : 
     244           1 :     aActual = getFormula(getRun(getParagraph(7), 1));
     245           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);
     246           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     247             : 
     248           1 :     aActual = getFormula(getRun(getParagraph(8), 1));
     249           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);
     250           1 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     251             : 
     252           1 :     aActual = getFormula(getRun(getParagraph(9), 1));
     253           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);
     254           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     255           1 : }
     256             : 
     257          13 : DECLARE_RTFEXPORT_TEST(testMathNary, "math-nary.rtf")
     258             : {
     259           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     260           2 :     OUString aExpected("lllint from {1} to {2} {x + 1} prod from {a} {b} sum to {2} {x}");
     261           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     262           1 : }
     263             : 
     264          14 : DECLARE_RTFEXPORT_TEST(testMathLimupp, "math-limupp.rtf")
     265             : {
     266           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     267           2 :     CPPUNIT_ASSERT_EQUAL(OUString("{abcd} overbrace {4}"), aActual);
     268             : 
     269           2 :     aActual = getFormula(getRun(getParagraph(2), 1));
     270           2 :     CPPUNIT_ASSERT_EQUAL(OUString("{xyz} underbrace {3}"), aActual);
     271           2 : }
     272             : 
     273          14 : DECLARE_RTFEXPORT_TEST(testMathStrikeh, "math-strikeh.rtf")
     274             : {
     275           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     276           2 :     CPPUNIT_ASSERT_EQUAL(OUString("overstrike {abc}"), aActual);
     277           2 : }
     278             : 
     279          14 : DECLARE_RTFEXPORT_TEST(testMathPlaceholders, "math-placeholders.rtf")
     280             : {
     281           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     282           2 :     CPPUNIT_ASSERT_EQUAL(OUString("sum from <?> to <?> <?>"), aActual);
     283           2 : }
     284             : 
     285          13 : DECLARE_RTFEXPORT_TEST(testMathRad, "math-rad.rtf")
     286             : {
     287           1 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     288           1 :     CPPUNIT_ASSERT_EQUAL(OUString("sqrt {4} nroot {3} {x + 1}"), aActual);
     289           1 : }
     290             : 
     291          14 : DECLARE_RTFEXPORT_TEST(testMathSepchr, "math-sepchr.rtf")
     292             : {
     293           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     294           2 :     CPPUNIT_ASSERT_EQUAL(OUString("AxByBzC"), aActual);
     295           2 : }
     296             : 
     297          14 : DECLARE_RTFEXPORT_TEST(testMathSubscripts, "math-subscripts.rtf")
     298             : {
     299           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     300           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}");
     301           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     302           2 : }
     303             : 
     304          13 : DECLARE_RTFEXPORT_TEST(testMathVerticalstacks, "math-vertical-stacks.rtf")
     305             : {
     306           1 :     CPPUNIT_ASSERT_EQUAL(OUString("{a} over {b}"), getFormula(getRun(getParagraph(1), 1)));
     307           1 :     CPPUNIT_ASSERT_EQUAL(OUString("{a} / {b}"), getFormula(getRun(getParagraph(2), 1)));
     308           1 :     CPPUNIT_ASSERT_EQUAL(OUString("stack { a # b }"), getFormula(getRun(getParagraph(3), 1)));
     309           1 :     CPPUNIT_ASSERT_EQUAL(OUString("stack { a # stack { b # c } }"), getFormula(getRun(getParagraph(4), 1)));
     310           1 : }
     311             : 
     312          13 : DECLARE_RTFEXPORT_TEST(testMathRuns, "math-runs.rtf")
     313             : {
     314             :     // was [](){}, i.e. first curly bracket had an incorrect position
     315           1 :     CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"), getFormula(getRun(getParagraph(1), 1)));
     316           1 : }
     317             : 
     318          13 : DECLARE_RTFEXPORT_TEST(testFdo53113, "fdo53113.odt")
     319             : {
     320             :     /*
     321             :      * The problem was that a custom shape was missings its second (and all the other remaining) coordinates.
     322             :      *
     323             :      * oShape = ThisComponent.DrawPage(0)
     324             :      * oPathPropVec = oShape.CustomShapeGeometry(1).Value
     325             :      * oCoordinates = oPathPropVec(0).Value
     326             :      * xray oCoordinates(1).First.Value ' 535
     327             :      * xray oCoordinates(1).Second.Value ' 102
     328             :      */
     329             : 
     330           1 :     uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(getShape(1), "CustomShapeGeometry");
     331           2 :     uno::Sequence<beans::PropertyValue> aPathProps;
     332           4 :     for (int i = 0; i < aProps.getLength(); ++i)
     333             :     {
     334           3 :         const beans::PropertyValue& rProp = aProps[i];
     335           3 :         if (rProp.Name == "Path")
     336           1 :             rProp.Value >>= aPathProps;
     337             :     }
     338           2 :     uno::Sequence<drawing::EnhancedCustomShapeParameterPair> aPairs;
     339           3 :     for (int i = 0; i < aPathProps.getLength(); ++i)
     340             :     {
     341           2 :         const beans::PropertyValue& rProp = aPathProps[i];
     342           2 :         if (rProp.Name == "Coordinates")
     343           1 :             rProp.Value >>= aPairs;
     344             :     }
     345           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(16), aPairs.getLength());
     346           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(535), aPairs[1].First.Value.get<sal_Int32>());
     347           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(102), aPairs[1].Second.Value.get<sal_Int32>());
     348           1 : }
     349             : 
     350          13 : DECLARE_RTFEXPORT_TEST(testFdo55939, "fdo55939.odt")
     351             : {
     352             :     // The problem was that the exported RTF was invalid.
     353             :     // Also, the 'Footnote text.' had an additional newline at its end.
     354           1 :     uno::Reference<text::XTextRange> xParagraph(getParagraph(1));
     355           1 :     getRun(xParagraph, 1, "Main text before footnote.");
     356             :     // Why the tab has to be removed here?
     357           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Footnote text."),
     358           1 :             getProperty< uno::Reference<text::XTextRange> >(getRun(xParagraph, 2), "Footnote")->getText()->getString().replaceAll("\t", ""));
     359           1 :     getRun(xParagraph, 3, " Text after the footnote."); // However, this leading space is intentional and OK.
     360           1 : }
     361             : 
     362          13 : DECLARE_RTFEXPORT_TEST(testTextFrames, "textframes.odt")
     363             : {
     364             :     // The output was simply invalid, so let's check if all 3 frames were imported back.
     365           1 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     366           2 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     367           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount());
     368           1 : }
     369             : 
     370          13 : DECLARE_RTFEXPORT_TEST(testFdo53604, "fdo53604.odt")
     371             : {
     372             :     // Invalid output on empty footnote.
     373           1 :     uno::Reference<text::XFootnotesSupplier> xFootnotesSupplier(mxComponent, uno::UNO_QUERY);
     374           2 :     uno::Reference<container::XIndexAccess> xFootnotes(xFootnotesSupplier->getFootnotes(), uno::UNO_QUERY);
     375           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xFootnotes->getCount());
     376           1 : }
     377             : 
     378          13 : DECLARE_RTFEXPORT_TEST(testFdo52286, "fdo52286.odt")
     379             : {
     380             :     // The problem was that font size wasn't reduced in sub/super script.
     381           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(1), 2), "CharEscapementHeight"));
     382           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(58), getProperty<sal_Int32>(getRun(getParagraph(2), 2), "CharEscapementHeight"));
     383           1 : }
     384             : 
     385          14 : DECLARE_RTFEXPORT_TEST(testFdo61507, "fdo61507.rtf")
     386             : {
     387             :     /*
     388             :      * Unicode-only characters in \title confused Wordpad. Once the exporter
     389             :      * was fixed to guard the problematic characters with \upr and \ud, the
     390             :      * importer didn't cope with these new keywords.
     391             :      */
     392             : 
     393           2 :     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
     394           4 :     uno::Reference<document::XDocumentProperties> xDocumentProperties(xDocumentPropertiesSupplier->getDocumentProperties());
     395           4 :     OUString aExpected = OUString("\xc3\x89\xc3\x81\xc5\x90\xc5\xb0\xe2\x88\xad", 11, RTL_TEXTENCODING_UTF8);
     396           2 :     CPPUNIT_ASSERT_EQUAL(aExpected, xDocumentProperties->getTitle());
     397             : 
     398             :     // Only "Hello.", no additional characters.
     399           4 :     CPPUNIT_ASSERT_EQUAL(6, getLength());
     400           2 : }
     401             : 
     402          14 : DECLARE_RTFEXPORT_TEST(testFdo30983, "fdo30983.rtf")
     403             : {
     404             :     // These were 'page text area', not 'entire page', i.e. both the horizontal
     405             :     // and vertical positions were incorrect.
     406           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), "HoriOrientRelation"));
     407           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(getShape(1), "VertOrientRelation"));
     408           2 : }
     409             : 
     410          13 : DECLARE_RTFEXPORT_TEST(testPlaceholder, "placeholder.odt")
     411             : {
     412             :     // Only the field text was exported, make sure we still have a field with the correct Hint text.
     413           1 :     uno::Reference<text::XTextRange> xRun(getRun(getParagraph(1), 2));
     414           1 :     CPPUNIT_ASSERT_EQUAL(OUString("TextField"), getProperty<OUString>(xRun, "TextPortionType"));
     415           2 :     uno::Reference<beans::XPropertySet> xField = getProperty< uno::Reference<beans::XPropertySet> >(xRun, "TextField");
     416           2 :     CPPUNIT_ASSERT_EQUAL(OUString("place holder"), getProperty<OUString>(xField, "Hint"));
     417           1 : }
     418             : 
     419          14 : DECLARE_RTFEXPORT_TEST(testMnor, "mnor.rtf")
     420             : {
     421             :     // \mnor wasn't handled, leading to missing quotes around "divF" and so on.
     422           2 :     OUString aActual = getFormula(getRun(getParagraph(1), 1));
     423           4 :     OUString aExpected("iiint from {V} to <?> {\"divF\"} dV = llint from {S} to <?> {\"F\" \xe2\x88\x99 \"n\" dS}", 74, RTL_TEXTENCODING_UTF8);
     424           4 :     CPPUNIT_ASSERT_EQUAL(aExpected, aActual);
     425           2 : }
     426             : 
     427          14 : DECLARE_RTFEXPORT_TEST(testI120928, "i120928.rtf")
     428             : {
     429             :     // \listpicture and \levelpicture0 was ignored, leading to missing graphic bullet in numbering.
     430           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
     431           4 :     uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
     432           4 :     uno::Sequence<beans::PropertyValue> aProps;
     433           2 :     xLevels->getByIndex(0) >>= aProps; // 1st level
     434             : 
     435           2 :     bool bIsGraphic = false;
     436          32 :     for (int i = 0; i < aProps.getLength(); ++i)
     437             :     {
     438          30 :         const beans::PropertyValue& rProp = aProps[i];
     439             : 
     440          30 :         if (rProp.Name == "NumberingType")
     441           2 :             CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>());
     442          28 :         else if (rProp.Name == "GraphicURL")
     443           2 :             bIsGraphic = true;
     444             :     }
     445           4 :     CPPUNIT_ASSERT_EQUAL(true, bIsGraphic);
     446           2 : }
     447             : 
     448          14 : DECLARE_RTFEXPORT_TEST(testBookmark, "bookmark.rtf")
     449             : {
     450           2 :     uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY);
     451           4 :     uno::Reference<text::XTextContent> xBookmark(xBookmarksSupplier->getBookmarks()->getByName("firstword"), uno::UNO_QUERY);
     452           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Hello"), xBookmark->getAnchor()->getString());
     453           2 : }
     454             : 
     455          14 : DECLARE_RTFEXPORT_TEST(testHyperlink, "hyperlink.rtf")
     456             : {
     457           2 :     CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 1, "Hello"), "HyperLinkURL"));
     458           2 :     CPPUNIT_ASSERT_EQUAL(OUString("http://en.wikipedia.org/wiki/World"), getProperty<OUString>(getRun(getParagraph(1), 2, "world"), "HyperLinkURL"));
     459           2 :     CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 3, "!"), "HyperLinkURL"));
     460           2 : }
     461             : 
     462          14 : DECLARE_RTFEXPORT_TEST(testTextFrameBorders, "textframe-borders.rtf")
     463             : {
     464           2 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     465           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     466           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
     467           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xFrame, "BackColor"));
     468             : 
     469           2 :     table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder");
     470           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aBorder.Color);
     471           2 :     CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth);
     472             : 
     473           2 :     table::ShadowFormat aShadowFormat = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat");
     474           2 :     CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location);
     475           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth);
     476           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aShadowFormat.Color);
     477           2 : }
     478             : 
     479          14 : DECLARE_RTFEXPORT_TEST(testTextframeGradient, "textframe-gradient.rtf")
     480             : {
     481           2 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     482           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     483           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
     484             : 
     485           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
     486           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
     487           2 :     awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
     488           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor);
     489           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor);
     490           2 :     CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
     491             : 
     492           2 :     xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
     493           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
     494           2 :     aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
     495           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor);
     496           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor);
     497           4 :     CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
     498           2 : }
     499             : 
     500          14 : DECLARE_RTFEXPORT_TEST(testRecordChanges, "record-changes.rtf")
     501             : {
     502             :     // \revisions wasn't imported/exported.
     503           2 :     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(mxComponent, "RecordChanges"));
     504           2 : }
     505             : 
     506          14 : DECLARE_RTFEXPORT_TEST(testTextframeTable, "textframe-table.rtf")
     507             : {
     508           2 :     uno::Reference<text::XTextRange> xTextRange(getShape(1), uno::UNO_QUERY);
     509           4 :     uno::Reference<text::XText> xText = xTextRange->getText();
     510           2 :     CPPUNIT_ASSERT_EQUAL(OUString("First para."), getParagraphOfText(1, xText)->getString());
     511           4 :     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(2, xText), uno::UNO_QUERY);
     512           2 :     CPPUNIT_ASSERT_EQUAL(OUString("A"), uno::Reference<text::XTextRange>(xTable->getCellByName("A1"), uno::UNO_QUERY)->getString());
     513           2 :     CPPUNIT_ASSERT_EQUAL(OUString("B"), uno::Reference<text::XTextRange>(xTable->getCellByName("B1"), uno::UNO_QUERY)->getString());
     514           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Last para."), getParagraphOfText(3, xText)->getString());
     515           2 : }
     516             : 
     517          14 : DECLARE_RTFEXPORT_TEST(testFdo66682, "fdo66682.rtf")
     518             : {
     519           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
     520           4 :     uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
     521           4 :     uno::Sequence<beans::PropertyValue> aProps;
     522           2 :     xLevels->getByIndex(0) >>= aProps; // 1st level
     523             : 
     524           4 :     OUString aSuffix;
     525          26 :     for (int i = 0; i < aProps.getLength(); ++i)
     526             :     {
     527          24 :         const beans::PropertyValue& rProp = aProps[i];
     528             : 
     529          24 :         if (rProp.Name == "Suffix")
     530           2 :             aSuffix = rProp.Value.get<OUString>();
     531             :     }
     532             :     // Suffix was '\0' instead of ' '.
     533           4 :     CPPUNIT_ASSERT_EQUAL(OUString(" "), aSuffix);
     534           2 : }
     535             : 
     536          14 : DECLARE_RTFEXPORT_TEST(testParaShadow, "para-shadow.rtf")
     537             : {
     538             :     // The problem was that \brdrsh was ignored.
     539           2 :     table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getParagraph(2), "ParaShadowFormat");
     540           2 :     CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
     541           2 :     CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
     542           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(TWIP_TO_MM100(60)), aShadow.ShadowWidth);
     543           2 : }
     544             : 
     545          13 : DECLARE_RTFEXPORT_TEST(testCharacterBorder, "charborder.odt")
     546             : {
     547           1 :     uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
     548             :     // RTF has just one border attribute (chbrdr) for text border so all side has
     549             :     // the same border with the same padding
     550             :     // Border
     551             :     {
     552           1 :         const table::BorderLine2 aTopBorder = getProperty<table::BorderLine2>(xRun,"CharTopBorder");
     553           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF6600,0,318,0,0,318), aTopBorder);
     554           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharLeftBorder"));
     555           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharBottomBorder"));
     556           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharRightBorder"));
     557             :     }
     558             : 
     559             :     // Padding (brsp)
     560             :     {
     561           1 :         const sal_Int32 nTopPadding = getProperty<sal_Int32>(xRun,"CharTopBorderDistance");
     562             :         // In the original ODT file the padding is 150, but the unit conversion round it down.
     563           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(141), nTopPadding);
     564           1 :         CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharLeftBorderDistance"));
     565           1 :         CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharBottomBorderDistance"));
     566           1 :         CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharRightBorderDistance"));
     567             :     }
     568             : 
     569             :     // Shadow (brdrsh)
     570             :     /* RTF use just one bool value for shadow so the next conversions
     571             :        are made during an export-import round
     572             :        color: any -> black
     573             :        location: any -> bottom-right
     574             :        width: any -> border width */
     575             :     {
     576           1 :         const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
     577           1 :         CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
     578           1 :         CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
     579           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth);
     580           1 :     }
     581           1 : }
     582             : 
     583          14 : DECLARE_RTFEXPORT_TEST(testFdo66743, "fdo66743.rtf")
     584             : {
     585           2 :     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
     586           4 :     uno::Reference<table::XCell> xCell = xTable->getCellByName("A1");
     587             :     // This was too dark, 0x7f7f7f.
     588           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xd8d8d8), getProperty<sal_Int32>(xCell, "BackColor"));
     589           2 : }
     590             : 
     591          14 : DECLARE_RTFEXPORT_TEST(testFdo68787, "fdo68787.rtf")
     592             : {
     593           2 :     uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
     594             :     // This was 0, the 'lack of \chftnsep' <-> '0 line width' mapping was missing in the RTF tokenizer / exporter.
     595           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(25), getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth"));
     596           2 : }
     597             : 
     598          14 : DECLARE_RTFEXPORT_TEST(testFdo74709, "fdo74709.rtf")
     599             : {
     600           2 :     uno::Reference<table::XCell> xCell = getCell(getParagraphOrTable(1), "B1");
     601             :     // This was 0, as top/bottom/left/right padding wasn't imported.
     602           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(TWIP_TO_MM100(360)), getProperty<sal_Int32>(xCell, "RightBorderDistance"));
     603           2 : }
     604             : 
     605          14 : DECLARE_RTFEXPORT_TEST(testRelsize, "relsize.rtf")
     606             : {
     607           2 :     uno::Reference<drawing::XShape> xShape = getShape(1);
     608           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(40), getProperty<sal_Int16>(xShape, "RelativeWidth"));
     609           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation"));
     610           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(20), getProperty<sal_Int16>(xShape, "RelativeHeight"));
     611           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation"));
     612           2 : }
     613             : 
     614          14 : DECLARE_RTFEXPORT_TEST(testLineNumbering, "linenumbering.rtf")
     615             : {
     616           2 :     uno::Reference<text::XLineNumberingProperties> xLineNumberingProperties(mxComponent, uno::UNO_QUERY_THROW);
     617           4 :     uno::Reference<beans::XPropertySet> xPropertySet = xLineNumberingProperties->getLineNumberingProperties();
     618           2 :     CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xPropertySet, "IsOn")));
     619           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(5), getProperty<sal_Int32>(xPropertySet, "Interval"));
     620           2 : }
     621             : 
     622             : #endif
     623             : 
     624           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     625             : 
     626             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10