LCOV - code coverage report
Current view: top level - sw/qa/extras/ooxmlexport - ooxmlexport.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 1674 1680 99.6 %
Date: 2014-04-11 Functions: 1817 2020 90.0 %
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             : #if !defined(WNT)
      13             : 
      14             : #include <com/sun/star/frame/XStorable.hpp>
      15             : #include <com/sun/star/drawing/FillStyle.hpp>
      16             : #include <com/sun/star/drawing/LineJoint.hpp>
      17             : #include <com/sun/star/drawing/LineStyle.hpp>
      18             : #include <com/sun/star/drawing/XControlShape.hpp>
      19             : #include <com/sun/star/awt/Gradient.hpp>
      20             : #include <com/sun/star/style/TabStop.hpp>
      21             : #include <com/sun/star/view/XViewSettingsSupplier.hpp>
      22             : #include <com/sun/star/text/RelOrientation.hpp>
      23             : #include <com/sun/star/text/XTextFrame.hpp>
      24             : #include <com/sun/star/text/XTextTable.hpp>
      25             : #include <com/sun/star/text/XTextFramesSupplier.hpp>
      26             : #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
      27             : #include <com/sun/star/text/XTextSection.hpp>
      28             : #include <com/sun/star/style/CaseMap.hpp>
      29             : #include <com/sun/star/style/ParagraphAdjust.hpp>
      30             : #include <com/sun/star/style/LineSpacing.hpp>
      31             : #include <com/sun/star/style/LineSpacingMode.hpp>
      32             : #include <com/sun/star/view/XSelectionSupplier.hpp>
      33             : #include <com/sun/star/table/BorderLine2.hpp>
      34             : #include <com/sun/star/table/ShadowFormat.hpp>
      35             : #include <com/sun/star/text/GraphicCrop.hpp>
      36             : #include <com/sun/star/text/XPageCursor.hpp>
      37             : #include <com/sun/star/awt/FontWeight.hpp>
      38             : #include <com/sun/star/awt/FontUnderline.hpp>
      39             : #include <com/sun/star/awt/FontSlant.hpp>
      40             : #include <com/sun/star/text/WritingMode2.hpp>
      41             : #include <com/sun/star/text/WrapTextMode.hpp>
      42             : #include <com/sun/star/xml/dom/XDocument.hpp>
      43             : #include <com/sun/star/style/BreakType.hpp>
      44             : #include <unotools/tempfile.hxx>
      45             : #include <comphelper/sequenceashashmap.hxx>
      46             : #include <com/sun/star/text/XDocumentIndex.hpp>
      47             : #include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
      48             : #include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
      49             : #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
      50             : #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
      51             : #include <com/sun/star/drawing/Hatch.hpp>
      52             : 
      53             : #include <string>
      54             : 
      55         402 : class Test : public SwModelTestBase
      56             : {
      57             : public:
      58         402 :     Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
      59             : 
      60             : protected:
      61             :     /**
      62             :      * Blacklist handling
      63             :      */
      64         201 :     bool mustTestImportOf(const char* filename) const SAL_OVERRIDE {
      65             :         const char* aBlacklist[] = {
      66             :             "math-escape.docx",
      67             :             "math-mso2k7.docx",
      68             :             "ImageCrop.docx",
      69             :             "test_GIF_ImageCrop.docx",
      70             :             "test_PNG_ImageCrop.docx"
      71         201 :         };
      72         201 :         std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist));
      73             : 
      74             :         // If the testcase is stored in some other format, it's pointless to test.
      75         201 :         return (OString(filename).endsWith(".docx") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end());
      76             :     }
      77             : };
      78             : 
      79             : #if 1
      80             : #define DECLARE_OOXMLEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, Test)
      81             : 
      82             : // For testing during development of a tast, you want to use
      83             : // DECLARE_OOXMLEXPORT_TEST_ONLY, and change the above to #if 0
      84             : // Of course, don't forget to set back to #if 1 when you are done :-)
      85             : #else
      86             : #define DECLARE_OOXMLEXPORT_TEST_ONLY(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, Test)
      87             : 
      88             : #undef DECLARE_OOXMLEXPORT_TEST
      89             : #define DECLARE_OOXMLEXPORT_TEST(TestName, filename) class disabled##TestName : public Test { void disabled(); }; void disabled##TestName::disabled()
      90             : #endif
      91             : 
      92          14 : DECLARE_OOXMLEXPORT_TEST(testZoom, "zoom.docx")
      93             : {
      94           2 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
      95           3 :     uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
      96           3 :     uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings());
      97           2 :     sal_Int16 nValue = 0;
      98           2 :     xPropertySet->getPropertyValue("ZoomValue") >>= nValue;
      99           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue);
     100             : 
     101             :     // Validation test: order of elements were wrong.
     102           2 :     xmlDocPtr pXmlDoc = parseExport("word/styles.xml");
     103           2 :     if (!pXmlDoc)
     104           3 :         return;
     105             :     // Order was: rsid, next.
     106           1 :     int nNext = getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "next");
     107           1 :     int nRsid = getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "rsid");
     108           1 :     CPPUNIT_ASSERT(nNext < nRsid);
     109             : 
     110           1 :     pXmlDoc = parseExport("docProps/app.xml");
     111             :     // One paragraph in the document.
     112           2 :     assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Paragraphs", "1");
     113             : }
     114             : 
     115          13 : DECLARE_OOXMLEXPORT_TEST(defaultTabStopNotInStyles, "empty.odt")
     116             : {
     117             : // The default tab stop was mistakenly exported to a style.
     118             : // xray ThisComponent.StyleFamilies(1)(0).ParaTabStop
     119           1 :     uno::Reference< container::XNameAccess > paragraphStyles = getStyles( "ParagraphStyles" );
     120           2 :     uno::Reference< beans::XPropertySet > properties( paragraphStyles->getByName( "Standard" ), uno::UNO_QUERY );
     121             :     uno::Sequence< style::TabStop > stops = getProperty< uno::Sequence< style::TabStop > >(
     122           2 :         paragraphStyles->getByName( "Standard" ), "ParaTabStops" );
     123             : // There actually be be one tab stop, but it will be the default.
     124           1 :     CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(1), stops.getLength());
     125           2 :     CPPUNIT_ASSERT_EQUAL( style::TabAlign_DEFAULT, stops[ 0 ].Alignment );
     126           1 : }
     127             : 
     128          14 : DECLARE_OOXMLEXPORT_TEST(testFdo38244, "fdo38244.docx")
     129             : {
     130             :     /*
     131             :      * Comments attached to a range was imported without the range, check for the annotation mark start/end positions.
     132             :      *
     133             :      * oParas = ThisComponent.Text.createEnumeration
     134             :      * oPara = oParas.nextElement
     135             :      * oRuns = oPara.createEnumeration
     136             :      * oRun = oRuns.nextElement
     137             :      * oRun = oRuns.nextElement 'Annotation
     138             :      * oRun = oRuns.nextElement
     139             :      * oRun = oRuns.nextElement 'AnnotationEnd
     140             :      * xray oRun.TextPortionType
     141             :      */
     142           2 :     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
     143           4 :     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
     144           4 :     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
     145           4 :     uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
     146           4 :     uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
     147           2 :     xRunEnum->nextElement();
     148           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
     149           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(xPropertySet, "TextPortionType"));
     150           2 :     xRunEnum->nextElement();
     151           2 :     xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
     152           2 :     CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(xPropertySet, "TextPortionType"));
     153             : 
     154             :     /*
     155             :      * Initials were not imported.
     156             :      *
     157             :      * oFields = ThisComponent.TextFields.createEnumeration
     158             :      * oField = oFields.nextElement
     159             :      * xray oField.Initials
     160             :      */
     161           4 :     uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
     162           4 :     uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
     163           4 :     uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
     164           2 :     xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY);
     165           2 :     CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials"));
     166             : 
     167             :     /*
     168             :      * There was a fake empty paragraph at the end of the comment text.
     169             :      *
     170             :      * oFields = ThisComponent.TextFields.createEnumeration
     171             :      * oField = oFields.nextElement
     172             :      * oParas = oField.TextRange.createEnumeration
     173             :      * oPara = oParas.nextElement
     174             :      * oPara = oParas.nextElement
     175             :      */
     176             : 
     177           2 :     xParaEnumAccess.set(getProperty< uno::Reference<container::XEnumerationAccess> >(xPropertySet, "TextRange"), uno::UNO_QUERY);
     178           2 :     xParaEnum = xParaEnumAccess->createEnumeration();
     179           2 :     xParaEnum->nextElement();
     180           2 :     bool bCaught = false;
     181             :     try
     182             :     {
     183           2 :         xParaEnum->nextElement();
     184             :     }
     185           4 :     catch (container::NoSuchElementException&)
     186             :     {
     187           2 :         bCaught = true;
     188             :     }
     189           4 :     CPPUNIT_ASSERT_EQUAL(true, bCaught);
     190           2 : }
     191             : 
     192          13 : DECLARE_OOXMLEXPORT_TEST(testCommentsNested, "comments-nested.odt")
     193             : {
     194           1 :     uno::Reference<beans::XPropertySet> xOuter(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField"), uno::UNO_QUERY);
     195           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Outer"), getProperty<OUString>(xOuter, "Content"));
     196             : 
     197           2 :     uno::Reference<beans::XPropertySet> xInner(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 4), "TextField"), uno::UNO_QUERY);
     198           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content"));
     199           1 : }
     200             : 
     201          13 : DECLARE_OOXMLEXPORT_TEST(testMathEscape, "math-escape.docx")
     202             : {
     203           1 :     CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"), getFormula(getRun(getParagraph(1), 1)));
     204           1 : }
     205             : 
     206          13 : DECLARE_OOXMLEXPORT_TEST(testFdo51034, "fdo51034.odt")
     207             : {
     208             :     // The problem was that the 'l' param of the HYPERLINK field was parsed with = "#", not += "#".
     209           1 :     CPPUNIT_ASSERT_EQUAL(OUString("http://Www.google.com/#a"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL"));
     210           1 : }
     211             : 
     212             : // Construct the expected formula from UTF8, as there may be such characters.
     213             : // Remove all spaces, as LO export/import may change that.
     214             : // Replace symbol - (i.e. U+2212) with ASCII - , LO does this change and it shouldn't matter.
     215             : #define CHECK_FORMULA( expected, actual ) \
     216             :     CPPUNIT_ASSERT_EQUAL( \
     217             :         OUString( expected, strlen( expected ), RTL_TEXTENCODING_UTF8 ) \
     218             :             .replaceAll( " ", "" ).replaceAll( OUString( "\xe2\x88\x92", strlen( "\xe2\x88\x92" ), RTL_TEXTENCODING_UTF8 ), "-" ), \
     219             :         OUString( actual ).replaceAll( " ", "" ).replaceAll( OUString( "\xe2\x88\x92", strlen( "\xe2\x88\x92" ), RTL_TEXTENCODING_UTF8 ), "-" ))
     220             : 
     221          14 : DECLARE_OOXMLEXPORT_TEST(testMathAccents, "math-accents.docx")
     222             : {
     223           4 :     CHECK_FORMULA(
     224             :         "acute {a} grave {a} check {a} breve {a} circle {a} widevec {a} widetilde {a}"
     225             :             " widehat {a} dot {a} widevec {a} widevec {a} widetilde {a} underline {a}",
     226           2 :         getFormula( getRun( getParagraph( 1 ), 1 )));
     227           2 : }
     228             : 
     229          14 : DECLARE_OOXMLEXPORT_TEST(testMathD, "math-d.docx")
     230             : {
     231           2 :     CHECK_FORMULA( "left (x mline y mline z right )", getFormula( getRun( getParagraph( 1 ), 1 )));
     232           2 :     CHECK_FORMULA( "left (1 right )", getFormula( getRun( getParagraph( 1 ), 2 )));
     233           2 :     CHECK_FORMULA( "left [2 right ]", getFormula( getRun( getParagraph( 1 ), 3 )));
     234           2 :     CHECK_FORMULA( "left ldbracket 3 right rdbracket", getFormula( getRun( getParagraph( 1 ), 4 )));
     235           2 :     CHECK_FORMULA( "left lline 4 right rline", getFormula( getRun( getParagraph( 1 ), 5 )));
     236           2 :     CHECK_FORMULA( "left ldline 5 right rdline", getFormula( getRun( getParagraph( 1 ), 6 )));
     237           2 :     CHECK_FORMULA( "left langle 6 right rangle", getFormula( getRun( getParagraph( 1 ), 7 )));
     238           2 :     CHECK_FORMULA( "left langle a mline b right rangle", getFormula( getRun( getParagraph( 1 ), 8 )));
     239           2 :     CHECK_FORMULA( "left ({x} over {y} right )", getFormula( getRun( getParagraph( 1 ), 9 )));
     240           2 : }
     241             : 
     242          14 : DECLARE_OOXMLEXPORT_TEST(testMathEscaping, "math-escaping.docx")
     243             : {
     244           2 :     CHECK_FORMULA( "\xe2\x88\x92 \xe2\x88\x9e < x < \xe2\x88\x9e", getFormula( getRun( getParagraph( 1 ), 1 )));
     245           2 : }
     246             : 
     247          14 : DECLARE_OOXMLEXPORT_TEST(testMathLim, "math-lim.docx")
     248             : {
     249           2 :     CHECK_FORMULA( "lim from {x \xe2\x86\x92 1} {x}", getFormula( getRun( getParagraph( 1 ), 1 )));
     250           2 : }
     251             : 
     252          14 : DECLARE_OOXMLEXPORT_TEST(testMathMalformedXml, "math-malformed_xml.docx")
     253             : {
     254           2 :     CPPUNIT_ASSERT_EQUAL( 0, getLength());
     255           2 : }
     256             : 
     257          14 : DECLARE_OOXMLEXPORT_TEST(testMathMatrix, "math-matrix.docx")
     258             : {
     259           2 :     CHECK_FORMULA( "left [matrix {1 # 2 ## 3 # 4} right ]", getFormula( getRun( getParagraph( 1 ), 1 )));
     260           2 : }
     261             : 
     262          13 : DECLARE_OOXMLEXPORT_TEST(testMathMso2k7, "math-mso2k7.docx")
     263             : {
     264           1 :     CHECK_FORMULA( "A = \xcf\x80 {r} ^ {2}", getFormula( getRun( getParagraph( 1 ), 1 )));
     265             : // TODO check the stack/binom difference
     266             : //    CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (binom {n} {k} right ) {x} ^ {k} {a} ^ {n-k}}",
     267           2 :     CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (stack {n # k} right ) {x} ^ {k} {a} ^ {n-k}}",
     268           1 :         getFormula( getRun( getParagraph( 2 ), 1 )));
     269           2 :     CHECK_FORMULA( "{left (1+x right )} ^ {n} =1+ {nx} over {1!} + {n left (n-1 right ) {x} ^ {2}} over {2!} +\xe2\x80\xa6",
     270           1 :         getFormula( getRun( getParagraph( 3 ), 1 )));
     271             : // TODO check (cos/sin miss {})
     272             : //    CHECK_FORMULA( "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 )}",
     273           2 :     CHECK_FORMULA( "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 )}",
     274           1 :         getFormula( getRun( getParagraph( 4 ), 1 )));
     275           1 :     CHECK_FORMULA( "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}", getFormula( getRun( getParagraph( 5 ), 1 )));
     276           2 :     CHECK_FORMULA( "x = {- b \xc2\xb1 sqrt {{b} ^ {2} -4 ac}} over {2 a}",
     277           1 :         getFormula( getRun( getParagraph( 6 ), 1 )));
     278           2 :     CHECK_FORMULA(
     279             :         "{e} ^ {x} =1+ {x} over {1!} + {{x} ^ {2}} over {2!} + {{x} ^ {3}} over {3!} +\xe2\x80\xa6,    -\xe2\x88\x9e<x<\xe2\x88\x9e",
     280           1 :         getFormula( getRun( getParagraph( 7 ), 1 )));
     281           2 :     CHECK_FORMULA(
     282             : //        "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 )}",
     283             : // TODO check (cos/in miss {})
     284             :         "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 )",
     285           1 :         getFormula( getRun( getParagraph( 8 ), 1 )));
     286           2 :     CHECK_FORMULA(
     287             : //        "cos {\xce\xb1} + cos {\xce\xb2} =2 cos {{1} over {2} left (\xce\xb1+\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1-\xce\xb2 right )}",
     288             : // TODO check (cos/sin miss {})
     289             :         "cos \xce\xb1 + cos \xce\xb2 =2 cos {1} over {2} left (\xce\xb1+\xce\xb2 right ) cos {1} over {2} left (\xce\xb1-\xce\xb2 right )",
     290           1 :         getFormula( getRun( getParagraph( 9 ), 1 )));
     291           1 : }
     292             : 
     293          14 : DECLARE_OOXMLEXPORT_TEST(testMathNary, "math-nary.docx")
     294             : {
     295           2 :     CHECK_FORMULA( "lllint from {1} to {2} {x + 1}", getFormula( getRun( getParagraph( 1 ), 1 )));
     296           2 :     CHECK_FORMULA( "prod from {a} {b}", getFormula( getRun( getParagraph( 1 ), 2 )));
     297           2 :     CHECK_FORMULA( "sum to {2} {x}", getFormula( getRun( getParagraph( 1 ), 3 )));
     298           2 : }
     299             : 
     300          14 : DECLARE_OOXMLEXPORT_TEST(testMathOverbraceUnderbrace, "math-overbrace_underbrace.docx")
     301             : {
     302           2 :     CHECK_FORMULA( "{abcd} overbrace {4}", getFormula( getRun( getParagraph( 1 ), 1 )));
     303           2 :     CHECK_FORMULA( "{xyz} underbrace {3}", getFormula( getRun( getParagraph( 2 ), 1 )));
     304           2 : }
     305             : 
     306          14 : DECLARE_OOXMLEXPORT_TEST(testMathOverstrike, "math-overstrike.docx")
     307             : {
     308           2 :     CHECK_FORMULA( "overstrike {abc}", getFormula( getRun( getParagraph( 1 ), 1 )));
     309           2 : }
     310             : 
     311          14 : DECLARE_OOXMLEXPORT_TEST(testMathPlaceholders, "math-placeholders.docx")
     312             : {
     313           2 :     CHECK_FORMULA( "sum from <?> to <?> <?>", getFormula( getRun( getParagraph( 1 ), 1 )));
     314           2 : }
     315             : 
     316          14 : DECLARE_OOXMLEXPORT_TEST(testMathRad, "math-rad.docx")
     317             : {
     318           2 :     CHECK_FORMULA( "sqrt {4}", getFormula( getRun( getParagraph( 1 ), 1 )));
     319           2 :     CHECK_FORMULA( "nroot {3} {x + 1}", getFormula( getRun( getParagraph( 1 ), 2 )));
     320           2 : }
     321             : 
     322          14 : DECLARE_OOXMLEXPORT_TEST(testMathSubscripts, "math-subscripts.docx")
     323             : {
     324           2 :     CHECK_FORMULA( "{x} ^ {y} + {e} ^ {x}", getFormula( getRun( getParagraph( 1 ), 1 )));
     325           2 :     CHECK_FORMULA( "{x} ^ {b}", getFormula( getRun( getParagraph( 1 ), 2 )));
     326           2 :     CHECK_FORMULA( "{x} rsub {b}", getFormula( getRun( getParagraph( 1 ), 3 )));
     327           2 :     CHECK_FORMULA( "{a} rsub {c} rsup {b}", getFormula( getRun( getParagraph( 1 ), 4 )));
     328           2 :     CHECK_FORMULA( "{x} lsub {2} lsup {1}", getFormula( getRun( getParagraph( 1 ), 5 )));
     329           4 :     CHECK_FORMULA( "{{x csup {6} csub {3}} lsub {4} lsup {5}} rsub {2} rsup {1}",
     330           2 :         getFormula( getRun( getParagraph( 1 ), 6 )));
     331           2 : }
     332             : 
     333          14 : DECLARE_OOXMLEXPORT_TEST(testMathVerticalStacks, "math-vertical_stacks.docx")
     334             : {
     335           2 :     CHECK_FORMULA( "{a} over {b}", getFormula( getRun( getParagraph( 1 ), 1 )));
     336           2 :     CHECK_FORMULA( "{a} / {b}", getFormula( getRun( getParagraph( 2 ), 1 )));
     337             : // TODO check these
     338             : //    CHECK_FORMULA( "binom {a} {b}", getFormula( getRun( getParagraph( 3 ), 1 )));
     339             : //    CHECK_FORMULA( "binom {a} {binom {b} {c}}", getFormula( getRun( getParagraph( 4 ), 1 )));
     340           2 : }
     341             : 
     342          13 : DECLARE_OOXMLEXPORT_TEST(testTable, "table.odt")
     343             : {
     344             :     // Validation test: order of elements were wrong.
     345           1 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     346           1 :     if (!pXmlDoc)
     347           1 :         return;
     348             :     // Order was: insideH, end, insideV.
     349           1 :     int nEnd = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "end");
     350           1 :     int nInsideH = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "insideH");
     351           1 :     int nInsideV = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "insideV");
     352           1 :     CPPUNIT_ASSERT(nEnd < nInsideH);
     353           1 :     CPPUNIT_ASSERT(nInsideH < nInsideV);
     354             : }
     355             : 
     356          14 : DECLARE_OOXMLEXPORT_TEST(testTablePosition, "table-position.docx")
     357             : {
     358           2 :     sal_Int32 xCoordsFromOffice[] = { 2500, -1000, 0, 0 };
     359           2 :     sal_Int32 cellLeftMarginFromOffice[] = { 250, 100, 0, 0 };
     360             : 
     361           2 :     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
     362           4 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
     363           4 :     uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
     364             : 
     365          10 :     for (int i=0; i<4; i++) {
     366           8 :         uno::Reference<text::XTextTable> xTable1 (xTables->getByIndex(i), uno::UNO_QUERY);
     367             :         // Verify X coord
     368          16 :         uno::Reference<view::XSelectionSupplier> xCtrl(xModel->getCurrentController(), uno::UNO_QUERY);
     369           8 :         xCtrl->select(uno::makeAny(xTable1));
     370          16 :         uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xCtrl, uno::UNO_QUERY);
     371          16 :         uno::Reference<text::XTextViewCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
     372           8 :         awt::Point pos = xCursor->getPosition();
     373          16 :         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Incorrect X coord computed from docx",
     374           8 :             xCoordsFromOffice[i], pos.X, 1);
     375             : 
     376             :         // Verify left margin of 1st cell :
     377             :         //  * Office left margins are measured relative to the right of the border
     378             :         //  * LO left spacing is measured from the center of the border
     379          16 :         uno::Reference<table::XCell> xCell = xTable1->getCellByName("A1");
     380          16 :         uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW);
     381           8 :         sal_Int32 aLeftMargin = -1;
     382           8 :         xPropSet->getPropertyValue("LeftBorderDistance") >>= aLeftMargin;
     383          16 :         uno::Any aLeftBorder = xPropSet->getPropertyValue("LeftBorder");
     384           8 :         table::BorderLine2 aLeftBorderLine;
     385           8 :         aLeftBorder >>= aLeftBorderLine;
     386          16 :         CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Incorrect left spacing computed from docx cell margin",
     387           8 :             cellLeftMarginFromOffice[i], aLeftMargin - 0.5 * aLeftBorderLine.LineWidth, 1);
     388          10 :     }
     389           2 : }
     390             : 
     391          14 : DECLARE_OOXMLEXPORT_TEST(testFdo47669, "fdo47669.docx")
     392             : {
     393             :     /*
     394             :      * Problem: we created imbalance </w:hyperlink> which shouldn't be there,
     395             :      * resulting in loading error: missing last character of hyperlink text
     396             :      * and content after it wasn't loaded.
     397             :      */
     398           2 :     getParagraph(1, "This is a hyperlink with anchor. Also, this sentence should be seen.");
     399           2 :     getRun(getParagraph(1), 2, "hyperlink with anchor");
     400           2 :     CPPUNIT_ASSERT_EQUAL(OUString("http://www.google.com/#a"), getProperty<OUString>(getRun(getParagraph(1), 2), "HyperLinkURL"));
     401           2 : }
     402             : 
     403             : struct SingleLineBorders {
     404             :     sal_Int16 top, bottom, left, right;
     405          48 :     SingleLineBorders(int t=0, int b=0, int l=0, int r=0)
     406          48 :         : top(t), bottom(b), left(l), right(r) {}
     407          96 :     sal_Int16 getBorder(int i) const
     408             :     {
     409          96 :         switch (i) {
     410          24 :             case 0: return top;
     411          24 :             case 1: return bottom;
     412          24 :             case 2: return left;
     413          24 :             case 3: return right;
     414           0 :             default: assert(false); return 0;
     415             :         }
     416             :     }
     417             : };
     418          14 : DECLARE_OOXMLEXPORT_TEST(testTableBorders, "table-borders.docx")
     419             : {
     420           2 :     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
     421           4 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
     422           4 :     uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY);
     423           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
     424           4 :     uno::Reference<text::XTextTable> xTextTable (xTables->getByIndex(0), uno::UNO_QUERY);
     425             : 
     426           4 :     std::map<OUString, SingleLineBorders> cellBorders;
     427           2 :     cellBorders[OUString("A1")] = SingleLineBorders(106, 106, 106, 106);
     428           2 :     cellBorders[OUString("B1")] = SingleLineBorders(106, 0, 106, 35);
     429           2 :     cellBorders[OUString("C1")] = SingleLineBorders(106, 106, 35, 106);
     430           2 :     cellBorders[OUString("A2")] = SingleLineBorders(106, 35, 106, 0);
     431           2 :     cellBorders[OUString("B2")] = SingleLineBorders(0, 0, 0, 0);
     432           2 :     cellBorders[OUString("C2")] = SingleLineBorders(106, 106, 0, 106);
     433           2 :     cellBorders[OUString("A3")] = SingleLineBorders(35, 35, 106, 106);
     434           2 :     cellBorders[OUString("B3")] = SingleLineBorders(0, 106, 106, 106);
     435           2 :     cellBorders[OUString("C3")] = SingleLineBorders(106, 106, 106, 106);
     436           2 :     cellBorders[OUString("A4")] = SingleLineBorders(35, 106, 106, 35);
     437           2 :     cellBorders[OUString("B4")] = SingleLineBorders(106, 106, 35, 106);
     438           2 :     cellBorders[OUString("C4")] = SingleLineBorders(106, 106, 106, 106);
     439             : 
     440             :     const OUString borderNames[] = {
     441             :         OUString("TopBorder"),
     442             :         OUString("BottomBorder"),
     443             :         OUString("LeftBorder"),
     444             :         OUString("RightBorder"),
     445           4 :     };
     446             : 
     447           4 :     uno::Sequence<OUString> const cells = xTextTable->getCellNames();
     448           2 :     sal_Int32 nLength = cells.getLength();
     449           2 :     CPPUNIT_ASSERT_EQUAL((sal_Int32)cellBorders.size(), nLength);
     450             : 
     451          26 :     for (sal_Int32 i = 0; i < nLength; ++i)
     452             :     {
     453          24 :         uno::Reference<table::XCell> xCell = xTextTable->getCellByName(cells[i]);
     454          48 :         uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW);
     455          24 :         const SingleLineBorders& borders = cellBorders[cells[i]];
     456             : 
     457         120 :         for (sal_Int32 j = 0; j < 4; ++j)
     458             :         {
     459          96 :             uno::Any aBorder = xPropSet->getPropertyValue(borderNames[j]);
     460          96 :             table::BorderLine aBorderLine;
     461          96 :             if (aBorder >>= aBorderLine)
     462             :             {
     463          96 :                 std::stringstream message;
     464          96 :                 message << cells[i] << "'s " << borderNames[j] << " is incorrect";
     465         192 :                 CPPUNIT_ASSERT_EQUAL_MESSAGE(message.str(),
     466         192 :                         borders.getBorder(j), aBorderLine.OuterLineWidth);
     467             :             }
     468          96 :         }
     469          26 :     }
     470           2 : }
     471             : 
     472          13 : DECLARE_OOXMLEXPORT_TEST(testFdo51550, "fdo51550.odt")
     473             : {
     474             :     // The problem was that we lacked the fallback to export the replacement graphic for OLE objects.
     475           1 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
     476           2 :     uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
     477           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount());
     478           1 : }
     479             : 
     480          14 : DECLARE_OOXMLEXPORT_TEST(testN789482, "n789482.docx")
     481             : {
     482             :     // The problem was that w:del was exported before w:hyperlink, resulting in an invalid XML.
     483           2 :     uno::Reference<text::XTextRange> xParagraph = getParagraph(1);
     484           2 :     getRun(xParagraph, 1, "Before. ");
     485             : 
     486           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Delete"), getProperty<OUString>(getRun(xParagraph, 2), "RedlineType"));
     487           2 :     CPPUNIT_ASSERT_EQUAL(sal_True, getProperty<sal_Bool>(getRun(xParagraph, 2), "IsStart"));
     488             : 
     489           2 :     getRun(xParagraph, 3, "www.test.com");
     490           2 :     CPPUNIT_ASSERT_EQUAL(OUString("http://www.test.com/"), getProperty<OUString>(getRun(xParagraph, 3), "HyperLinkURL"));
     491             : 
     492           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Delete"), getProperty<OUString>(getRun(xParagraph, 4), "RedlineType"));
     493           2 :     CPPUNIT_ASSERT_EQUAL(sal_False, getProperty<sal_Bool>(getRun(xParagraph, 4), "IsStart"));
     494             : 
     495           2 :     getRun(xParagraph, 5, " After.");
     496           2 : }
     497             : 
     498             : /*
     499             :  * doesn't work on openSUSE12.2 at least
     500             : DECLARE_OOXMLEXPORT_TEST(test1Table1Page, "1-table-1-page.docx")
     501             : {
     502             :     // 2 problem for this document after export:
     503             :     //   - invalid sectPr inserted at the beginning of the page
     504             :     //   - font of empty cell is not preserved, leading to change in rows height
     505             :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
     506             :     uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
     507             :     uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
     508             :     xCursor->jumpToLastPage();
     509             :     CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage());
     510             : }
     511             : */
     512             : 
     513          13 : DECLARE_OOXMLEXPORT_TEST(testTextFrames, "textframes.odt")
     514             : {
     515             :     // The frames were simply missing, so let's check if all 3 frames were imported back.
     516           1 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     517           2 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     518           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount());
     519           1 : }
     520             : 
     521          14 : DECLARE_OOXMLEXPORT_TEST(testTextFrameBorders, "textframe-borders.docx")
     522             : {
     523           2 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     524           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     525           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
     526           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xFrame, "BackColor"));
     527             : 
     528           2 :     table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder");
     529           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aBorder.Color);
     530           2 :     CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth);
     531             : 
     532           2 :     table::ShadowFormat aShadowFormat = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat");
     533           2 :     CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location);
     534           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth);
     535           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aShadowFormat.Color);
     536           2 : }
     537             : 
     538          14 : DECLARE_OOXMLEXPORT_TEST(testTextframeGradient, "textframe-gradient.docx")
     539             : {
     540           2 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     541           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     542           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
     543             : 
     544           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
     545           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
     546           2 :     awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
     547           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor);
     548           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor);
     549           2 :     CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
     550             : 
     551           2 :     xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
     552           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
     553           2 :     aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient");
     554           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor);
     555           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor);
     556           2 :     CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style);
     557             : 
     558             :     // Left / right margin was incorrect: the attribute was missing and we
     559             :     // didn't have the right default (had 0 instead of the below one).
     560           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xFrame, "LeftMargin"));
     561           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xFrame, "RightMargin"));
     562           2 : }
     563             : 
     564          14 : DECLARE_OOXMLEXPORT_TEST(testCellBtlr, "cell-btlr.docx")
     565             : {
     566             :     /*
     567             :      * The problem was that the exporter didn't mirror the workaround of the
     568             :      * importer, regarding the btLr text direction: the <w:textDirection
     569             :      * w:val="btLr"/> token was completely missing in the output.
     570             :      */
     571             : 
     572           2 :     xmlDocPtr pXmlDoc = parseExport();
     573           2 :     if (!pXmlDoc)
     574           3 :         return;
     575           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:textDirection", "val", "btLr");
     576             : }
     577             : 
     578          14 : DECLARE_OOXMLEXPORT_TEST(testTableStylerPrSz, "table-style-rPr-sz.docx")
     579             : {
     580             :     // Verify that font size inside the table is 20pt, despite the sz attribute in the table size.
     581             :     // Also check that other rPr attribute are used: italic, bold, underline
     582             :     // Office has the same behavior
     583           2 :     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
     584           4 :     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
     585           4 :     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
     586           4 :     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
     587           4 :     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY);
     588           4 :     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
     589           4 :     uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
     590             : 
     591           4 :     CPPUNIT_ASSERT_EQUAL(20.f, getProperty<float>(getRun(xPara, 1), "CharHeight"));
     592             : //    CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<short>(getRun(xPara, 1), "CharUnderline"));
     593             : //    CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xPara, 1), "CharWeight"));
     594             : //    CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, getProperty<awt::FontSlant>(getRun(xPara, 1), "CharPosture"));
     595           2 : }
     596             : 
     597          14 : DECLARE_OOXMLEXPORT_TEST(testMathLiteral, "math-literal.docx")
     598             : {
     599           4 :     CHECK_FORMULA( "iiint from {V} to <?> {\"div\" \"F\"}  dV= llint from {S} to <?> {\"F\" \xe2\x88\x99 \"n \" dS}",
     600           2 :         getFormula( getRun( getParagraph( 1 ), 1 )));
     601           2 : }
     602             : 
     603          13 : DECLARE_OOXMLEXPORT_TEST(testFdo48557, "fdo48557.odt")
     604             : {
     605             :     // Inner margins of the textframe wasn't exported.
     606           1 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     607           2 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     608           2 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
     609           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "LeftBorderDistance"));
     610           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "RightBorderDistance"));
     611           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TopBorderDistance"));
     612           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "BottomBorderDistance"));
     613           1 : }
     614             : 
     615          14 : DECLARE_OOXMLEXPORT_TEST(testI120928, "i120928.docx")
     616             : {
     617             :     // w:numPicBullet was ignored, leading to missing graphic bullet in numbering.
     618           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
     619           4 :     uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
     620           4 :     uno::Sequence<beans::PropertyValue> aProps;
     621           2 :     xLevels->getByIndex(0) >>= aProps; // 1st level
     622             : 
     623           2 :     bool bIsGraphic = false;
     624          32 :     for (int i = 0; i < aProps.getLength(); ++i)
     625             :     {
     626          30 :         const beans::PropertyValue& rProp = aProps[i];
     627             : 
     628          30 :         if (rProp.Name == "NumberingType")
     629           2 :             CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>());
     630          28 :         else if (rProp.Name == "GraphicURL")
     631           2 :             bIsGraphic = true;
     632             :     }
     633           4 :     CPPUNIT_ASSERT_EQUAL(true, bIsGraphic);
     634           2 : }
     635             : 
     636          14 : DECLARE_OOXMLEXPORT_TEST(testFdo64826, "fdo64826.docx")
     637             : {
     638             :     // 'Track-Changes' (Track Revisions) wasn't exported.
     639           2 :     CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(mxComponent, "RecordChanges")));
     640           2 : }
     641             : 
     642          14 : DECLARE_OOXMLEXPORT_TEST(testPageBackground, "page-background.docx")
     643             : {
     644             :     // 'Document Background' wasn't exported.
     645           2 :     uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
     646           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor"));
     647           2 : }
     648             : 
     649          13 : DECLARE_OOXMLEXPORT_TEST(testPageGraphicBackground, "page-graphic-background.odt")
     650             : {
     651             :     // No idea how the graphic background should be exported (seems there is no
     652             :     // way to do a non-tiling export to OOXML), but at least the background
     653             :     // color shouldn't be black.
     654           1 :     uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
     655           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xPageStyle, "BackColor"));
     656           1 : }
     657             : 
     658          14 : DECLARE_OOXMLEXPORT_TEST(testFdo65265, "fdo65265.docx")
     659             : {
     660             :     // Redline (tracked changes) of text formatting were not exported
     661           2 :     uno::Reference<text::XTextRange> xParagraph1 = getParagraph(1);
     662           4 :     uno::Reference<text::XTextRange> xParagraph2 = getParagraph(2);
     663             : 
     664           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty<OUString>(getRun(xParagraph1, 3), "RedlineType"));
     665           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty<OUString>(getRun(xParagraph2, 2), "RedlineType"));
     666           2 : }
     667             : 
     668          14 : DECLARE_OOXMLEXPORT_TEST(testFdo65655, "fdo65655.docx")
     669             : {
     670             :     // The problem was that the DOCX had a non-blank odd footer and a blank even footer
     671             :     // The 'Different Odd & Even Pages' was turned on
     672             :     // However - LO assumed that because the 'even' footer is blank - it should ignore the 'Different Odd & Even Pages' flag
     673             :     // So it did not import it and did not export it
     674           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
     675           2 :     sal_Bool bValue = false;
     676           2 :     xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue;
     677           2 :     CPPUNIT_ASSERT_EQUAL(false, bool(bValue));
     678           2 :     xPropertySet->getPropertyValue("FooterIsShared") >>= bValue;
     679           2 :     CPPUNIT_ASSERT_EQUAL(false, bool(bValue));
     680           2 : }
     681             : 
     682          14 : DECLARE_OOXMLEXPORT_TEST(testFDO63053, "fdo63053.docx")
     683             : {
     684           2 :     uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
     685           4 :     uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties();
     686           2 :     CPPUNIT_ASSERT_EQUAL(OUString("test1&test2"), xDocumentProperties->getTitle());
     687           4 :     CPPUNIT_ASSERT_EQUAL(OUString("test1&test2"), xDocumentProperties->getSubject());
     688           2 : }
     689             : 
     690          14 : DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx")
     691             : {
     692           2 :     uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY);
     693             :     // 1st problem: last character was missing
     694           2 :     CPPUNIT_ASSERT_EQUAL(OUString("SAMPLE"), xShape->getString());
     695             : 
     696           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY);
     697           4 :     uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xShape, "CustomShapeGeometry");
     698           2 :     bool bFound = false;
     699          16 :     for (int i = 0; i < aProps.getLength(); ++i)
     700          14 :         if (aProps[i].Name == "TextPath")
     701           2 :             bFound = true;
     702             :     // 2nd problem: v:textpath wasn't imported
     703           2 :     CPPUNIT_ASSERT_EQUAL(true, bFound);
     704             : 
     705             :     // 3rd problem: rotation angle was 315, not 45.
     706           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(45 * 100), getProperty<sal_Int32>(xShape, "RotateAngle"));
     707             : 
     708             :     // 4th problem: mso-position-vertical-relative:margin was ignored, VertOrientRelation was text::RelOrientation::FRAME.
     709           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xShape, "VertOrientRelation"));
     710             : 
     711             :     // These problems were in the exporter
     712             :     // The textpath wasn't semi-transparent.
     713           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty<sal_Int16>(xShape, "FillTransparence"));
     714             :     // The textpath had a stroke.
     715           4 :     CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, getProperty<drawing::LineStyle>(xShape, "LineStyle"));
     716           2 : }
     717             : 
     718          14 : DECLARE_OOXMLEXPORT_TEST(testFdo43093, "fdo43093.docx")
     719             : {
     720             :     // The problem was that the alignment are not exchange when the paragraph are RTL.
     721           2 :     uno::Reference<uno::XInterface> xParaRtlLeft(getParagraph( 1, "RTL Left"));
     722           2 :     sal_Int32 nRtlLeft = getProperty< sal_Int32 >( xParaRtlLeft, "ParaAdjust" );
     723             :     // test the text Direction value for the pragraph
     724           2 :     sal_Int16 nRLDir  = getProperty< sal_Int32 >( xParaRtlLeft, "WritingMode" );
     725             : 
     726           4 :     uno::Reference<uno::XInterface> xParaRtlRight(getParagraph( 3, "RTL Right"));
     727           2 :     sal_Int32 nRtlRight = getProperty< sal_Int32 >( xParaRtlRight, "ParaAdjust" );
     728           2 :     sal_Int16 nRRDir  = getProperty< sal_Int32 >( xParaRtlRight, "WritingMode" );
     729             : 
     730           4 :     uno::Reference<uno::XInterface> xParaLtrLeft(getParagraph( 5, "LTR Left"));
     731           2 :     sal_Int32 nLtrLeft = getProperty< sal_Int32 >( xParaLtrLeft, "ParaAdjust" );
     732           2 :     sal_Int16 nLLDir  = getProperty< sal_Int32 >( xParaLtrLeft, "WritingMode" );
     733             : 
     734           4 :     uno::Reference<uno::XInterface> xParaLtrRight(getParagraph( 7, "LTR Right"));
     735           2 :     sal_Int32 nLtrRight = getProperty< sal_Int32 >( xParaLtrRight, "ParaAdjust" );
     736           2 :     sal_Int16 nLRDir  = getProperty< sal_Int32 >( xParaLtrRight, "WritingMode" );
     737             : 
     738             :     // this will test the both the text direction and alignment for each paragraph
     739           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nRtlLeft);
     740           2 :     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRLDir);
     741             : 
     742           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nRtlRight);
     743           2 :     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRRDir);
     744             : 
     745           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLtrLeft);
     746           2 :     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir);
     747             : 
     748           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nLtrRight);
     749           4 :     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir);
     750           2 : }
     751             : 
     752          14 : DECLARE_OOXMLEXPORT_TEST(testFdo64238_a, "fdo64238_a.docx")
     753             : {
     754             :     // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled*
     755             :     // then LO would still import the Even footer and concatenate it to to the odd footer.
     756             :     // This case specifically is for :
     757             :     // 'Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word
     758             :     // In this case the imported footer in LO was supposed to be blank, but instead was the 'even' footer
     759           2 :     uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText");
     760           4 :     uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText );
     761           4 :     uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY);
     762           4 :     uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
     763           2 :     sal_Int32 numOfRuns = 0;
     764           8 :     while (xRunEnum->hasMoreElements())
     765             :     {
     766           4 :         uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
     767           4 :         numOfRuns++;
     768           4 :     }
     769           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), numOfRuns);
     770           2 : }
     771             : 
     772          14 : DECLARE_OOXMLEXPORT_TEST(testFdo64238_b, "fdo64238_b.docx")
     773             : {
     774             :     // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled*
     775             :     // then LO would still import the Even footer and concatenate it to to the odd footer.
     776             :     // This case specifically is for :
     777             :     // 'Non-Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word
     778             :     // In this case the imported footer in LO was supposed to be just the odd footer, but instead was the 'odd' and 'even' footers concatenated
     779           2 :     uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText");
     780           4 :     uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText );
     781           4 :     uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY);
     782           4 :     uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
     783           2 :     sal_Int32 numOfRuns = 0;
     784          14 :     while (xRunEnum->hasMoreElements())
     785             :     {
     786          10 :         uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY);
     787          10 :         numOfRuns++;
     788          10 :     }
     789           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(5), numOfRuns);
     790           2 : }
     791             : 
     792          14 : DECLARE_OOXMLEXPORT_TEST(testFdo56679, "fdo56679.docx")
     793             : {
     794             :     // The problem was that the DOCX importer and exporter did not handle the 'color' of an underline
     795             :     // (not the color of the text, the color of the underline itself)
     796           2 :     uno::Reference< text::XTextRange > xParagraph = getParagraph( 1 );
     797           4 :     uno::Reference< text::XTextRange > xText = getRun( xParagraph, 2, "This is a simple sentence.");
     798             : 
     799           2 :     CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xText, "CharUnderlineHasColor")));
     800           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), getProperty<sal_Int32>(xText, "CharUnderlineColor"));
     801           2 : }
     802             : 
     803          14 : DECLARE_OOXMLEXPORT_TEST(testFdo65400, "fdo65400.docx")
     804             : {
     805             :     // The problem was that if in Word you choose 'Character Shading' - then the text portion
     806             :     // is marked with 'w:shd val=pct15'. LO did not store this value and so when importing and exporting
     807             :     // this value was lost (and so Word did not show 'Character Shading' was on)
     808           2 :     uno::Reference< text::XTextRange > paragraph1 = getParagraph( 1 );
     809           4 :     uno::Reference< text::XTextRange > shaded = getRun( paragraph1, 2, "normal" );
     810           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 0x0026 ), getProperty< sal_Int32 >( shaded, "CharShadingValue" ));
     811           4 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 0xd8d8d8 ), getProperty< sal_Int32 >( shaded, "CharBackColor" ));
     812           2 : }
     813             : 
     814          14 : DECLARE_OOXMLEXPORT_TEST(testFdo66543, "fdo66543.docx")
     815             : {
     816             :     // The problem was that when importing DOCX with 'line numbers' - the 'start value' was imported
     817             :     // but nothing was done with it.
     818             : 
     819           2 :     uno::Reference< text::XTextRange > paragraph1 = getParagraph( 1 );
     820           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 1 ), getProperty< sal_Int32 >( paragraph1, "ParaLineNumberStartValue" ));
     821           2 : }
     822             : 
     823          13 : DECLARE_OOXMLEXPORT_TEST(testN822175, "n822175.odt")
     824             : {
     825           1 :     uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY);
     826             :     // Was text::WrapTextMode_THROUGH, due to missing Surround handling in the exporter.
     827           1 :     CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_PARALLEL, getProperty<text::WrapTextMode>(xFrame, "Surround"));
     828           1 : }
     829             : 
     830          14 : DECLARE_OOXMLEXPORT_TEST(testFdo66688, "fdo66688.docx")
     831             : {
     832             :     // The problem was that TextFrame imported and exported the wrong value for transparency
     833             :     // (was stored as 'FillTransparence' instead of 'BackColorTransparency'
     834           2 :     uno::Reference<text::XTextFramesSupplier> xFramesSupplier(mxComponent, uno::UNO_QUERY);
     835           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     836           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
     837           4 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 80 ), getProperty< sal_Int32 >( xFrame, "BackColorTransparency" ) );
     838           2 : }
     839             : 
     840          14 : DECLARE_OOXMLEXPORT_TEST(testFdo66773, "fdo66773.docx")
     841             : {
     842             :     // The problem was the line spacing was interpreted by Word as 'Multiple 1.08' if no default settings were written.
     843             :     // Now after the 'docDefaults' section is written in <styles.xml> - there is no more problem.
     844             :     // (Word does not try to calculate some arbitrary value for line spacing).
     845           2 :     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
     846           4 :     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
     847           4 :     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
     848           2 :     CPPUNIT_ASSERT(xParaEnum->hasMoreElements());
     849             : 
     850           2 :     style::LineSpacing alineSpacing = getProperty<style::LineSpacing>(xParaEnum->nextElement(), "ParaLineSpacing");
     851           2 :     CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP, alineSpacing.Mode);
     852           4 :     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(100), static_cast<sal_Int32>(alineSpacing.Height));
     853           2 : }
     854             : 
     855          13 : DECLARE_OOXMLEXPORT_TEST(testFdo58577, "fdo58577.odt")
     856             : {
     857             :     // The second frame was simply missing, so let's check if both frames were imported back.
     858           1 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     859           2 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     860           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount());
     861           1 : }
     862             : 
     863          13 : DECLARE_OOXMLEXPORT_TEST(testBnc581614, "bnc581614.doc")
     864             : {
     865           1 :     uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY);
     866           1 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
     867           1 : }
     868             : 
     869          14 : DECLARE_OOXMLEXPORT_TEST(testFdo66929, "fdo66929.docx")
     870             : {
     871             :     // The problem was that the default 'inset' attribute of the 'textbox' node was exported incorrectly.
     872             :     // A node like '<v:textbox inset="0">' was exported back as '<v:textbox inset="0pt,0pt,0pt,0pt">'
     873             :     // This is wrong because the original node denotes a specific 'left' inset, and a default 'top','right','bottom' inset
     874           2 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
     875           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
     876           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
     877           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 )  , getProperty< sal_Int32 >( xFrame, "LeftBorderDistance" ) );
     878           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty< sal_Int32 >( xFrame, "TopBorderDistance" ) );
     879           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 254 ), getProperty< sal_Int32 >( xFrame, "RightBorderDistance" ) );
     880           4 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty< sal_Int32 >( xFrame, "BottomBorderDistance" ) );
     881           2 : }
     882             : 
     883          14 : DECLARE_OOXMLEXPORT_TEST(testPageBorderSpacingExportCase2, "page-borders-export-case-2.docx")
     884             : {
     885             :     // The problem was that the exporter didn't mirror the workaround of the
     886             :     // importer, regarding the page border's spacing : the <w:pgBorders w:offsetFrom="page">
     887             :     // and the inner nodes like <w:top w:space="24" .... />
     888             :     //
     889             :     // The exporter ALWAYS exported 'w:offsetFrom="text"' even when the spacing values where too large
     890             :     // for Word to handle (larger than 31 points)
     891             : 
     892           2 :     xmlDocPtr pXmlDoc = parseExport();
     893           2 :     if (!pXmlDoc)
     894           3 :         return;
     895             : 
     896             :     // Assert the XPath expression - page borders
     897           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgBorders", "offsetFrom", "page");
     898             : 
     899             :     // Assert the XPath expression - 'left' border
     900           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgBorders/w:left", "space", "24");
     901             : 
     902             :     // Assert the XPath expression - 'right' border
     903           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgBorders/w:right", "space", "24");
     904             : }
     905             : 
     906          14 : DECLARE_OOXMLEXPORT_TEST(testFdo66145, "fdo66145.docx")
     907             : {
     908             :     // The Writer ignored the 'First Is Shared' flag
     909           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName("First Page"), uno::UNO_QUERY);
     910           2 :     CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(xPropertySet, "FirstIsShared")));
     911           2 : }
     912             : 
     913          14 : DECLARE_OOXMLEXPORT_TEST(testGrabBag, "grabbag.docx")
     914             : {
     915             :     // w:mirrorIndents was lost on roundtrip, now should be handled as a grab bag property
     916           2 :     xmlDocPtr pXmlDoc = parseExport();
     917           2 :     if (!pXmlDoc)
     918           3 :         return;
     919           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:mirrorIndents");
     920             : }
     921             : 
     922          14 : DECLARE_OOXMLEXPORT_TEST(testFdo66781, "fdo66781.docx")
     923             : {
     924             :     // The problem was that bullets with level=0 were shown in LO as normal bullets,
     925             :     // and when saved back to DOCX were saved with level=1 (so hidden bullets became visible)
     926           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY);
     927           2 :     uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
     928           2 :     uno::Sequence<beans::PropertyValue> aProps;
     929           2 :     xLevels->getByIndex(0) >>= aProps; // 1st level
     930             : 
     931          28 :     for (int i = 0; i < aProps.getLength(); ++i)
     932             :     {
     933          28 :         const beans::PropertyValue& rProp = aProps[i];
     934          28 :         if (rProp.Name == "BulletChar")
     935             :         {
     936           2 :             CPPUNIT_ASSERT_EQUAL(OUString("\x0", 1, RTL_TEXTENCODING_UTF8), rProp.Value.get<OUString>());
     937           4 :             return;
     938             :         }
     939             :     }
     940             : 
     941             :     // Shouldn't reach here
     942           0 :     CPPUNIT_FAIL("Did not find bullet with level 0");
     943             : }
     944             : 
     945          13 : DECLARE_OOXMLEXPORT_TEST(testFdo60990, "fdo60990.odt")
     946             : {
     947             :     // The shape had no background, no paragraph adjust and no font color.
     948           1 :     uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY);
     949           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00CFE7F5), getProperty<sal_Int32>(xShape, "BackColor"));
     950           2 :     uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText();
     951           2 :     uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText);
     952           1 :     CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust")));
     953           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF00), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor"));
     954           1 : }
     955             : 
     956          14 : DECLARE_OOXMLEXPORT_TEST(testFdo65718, "fdo65718.docx")
     957             : {
     958             :     // The problem was that the exporter always exported values of "0" for an images distance from text.
     959             :     // the actual attributes where 'distT', 'distB', 'distL', 'distR'
     960           2 :     uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY);
     961             : 
     962           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(0) ), getProperty<sal_Int32>(xPropertySet, "TopMargin") );
     963           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(0) ), getProperty<sal_Int32>(xPropertySet, "BottomMargin") );
     964             : 
     965             :     // Going to do '+1' because the 'getProperty' return 318 (instead of 317.5)
     966             :     // I think this is because it returns an integer, instead of a float.
     967             :     // The actual exporting to DOCX exports the correct value (114300 = 317.5 * 360)
     968             :     // The exporting to DOCX uses the 'SvxLRSpacing' that stores the value in TWIPS (180 TWIPS)
     969             :     // However, the 'LeftMargin' property is an integer property that holds that value in 'MM100' (should hold 317.5, but it is 318)
     970             :     // So I had to add the hack of the '+1' to make the test-case pass
     971           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(114300) + 1 ), getProperty<sal_Int32>(xPropertySet, "LeftMargin") );
     972           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(114300) + 1), getProperty<sal_Int32>(xPropertySet, "RightMargin") );
     973           2 : }
     974             : 
     975          14 : DECLARE_OOXMLEXPORT_TEST(testFdo64350, "fdo64350.docx")
     976             : {
     977             :     // The problem was that page border shadows were not exported
     978           2 :     table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "ShadowFormat");
     979           2 :     CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
     980           2 : }
     981             : 
     982          14 : DECLARE_OOXMLEXPORT_TEST(testFdo67013, "fdo67013.docx")
     983             : {
     984             :     /*
     985             :      * The problem was that borders inside headers \ footers were not exported
     986             :      * This was checked in xray using these commands:
     987             :      *
     988             :      * xHeaderText = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Standard").HeaderText
     989             :      * xHeaderEnum = xHeaderText.createEnumeration()
     990             :      * xHeaderFirstParagraph = xHeaderEnum.nextElement()
     991             :      * xHeaderBottomBorder = xHeaderFirstParagraph.BottomBorder
     992             :      *
     993             :      * xFooterText = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Standard").FooterText
     994             :      * xFooterEnum = xFooterText.createEnumeration()
     995             :      * xFooterFirstParagraph = xFooterEnum.nextElement()
     996             :      * xFooterTopBorder = xFooterFirstParagraph.TopBorder
     997             :      */
     998           2 :     uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText");
     999           4 :     uno::Reference< text::XTextRange > xHeaderParagraph = getParagraphOfText( 1, xHeaderText );
    1000           2 :     table::BorderLine2 aHeaderBottomBorder = getProperty<table::BorderLine2>(xHeaderParagraph, "BottomBorder");
    1001           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aHeaderBottomBorder.Color);
    1002           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(106), aHeaderBottomBorder.InnerLineWidth);
    1003           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aHeaderBottomBorder.LineDistance);
    1004           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(7), aHeaderBottomBorder.LineStyle);
    1005           2 :     CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aHeaderBottomBorder.LineWidth);
    1006           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aHeaderBottomBorder.OuterLineWidth);
    1007             : 
    1008           4 :     uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText");
    1009           4 :     uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText );
    1010           2 :     table::BorderLine2 aFooterTopBorder = getProperty<table::BorderLine2>(xFooterParagraph, "TopBorder");
    1011           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aFooterTopBorder.Color);
    1012           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aFooterTopBorder.InnerLineWidth);
    1013           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aFooterTopBorder.LineDistance);
    1014           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(4), aFooterTopBorder.LineStyle);
    1015           2 :     CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aFooterTopBorder.LineWidth);
    1016           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(106), aFooterTopBorder.OuterLineWidth);
    1017           2 : }
    1018             : 
    1019          14 : DECLARE_OOXMLEXPORT_TEST(testParaShadow, "para-shadow.docx")
    1020             : {
    1021             :     // The problem was that in w:pBdr, child elements had a w:shadow attribute, but that was ignored.
    1022           2 :     table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getParagraph(2), "ParaShadowFormat");
    1023           2 :     CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
    1024           2 :     CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
    1025             :     // w:sz="48" is in eights of a point, 1 pt is 20 twips.
    1026           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(TWIP_TO_MM100(24/8*20)), aShadow.ShadowWidth);
    1027           2 : }
    1028             : 
    1029          14 : DECLARE_OOXMLEXPORT_TEST(testTableFloating, "table-floating.docx")
    1030             : {
    1031             :     // Both the size and the position of the table was incorrect.
    1032           2 :     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
    1033           4 :     uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
    1034             :     // Second table was too wide: 16249, i.e. as wide as the first table.
    1035           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(11248), getProperty<sal_Int32>(xTables->getByIndex(1), "Width"));
    1036             : 
    1037           4 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
    1038           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
    1039           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
    1040             :     // This was 0, should be the the opposite of (left margin + half of the border width).
    1041           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty<sal_Int32>(xFrame, "HoriOrientPosition"));
    1042             :     // Was 0 as well, should be the right margin.
    1043           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xFrame, "RightMargin"));
    1044           2 : }
    1045             : 
    1046          14 : DECLARE_OOXMLEXPORT_TEST(testFdo44689_start_page_0, "fdo44689_start_page_0.docx")
    1047             : {
    1048             :     // The problem was that the import & export process did not analyze the 'start from page' attribute of a section
    1049           2 :     uno::Reference<beans::XPropertySet> xPara(getParagraph(0), uno::UNO_QUERY);
    1050           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xPara, "PageNumberOffset"));
    1051           2 : }
    1052             : 
    1053          14 : DECLARE_OOXMLEXPORT_TEST(testFdo44689_start_page_7, "fdo44689_start_page_7.docx")
    1054             : {
    1055             :     // The problem was that the import & export process did not analyze the 'start from page' attribute of a section
    1056           2 :     uno::Reference<beans::XPropertySet> xPara(getParagraph(0), uno::UNO_QUERY);
    1057           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(7), getProperty<sal_Int16>(xPara, "PageNumberOffset"));
    1058           2 : }
    1059             : 
    1060          14 : DECLARE_OOXMLEXPORT_TEST(testFdo67737, "fdo67737.docx")
    1061             : {
    1062             :     // The problem was that imported shapes did not import and render the 'flip:x' and 'flip:y' attributes
    1063           2 :     uno::Reference<drawing::XShape> xArrow = getShape(1);
    1064           2 :     uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xArrow, "CustomShapeGeometry");
    1065           4 :     for (int i = 0; i < aProps.getLength(); ++i)
    1066             :     {
    1067           4 :         const beans::PropertyValue& rProp = aProps[i];
    1068           4 :         if (rProp.Name == "MirroredY")
    1069             :         {
    1070           2 :             CPPUNIT_ASSERT_EQUAL( true, bool(rProp.Value.get<sal_Bool>()) );
    1071           4 :             return;
    1072             :         }
    1073             :     }
    1074             : 
    1075             :     // Shouldn't reach here
    1076           0 :     CPPUNIT_FAIL("Did not find MirroredY=true property");
    1077             : }
    1078             : 
    1079          14 : DECLARE_OOXMLEXPORT_TEST(testTransparentShadow, "transparent-shadow.docx")
    1080             : {
    1081           2 :     uno::Reference<drawing::XShape> xPicture = getShape(1);
    1082           2 :     table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xPicture, "ShadowFormat");
    1083           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x7f808080), aShadow.Color);
    1084           2 : }
    1085             : 
    1086          13 : DECLARE_OOXMLEXPORT_TEST(testBnc834035, "bnc834035.odt")
    1087             : {
    1088             :     // Illustration index had wrong hyperlinks: anchor was using Writer's
    1089             :     // <seqname>!<index>|sequence syntax, not a bookmark name.
    1090           1 :     xmlDocPtr pXmlDoc = parseExport();
    1091           1 :     if (!pXmlDoc)
    1092           1 :         return;
    1093             :     // This was Figure!1|sequence.
    1094           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[10]/w:hyperlink", "anchor", "_Toc363553908");
    1095             : }
    1096             : 
    1097          14 : DECLARE_OOXMLEXPORT_TEST(testBnc837302, "bnc837302.docx")
    1098             : {
    1099             :     // The problem was that text with empty author was not inserted as a redline
    1100           2 :     uno::Reference<text::XTextRange> xParagraph = getParagraph(1);
    1101             : 
    1102             :     // previously 'AAA' was not an own run
    1103           2 :     getRun(xParagraph, 3, "AAA");
    1104             :     // interestingly the 'Insert' is set on the _previous_ run
    1105           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Insert"), getProperty<OUString>(getRun(xParagraph, 2), "RedlineType"));
    1106             : 
    1107             :     // make sure we don't introduce a redlined delete in the 2nd paragraph
    1108           2 :     xParagraph = getParagraph(2);
    1109           2 :     CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(xParagraph, 1), "RedlineType"));
    1110           2 : }
    1111             : 
    1112          14 : DECLARE_OOXMLEXPORT_TEST(testFdo68418, "fdo68418.docx")
    1113             : {
    1114             :     // The problem was that in 'MSWordExportBase::SectionProperties' function in 'wrt8sty.cxx'
    1115             :     // it checked if it 'IsPlausableSingleWordSection'.
    1116             :     // The 'IsPlausableSingleWordSection' compared different aspects of 2 'SwFrmFmt' objects.
    1117             :     // One of the checks was 'do both formats have the same distance from the top and bottom ?'
    1118             :     // This check is correct if both have headers or both don't have headers.
    1119             :     // However - if one has a header, and the other one has an empty header (no header) - it is not correct to compare
    1120             :     // between them (same goes for 'footer').
    1121           2 :     uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText");
    1122           4 :     uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText );
    1123             : 
    1124             :     // First page footer is empty, second page footer is 'aaaa'
    1125           4 :     CPPUNIT_ASSERT_EQUAL(OUString("aaaa"), xFooterParagraph->getString());        // I get an error that it expects ''
    1126           2 : }
    1127             : 
    1128          14 : DECLARE_OOXMLEXPORT_TEST(testA4AndBorders, "a4andborders.docx")
    1129             : {
    1130             :     /*
    1131             :      * The problem was that in case of a document with borders, the pgSz attribute
    1132             :      * was exported as a child of pgBorders, thus being ignored on reload.
    1133             :      * We assert dimension against A4 size in mm (to avoid minor rounding errors)
    1134             :      */
    1135           2 :     uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
    1136           2 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect Page Width (mm)", sal_Int32(210), getProperty<sal_Int32>(xPageStyle, "Width") / 100);
    1137           2 :     CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect Page Height (mm)", sal_Int32(297), getProperty<sal_Int32>(xPageStyle, "Height") / 100);
    1138           2 : }
    1139             : 
    1140          14 : DECLARE_OOXMLEXPORT_TEST(testFdo68787, "fdo68787.docx")
    1141             : {
    1142           2 :     uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
    1143             :     // This was 25, the 'lack of w:separator' <-> '0 line width' mapping was missing.
    1144           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth"));
    1145           2 : }
    1146             : 
    1147          13 : DECLARE_OOXMLEXPORT_TEST(testCharacterBorder, "charborder.odt")
    1148             : {
    1149           1 :     uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
    1150             :     // OOXML has just one border attribute (<w:bdr>) for text border so all side has
    1151             :     // the same border with the same padding
    1152             :     // Border
    1153             :     {
    1154           1 :         const table::BorderLine2 aTopBorder = getProperty<table::BorderLine2>(xRun,"CharTopBorder");
    1155           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF6600,0,318,0,0,318), aTopBorder);
    1156           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharLeftBorder"));
    1157           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharBottomBorder"));
    1158           1 :         CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharRightBorder"));
    1159             :     }
    1160             : 
    1161             :     // Padding (w:space)
    1162             :     {
    1163           1 :         const sal_Int32 nTopPadding = getProperty<sal_Int32>(xRun,"CharTopBorderDistance");
    1164             :         // In the original ODT the padding is 150, but the unit conversion round it down.
    1165           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(141), nTopPadding);
    1166           1 :         CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharLeftBorderDistance"));
    1167           1 :         CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharBottomBorderDistance"));
    1168           1 :         CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharRightBorderDistance"));
    1169             :     }
    1170             : 
    1171             :     // Shadow (w:shadow)
    1172             :     /* OOXML use just one bool value for shadow so the next conversions
    1173             :        are made during an export-import round
    1174             :        color: any -> black
    1175             :        location: any -> bottom-right
    1176             :        width: any -> border width */
    1177             :     {
    1178           1 :         const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat");
    1179           1 :         CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
    1180           1 :         CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
    1181           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth);
    1182             :     }
    1183             : 
    1184             :     // Also check shadow when it is in middle of the paragraph
    1185             :     // (problem can be during export with SwWW8AttrIter::HasTextItem())
    1186             :     {
    1187           1 :         uno::Reference<beans::XPropertySet> xMiddleRun(getRun(getParagraph(2),2), uno::UNO_QUERY);
    1188           1 :         const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xMiddleRun, "CharShadowFormat");
    1189           1 :         CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color));
    1190           1 :         CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location);
    1191           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth);
    1192           1 :     }
    1193           1 : }
    1194             : 
    1195          14 : DECLARE_OOXMLEXPORT_TEST(testStyleInheritance, "style-inheritance.docx")
    1196             : {
    1197             :     // Check that now styleId's are more like what MSO produces
    1198           2 :     xmlDocPtr pXmlStyles = parseExport("word/styles.xml");
    1199           2 :     if (!pXmlStyles)
    1200           3 :         return;
    1201             :     // the 1st style always must be Normal
    1202           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[1]", "styleId", "Normal");
    1203             :     // some random style later
    1204           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[4]", "styleId", "Heading3");
    1205             : 
    1206             :     // Check that we do _not_ export w:next for styles that point to themselves.
    1207           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[1]/w:next", 0);
    1208             : 
    1209             :     // Check that we roundtrip <w:next> correctly - on XML level
    1210           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[2]/w:next", "val", "Normal");
    1211             :     // And to be REALLY sure, check it on the API level too ;-)
    1212           1 :     uno::Reference< container::XNameAccess > paragraphStyles = getStyles("ParagraphStyles");
    1213           2 :     uno::Reference< beans::XPropertySet > properties(paragraphStyles->getByName("Heading 1"), uno::UNO_QUERY);
    1214           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty<OUString>(properties, "FollowStyle"));
    1215             : 
    1216             :     // This was 0, as export of w:outlineLvl was missing.
    1217           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(properties, "OutlineLevel"));
    1218             : 
    1219           1 :     properties = uno::Reference< beans::XPropertySet >(paragraphStyles->getByName("Heading 11"), uno::UNO_QUERY);
    1220           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty<OUString>(properties, "FollowStyle"));
    1221             : 
    1222             :     // Make sure style #2 is Heading 1.
    1223           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[2]", "styleId", "Heading1");
    1224             :     // w:ind was copied from the parent (Normal) style without a good reason.
    1225           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[2]/w:pPr/w:ind", 0);
    1226             : 
    1227             :     // We output exactly 2 properties in rPrDefault, nothing else was
    1228             :     // introduced as an additional default
    1229           1 :     assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/*", 2);
    1230             :     // Check that we output real content of rPrDefault
    1231           1 :     assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "ascii", "Times New Roman");
    1232           1 :     assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:lang", "bidi", "ar-SA");
    1233             :     // pPrDefault is empty
    1234           1 :     assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:pPrDefault/w:pPr/*", 0);
    1235             : 
    1236             :     // Check latent styles
    1237           2 :     uno::Sequence<beans::PropertyValue> aGrabBag = getProperty< uno::Sequence<beans::PropertyValue> >(mxComponent, "InteropGrabBag");
    1238           2 :     uno::Sequence<beans::PropertyValue> aLatentStyles;
    1239          13 :     for (sal_Int32 i = 0; i < aGrabBag.getLength(); ++i)
    1240          12 :         if (aGrabBag[i].Name == "latentStyles")
    1241           1 :             aGrabBag[i].Value >>= aLatentStyles;
    1242           1 :     CPPUNIT_ASSERT(aLatentStyles.getLength()); // document should have latent styles
    1243             : 
    1244             :     // Check latent style default attributes
    1245           2 :     OUString aCount;
    1246           2 :     uno::Sequence<beans::PropertyValue> aLatentStyleExceptions;
    1247           8 :     for (sal_Int32 i = 0; i < aLatentStyles.getLength(); ++i)
    1248             :     {
    1249           7 :         if (aLatentStyles[i].Name == "count")
    1250           1 :             aCount = aLatentStyles[i].Value.get<OUString>();
    1251           6 :         else if (aLatentStyles[i].Name == "lsdExceptions")
    1252           1 :             aLatentStyles[i].Value >>= aLatentStyleExceptions;
    1253             :     }
    1254           1 :     CPPUNIT_ASSERT_EQUAL(OUString("371"), aCount); // This check the "count" attribute.
    1255             : 
    1256             :     // Check exceptions to the latent style defaults.
    1257           2 :     uno::Sequence<beans::PropertyValue> aLatentStyleException;
    1258           1 :     aLatentStyleExceptions[0].Value >>= aLatentStyleException;
    1259           2 :     OUString aName;
    1260           4 :     for (sal_Int32 i = 0; i < aLatentStyleException.getLength(); ++i)
    1261           3 :         if (aLatentStyleException[i].Name == "name")
    1262           1 :             aName = aLatentStyleException[i].Value.get<OUString>();
    1263           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Normal"), aName); // This checks the "name" attribute of the first exception.
    1264             : 
    1265             :     // This numbering style wasn't roundtripped.
    1266           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='NoList']/w:name", "val", "No List");
    1267             : 
    1268             :     // Table style wasn't roundtripped.
    1269           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:tblPr/w:tblCellMar/w:left", "w", "108");
    1270           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:semiHidden", 1);
    1271           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:unhideWhenUsed", 1);
    1272             : 
    1273             :     // Additional para style properties should be also roundtripped.
    1274           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='ListParagraph']/w:uiPriority", "val", "34");
    1275           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']/w:qFormat", 1);
    1276           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']/w:rsid", "val", "00780346");
    1277           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']", "default", "1");
    1278             : 
    1279           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:link", "val", "Heading1Char");
    1280           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:locked", 1);
    1281             : 
    1282           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading11']", "customStyle", "1");
    1283           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading11']/w:autoRedefine", 1);
    1284             : 
    1285             :     // Additional char style properties should be also roundtripped.
    1286           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='DefaultParagraphFont']", "default", "1");
    1287             : 
    1288             :     // Finally check the same for numbering styles.
    1289           2 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='NoList']", "default", "1");
    1290             : }
    1291             : 
    1292          14 : DECLARE_OOXMLEXPORT_TEST(testCalendar1, "calendar1.docx")
    1293             : {
    1294             :     // Document has a non-trivial table style, test the roundtrip of it.
    1295           2 :     xmlDocPtr pXmlStyles = parseExport("word/styles.xml");
    1296           2 :     if (!pXmlStyles)
    1297           3 :         return;
    1298           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:basedOn", "val", "TableNormal");
    1299           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:rsid", "val", "00903003");
    1300           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblPr/w:tblStyleColBandSize", "val", "1");
    1301           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tcPr/w:shd", "val", "clear");
    1302             : 
    1303             :     // Table style lost its paragraph / run properties.
    1304           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:pPr/w:spacing", "lineRule", "auto");
    1305           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:rPr/w:lang", "eastAsia", "ja-JP");
    1306             : 
    1307             :     // Table style lost its conditional table formatting properties.
    1308           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:pPr/w:wordWrap", 1);
    1309           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:rFonts", "hAnsiTheme", "minorHAnsi");
    1310           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:tblPr", 1);
    1311           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:tcPr/w:vAlign", "val", "bottom");
    1312           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='lastRow']/w:tcPr/w:tcBorders/w:tr2bl", "val", "nil");
    1313           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='band2Horz']/w:tcPr/w:tcBorders/w:top", "themeColor", "text1");
    1314             : }
    1315             : 
    1316          14 : DECLARE_OOXMLEXPORT_TEST(testCalendar2, "calendar2.docx")
    1317             : {
    1318             :     // Problem was that CharCaseMap was style::CaseMap::NONE.
    1319           2 :     uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY);
    1320           3 :     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY);
    1321           2 :     CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE, getProperty<sal_Int16>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharCaseMap"));
    1322             :     // Font size in the second row was 11.
    1323           2 :     xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY);
    1324           2 :     CPPUNIT_ASSERT_EQUAL(16.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight"));
    1325             :     // Font size in the third row was 11 as well.
    1326           2 :     xCell.set(xTable->getCellByName("B3"), uno::UNO_QUERY);
    1327           2 :     CPPUNIT_ASSERT_EQUAL(14.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight"));
    1328             : 
    1329             :     // This paragraph property was missing in table style.
    1330           2 :     xmlDocPtr pXmlStyles = parseExport("word/styles.xml");
    1331           2 :     if (!pXmlStyles)
    1332           3 :         return;
    1333           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:pPr/w:jc", "val", "center");
    1334             : 
    1335             :     // These run properties were missing
    1336           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:rPr/w:lang", "val", "en-US");
    1337           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:rPr/w:lang", "bidi", "ar-SA");
    1338           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:caps", 1);
    1339           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:smallCaps", "val", "0");
    1340           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:color", "themeColor", "accent1");
    1341           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:spacing", "val", "20");
    1342             : 
    1343             :     // Table borders were also missing
    1344           2 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblPr/w:tblBorders/w:insideV", "themeTint", "99");
    1345             : }
    1346             : 
    1347          14 : DECLARE_OOXMLEXPORT_TEST(testQuicktables, "quicktables.docx")
    1348             : {
    1349           2 :     xmlDocPtr pXmlStyles = parseExport("word/styles.xml");
    1350           2 :     if (!pXmlStyles)
    1351           3 :         return;
    1352             : 
    1353             :     // These were missing in the Calendar3 table style.
    1354           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:rPr/w:rFonts", "cstheme", "majorBidi");
    1355           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:rPr/w:color", "themeTint", "80");
    1356           1 :     CPPUNIT_ASSERT(getXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:color", "themeShade").equalsIgnoreAsciiCase("BF"));
    1357             : 
    1358             :     // Calendar4.
    1359           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:pPr/w:snapToGrid", "val", "0");
    1360           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:rPr/w:bCs", 1);
    1361           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tcPr/w:shd", "themeFill", "accent1");
    1362           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tcPr/w:shd", "themeFillShade", "80");
    1363           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='firstCol']/w:pPr/w:ind", "rightChars", "0");
    1364           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='firstCol']/w:pPr/w:ind", "right", "144");
    1365           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='band2Horz']/w:tcPr/w:tcMar/w:bottom", "w", "86");
    1366             : 
    1367             :     // LightList.
    1368           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='LightList']/w:tblStylePr[@w:type='firstRow']/w:pPr/w:spacing", "before", "0");
    1369             : 
    1370             :     // MediumList2-Accent1.
    1371           1 :     CPPUNIT_ASSERT(getXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='MediumList2-Accent1']/w:tblStylePr[@w:type='band1Vert']/w:tcPr/w:shd", "themeFillTint").equalsIgnoreAsciiCase("3F"));
    1372             : 
    1373             :     // MediumShading2-Accent5.
    1374           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='MediumShading2-Accent5']/w:tblStylePr[@w:type='firstRow']/w:tcPr/w:tcBorders/w:top", "color", "auto");
    1375             : }
    1376             : 
    1377          14 : DECLARE_OOXMLEXPORT_TEST(testFdo71302, "fdo71302.docx")
    1378             : {
    1379           2 :     xmlDocPtr pXmlStyles = parseExport("word/styles.xml");
    1380           2 :     if (!pXmlStyles)
    1381           3 :         return;
    1382             : 
    1383             :     // This got renamed to "Strong Emphasis" without a good reason.
    1384           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Strong']", 1);
    1385             : }
    1386             : 
    1387          14 : DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx")
    1388             : {
    1389           2 :     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
    1390           4 :     uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
    1391           4 :     uno::Sequence<beans::PropertyValue> aGrabBag(0);
    1392           2 :     xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag;
    1393           2 :     CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty
    1394             : 
    1395           2 :     sal_Bool bTheme = sal_False;
    1396          26 :     for(int i = 0; i < aGrabBag.getLength(); ++i)
    1397             :     {
    1398          24 :       if (aGrabBag[i].Name == "OOXTheme")
    1399             :       {
    1400           2 :         bTheme = sal_True;
    1401           2 :         uno::Reference<xml::dom::XDocument> aThemeDom;
    1402           2 :         CPPUNIT_ASSERT(aGrabBag[i].Value >>= aThemeDom); // PropertyValue of proper type
    1403           2 :         CPPUNIT_ASSERT(aThemeDom.get()); // Reference not empty
    1404             :       }
    1405             :     }
    1406           2 :     CPPUNIT_ASSERT(bTheme); // Grab Bag has all the expected elements
    1407             : 
    1408           4 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
    1409           4 :     uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
    1410           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc
    1411             : 
    1412           4 :     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
    1413           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xGroup->getCount()); // 1 rendered bitmap from the original shapes
    1414             : 
    1415           4 :     uno::Reference<beans::XPropertySet> xGroupPropertySet(getShape(1), uno::UNO_QUERY);
    1416           2 :     xGroupPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag;
    1417           2 :     CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty
    1418             : 
    1419           2 :     sal_Bool bData = sal_False, bLayout = sal_False, bQStyle = sal_False, bColor = sal_False, bDrawing = sal_False;
    1420          12 :     for(int i = 0; i < aGrabBag.getLength(); ++i)
    1421             :     {
    1422          10 :       if (aGrabBag[i].Name == "OOXData")
    1423             :       {
    1424           2 :         bData = sal_True;
    1425           2 :         uno::Reference<xml::dom::XDocument> aDataDom;
    1426           2 :         CPPUNIT_ASSERT(aGrabBag[i].Value >>= aDataDom); // PropertyValue of proper type
    1427           2 :         CPPUNIT_ASSERT(aDataDom.get()); // Reference not empty
    1428             :       }
    1429           8 :       else if (aGrabBag[i].Name == "OOXLayout")
    1430             :       {
    1431           2 :         bLayout = sal_True;
    1432           2 :         uno::Reference<xml::dom::XDocument> aLayoutDom;
    1433           2 :         CPPUNIT_ASSERT(aGrabBag[i].Value >>= aLayoutDom); // PropertyValue of proper type
    1434           2 :         CPPUNIT_ASSERT(aLayoutDom.get()); // Reference not empty
    1435             :       }
    1436           6 :       else if (aGrabBag[i].Name == "OOXStyle")
    1437             :       {
    1438           2 :         bQStyle = sal_True;
    1439           2 :         uno::Reference<xml::dom::XDocument> aStyleDom;
    1440           2 :         CPPUNIT_ASSERT(aGrabBag[i].Value >>= aStyleDom); // PropertyValue of proper type
    1441           2 :         CPPUNIT_ASSERT(aStyleDom.get()); // Reference not empty
    1442             :       }
    1443           4 :       else if (aGrabBag[i].Name == "OOXColor")
    1444             :       {
    1445           2 :         bColor = sal_True;
    1446           2 :         uno::Reference<xml::dom::XDocument> aColorDom;
    1447           2 :         CPPUNIT_ASSERT(aGrabBag[i].Value >>= aColorDom); // PropertyValue of proper type
    1448           2 :         CPPUNIT_ASSERT(aColorDom.get()); // Reference not empty
    1449             :       }
    1450           2 :       else if (aGrabBag[i].Name == "OOXDrawing")
    1451             :       {
    1452           2 :         bDrawing = sal_True;
    1453           2 :         uno::Sequence< uno::Any > diagramDrawing;
    1454           4 :         uno::Reference<xml::dom::XDocument> aDrawingDom;
    1455           2 :         CPPUNIT_ASSERT(aGrabBag[i].Value >>= diagramDrawing);
    1456           2 :         CPPUNIT_ASSERT(diagramDrawing[0] >>= aDrawingDom); // PropertyValue of proper type
    1457           4 :         CPPUNIT_ASSERT(aDrawingDom.get()); // Reference not empty
    1458             :       }
    1459             :     }
    1460           2 :     CPPUNIT_ASSERT(bData && bLayout && bQStyle && bColor && bDrawing); // Grab Bag has all the expected elements
    1461             : 
    1462           4 :     uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(0), uno::UNO_QUERY);
    1463           4 :     OUString nValue;
    1464           2 :     xPropertySet->getPropertyValue("Name") >>= nValue;
    1465           4 :     CPPUNIT_ASSERT_EQUAL(OUString("RenderedShapes"), nValue); // Rendered bitmap has the proper name
    1466           2 : }
    1467             : 
    1468          14 : DECLARE_OOXMLEXPORT_TEST(testCharHighlight, "char_highlight.docx")
    1469             : {
    1470           2 :     const uno::Reference< text::XTextRange > xPara = getParagraph(1);
    1471             :     // Both highlight and background
    1472           2 :     const sal_Int32 nBackColor(0x4F81BD);
    1473          34 :     for( int nRun = 1; nRun <= 16; ++nRun )
    1474             :     {
    1475          32 :         const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,nRun), uno::UNO_QUERY);
    1476          32 :         sal_Int32 nHighlightColor = 0;
    1477          32 :         switch( nRun )
    1478             :         {
    1479           2 :             case 1: nHighlightColor = 0x000000; break; //black
    1480           2 :             case 2: nHighlightColor = 0x0000ff; break; //blue
    1481           2 :             case 3: nHighlightColor = 0x00ffff; break; //cyan
    1482           2 :             case 4: nHighlightColor = 0x00ff00; break; //green
    1483           2 :             case 5: nHighlightColor = 0xff00ff; break; //magenta
    1484           2 :             case 6: nHighlightColor = 0xff0000; break; //red
    1485           2 :             case 7: nHighlightColor = 0xffff00; break; //yellow
    1486           2 :             case 8: nHighlightColor = 0xffffff; break; //white
    1487           2 :             case 9: nHighlightColor = 0x000080;  break;//dark blue
    1488           2 :             case 10: nHighlightColor = 0x008080; break; //dark cyan
    1489           2 :             case 11: nHighlightColor = 0x008000; break; //dark green
    1490           2 :             case 12: nHighlightColor = 0x800080; break; //dark magenta
    1491           2 :             case 13: nHighlightColor = 0x800000; break; //dark red
    1492           2 :             case 14: nHighlightColor = 0x808000; break; //dark yellow
    1493           2 :             case 15: nHighlightColor = 0x808080; break; //dark gray
    1494           2 :             case 16: nHighlightColor = 0xC0C0C0; break; //light gray
    1495             :         }
    1496          32 :         CPPUNIT_ASSERT_EQUAL(nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight"));
    1497          32 :         CPPUNIT_ASSERT_EQUAL(nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor"));
    1498          32 :     }
    1499             : 
    1500             :     // Only highlight
    1501             :     {
    1502           2 :         const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY);
    1503           2 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight"));
    1504           2 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor"));
    1505             :     }
    1506             : 
    1507             :     // Only background
    1508             :     {
    1509           2 :         const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY);
    1510           2 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight"));
    1511           2 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor"));
    1512           2 :     }
    1513           2 : }
    1514             : 
    1515          14 : DECLARE_OOXMLEXPORT_TEST(testFontNameIsEmpty, "font-name-is-empty.docx")
    1516             : {
    1517             :     // Check no empty font name is exported
    1518             :     // This test does not fail, if the document contains a font with empty name.
    1519             : 
    1520           2 :     xmlDocPtr pXmlFontTable = parseExport("word/fontTable.xml");
    1521           2 :     if (!pXmlFontTable)
    1522           3 :         return;
    1523           1 :     xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlFontTable, "/w:fonts/w:font");
    1524           1 :     sal_Int32 length = xmlXPathNodeSetGetLength(pXmlNodes);
    1525          11 :     for(sal_Int32 index = 0; index < length; index++){
    1526          10 :         xmlNodePtr pXmlNode = pXmlNodes->nodeTab[index];
    1527          10 :         OUString attrVal = OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST("name")));
    1528          10 :          if (attrVal == ""){
    1529           0 :             CPPUNIT_FAIL("Font name is empty.");
    1530             :         }
    1531          10 :     }
    1532             : }
    1533             : 
    1534          14 : DECLARE_OOXMLEXPORT_TEST(testMultiColumnLineSeparator, "multi-column-line-separator-SAVED.docx")
    1535             : {
    1536             :     // Check for the Column Separator value.It should be FALSE as the document doesnt contains separator line.
    1537           2 :     xmlDocPtr pXmlDoc = parseExport();
    1538           2 :     if (!pXmlDoc)
    1539           3 :         return;
    1540           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:sectPr/w:cols","sep","false");
    1541             : }
    1542             : 
    1543          14 : DECLARE_OOXMLEXPORT_TEST(testCustomXmlGrabBag, "customxml.docx")
    1544             : {
    1545             :    // The problem was that item[n].xml and itemProps[n].xml and .rels files for item[n].xml
    1546             :    // files were missing from docx file after saving file.
    1547             :    // This test case tests whether customxml files grabbagged properly in correct object.
    1548             : 
    1549           2 :    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
    1550           4 :    uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
    1551           4 :    uno::Sequence<beans::PropertyValue> aGrabBag(0);
    1552           2 :    xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag;
    1553           2 :    CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty
    1554           2 :    sal_Bool CustomXml = sal_False;
    1555          26 :    for(int i = 0; i < aGrabBag.getLength(); ++i)
    1556             :    {
    1557          24 :        if (aGrabBag[i].Name == "OOXCustomXml" || aGrabBag[i].Name == "OOXCustomXmlProps")
    1558             :        {
    1559           4 :            CustomXml = sal_True;
    1560           4 :            uno::Reference<xml::dom::XDocument> aCustomXmlDom;
    1561           8 :            uno::Sequence<uno::Reference<xml::dom::XDocument> > aCustomXmlDomList;
    1562           4 :            CPPUNIT_ASSERT(aGrabBag[i].Value >>= aCustomXmlDomList); // PropertyValue of proper type
    1563           4 :            sal_Int32 length = aCustomXmlDomList.getLength();
    1564           4 :            CPPUNIT_ASSERT_EQUAL(sal_Int32(1), length);
    1565           4 :            aCustomXmlDom = aCustomXmlDomList[0];
    1566           8 :            CPPUNIT_ASSERT(aCustomXmlDom.get()); // Reference not empty
    1567             :        }
    1568             :    }
    1569           4 :    CPPUNIT_ASSERT(CustomXml); // Grab Bag has all the expected elements
    1570           2 : }
    1571             : 
    1572          14 : DECLARE_OOXMLEXPORT_TEST(testActiveXGrabBag, "activex.docx")
    1573             : {
    1574             :    // The problem was that activeX.xml files were missing from docx file after saving file.
    1575             :    // This test case tests whether activex files grabbagged properly in correct object.
    1576             : 
    1577           2 :    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
    1578           4 :    uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
    1579           4 :    uno::Sequence<beans::PropertyValue> aGrabBag(0);
    1580           2 :    xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag;
    1581           2 :    CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty
    1582           2 :    bool bActiveX = false;
    1583          26 :    for(int i = 0; i < aGrabBag.getLength(); ++i)
    1584             :    {
    1585          24 :        if (aGrabBag[i].Name == "OOXActiveX")
    1586             :        {
    1587           2 :            bActiveX = true;
    1588           2 :            uno::Reference<xml::dom::XDocument> aActiveXDom;
    1589           4 :            uno::Sequence<uno::Reference<xml::dom::XDocument> > aActiveXDomList;
    1590           2 :            CPPUNIT_ASSERT(aGrabBag[i].Value >>= aActiveXDomList); // PropertyValue of proper type
    1591           2 :            sal_Int32 length = aActiveXDomList.getLength();
    1592           2 :            CPPUNIT_ASSERT_EQUAL(sal_Int32(5), length);
    1593           2 :            aActiveXDom = aActiveXDomList[0];
    1594           4 :            CPPUNIT_ASSERT(aActiveXDom.get()); // Reference not empty
    1595             :        }
    1596             :    }
    1597           4 :    CPPUNIT_ASSERT(bActiveX); // Grab Bag has all the expected elements
    1598           2 : }
    1599             : 
    1600          14 : DECLARE_OOXMLEXPORT_TEST(testActiveXBinGrabBag, "activexbin.docx")
    1601             : {
    1602             :    // The problem was that activeX.bin files were missing from docx file after saving file.
    1603             :    // This test case tests whether activex bin files grabbagged properly in correct object.
    1604             : 
    1605           2 :    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
    1606           4 :    uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
    1607           4 :    uno::Sequence<beans::PropertyValue> aGrabBag(0);
    1608           2 :    xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag;
    1609           2 :    CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty
    1610           2 :    bool bActiveX = false;
    1611          26 :    for(int i = 0; i < aGrabBag.getLength(); ++i)
    1612             :    {
    1613          24 :        if (aGrabBag[i].Name == "OOXActiveXBin")
    1614             :        {
    1615           2 :            bActiveX = true;
    1616           2 :            uno::Reference<io::XInputStream> aActiveXBin;
    1617           4 :            uno::Sequence<uno::Reference<io::XInputStream> > aActiveXBinList;
    1618           2 :            CPPUNIT_ASSERT(aGrabBag[i].Value >>= aActiveXBinList); // PropertyValue of proper type
    1619           2 :            sal_Int32 length = aActiveXBinList.getLength();
    1620           2 :            CPPUNIT_ASSERT_EQUAL(sal_Int32(5), length);
    1621           2 :            aActiveXBin = aActiveXBinList[0];
    1622           4 :            CPPUNIT_ASSERT(aActiveXBin.get()); // Reference not empty
    1623             :        }
    1624             :    }
    1625           4 :    CPPUNIT_ASSERT(bActiveX); // Grab Bag has all the expected elements
    1626           2 : }
    1627             : 
    1628          14 : DECLARE_OOXMLEXPORT_TEST(testFdo69644, "fdo69644.docx")
    1629             : {
    1630             :     // The problem was that the exporter exported the table definition
    1631             :     // with only 3 columns, instead of 5 columns.
    1632             :     // Check that the table grid is exported with 5 columns
    1633           2 :     xmlDocPtr pXmlDoc = parseExport();
    1634           2 :     if (!pXmlDoc)
    1635           3 :         return;
    1636           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol", 5);
    1637             : }
    1638             : 
    1639          13 : DECLARE_OOXMLEXPORT_TEST(testCp1000015, "cp1000015.odt")
    1640             : {
    1641             :     // Redline and hyperlink end got exported in an incorrect order.
    1642           1 :     getParagraph(1, "Hello.");
    1643           1 :     getParagraph(2, "http://www.google.com/");
    1644           1 : }
    1645             : 
    1646          14 : DECLARE_OOXMLEXPORT_TEST(testFdo70812, "fdo70812.docx")
    1647             : {
    1648             :     // Import just crashed.
    1649           2 :     getParagraph(1, "Sample pages document.");
    1650           2 : }
    1651             : 
    1652          14 : DECLARE_OOXMLEXPORT_TEST(testPgMargin, "testPgMargin.docx")
    1653             : {
    1654           2 :     xmlDocPtr pXmlDoc = parseExport();
    1655           2 :     if (!pXmlDoc)
    1656           3 :         return;
    1657           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgMar", "left", "1440");
    1658             : }
    1659             : 
    1660          13 : DECLARE_OOXMLEXPORT_TEST(testImageCrop, "ImageCrop.docx")
    1661             : {
    1662           1 :     uno::Reference<drawing::XShape> image = getShape(1);
    1663           2 :     uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
    1664           1 :     ::com::sun::star::text::GraphicCrop aGraphicCropStruct;
    1665             : 
    1666           1 :     imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct;
    1667             : 
    1668           1 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 2955 ), aGraphicCropStruct.Left );
    1669           1 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 5477 ), aGraphicCropStruct.Right );
    1670           1 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 2856 ), aGraphicCropStruct.Top );
    1671             :     // FIXME import test is disabled (we only check after import-export-import)
    1672             :     // The reason is that after import this is 2291 -- rounding error?
    1673           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 2290 ), aGraphicCropStruct.Bottom );
    1674           1 : }
    1675             : 
    1676          14 : DECLARE_OOXMLEXPORT_TEST(testLineSpacingexport, "test_line_spacing.docx")
    1677             : {
    1678             :      // The Problem was that the w:line attribute value in w:spacing tag was incorrect
    1679           2 :     uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
    1680           4 :     uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
    1681           4 :     uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
    1682           4 :     CPPUNIT_ASSERT(xParaEnum->hasMoreElements());
    1683             : 
    1684             :     // FIXME The test passes on most machines (including Linux x86_64 with gcc-4.7), but fails on various configs:
    1685             :     // Linux arm, Linux x86_64 with gcc-4.8 and Mac. Need to figure out what goes wrong and fix that.
    1686             : #if 0
    1687             :     style::LineSpacing alineSpacing = getProperty<style::LineSpacing>(xParaEnum->nextElement(), "ParaLineSpacing");
    1688             :     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(13200), static_cast<sal_Int16>(alineSpacing.Height));
    1689             :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    1690             :     if (!pXmlDoc)
    1691             :         return;
    1692             :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "line", "31680");
    1693             : #endif
    1694           2 : }
    1695             : 
    1696          14 : DECLARE_OOXMLEXPORT_TEST(testHyperlineIsEnd, "hyperlink.docx")
    1697             : {
    1698             :     // Check  that the document.xml contents all the tag properly closed.
    1699           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    1700           2 :     if (!pXmlDoc)
    1701           3 :         return;
    1702             :     // If  document.xml miss any ending tag then parseExport() returns NULL which fail the test case.
    1703           1 :     CPPUNIT_ASSERT(pXmlDoc) ;
    1704             :     // Check hyperlink is properly open.
    1705           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:hyperlink",1);
    1706             : }
    1707             : 
    1708          14 : DECLARE_OOXMLEXPORT_TEST(testTextBoxGradientAngle, "fdo65295.docx")
    1709             : {
    1710           2 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
    1711           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
    1712           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xIndexAccess->getCount());
    1713             : 
    1714             :     // Angle of frame#1 is 135 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
    1715           4 :     uno::Reference<beans::XPropertySet> xFrame1(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
    1716           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame1, "FillStyle"));
    1717           2 :     awt::Gradient aGradient1 = getProperty<awt::Gradient>(xFrame1, "FillGradient");
    1718           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(135 * 10), aGradient1.Angle);
    1719             : 
    1720             :     // Angle of frame#2 is 180 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
    1721           4 :     uno::Reference<beans::XPropertySet> xFrame2(xIndexAccess->getByIndex(1), uno::UNO_QUERY);
    1722           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame2, "FillStyle"));
    1723           2 :     awt::Gradient aGradient2 = getProperty<awt::Gradient>(xFrame2, "FillGradient");
    1724           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(180 * 10), aGradient2.Angle);
    1725             : 
    1726             :     // Angle of frame#3 is  90 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
    1727           4 :     uno::Reference<beans::XPropertySet> xFrame3(xIndexAccess->getByIndex(2), uno::UNO_QUERY);
    1728           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame3, "FillStyle"));
    1729           2 :     awt::Gradient aGradient3 = getProperty<awt::Gradient>(xFrame3, "FillGradient");
    1730           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16( 90 * 10), aGradient3.Angle);
    1731             : 
    1732             :     // Angle of frame#4 is 225 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
    1733           4 :     uno::Reference<beans::XPropertySet> xFrame4(xIndexAccess->getByIndex(3), uno::UNO_QUERY);
    1734           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame4, "FillStyle"));
    1735           2 :     awt::Gradient aGradient4 = getProperty<awt::Gradient>(xFrame4, "FillGradient");
    1736           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(225 * 10), aGradient4.Angle);
    1737             : 
    1738             :     // Angle of frame#5 is 270 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
    1739           4 :     uno::Reference<beans::XPropertySet> xFrame5(xIndexAccess->getByIndex(4), uno::UNO_QUERY);
    1740           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame5, "FillStyle"));
    1741           2 :     awt::Gradient aGradient5 = getProperty<awt::Gradient>(xFrame5, "FillGradient");
    1742           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(270 * 10), aGradient5.Angle);
    1743             : 
    1744             :     // Angle of frame#6 is 315 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
    1745           4 :     uno::Reference<beans::XPropertySet> xFrame6(xIndexAccess->getByIndex(5), uno::UNO_QUERY);
    1746           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame6, "FillStyle"));
    1747           2 :     awt::Gradient aGradient6 = getProperty<awt::Gradient>(xFrame6, "FillGradient");
    1748           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(315 * 10), aGradient6.Angle);
    1749             : 
    1750             :     // Angle of frame#7 is   0 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
    1751           4 :     uno::Reference<beans::XPropertySet> xFrame7(xIndexAccess->getByIndex(6), uno::UNO_QUERY);
    1752           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame7, "FillStyle"));
    1753           2 :     awt::Gradient aGradient7 = getProperty<awt::Gradient>(xFrame7, "FillGradient");
    1754           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(  0 * 10), aGradient7.Angle);
    1755             : 
    1756             :     // Angle of frame#8 is  45 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree
    1757           4 :     uno::Reference<beans::XPropertySet> xFrame8(xIndexAccess->getByIndex(7), uno::UNO_QUERY);
    1758           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame8, "FillStyle"));
    1759           2 :     awt::Gradient aGradient8 = getProperty<awt::Gradient>(xFrame8, "FillGradient");
    1760           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int16( 45 * 10), aGradient8.Angle);
    1761           2 : }
    1762             : 
    1763          14 : DECLARE_OOXMLEXPORT_TEST(testCellGridSpan, "cell-grid-span.docx")
    1764             : {
    1765             :     // The problem was during export gridSpan value for 1st & 2nd cells for test document
    1766             :     // used to get set wrongly to 5 and 65532 respectively which was the reason for crash during save operation
    1767             :     // Varifying gridSpan element is not present in RoundTriped Document (As it's Default value is 1).
    1768           2 :     xmlDocPtr pXmlDoc = parseExport();
    1769           2 :     if (!pXmlDoc)
    1770           3 :         return;
    1771           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:tcPr/w:gridSpan",0);
    1772           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[2]/w:tcPr/w:gridSpan",0);
    1773             : }
    1774          14 : DECLARE_OOXMLEXPORT_TEST(testFdo71646, "fdo71646.docx")
    1775             : {
    1776             :     // The problem was after save file created by MS the direction changed to RTL.
    1777           2 :     uno::Reference<uno::XInterface> xParaLTRLeft(getParagraph( 1, "LTR LEFT"));
    1778           2 :     sal_Int32 nLTRLeft = getProperty< sal_Int32 >( xParaLTRLeft, "ParaAdjust" );
    1779             :     // test the text Direction value for the pragraph
    1780           2 :     sal_Int16 nLRDir  = getProperty< sal_Int32 >( xParaLTRLeft, "WritingMode" );
    1781             : 
    1782             :     // this will test the both the text direction and alignment for paragraph
    1783           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLTRLeft);
    1784           2 :     CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir);
    1785           2 : }
    1786             : 
    1787          14 : DECLARE_OOXMLEXPORT_TEST(testParaAutoSpacing, "para-auto-spacing.docx")
    1788             : {
    1789           2 :     xmlDocPtr pXmlDoc = parseExport();
    1790           2 :     if (!pXmlDoc)
    1791           3 :         return;
    1792           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "beforeAutospacing","1");
    1793           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "afterAutospacing","1");
    1794             : 
    1795           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "beforeAutospacing","");
    1796           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "afterAutospacing","");
    1797           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "before","400");
    1798           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "after","400");
    1799             : }
    1800             : 
    1801          13 : DECLARE_OOXMLEXPORT_TEST(testGIFImageCrop, "test_GIF_ImageCrop.docx")
    1802             : {
    1803             :     // FIXME why does this fail on Mac?
    1804             : #if !defined(MACOSX)
    1805           1 :     uno::Reference<drawing::XShape> image = getShape(1);
    1806           2 :     uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
    1807           1 :     ::com::sun::star::text::GraphicCrop aGraphicCropStruct;
    1808             : 
    1809           1 :     imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct;
    1810             : 
    1811             :     // FIXME import test is disabled (we only check after import-export-import)
    1812             :     // The reason is that after import this is 1171 -- why?
    1813           1 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 1265 ), aGraphicCropStruct.Left );
    1814           1 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 4256 ), aGraphicCropStruct.Right );
    1815           1 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 1109 ), aGraphicCropStruct.Top );
    1816           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 1448 ), aGraphicCropStruct.Bottom );
    1817             : #endif
    1818           1 : }
    1819             : 
    1820          13 : DECLARE_OOXMLEXPORT_TEST(testPNGImageCrop, "test_PNG_ImageCrop.docx")
    1821             : {
    1822             :     // FIXME why does this fail on Mac?
    1823             : #if !defined(MACOSX)
    1824             :     /* The problem was image cropping information was not getting saved
    1825             :      * after roundtrip.
    1826             :      * Check for presenece of cropping parameters in exported file.
    1827             :      */
    1828           1 :     uno::Reference<drawing::XShape> image = getShape(1);
    1829           2 :     uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY);
    1830           1 :     ::com::sun::star::text::GraphicCrop aGraphicCropStruct;
    1831             : 
    1832           1 :     imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct;
    1833             : 
    1834             :     // FIXME import test is disabled (we only check after import-export-import)
    1835             :     // The reason is that after import this is 1141 -- why?
    1836           1 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 1231 ), aGraphicCropStruct.Left );
    1837           1 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 1295 ), aGraphicCropStruct.Right );
    1838           1 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 1358 ), aGraphicCropStruct.Top );
    1839           2 :     CPPUNIT_ASSERT_EQUAL( sal_Int32( 737 ), aGraphicCropStruct.Bottom );
    1840             : #endif
    1841           1 : }
    1842             : 
    1843          14 : DECLARE_OOXMLEXPORT_TEST(testFootnoteParagraphTag, "testFootnote.docx")
    1844             : {
    1845             :     /* In footnotes.xml, the paragraph tag inside <w:footnote w:id="2"> was getting written into document.xml.
    1846             :      * Check for, paragraph tag is correctly written into footnotes.xml.
    1847             :      */
    1848           2 :     xmlDocPtr pXmlFootnotes = parseExport("word/footnotes.xml");
    1849           2 :     if (!pXmlFootnotes)
    1850           3 :         return;
    1851           1 :     assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]","id","2");
    1852           1 :     assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]/w:p/w:r/w:rPr/w:rStyle","val","Footnotereference");
    1853             : }
    1854             : 
    1855          14 : DECLARE_OOXMLEXPORT_TEST(testSpacingLineRule,"table_lineRule.docx")
    1856             : {
    1857           2 :      xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    1858           2 :     if (!pXmlDoc)
    1859           3 :         return;
    1860           1 :      assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:spacing", "lineRule", "auto");
    1861             : }
    1862             : 
    1863          14 : DECLARE_OOXMLEXPORT_TEST(testTableLineSpacing, "table_atleast.docx")
    1864             : {
    1865           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    1866           2 :     if (!pXmlDoc)
    1867           3 :         return;
    1868           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:pPr/w:spacing", "line", "320");
    1869             : }
    1870             : 
    1871          14 : DECLARE_OOXMLEXPORT_TEST(testOoxmlTriangle, "ooxml-triangle.docx")
    1872             : {
    1873             :     // The problem was that ooxml-triangle shape type wasn't handled by VML
    1874             :     // export (only isosceles-triangle), leading to a missing shape.
    1875           2 :     getShape(1);
    1876           2 : }
    1877             : 
    1878          14 : DECLARE_OOXMLEXPORT_TEST(testMce, "mce.docx")
    1879             : {
    1880             :     // The shape is red in Word2007, green in Word2010. Check that our import follows the later.
    1881           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x9bbb59), getProperty<sal_Int32>(getShape(1), "FillColor"));
    1882           2 : }
    1883             : 
    1884          14 : DECLARE_OOXMLEXPORT_TEST(testThemePreservation, "theme-preservation.docx")
    1885             : {
    1886             :     // check default font theme values have been preserved
    1887           2 :     xmlDocPtr pXmlStyles = parseExport("word/styles.xml");
    1888           2 :     if (!pXmlStyles)
    1889           2 :         return;
    1890           1 :     assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "asciiTheme", "minorHAnsi");
    1891           1 :     assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "cstheme", "minorBidi");
    1892             : 
    1893             :     // check the font theme values in style definitions
    1894           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[1]/w:rPr/w:rFonts", "eastAsiaTheme", "minorEastAsia");
    1895             : 
    1896             :     // check the color theme values in style definitions
    1897           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Custom1']/w:rPr/w:color", "themeColor", "accent1");
    1898           1 :     assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Custom1']/w:rPr/w:color", "themeTint", "99");
    1899             : 
    1900             :     // check direct format font theme values have been preserved
    1901           1 :     xmlDocPtr pXmlDocument = parseExport("word/document.xml");
    1902           1 :     if (!pXmlDocument)
    1903           0 :         return;
    1904           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:p[5]/w:r[1]/w:rPr/w:rFonts", "hAnsiTheme", "majorHAnsi");
    1905           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:p[5]/w:r[1]/w:rPr/w:rFonts", "asciiTheme", "majorHAnsi");
    1906             : 
    1907             :     // check theme font color value has been preserved
    1908           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeColor", "accent3");
    1909           1 :     OUString sThemeShade = getXPath(pXmlDocument, "/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeShade");
    1910           1 :     CPPUNIT_ASSERT_EQUAL(sThemeShade.toInt32(16), sal_Int32(0xbf));
    1911           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:p[7]/w:r[1]/w:rPr/w:color", "themeColor", "accent1");
    1912           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:p[7]/w:r[1]/w:rPr/w:color", "themeTint", "99");
    1913             : 
    1914             :     // check the themeFontLang values in settings file
    1915           1 :     xmlDocPtr pXmlSettings = parseExport("word/settings.xml");
    1916           1 :     if (!pXmlSettings)
    1917           0 :         return;
    1918           1 :     assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "val", "en-US");
    1919           1 :     assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "eastAsia", "zh-CN");
    1920           1 :     assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "bidi", "he-IL");
    1921             : 
    1922             :     // check fonts have been applied properly
    1923             :     sal_Unicode fontName[2]; //represents the string "宋体"
    1924           1 :     fontName[0] = 0x5b8b;
    1925           1 :     fontName[1] = 0x4f53;
    1926           1 :     CPPUNIT_ASSERT_EQUAL(OUString(fontName, 2), getProperty<OUString>(getParagraph(1), "CharFontNameAsian"));
    1927           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Arial"),
    1928           1 :                          getProperty<OUString>(getParagraph(2), "CharFontNameComplex"));
    1929           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Trebuchet MS"),
    1930           1 :                          getProperty<OUString>(getParagraph(3, "Default style theme font"), "CharFontName"));
    1931           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Arial Black"),
    1932           1 :                          getProperty<OUString>(getRun(getParagraph(4, "Direct format font"), 1), "CharFontName"));
    1933           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Trebuchet MS"),
    1934           1 :                          getProperty<OUString>(getParagraph(5, "Major theme font"), "CharFontName"));
    1935             : 
    1936             :     // check the paragraph background theme color has been preserved
    1937           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeFill", "text2");
    1938             : }
    1939             : 
    1940          14 : DECLARE_OOXMLEXPORT_TEST(testTableThemePreservation, "table-theme-preservation.docx")
    1941             : {
    1942           2 :     xmlDocPtr pXmlDocument = parseExport("word/document.xml");
    1943           2 :     if (!pXmlDocument)
    1944           3 :         return;
    1945             : 
    1946             :     // check cell theme colors have been preserved
    1947           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFill", "accent6");
    1948           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFillShade", "");
    1949           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFillTint", "33");
    1950           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFill", "accent6");
    1951           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFillShade", "");
    1952           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFillTint", "");
    1953           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFill", "accent6");
    1954           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFillShade", "80");
    1955           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFillTint", "");
    1956             : 
    1957             :     // check table style has been preserved
    1958           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tblPr/w:tblStyle", "val", "Sombreadoclaro-nfasis1");
    1959             :     // check table style is not overwritten by other properties
    1960           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:tcPr/w:tcBorders/*", 0);
    1961           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[3]/w:tcPr/w:tcBorders/*", 0);
    1962             :     // check that one cell attribute present in the original document has been preserved
    1963           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/*", 1);
    1964             : 
    1965             : }
    1966             : 
    1967          14 : DECLARE_OOXMLEXPORT_TEST(testcantSplit, "2_table_doc.docx")
    1968             : {
    1969             :     // if Split table value is true for a table then during export do not write <w:cantSplit w:val="false"/>
    1970             :     // in table row property,As default row prop is allow row to break across page.
    1971             :     // writing <w:cantSplit w:val="false"/> during export was causing problem that all the cell data used to come on same page
    1972           2 :     xmlDocPtr pXmlDoc = parseExport();
    1973           2 :     if (!pXmlDoc)
    1974           3 :         return;
    1975           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr/w:trPr/w:cantSplit",0);
    1976           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[2]/w:tr/w:trPr/w:cantSplit","val","true");
    1977             : }
    1978             : 
    1979          14 : DECLARE_OOXMLEXPORT_TEST(testExtraSectionBreak, "1_page.docx")
    1980             : {
    1981             :     // There was a problem for some documents during export.Invalid sectPr getting added
    1982             :     // because of faulty calculation of PageDesc value
    1983             :     // This was the reason for increasing number of pages after RT
    1984           2 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
    1985           4 :     uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
    1986           4 :     uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
    1987           2 :     xCursor->jumpToLastPage();
    1988           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage());
    1989           2 : }
    1990             : 
    1991          14 : DECLARE_OOXMLEXPORT_TEST(testcolumnbreak, "columnbreak.docx")
    1992             : {
    1993           2 :     CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(5, "This is first line after col brk."), "BreakType"));
    1994           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    1995           2 :     if (!pXmlDoc)
    1996           3 :         return;
    1997           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[1]/w:br", "type", "column");
    1998             : }
    1999             : 
    2000          14 : DECLARE_OOXMLEXPORT_TEST(testGlossary, "testGlossary.docx")
    2001             : {
    2002           2 :     xmlDocPtr pXmlDoc = parseExport("word/glossary/document.xml");
    2003           2 :     if (!pXmlDoc)
    2004           3 :         return;
    2005           1 :     assertXPath(pXmlDoc, "/w:glossaryDocument", "Ignorable", "w14 wp14");
    2006             : }
    2007             : 
    2008          14 : DECLARE_OOXMLEXPORT_TEST(testFdo71785, "fdo71785.docx")
    2009             : {
    2010             :     // crashtest
    2011           2 : }
    2012             : 
    2013          14 : DECLARE_OOXMLEXPORT_TEST(testCrashWhileSave, "testCrashWhileSave.docx")
    2014             : {
    2015           2 :     xmlDocPtr pXmlDoc = parseExport("word/footer1.xml");
    2016           2 :     if (!pXmlDoc)
    2017           3 :         return;
    2018           1 :     CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:ftr/w:tbl/w:tr/w:tc[1]/w:p[1]/w:pPr/w:pStyle", "val").match("Normal"));
    2019             : }
    2020             : 
    2021          14 : DECLARE_OOXMLEXPORT_TEST(testFileOpenInputOutputError,"floatingtbl_with_formula.docx")
    2022             : {
    2023             :      // Docx containing Floating table with formula was giving "General input/output error" while opening in LibreOffice
    2024           2 :      xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2025           2 :      if (!pXmlDoc)
    2026           3 :          return;
    2027           1 :       assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pStyle", "val", "Normal");
    2028             : }
    2029             : 
    2030          14 : DECLARE_OOXMLEXPORT_TEST(testRelorientation, "relorientation.docx")
    2031             : {
    2032           2 :     uno::Reference<drawing::XShape> xShape = getShape(1);
    2033             :     // This was text::RelOrientation::FRAME, when handling relativeFrom=page, align=right
    2034           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_RIGHT, getProperty<sal_Int16>(xShape, "HoriOrientRelation"));
    2035             : 
    2036           4 :     uno::Reference<drawing::XShapes> xGroup(xShape, uno::UNO_QUERY);
    2037             :     // This resulted in lang::IndexOutOfBoundsException, as nested groupshapes weren't handled.
    2038           4 :     uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(0), uno::UNO_QUERY);
    2039           2 :     CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), xShapeDescriptor->getShapeType());
    2040             : 
    2041             :     // Right after import we get a rounding error: 8662 vs 8664.
    2042           2 :     if (m_bExported)
    2043             :     {
    2044           1 :         uno::Reference<drawing::XShape> xYear(xGroup->getByIndex(1), uno::UNO_QUERY);
    2045             :         // This was 2, due to incorrect handling of parent transformations inside DML groupshapes.
    2046           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(8664), xYear->getSize().Width);
    2047           2 :     }
    2048           2 : }
    2049             : 
    2050          13 : DECLARE_OOXMLEXPORT_TEST(testBezier, "bezier.odt")
    2051             : {
    2052           1 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
    2053           2 :     uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
    2054             :     // Check that no shape got lost: a bezier, a line and a text shape.
    2055           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xDraws->getCount());
    2056           1 : }
    2057             : 
    2058          14 : DECLARE_OOXMLEXPORT_TEST(testGroupshapeTextbox, "groupshape-textbox.docx")
    2059             : {
    2060           2 :     uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
    2061           4 :     uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY);
    2062             :     // The VML export lost text on textboxes inside groupshapes.
    2063             :     // The DML export does not, make sure it stays that way.
    2064           2 :     CPPUNIT_ASSERT_EQUAL(OUString("first"), xShape->getString());
    2065             :     // This was 16, i.e. inheriting doc default char height didn't work.
    2066           4 :     CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight"));
    2067           2 : }
    2068             : 
    2069          14 : DECLARE_OOXMLEXPORT_TEST(testGroupshapePicture, "groupshape-picture.docx")
    2070             : {
    2071             :     // Picture in the groupshape got lost, groupshape had only one child.
    2072           2 :     uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
    2073           4 :     uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(1), uno::UNO_QUERY);
    2074           4 :     CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GraphicObjectShape"), xShapeDescriptor->getShapeType());
    2075           2 : }
    2076             : 
    2077          14 : DECLARE_OOXMLEXPORT_TEST(testAutofit, "autofit.docx")
    2078             : {
    2079           2 :     CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(getShape(1), "FrameIsAutomaticHeight")));
    2080           2 :     CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(getShape(2), "FrameIsAutomaticHeight")));
    2081           2 : }
    2082             : 
    2083          14 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedParagraphMark, "testTrackChangesDeletedParagraphMark.docx")
    2084             : {
    2085           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2086           2 :     if (!pXmlDoc)
    2087           3 :         return;
    2088           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:del");
    2089             : }
    2090             : 
    2091          14 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedParagraphMark, "testTrackChangesInsertedParagraphMark.docx")
    2092             : {
    2093           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2094           2 :     if (!pXmlDoc)
    2095           3 :         return;
    2096           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:ins");
    2097             : }
    2098             : 
    2099          14 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedTableRow, "testTrackChangesDeletedTableRow.docx")
    2100             : {
    2101           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2102           2 :     if (!pXmlDoc)
    2103           3 :         return;
    2104           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:del");
    2105             : }
    2106             : 
    2107          14 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedTableRow, "testTrackChangesInsertedTableRow.docx")
    2108             : {
    2109           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2110           2 :     if (!pXmlDoc)
    2111           3 :         return;
    2112           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:ins");
    2113             : }
    2114             : 
    2115          14 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedTableCell, "testTrackChangesDeletedTableCell.docx")
    2116             : {
    2117           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2118           2 :     if (!pXmlDoc)
    2119           3 :         return;
    2120           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellDel");
    2121             : }
    2122             : 
    2123          14 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedTableCell, "testTrackChangesInsertedTableCell.docx")
    2124             : {
    2125           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2126           2 :     if (!pXmlDoc)
    2127           3 :         return;
    2128           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellIns");
    2129             : }
    2130             : 
    2131          14 : DECLARE_OOXMLEXPORT_TEST(testFdo69649, "fdo69649.docx")
    2132             : {
    2133             :     // The DOCX containing the Table of Contents was not exported with correct page nos
    2134           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2135           2 :     if (!pXmlDoc)
    2136           3 :         return;
    2137             : 
    2138           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[21]/w:hyperlink/w:r[5]/w:t", "15");
    2139             : }
    2140             : 
    2141          14 : DECLARE_OOXMLEXPORT_TEST(testTextBoxPictureFill, "textbox_picturefill.docx")
    2142             : {
    2143           2 :     uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY);
    2144           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
    2145           2 :     CPPUNIT_ASSERT(!(getProperty<OUString>(xFrame,"BackGraphicURL")).isEmpty());
    2146           2 : }
    2147             : 
    2148          14 : DECLARE_OOXMLEXPORT_TEST(testFDO73034, "FDO73034.docx")
    2149             : {
    2150           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2151           2 :     if (!pXmlDoc)
    2152           3 :         return;
    2153           1 :     CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:u", "val").match("single"));
    2154             : }
    2155             : 
    2156          14 : DECLARE_OOXMLEXPORT_TEST(testFDO71834, "fdo71834.docx")
    2157             : {
    2158           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2159           2 :     if (!pXmlDoc)
    2160           3 :         return;
    2161           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[4]/w:tr[2]/w:tc[1]/w:tcPr[1]/w:tcW[1]","type", "dxa");
    2162             : }
    2163             : 
    2164          14 : DECLARE_OOXMLEXPORT_TEST(testFieldFlagO,"TOC_field_f.docx")
    2165             : {
    2166             :    // This test case is to verify \o flag should come once.
    2167           2 :     xmlDocPtr pXmlDoc = parseExport();
    2168           2 :     if (!pXmlDoc)
    2169           3 :         return;
    2170             : 
    2171             :     // FIXME "p[2]" will have to be "p[1]", once the TOC import code is fixed
    2172             :     // not to insert an empty paragraph before TOC.
    2173           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:instrText", " TOC \\z \\f \\o \"1-3\" \\u \\h");
    2174             : }
    2175             : 
    2176          14 : DECLARE_OOXMLEXPORT_TEST(testTOCFlag_f, "toc_doc.docx")
    2177             : {
    2178             :     // Export logic for all TOC field flags was enclosed inside
    2179             :     // if( nsSwTOXElement::TOX_MARK & pTOX->GetCreateType() ) in ww8atr.cxx which gets true for \f,
    2180             :     // this was the reason if there is \f flag present in original doc then only other flags like
    2181             :     // \o \h \n used to come after RoundTrip.
    2182             :     // This test case is to verify even if there is no \f flag in original doc, \h flag is getting
    2183             :     // preserved after RT.
    2184           2 :     xmlDocPtr pXmlDoc = parseExport();
    2185           2 :     if (!pXmlDoc)
    2186           3 :         return;
    2187             : 
    2188             :     // FIXME "p[2]" will have to be "p[1]", once the TOC import code is fixed
    2189             :     // not to insert an empty paragraph before TOC.
    2190           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:instrText", " TOC \\z \\o \"1-3\" \\u \\h");
    2191             : }
    2192             : 
    2193          14 : DECLARE_OOXMLEXPORT_TEST(testPreserveZfield,"preserve_Z_field_TOC.docx")
    2194             : {
    2195           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2196           2 :     if (!pXmlDoc)
    2197           3 :         return;
    2198             : 
    2199           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[2]/w:instrText", " TOC \\z \\f \\o \"1-3\" \\h");
    2200             : }
    2201             : 
    2202          14 : DECLARE_OOXMLEXPORT_TEST(testPreserveWfieldTOC, "PreserveWfieldTOC.docx")
    2203             : {
    2204           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2205           2 :     if (!pXmlDoc)
    2206           3 :         return;
    2207             : 
    2208           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:instrText", " TOC \\z \\w \\f \\o \"1-3\" \\h");
    2209             : }
    2210             : 
    2211          14 : DECLARE_OOXMLEXPORT_TEST(testFieldFlagB,"TOC_field_b.docx")
    2212             : {
    2213             :     // This test case is to verify \b flag.
    2214           2 :     xmlDocPtr pXmlDoc = parseExport();
    2215           2 :     if (!pXmlDoc)
    2216           3 :         return;
    2217             : 
    2218             :     // FIXME "p[2]" will have to be "p[1]", once the TOC import code is fixed
    2219             :     // not to insert an empty paragraph before TOC.
    2220           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:instrText", " TOC \\b \"bookmark111\" \\o \"1-9\" \\h");
    2221             : }
    2222             : 
    2223          14 : DECLARE_OOXMLEXPORT_TEST(testPreserveXfieldTOC, "PreserveXfieldTOC.docx")
    2224             : {
    2225           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2226           2 :     if (!pXmlDoc)
    2227           3 :         return;
    2228             : 
    2229           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:instrText", " TOC \\x \\f \\o \"1-3\" \\h");
    2230             : }
    2231             : 
    2232          14 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesParagraphProperties, "testTrackChangesParagraphProperties.docx")
    2233             : {
    2234           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2235           2 :     if (!pXmlDoc)
    2236           3 :         return;
    2237           1 :     assertXPathChildren(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pPrChange", 0);
    2238             : }
    2239             : 
    2240          14 : DECLARE_OOXMLEXPORT_TEST(testMsoSpt180, "mso-spt180.docx")
    2241             : {
    2242           2 :     if (!m_bExported)
    2243           3 :         return;
    2244             : 
    2245           1 :     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
    2246           2 :     uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xGroup->getByIndex(0), "CustomShapeGeometry");
    2247           2 :     OUString aType;
    2248          11 :     for (int i = 0; i < aProps.getLength(); ++i)
    2249          10 :         if (aProps[i].Name == "Type")
    2250           1 :             aType = aProps[i].Value.get<OUString>();
    2251             :     // This was exported as borderCallout90, which is an invalid drawingML preset shape string.
    2252           2 :     CPPUNIT_ASSERT_EQUAL(OUString("ooxml-borderCallout1"), aType);
    2253             : }
    2254             : 
    2255          14 : DECLARE_OOXMLEXPORT_TEST(testFdo73550, "fdo73550.docx")
    2256             : {
    2257           2 :     xmlDocPtr pXmlDocument = parseExport("word/document.xml");
    2258           2 :     if (!pXmlDocument)
    2259           3 :         return;
    2260             :     // This was wrap="none".
    2261           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:rFonts");
    2262             : }
    2263             : 
    2264          14 : DECLARE_OOXMLEXPORT_TEST(testPageRelSize, "pagerelsize.docx")
    2265             : {
    2266             :     // First textframe: width is relative from page, but not height.
    2267           2 :     uno::Reference<drawing::XShape> xTextFrame = getTextFrameByName("Frame1");
    2268           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation"));
    2269           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation"));
    2270             : 
    2271             :     // Second textframe: height is relative from page, but not height.
    2272           2 :     xTextFrame = getTextFrameByName("Text Box 2");
    2273           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeHeightRelation"));
    2274           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xTextFrame, "RelativeWidthRelation"));
    2275           2 : }
    2276             : 
    2277          14 : DECLARE_OOXMLEXPORT_TEST(testRelSizeRound, "rel-size-round.docx")
    2278             : {
    2279             :     // This was 9: 9.8 was imported as 9 instead of being rounded to 10.
    2280           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty<sal_Int16>(getShape(1), "RelativeHeight"));
    2281           2 : }
    2282             : 
    2283          14 : DECLARE_OOXMLEXPORT_TEST(testTOCFlag_u,"testTOCFlag_u.docx")
    2284             : {
    2285             :     // DOCX contaning TOC should preserve code field '\u'.
    2286           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2287           2 :     if (!pXmlDoc)
    2288           3 :         return;
    2289             : 
    2290             :     // FIXME "p[2]" will have to be "p[1]", once the TOC import code is fixed
    2291             :     // not to insert an empty paragraph before TOC.
    2292           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:instrText", " TOC \\z \\o \"1-9\" \\u \\h");
    2293             : }
    2294             : 
    2295          14 : DECLARE_OOXMLEXPORT_TEST(testTestTitlePage, "testTitlePage.docx")
    2296             : {
    2297           2 :     CPPUNIT_ASSERT_EQUAL(OUString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), parseDump("/root/page[2]/footer/txt/text()"));
    2298           2 : }
    2299             : 
    2300          14 : DECLARE_OOXMLEXPORT_TEST(testTableRowDataDisplayedTwice,"table-row-data-displayed-twice.docx")
    2301             : {
    2302             :     // fdo#73534: There was a problem for some documents during export.Invalid sectPr getting added
    2303             :     // because of wrong condition in code.
    2304             :     // This was the reason for increasing number of pages after RT
    2305           2 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
    2306           4 :     uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
    2307           4 :     uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
    2308           2 :     xCursor->jumpToLastPage();
    2309           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
    2310           2 : }
    2311             : 
    2312          14 : DECLARE_OOXMLEXPORT_TEST(testFdo73556,"fdo73556.docx")
    2313             : {
    2314             :     /*
    2315             :     *  The file contains a table with 3 columns
    2316             :     *  the girdcols are as follows: {1210, 1331, 1210}
    2317             :     *  whereas the individual cells have {1210, 400, 1210}
    2318             :     *  The table column separators were taken from the Grid, while
    2319             :     *  the table width was calculated as 2820 from cells instead
    2320             :     *  of 3751 from the Grid.
    2321             :     */
    2322           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2323           2 :     if (!pXmlDoc)
    2324           3 :         return;
    2325           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol", 3);
    2326           1 :     sal_Int32 tableWidth = 0;
    2327           1 :     tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[1]", "w").toInt32();
    2328           1 :     tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32();
    2329           1 :     tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[3]", "w").toInt32();
    2330           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(3751), tableWidth);
    2331             : }
    2332             : 
    2333          14 : DECLARE_OOXMLEXPORT_TEST(testSegFaultWhileSave, "test_segfault_while_save.docx")
    2334             : {
    2335             :     // fdo#74499
    2336           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2337           2 :     if (!pXmlDoc)
    2338           3 :         return;
    2339           1 :     CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").match("6138"));
    2340             : }
    2341             : 
    2342          14 : DECLARE_OOXMLEXPORT_TEST(fdo69656, "Table_cell_auto_width_fdo69656.docx")
    2343             : {
    2344             :     // Check for the width type of table and its cells.
    2345           2 :     xmlDocPtr pXmlDoc = parseExport();
    2346           2 :     if (!pXmlDoc)
    2347           3 :         return;
    2348           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblW","type","auto");
    2349             : }
    2350             : 
    2351          14 : DECLARE_OOXMLEXPORT_TEST(testFdo73541,"fdo73541.docx")
    2352             : {
    2353             :     // fdo#73541: The mirrored margins were not imported and mapped correctly in Page Layout
    2354             :     // Hence <w:mirrorMargins /> tag was not exported back in settings.xml
    2355           2 :     xmlDocPtr pXmlDoc = parseExport("word/settings.xml");
    2356           2 :     if (!pXmlDoc)
    2357           3 :         return;
    2358           1 :     assertXPath(pXmlDoc, "/w:settings/w:mirrorMargins");
    2359             : }
    2360             : 
    2361          14 : DECLARE_OOXMLEXPORT_TEST(testfdo73596_RunInStyle,"fdo73596_RunInStyle.docx")
    2362             : {
    2363             :     // INDEX should be preserved.
    2364           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2365           2 :     if (!pXmlDoc)
    2366           3 :         return;
    2367             : 
    2368           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:instrText[1]", " INDEX \\e \"");
    2369             : }
    2370             : 
    2371          14 : DECLARE_OOXMLEXPORT_TEST(testfdo73596_AlphaSeparator,"fdo73596_AlphaSeparator.docx")
    2372             : {
    2373             :     // INDEX flag \h "A" should be preserved.
    2374           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2375           2 :     if (!pXmlDoc)
    2376           3 :         return;
    2377             : 
    2378           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:instrText[1]", " INDEX \\h \"A\" \\e \"");
    2379             : }
    2380             : 
    2381          14 : DECLARE_OOXMLEXPORT_TEST(testFDO74106, "FDO74106.docx")
    2382             : {
    2383           2 :     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
    2384           2 :     if (!pXmlDoc)
    2385           3 :         return;
    2386           1 :     assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:numFmt", "val","hebrew1");
    2387             : }
    2388             : 
    2389          14 : DECLARE_OOXMLEXPORT_TEST(testFDO74215, "FDO74215.docx")
    2390             : {
    2391           2 :     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
    2392           2 :     if (!pXmlDoc)
    2393           3 :         return;
    2394           1 :     assertXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style", "width:6.4pt;height:6.4pt");
    2395             : }
    2396             : 
    2397          14 : DECLARE_OOXMLEXPORT_TEST(testColumnBreak_ColumnCountIsZero,"fdo74153.docx")
    2398             : {
    2399             :     /* fdo73545: Column Break with Column_count = 0 was not getting preserved.
    2400             :      * The <w:br w:type="column" /> was missing after roundtrip
    2401             :      */
    2402           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2403           2 :     if (!pXmlDoc)
    2404           3 :         return;
    2405           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/w:br","type","column");
    2406             : }
    2407             : 
    2408          14 : DECLARE_OOXMLEXPORT_TEST(testIndentation, "test_indentation.docx")
    2409             : {
    2410             :     // fdo#74141 :There was a problem that in style.xml and document.xml in <w:ind> tag "right" & "left" margin
    2411             :     // attributes gets added(w:right=0 & w:left=0) if these attributes are not set in original document.
    2412             :     // This test is to verify <w:ind> does not contain w:right attribute.
    2413           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2414           2 :     if (!pXmlDoc)
    2415           3 :         return;
    2416           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:ind", "end", "");
    2417             : }
    2418             : 
    2419          14 : DECLARE_OOXMLEXPORT_TEST(testCaption1, "EquationAsScientificNumbering.docx")
    2420             : {
    2421             :     // fdo#74431 : This test case is to verify the Captions are comming properly
    2422             :     //earlier it was comming as "SEQ "scientific"\*ROMAN now it is SEQ scientific\* ROMAN"
    2423             : 
    2424           2 :     xmlDocPtr pXmlDoc = parseExport();
    2425           2 :     if (!pXmlDoc)
    2426           3 :         return;
    2427             : 
    2428           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[3]/w:instrText", " SEQ scientific \\* ROMAN ");
    2429             : }
    2430             : 
    2431          14 : DECLARE_OOXMLEXPORT_TEST(testCaption2, "EquationWithAboveAndBelowCaption.docx")
    2432             : {
    2433             :     // fdo#72563 : There was a problem that in case of TOC,PAGEREF field tag was not preserved during Roundtrip
    2434             :     // This test case is to verify that PAGEREF tag is coming with proper values inside <hyperlink> tag.
    2435           2 :     xmlDocPtr pXmlDoc = parseExport();
    2436           2 :     if (!pXmlDoc)
    2437           3 :         return;
    2438             : 
    2439           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[3]/w:instrText", " SEQ Equation \\* ARABIC ");
    2440             : }
    2441             : 
    2442          14 : DECLARE_OOXMLEXPORT_TEST(testCaption3, "FigureAsLabelPicture.docx")
    2443             : {
    2444             :     // fdo#72563 : There was a problem that in case of TOC,PAGEREF field tag was not preserved during Roundtrip
    2445             :     // This test case is to verify that PAGEREF tag is coming with proper values inside <hyperlink> tag.
    2446           2 :     xmlDocPtr pXmlDoc = parseExport();
    2447           2 :     if (!pXmlDoc)
    2448           3 :         return;
    2449             : 
    2450           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[3]/w:instrText", " SEQ picture \\* ARABIC ");
    2451             : }
    2452             : 
    2453          14 : DECLARE_OOXMLEXPORT_TEST(testCaption4, "TableWithAboveCaptions.docx")
    2454             : {
    2455             :     // fdo#72563 : There was a problem that in case of TOC,PAGEREF field tag was not preserved during Roundtrip
    2456             :     // This test case is to verify that PAGEREF tag is coming with proper values inside <hyperlink> tag.
    2457           2 :     xmlDocPtr pXmlDoc = parseExport();
    2458           2 :     if (!pXmlDoc)
    2459           3 :         return;
    2460             : 
    2461           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[3]/w:instrText", " SEQ Table \\* ARABIC ");
    2462             : }
    2463             : 
    2464          14 : DECLARE_OOXMLEXPORT_TEST(testChartInFooter, "chart-in-footer.docx")
    2465             : {
    2466             :     // fdo#73872: document contains chart in footer.
    2467             :     // The problem was that  footer1.xml.rels files for footer1.xml
    2468             :     // files were missing from docx file after roundtrip.
    2469           2 :     xmlDocPtr pXmlDoc = parseExport("word/_rels/footer1.xml.rels");
    2470           2 :     if(!pXmlDoc)
    2471           3 :         return;
    2472             : 
    2473             :     // Check footer1.xml.rels contains in doc after roundtrip.
    2474             :     // Check Id = rId1 in footer1.xml.rels
    2475           1 :     assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship","Id","rId1");
    2476             : 
    2477           1 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
    2478           1 :     if (xDrawPageSupplier.is())
    2479             :     {
    2480             :         // If xDrawPage->getCount()==1, then document conatins one shape.
    2481           1 :         uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
    2482           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount()); // One shape in the doc
    2483           1 :     }
    2484             : }
    2485             : 
    2486          13 : DECLARE_OOXMLEXPORT_TEST(testNestedTextFrames, "nested-text-frames.odt")
    2487             : {
    2488             :     // First problem was LO crashed during export (crash test)
    2489             : 
    2490             :     // Second problem was LO made file corruption, writing out nested text boxes, which can't be handled by Word.
    2491             :     // Test that all three exported text boxes are anchored to the same paragraph and not each other.
    2492           1 :     uno::Reference<text::XTextContent> xTextContent(getShape(1), uno::UNO_QUERY);
    2493           2 :     uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
    2494           2 :     uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY);
    2495           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
    2496             : 
    2497           1 :     xTextContent.set(getShape(2), uno::UNO_QUERY);
    2498           1 :     xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY);
    2499           1 :     xText.set(xRange->getText(), uno::UNO_QUERY);
    2500           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
    2501             : 
    2502           1 :     xTextContent.set(getShape(3), uno::UNO_QUERY);
    2503           1 :     xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY);
    2504           1 :     xText.set(xRange->getText(), uno::UNO_QUERY);
    2505           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
    2506           1 : }
    2507             : 
    2508          14 : DECLARE_OOXMLEXPORT_TEST(testFloatingTablePosition, "floating-table-position.docx")
    2509             : {
    2510             :     // Position of text frame was wrong, because some conversion was missing.
    2511           2 :     uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
    2512           4 :     uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
    2513           4 :     uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
    2514             :     // This was 3295.
    2515           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(5964), getProperty<sal_Int32>(xFrame, "HoriOrientPosition"));
    2516             :     // This was 4611.
    2517           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(8133), getProperty<sal_Int32>(xFrame, "VertOrientPosition"));
    2518           2 : }
    2519             : 
    2520          14 : DECLARE_OOXMLEXPORT_TEST(testAbi11739, "abi11739.docx")
    2521             : {
    2522             :     // Validation test: order of elements were wrong.
    2523           2 :     xmlDocPtr pXmlDoc = parseExport("word/styles.xml");
    2524           2 :     if (!pXmlDoc)
    2525           3 :         return;
    2526             :     // Order was: uiPriority, link, basedOn.
    2527           1 :     CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "basedOn") < getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "link"));
    2528           1 :     CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "link") < getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "uiPriority"));
    2529             :     // Order was: qFormat, unhideWhenUsed.
    2530           1 :     CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "unhideWhenUsed") < getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "qFormat"));
    2531             : }
    2532             : 
    2533          14 : DECLARE_OOXMLEXPORT_TEST(testEmbeddedXlsx, "embedded-xlsx.docx")
    2534             : {
    2535             :     // check there are two objects and they are FrameShapes
    2536           2 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
    2537           3 :     uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
    2538           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
    2539           2 :     CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(1)->getShapeType());
    2540           2 :     CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(2)->getShapeType());
    2541             : 
    2542             :     // check the objects are present in the exported document.xml
    2543           2 :     xmlDocPtr pXmlDocument = parseExport("word/document.xml");
    2544           2 :     if (!pXmlDocument)
    2545           3 :         return;
    2546           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/w:object", 2);
    2547             : 
    2548             :     // finally check the embedded files are present in the zipped document
    2549           2 :     uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), m_aTempFile.GetURL());
    2550           2 :     uno::Sequence<OUString> names = xNameAccess->getElementNames();
    2551           1 :     int nSheetFiles = 0;
    2552           1 :     int nImageFiles = 0;
    2553          15 :     for (int i=0; i<names.getLength(); i++)
    2554             :     {
    2555          14 :         if(names[i].startsWith("word/embeddings/oleObject"))
    2556           2 :             nSheetFiles++;
    2557          14 :         if(names[i].startsWith("word/media/image"))
    2558           2 :             nImageFiles++;
    2559             :     }
    2560           1 :     CPPUNIT_ASSERT_EQUAL(2, nSheetFiles);
    2561           2 :     CPPUNIT_ASSERT_EQUAL(2, nImageFiles);
    2562             : }
    2563             : 
    2564          14 : DECLARE_OOXMLEXPORT_TEST(testNumberedLists_StartingWithZero, "FDO74105.docx")
    2565             : {
    2566             :     /* Issue : Numbered lists Starting with value '0' is not preserved after RT.
    2567             :      * In numbering.xml, an XML tag <w:start> is optional. If not mentioned,
    2568             :      * the Numbered list should start from 0.
    2569             :      * Problem was LO was writing <w:start> for all levels 0-8 with default value "1".
    2570             :      */
    2571           2 :     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
    2572           2 :     if (!pXmlDoc)
    2573           3 :       return;
    2574             : 
    2575             :     // Check that we do _not_ export w:start for <w:lvl w:ilvl="0">.
    2576           1 :     assertXPath(pXmlDoc, "w:numbering/w:abstractNum[1]/w:lvl[1]/w:start", 0);
    2577             : }
    2578             : 
    2579          14 : DECLARE_OOXMLEXPORT_TEST(testFooterContainHyperlink,"footer-contain-hyperlink.docx")
    2580             : {
    2581             :     // Problem is that footer1.xml.rels contains the empty
    2582             :     // Target due to which the file get corrupted
    2583             :     // in MS Office 2007.
    2584             :     // Check for footer1.xml.rels file.
    2585           2 :     xmlDocPtr pXmlRels = parseExport("word/_rels/footer1.xml.rels");
    2586           2 :     if (!pXmlRels)
    2587           3 :         return;
    2588             :     // Check the value of Target which is http://www.google.com/.
    2589           1 :     assertXPath(pXmlRels,"/rels:Relationships/rels:Relationship","Target","http://www.google.com/");
    2590             : }
    2591             : 
    2592          14 : DECLARE_OOXMLEXPORT_TEST(testPageBreak,"fdo74566.docx")
    2593             : {
    2594             :     /*  Break to next page was written into wrong paragraph as <w:pageBreakBefore />.
    2595             :      *  LO was not preserving Page Break as <w:br w:type="page" />.
    2596             :      *  Now after fix , LO writes Page Break as the new paragraph and also
    2597             :      *  preserves the xml tag <w:br>.
    2598             :      */
    2599           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2600           2 :     if (!pXmlDoc)
    2601           3 :         return;
    2602             : 
    2603           1 :     uno::Reference<text::XTextRange> xParagraph2 = getParagraph(2);
    2604           2 :     uno::Reference<text::XTextRange> xParagraph4 = getParagraph(4);
    2605             : 
    2606           1 :     getRun(xParagraph2, 1, "First Page Second Line");
    2607           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[2]/w:br","type","page");
    2608           2 :     getRun(xParagraph4, 1, "Second Page First line after Page Break");
    2609             : }
    2610             : 
    2611          14 : DECLARE_OOXMLEXPORT_TEST(testAlphabeticalIndex_MultipleColumns,"alphabeticalIndex_MultipleColumns.docx")
    2612             : {
    2613             :     // Bug :: fdo#73596
    2614             :     /*
    2615             :      * Index with multiple columns was not imported correctly and
    2616             :      * hence not exported correctly...
    2617             :      * The column count is given by the \c switch.
    2618             :      * If the column count is explicitly specified,
    2619             :      * MS Office adds section breaks before and after the Index.
    2620             :      */
    2621           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2622           2 :     if (!pXmlDoc)
    2623           3 :         return;
    2624             : 
    2625           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[2]/w:instrText", " INDEX \\c \"4\"\\e \"");
    2626             : 
    2627             :     // check for section breaks after and before the Index Section
    2628           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:sectPr/w:type","val","continuous");
    2629           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:sectPr/w:type","val","continuous");
    2630             :     // check for "w:space" attribute for the columns in Section Properties
    2631           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:sectPr/w:cols/w:col[1]","space","720");
    2632             : }
    2633             : 
    2634          14 : DECLARE_OOXMLEXPORT_TEST(testPageref, "testPageref.docx")
    2635             : {
    2636             :     // fdo#72563 : There was a problem that in case of TOC,PAGEREF field tag was not preserved during Roundtrip
    2637             :     // This test case is to verify that PAGEREF tag is coming with proper values inside <hyperlink> tag.
    2638           2 :     xmlDocPtr pXmlDoc = parseExport();
    2639           2 :     if (!pXmlDoc)
    2640           3 :         return;
    2641             : 
    2642           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:hyperlink/w:r[3]/w:instrText", "PAGEREF _Toc355095261 \\h");
    2643             : }
    2644             : 
    2645          14 : DECLARE_OOXMLEXPORT_TEST(testAlphabeticalIndex_AutoColumn,"alphabeticalIndex_AutoColumn.docx")
    2646             : {
    2647             :     // Bug :: fdo#73596
    2648             :     /*
    2649             :      * When the columns in Index are 0; i.e not specified by the
    2650             :      * "\c" switch, don't write back '\c "0"' or the section breaks
    2651             :      * before and after the Index Context
    2652             :      */
    2653           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2654           2 :     if (!pXmlDoc)
    2655           3 :         return;
    2656             : 
    2657           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:instrText", " INDEX \\e \"");
    2658             : 
    2659             :     // check for section break doestn't appear for any paragraph
    2660           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:sectPr", 0);
    2661             : }
    2662             : 
    2663          14 : DECLARE_OOXMLEXPORT_TEST(testIndexFieldFlagF,"IndexFieldFlagF.docx")
    2664             : {
    2665             :     // This test case is to verify the Index field flag '\f' with some
    2666             :     // Specific Entry Type (ex. "Syn" in our case).
    2667           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2668           2 :     if (!pXmlDoc)
    2669           3 :         return;
    2670             :     // We check the Index field flag '\f'.
    2671           1 :     assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[4]/w:r[2]/w:instrText[1]", " INDEX \\c \"2\"\\f \"Syn\" \" \\e \"");
    2672             : }
    2673             : 
    2674          14 : DECLARE_OOXMLEXPORT_TEST(testBibliography,"FDO75133.docx")
    2675             : {
    2676           2 :     xmlDocPtr pXmlDoc = parseExport();
    2677           2 :     if (!pXmlDoc)
    2678           3 :         return;
    2679             : 
    2680           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/w:instrText", " BIBLIOGRAPHY ");
    2681           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:docPartObj/w:docPartGallery", "val", "Bibliographies");
    2682           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:docPartObj/w:docPartUnique", 1);
    2683             : }
    2684             : 
    2685          14 : DECLARE_OOXMLEXPORT_TEST(testOleObject, "test_ole_object.docx")
    2686             : {
    2687           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2688           2 :     if (!pXmlDoc)
    2689           3 :         return;
    2690             : 
    2691           1 :      assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata", "o:title", "");
    2692             : }
    2693             : 
    2694          14 : DECLARE_OOXMLEXPORT_TEST(testFdo74792, "fdo74792.docx")
    2695             : {
    2696             :     /*
    2697             :      * fdo#74792 : The images associated with smart-art data[i].xml
    2698             :      * were not preserved on exporting to DOCX format
    2699             :      * Added support to grabbag the rels, with associated images.
    2700             :      */
    2701           2 :     xmlDocPtr pXmlDoc = parseExport("word/diagrams/_rels/data1.xml.rels");
    2702           2 :     if(!pXmlDoc)
    2703           3 :         return;
    2704           1 :     assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship", 4);
    2705             :     uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(
    2706           1 :                          comphelper::getComponentContext(m_xSFactory), m_aTempFile.GetURL());
    2707             : 
    2708             :     //check that images are also saved
    2709           2 :     OUString sImageFile( "word/media/OOXDiagramDataRels0.jpeg" );
    2710           2 :     uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName( sImageFile ), uno::UNO_QUERY);
    2711           2 :     CPPUNIT_ASSERT( xInputStream.is() );
    2712             : }
    2713             : 
    2714          14 : DECLARE_OOXMLEXPORT_TEST(testTableCurruption, "tableCurrupt.docx")
    2715             : {
    2716           2 :     xmlDocPtr pXmlDoc = parseExport("word/header4.xml");
    2717           2 :     if (!pXmlDoc)
    2718           3 :         return;
    2719           1 :     CPPUNIT_ASSERT(pXmlDoc) ;
    2720           1 :     assertXPath(pXmlDoc, "/w:hdr/w:tbl[1]/w:tr[1]/w:tc[1]",1);
    2721             : }
    2722             : 
    2723          14 : DECLARE_OOXMLEXPORT_TEST(testGenericTextField, "Unsupportedtextfields.docx")
    2724             : {
    2725             :     // fdo#75158 : This test case is to verify the unsupported textfields are exported properly.
    2726             : 
    2727           2 :     xmlDocPtr pXmlDoc = parseExport();
    2728           2 :     if (!pXmlDoc)
    2729           3 :         return;
    2730           1 :     xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc,"/w:document/w:body/w:p[2]/w:r[2]/w:instrText");
    2731           1 :     xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
    2732           1 :     OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content));
    2733           1 :     CPPUNIT_ASSERT(contents.match("PRINTDATE   \\* MERGEFORMAT"));
    2734             : }
    2735             : 
    2736          14 : DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx")
    2737             : {
    2738             :     // check XML
    2739           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2740           2 :     if (!pXmlDoc)
    2741           3 :         return;
    2742           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date", "fullDate", "2014-03-05T00:00:00Z");
    2743           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:dateFormat", "val", "dddd, dd' de 'MMMM' de 'yyyy");
    2744           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:lid", "val", "es-ES");
    2745           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "miƩrcoles, 05 de marzo de 2014");
    2746             : 
    2747             :     // check imported control
    2748           1 :     uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY);
    2749           1 :     util::Date aDate = getProperty<util::Date>(xControl->getControl(), "Date");
    2750           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(5),    sal_Int32(aDate.Day));
    2751           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(3),    sal_Int32(aDate.Month));
    2752           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2014), sal_Int32(aDate.Year));
    2753             : }
    2754             : 
    2755          14 : DECLARE_OOXMLEXPORT_TEST(test_OpeningBrace, "2120112713_OpenBrace.docx")
    2756             : {
    2757           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2758           2 :     if (!pXmlDoc)
    2759           3 :         return;
    2760             :     // Checking for OpeningBrace tag
    2761           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[1]/m:dPr[1]/m:begChr[1]","val","");
    2762             : }
    2763             : 
    2764          14 : DECLARE_OOXMLEXPORT_TEST(testFDO76312, "FDO76312.docx")
    2765             : {
    2766           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2767           2 :     if (!pXmlDoc)
    2768           3 :         return;
    2769             : 
    2770           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]");
    2771             : }
    2772             : 
    2773          14 : DECLARE_OOXMLEXPORT_TEST(test_FieldType, "99_Fields.docx")
    2774             : {
    2775           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2776           2 :     if (!pXmlDoc)
    2777           3 :         return;
    2778             :     // Checking for three field types (BIBLIOGRAPHY, BIDIOUTLINE, CITATION) in sequence
    2779           1 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:r[2]/w:instrText[1]",1);
    2780           1 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[5]/w:r[2]/w:instrText[1]",1);
    2781           1 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:sdt/w:sdtContent/w:p/w:r[2]/w:instrText[1]",1);
    2782             : }
    2783             : 
    2784          14 : DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx")
    2785             : {
    2786             :     // check XML
    2787           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2788           2 :     if (!pXmlDoc)
    2789           3 :         return;
    2790           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[1]", "value", "manolo");
    2791           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[2]", "value", "pepito");
    2792           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "Manolo");
    2793             : 
    2794             :     // check imported control
    2795           1 :     uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY);
    2796             : 
    2797           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Manolo"), getProperty<OUString>(xControl->getControl(), "Text"));
    2798             : 
    2799           2 :     uno::Sequence<OUString> aItems = getProperty< uno::Sequence<OUString> >(xControl->getControl(), "StringItemList");
    2800           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), sal_Int32(aItems.getLength()));
    2801           1 :     CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems[0]);
    2802           2 :     CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]);
    2803             : }
    2804             : 
    2805          14 : DECLARE_OOXMLEXPORT_TEST(testCheckBoxControl, "checkbox-control.docx")
    2806             : {
    2807             :     // check XML
    2808           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2809           2 :     if (!pXmlDoc)
    2810           3 :         return;
    2811           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w14:checkbox/w14:checked", "val", "1");
    2812           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w14:checkbox/w14:checkedState", "val", "2612");
    2813           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w14:checkbox/w14:uncheckedState", "val", "2610");
    2814             : 
    2815             :     // TODO: import control and add a check here
    2816             : }
    2817             : 
    2818          14 : DECLARE_OOXMLEXPORT_TEST(testParagraphWithComments, "paragraphWithComments.docx")
    2819             : {
    2820             :     /* Comment id's were getting overwritten for annotation mark(s),
    2821             :        which was causing a mismatch in the relationship for comment id's
    2822             :        in document.xml and comment.xml
    2823             :     */
    2824           2 :     xmlDocPtr pXmlDoc  = parseExport("word/document.xml");
    2825           2 :     xmlDocPtr pXmlComm = parseExport("word/comments.xml");
    2826           2 :     if(!pXmlDoc)
    2827           3 :         return;
    2828             : 
    2829           1 :     sal_Int32 idInDocXml     = 0;
    2830           1 :     sal_Int32 idInCommentXml = -1; //intentionally assigning -1 so that it differs from idInDocXml
    2831             :     //and also because getXpath does not assert.
    2832           1 :     idInDocXml     = getXPath(pXmlDoc,"/w:document/w:body/w:p[3]/w:commentRangeEnd[1]","id").toInt32();
    2833           1 :     idInCommentXml = getXPath(pXmlComm,"/w:comments/w:comment[1]","id").toInt32();
    2834           1 :     CPPUNIT_ASSERT_EQUAL( idInDocXml, idInCommentXml );
    2835             : }
    2836             : 
    2837          14 : DECLARE_OOXMLEXPORT_TEST(testOLEObjectinHeader, "2129393649.docx")
    2838             : {
    2839             :     // fdo#76015 : Document contains oleobject in header xml.
    2840             :     // Problem was relationship entry for oleobject from header was
    2841             :     // exported into document.xml.rels file because of this rels file
    2842             :     // for headers were missing from document/word/rels.
    2843           2 :     xmlDocPtr pXmlDoc = parseExport("word/_rels/header3.xml.rels");
    2844           2 :     if(!pXmlDoc)
    2845           3 :         return;
    2846             : 
    2847           1 :     assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship[1]","Id","rId1");
    2848             : }
    2849             : 
    2850          14 : DECLARE_OOXMLEXPORT_TEST(test_ClosingBrace, "2120112713.docx")
    2851             : {
    2852           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2853           2 :     if (!pXmlDoc)
    2854           3 :         return;
    2855             :     // Checking for ClosingBrace tag
    2856           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[2]/m:dPr[1]/m:endChr[1]","val","");
    2857             : }
    2858             : 
    2859          14 : DECLARE_OOXMLEXPORT_TEST(testlvlPicBulletId, "lvlPicBulletId.docx")
    2860             : {
    2861           2 :     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
    2862           2 :     if (!pXmlDoc)
    2863           3 :        return;
    2864           1 :     assertXPath(pXmlDoc, "/w:numbering[1]/w:abstractNum[1]/w:lvl[1]/w:lvlPicBulletId[1]", 0);
    2865             : }
    2866             : 
    2867          14 : DECLARE_OOXMLEXPORT_TEST(testCitation,"FDO74775.docx")
    2868             : {
    2869           2 :     xmlDocPtr pXmlDoc = parseExport();
    2870           2 :     if (!pXmlDoc)
    2871           3 :         return;
    2872           1 :     xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc,"/w:document/w:body/w:sdt/w:sdtContent/w:p[1]/w:r[3]/w:instrText");
    2873           1 :     xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
    2874           1 :     OUString contents = OUString::createFromAscii((const char*)((pXmlNode->children[0]).content));
    2875           1 :     CPPUNIT_ASSERT(contents.match(" CITATION [Kra06]"));
    2876             : }
    2877             : 
    2878          14 : DECLARE_OOXMLEXPORT_TEST(testFdo76016, "fdo76016.docx")
    2879             : {
    2880             :     // check XML
    2881           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2882           2 :     if (!pXmlDoc)
    2883           3 :         return;
    2884           1 :     assertXPath(pXmlDoc, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]", "name", "adj1");
    2885           1 :     assertXPath(pXmlDoc, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]", "name", "adj2");
    2886             : }
    2887             : 
    2888          14 : DECLARE_OOXMLEXPORT_TEST(testFileWithInvalidImageLink, "FileWithInvalidImageLink.docx")
    2889             : {
    2890             :     /* In case if the original file has an image whose link is
    2891             :        invalid, then the RT file used to result in corruption
    2892             :        since the exported image would be an empty image.
    2893             :      */
    2894           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2895           2 :     if (!pXmlDoc)
    2896           3 :       return;
    2897             : 
    2898           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/pic:pic[1]/pic:blipFill[1]/a:blip[1]", "embed", "");
    2899             : }
    2900             : 
    2901          14 : DECLARE_OOXMLEXPORT_TEST(testNestedAlternateContent, "nestedAlternateContent.docx")
    2902             : {
    2903           2 :      xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2904           2 :      if (!pXmlDoc)
    2905           3 :         return;
    2906             :     // We check alternateContent  could not contains alternateContent (i.e. nested alternateContent)
    2907           1 :     assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wpg:wgp[1]/wps:wsp[2]/wps:txbx[1]/w:txbxContent[1]/w:p[1]/w:r[2]/mc:AlternateContent[1]",0);
    2908             : }
    2909             : 
    2910          14 : DECLARE_OOXMLEXPORT_TEST(testContentTypeXLSM, "fdo76098.docx")
    2911             : {
    2912           2 :     xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
    2913             : 
    2914           2 :     if (!pXmlDoc)
    2915           3 :        return;
    2916             : 
    2917           1 :     assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "ContentType", "application/vnd.ms-excel.sheet.macroEnabled.12");
    2918             : }
    2919             : 
    2920          14 : DECLARE_OOXMLEXPORT_TEST(test76108, "test76108.docx")
    2921             : {
    2922           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2923           4 :     if (!pXmlDoc) return;
    2924             :     //docx file after RT is getting corrupted.
    2925           1 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:fldChar[1]", "fldCharType", "begin");
    2926             : }
    2927             : 
    2928          14 : DECLARE_OOXMLEXPORT_TEST(testTCTagMisMatch, "TCTagMisMatch.docx")
    2929             : {
    2930             :    // TCTagMisMatch.docx : This document contains a empty table with borders.
    2931             :    // there was a TC tag mismatch which resulted into a crash.
    2932             : 
    2933           2 :    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2934           2 :    if(!pXmlDoc)
    2935           3 :       return;
    2936           1 :    assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl[1]/w:tr[1]/w:tc[1]",0);
    2937           1 :    assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]", 1);
    2938             : }
    2939             : 
    2940          14 : DECLARE_OOXMLEXPORT_TEST(testHyperLinkTagEnded, "fdo76316.docx")
    2941             : {
    2942             :     /* XML tag <w:hyperlink> was not getting closed when its inside another
    2943             :      * <w:hyperlink> tag.
    2944             :      */
    2945           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2946             : 
    2947           4 :     if (!pXmlDoc) return;
    2948             : 
    2949           1 :     CPPUNIT_ASSERT(pXmlDoc);
    2950           1 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[2]/w:tc[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl[1]/w:tr[7]/w:tc[1]/w:tbl[1]/w:tr[2]/w:tc[6]/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[1]/w:hyperlink[1]/w:hyperlink[1]",1);
    2951             : }
    2952             : 
    2953          14 : DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx")
    2954             : {
    2955           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2956             : 
    2957           2 :     if (!pXmlDoc)
    2958           3 :        return;
    2959             : 
    2960           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:text", 1);
    2961           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:id", 1);
    2962           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:picture", 1);
    2963           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:group", 1);
    2964           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:citation", 1);
    2965             : 
    2966             : }
    2967             : 
    2968          14 : DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx")
    2969             : {
    2970           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2971           2 :     if (!pXmlDoc)
    2972           3 :        return;
    2973             :     // In two cases the a:graphicData elements had no children, which is invalid.
    2974           1 :     assertXPath(pXmlDoc, "//a:graphicData[not(*)]", 0);
    2975             : }
    2976             : 
    2977          14 : DECLARE_OOXMLEXPORT_TEST(test76317, "test76317.docx")
    2978             : {
    2979           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2980           4 :     if (!pXmlDoc) return;
    2981           1 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:prstGeom[1]", "prst", "hexagon");
    2982             : }
    2983             : 
    2984          14 : DECLARE_OOXMLEXPORT_TEST(testFdo76101, "fdo76101.docx")
    2985             : {
    2986           2 :     xmlDocPtr pXmlDoc = parseExport("word/styles.xml");
    2987             : 
    2988           2 :     if (!pXmlDoc)
    2989           3 :        return;
    2990           1 :     xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, "/w:styles/w:style");
    2991           1 :     CPPUNIT_ASSERT(4091 >= xmlXPathNodeSetGetLength(pXmlNodes));
    2992             : }
    2993             : 
    2994          14 : DECLARE_OOXMLEXPORT_TEST(testFDO76163 , "fdo76163.docx")
    2995             : {
    2996           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    2997           2 :     if (!pXmlDoc)
    2998           3 :         return;
    2999             :     //docx file after RT is getting corrupted.
    3000           1 :     assertXPath ( pXmlDoc, "/w:document/w:body/w:p[2]/w:hyperlink/w:r[11]/w:fldChar", "fldCharType", "end" );
    3001             : }
    3002             : 
    3003          14 : DECLARE_OOXMLEXPORT_TEST(fdo76591, "fdo76591.docx")
    3004             : {
    3005           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    3006           2 :     if (!pXmlDoc)
    3007           3 :         return;
    3008           1 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[3]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]", "relativeHeight", "3");
    3009             : }
    3010             : 
    3011          14 : DECLARE_OOXMLEXPORT_TEST(test76317_2K10, "test76317_2K10.docx")
    3012             : {
    3013           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    3014           4 :     if (!pXmlDoc) return;
    3015           1 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:prstGeom[1]/a:avLst[1]/a:gd[1]", "name", "adj");
    3016             : }
    3017             : 
    3018          14 : DECLARE_OOXMLEXPORT_TEST(testfdo76589 , "fdo76589.docx")
    3019             : {
    3020             :     /* Numbered list was not preserve after RT.
    3021             :      * In numbering.xml, when NumberingType is "decimal" and level is zero,
    3022             :      * w:val of w:lvlText was empty.
    3023             :      * It should be <w:lvlText w:val="%1" />
    3024             :      */
    3025           2 :     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
    3026           2 :     if (!pXmlDoc)
    3027           3 :         return;
    3028             : 
    3029           1 :     assertXPath ( pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val","%1" );
    3030             : }
    3031             : 
    3032          14 : DECLARE_OOXMLEXPORT_TEST(testAuthorPropertySdt, "author-property.docx")
    3033             : {
    3034           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    3035             : 
    3036           2 :     if (!pXmlDoc)
    3037           3 :        return;
    3038             : 
    3039           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns1:coreProperties[1]/ns0:creator[1]");
    3040           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "storeItemID","{6C3C8BC8-F283-45AE-878A-BAB7291924A1}");
    3041             :     // FIXME: the next property doesn't match, though it's correct in theory. A bug in assertXPath?
    3042             :     // assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "prefixMappings",
    3043             :     //            "xmlns:ns0='http://purl.org/dc/elements/1.1/' xmlns:ns1='http://schemas.openxmlformats.org/package/2006/metadata/core-properties'");
    3044             : }
    3045             : 
    3046          14 : DECLARE_OOXMLEXPORT_TEST(testFDO76586, "fdo76586.docx")
    3047             : {
    3048             :     /*
    3049             :      * In the test file gridCol had only one value for entire table width
    3050             :      * while there are two cells in a table row.
    3051             :      * So the table was not imported with the correct cell widths
    3052             :      */
    3053           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    3054             : 
    3055           2 :     if (!pXmlDoc)
    3056           3 :        return;
    3057             : 
    3058             :     // there is only one table in the test file
    3059           1 :     assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[1]", "w", "1601");
    3060           1 :     assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[2]", "w", "7843");
    3061             : }
    3062             : 
    3063          14 : DECLARE_OOXMLEXPORT_TEST(test76734_2K7, "test76734_2K7.docx")
    3064             : {
    3065           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
    3066           2 :     if (!pXmlDoc)
    3067           3 :         return;
    3068           1 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[3]/mc:AlternateContent[1]/mc:Choice[1]", "Requires", "wps");
    3069             : }
    3070             : 
    3071             : #endif
    3072             : 
    3073           4 : CPPUNIT_PLUGIN_IMPLEMENT();
    3074             : 
    3075             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10