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

Generated by: LCOV version 1.10