LCOV - code coverage report
Current view: top level - sw/qa/extras/ooxmlexport - ooxmlexport4.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 394 395 99.7 %
Date: 2015-06-13 12:38:46 Functions: 702 762 92.1 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : #include <swmodeltestbase.hxx>
      11             : 
      12             : #include <com/sun/star/awt/XBitmap.hpp>
      13             : #include <com/sun/star/graphic/XGraphic.hpp>
      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         116 : class Test : public SwModelTestBase
      56             : {
      57             : public:
      58         116 :     Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
      59             : 
      60             : protected:
      61             :     /**
      62             :      * Blacklist handling
      63             :      */
      64          58 :     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          58 :         };
      72          58 :         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          58 :         return (OString(filename).endsWith(".docx") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end());
      76             :     }
      77             : };
      78             : 
      79          17 : DECLARE_OOXMLEXPORT_TEST(testRelorientation, "relorientation.docx")
      80             : {
      81           2 :     uno::Reference<drawing::XShape> xShape = getShape(1);
      82             :     // This was text::RelOrientation::FRAME, when handling relativeFrom=page, align=right
      83           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_RIGHT, getProperty<sal_Int16>(xShape, "HoriOrientRelation"));
      84             : 
      85           4 :     uno::Reference<drawing::XShapes> xGroup(xShape, uno::UNO_QUERY);
      86             :     // This resulted in lang::IndexOutOfBoundsException, as nested groupshapes weren't handled.
      87           4 :     uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(0), uno::UNO_QUERY);
      88           2 :     CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), xShapeDescriptor->getShapeType());
      89             : 
      90             :     // Right after import we get a rounding error: 8662 vs 8664.
      91           2 :     if (mbExported)
      92             :     {
      93           1 :         uno::Reference<drawing::XShape> xYear(xGroup->getByIndex(1), uno::UNO_QUERY);
      94             :         // This was 2, due to incorrect handling of parent transformations inside DML groupshapes.
      95           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(8664), xYear->getSize().Width);
      96           2 :     }
      97           2 : }
      98             : 
      99          16 : DECLARE_OOXMLEXPORT_TEST(testBezier, "bezier.odt")
     100             : {
     101           1 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
     102           2 :     uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
     103             :     // Check that no shape got lost: a bezier, a line and a text shape.
     104           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xDraws->getCount());
     105           1 : }
     106             : 
     107          17 : DECLARE_OOXMLEXPORT_TEST(testGroupshapeTextbox, "groupshape-textbox.docx")
     108             : {
     109           2 :     uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
     110           4 :     uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY);
     111             :     // The VML export lost text on textboxes inside groupshapes.
     112             :     // The DML export does not, make sure it stays that way.
     113           2 :     CPPUNIT_ASSERT_EQUAL(OUString("first"), xShape->getString());
     114             :     // This was 16, i.e. inheriting doc default char height didn't work.
     115           4 :     CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight"));
     116           2 : }
     117             : 
     118          17 : DECLARE_OOXMLEXPORT_TEST(testGroupshapePicture, "groupshape-picture.docx")
     119             : {
     120             :     // Picture in the groupshape got lost, groupshape had only one child.
     121           2 :     uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
     122           4 :     uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(1), uno::UNO_QUERY);
     123           4 :     CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GraphicObjectShape"), xShapeDescriptor->getShapeType());
     124           2 : }
     125             : 
     126          17 : DECLARE_OOXMLEXPORT_TEST(testAutofit, "autofit.docx")
     127             : {
     128           2 :     CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(getShape(1), "TextAutoGrowHeight")));
     129           2 :     CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(getShape(2), "TextAutoGrowHeight")));
     130           2 : }
     131             : 
     132          17 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedParagraphMark, "testTrackChangesDeletedParagraphMark.docx")
     133             : {
     134           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     135           2 :     if (!pXmlDoc)
     136           3 :         return;
     137           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:del");
     138             : }
     139             : 
     140          17 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedParagraphMark, "testTrackChangesInsertedParagraphMark.docx")
     141             : {
     142           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     143           2 :     if (!pXmlDoc)
     144           3 :         return;
     145           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:ins");
     146             : }
     147             : 
     148          17 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedTableRow, "testTrackChangesDeletedTableRow.docx")
     149             : {
     150           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     151           2 :     if (!pXmlDoc)
     152           3 :         return;
     153           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:del");
     154             : }
     155             : 
     156          17 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedTableRow, "testTrackChangesInsertedTableRow.docx")
     157             : {
     158           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     159           2 :     if (!pXmlDoc)
     160           3 :         return;
     161           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:ins");
     162             : }
     163             : 
     164          17 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedTableCell, "testTrackChangesDeletedTableCell.docx")
     165             : {
     166           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     167           2 :     if (!pXmlDoc)
     168           3 :         return;
     169           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellDel");
     170             : }
     171             : 
     172          17 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedTableCell, "testTrackChangesInsertedTableCell.docx")
     173             : {
     174           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     175           2 :     if (!pXmlDoc)
     176           3 :         return;
     177           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellIns");
     178             : }
     179             : 
     180          17 : DECLARE_OOXMLEXPORT_TEST(testTextBoxPictureFill, "textbox_picturefill.docx")
     181             : {
     182           2 :     uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY);
     183           2 :     CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xFrame, "FillStyle"));
     184           2 :     CPPUNIT_ASSERT(!(getProperty<OUString>(xFrame,"FillBitmapURL")).isEmpty());
     185           2 : }
     186             : 
     187          17 : DECLARE_OOXMLEXPORT_TEST(testFDO73034, "FDO73034.docx")
     188             : {
     189           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     190           2 :     if (!pXmlDoc)
     191           3 :         return;
     192           1 :     CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:u", "val").match("single"));
     193             : }
     194             : 
     195          17 : DECLARE_OOXMLEXPORT_TEST(testFDO71834, "fdo71834.docx")
     196             : {
     197           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     198           2 :     if (!pXmlDoc)
     199           3 :         return;
     200           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[2]/w:tc[1]/w:tcPr[1]/w:tcW[1]","type", "dxa");
     201             : }
     202             : 
     203          17 : DECLARE_OOXMLEXPORT_TEST(testTrackChangesParagraphProperties, "testTrackChangesParagraphProperties.docx")
     204             : {
     205           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     206           2 :     if (!pXmlDoc)
     207           3 :         return;
     208           1 :     assertXPathChildren(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pPrChange", 0);
     209             : }
     210             : 
     211          17 : DECLARE_OOXMLEXPORT_TEST(testMsoSpt180, "mso-spt180.docx")
     212             : {
     213           2 :     if (!mbExported)
     214           3 :         return;
     215             : 
     216           1 :     uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY);
     217           2 :     uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xGroup->getByIndex(0), "CustomShapeGeometry");
     218           2 :     OUString aType;
     219          11 :     for (int i = 0; i < aProps.getLength(); ++i)
     220          10 :         if (aProps[i].Name == "Type")
     221           1 :             aType = aProps[i].Value.get<OUString>();
     222             :     // This was exported as borderCallout90, which is an invalid drawingML preset shape string.
     223           2 :     CPPUNIT_ASSERT_EQUAL(OUString("ooxml-borderCallout1"), aType);
     224             : }
     225             : 
     226          17 : DECLARE_OOXMLEXPORT_TEST(testFdo73550, "fdo73550.docx")
     227             : {
     228           2 :     xmlDocPtr pXmlDocument = parseExport("word/document.xml");
     229           2 :     if (!pXmlDocument)
     230           3 :         return;
     231             :     // This was wrap="none".
     232           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:rFonts");
     233             : }
     234             : 
     235          17 : DECLARE_OOXMLEXPORT_TEST(testPageRelSize, "pagerelsize.docx")
     236             : {
     237             :     // First shape: width is relative from page, but not height.
     238           2 :     uno::Reference<drawing::XShape> xShape = getShape(1);
     239           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation"));
     240           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation"));
     241             : 
     242             :     // Second shape: height is relative from page, but not height.
     243           2 :     xShape = getShape(2);
     244           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation"));
     245           2 :     CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation"));
     246           2 : }
     247             : 
     248          17 : DECLARE_OOXMLEXPORT_TEST(testRelSizeRound, "rel-size-round.docx")
     249             : {
     250             :     // This was 9: 9.8 was imported as 9 instead of being rounded to 10.
     251           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty<sal_Int16>(getShape(1), "RelativeHeight"));
     252           2 : }
     253             : 
     254          17 : DECLARE_OOXMLEXPORT_TEST(testTestTitlePage, "testTitlePage.docx")
     255             : {
     256           2 :     CPPUNIT_ASSERT_EQUAL(OUString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), parseDump("/root/page[2]/footer/txt/text()"));
     257           2 : }
     258             : 
     259          17 : DECLARE_OOXMLEXPORT_TEST(testTableRowDataDisplayedTwice,"table-row-data-displayed-twice.docx")
     260             : {
     261             :     // fdo#73534: There was a problem for some documents during export.Invalid sectPr getting added
     262             :     // because of wrong condition in code.
     263             :     // This was the reason for increasing number of pages after RT
     264           2 :     uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY);
     265           4 :     uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY);
     266           4 :     uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY);
     267           2 :     xCursor->jumpToLastPage();
     268           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage());
     269           2 : }
     270             : 
     271          17 : DECLARE_OOXMLEXPORT_TEST(testFdo73556,"fdo73556.docx")
     272             : {
     273             :     /*
     274             :     *  The file contains a table with 3 columns
     275             :     *  the girdcols are as follows: {1210, 1331, 1210}
     276             :     *  whereas the individual cells have {1210, 400, 1210}
     277             :     *  The table column separators were taken from the Grid, while
     278             :     *  the table width was calculated as 2820 from cells instead
     279             :     *  of 3751 from the Grid.
     280             :     */
     281           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     282           2 :     if (!pXmlDoc)
     283           3 :         return;
     284           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol", 3);
     285           1 :     sal_Int32 tableWidth = 0;
     286           1 :     tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[1]", "w").toInt32();
     287           1 :     tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32();
     288           1 :     tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[3]", "w").toInt32();
     289           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(3751), tableWidth);
     290             : }
     291             : 
     292          17 : DECLARE_OOXMLEXPORT_TEST(testSegFaultWhileSave, "test_segfault_while_save.docx")
     293             : {
     294             :     // fdo#74499
     295           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     296           2 :     if (!pXmlDoc)
     297           3 :         return;
     298           1 :     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(6137), getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32());
     299             : }
     300             : 
     301          17 : DECLARE_OOXMLEXPORT_TEST(fdo69656, "Table_cell_auto_width_fdo69656.docx")
     302             : {
     303             :     // Changed the UT to check "dxa" instead of "auto"
     304             :     // For this particular issue file few cells have width type "auto"
     305             :     // LO supports VARIABLE and FIXED width type.
     306             :     // If type is VARIABLE LO calculates width as percent of PageSize
     307             :     // Else if the width is fixed it uses the width value.
     308             :     // After changes for fdo76741 the fixed width is exported as "dxa" for DOCX
     309             : 
     310             :     // Check for the width type of table and its cells.
     311           2 :     xmlDocPtr pXmlDoc = parseExport();
     312           2 :     if (!pXmlDoc)
     313           3 :         return;
     314           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblW","type","dxa");
     315             : }
     316             : 
     317          17 : DECLARE_OOXMLEXPORT_TEST(testFdo76741, "fdo76741.docx")
     318             : {
     319             : 
     320             :      // There are two issue related to table in the saved(exported) file
     321             :      // - the table alignment in saved file is "left" instead of "center"
     322             :      // - the table width type in properties is "auto" instead of "dxa"
     323             : 
     324           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     325             : 
     326           2 :     if (!pXmlDoc)
     327           3 :        return;
     328           1 :     assertXPath(pXmlDoc, "//w:jc", "val", "center");
     329           1 :     assertXPath(pXmlDoc, "//w:tblW", "w", "10081");
     330           1 :     assertXPath(pXmlDoc, "//w:tblW", "type", "dxa");
     331             : }
     332             : 
     333          17 : DECLARE_OOXMLEXPORT_TEST(testFdo73541,"fdo73541.docx")
     334             : {
     335             :     // fdo#73541: The mirrored margins were not imported and mapped correctly in Page Layout
     336             :     // Hence <w:mirrorMargins /> tag was not exported back in settings.xml
     337           2 :     xmlDocPtr pXmlDoc = parseExport("word/settings.xml");
     338           2 :     if (!pXmlDoc)
     339           3 :         return;
     340           1 :     assertXPath(pXmlDoc, "/w:settings/w:mirrorMargins");
     341             : }
     342             : 
     343          17 : DECLARE_OOXMLEXPORT_TEST(testFDO74106, "FDO74106.docx")
     344             : {
     345           2 :     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
     346           2 :     if (!pXmlDoc)
     347           3 :         return;
     348           1 :     assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:numFmt", "val","hebrew1");
     349             : }
     350             : 
     351          17 : DECLARE_OOXMLEXPORT_TEST(testFDO74215, "FDO74215.docx")
     352             : {
     353           2 :     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
     354           2 :     if (!pXmlDoc)
     355           3 :         return;
     356           1 :     assertXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style", "width:6.4pt;height:6.4pt");
     357             : }
     358             : 
     359          17 : DECLARE_OOXMLEXPORT_TEST(testColumnBreak_ColumnCountIsZero,"fdo74153.docx")
     360             : {
     361             :     /* fdo73545: Column Break with Column_count = 0 was not getting preserved.
     362             :      * The <w:br w:type="column" /> was missing after roundtrip
     363             :      */
     364           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     365           2 :     if (!pXmlDoc)
     366           3 :         return;
     367           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/w:br","type","column");
     368             : }
     369             : 
     370          17 : DECLARE_OOXMLEXPORT_TEST(testIndentation, "test_indentation.docx")
     371             : {
     372             :     // fdo#74141 :There was a problem that in style.xml and document.xml in <w:ind> tag "right" & "left" margin
     373             :     // attributes gets added(w:right=0 & w:left=0) if these attributes are not set in original document.
     374             :     // This test is to verify <w:ind> does not contain w:right attribute.
     375           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     376           2 :     if (!pXmlDoc)
     377           3 :         return;
     378           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:ind", "end", "");
     379             : }
     380             : 
     381          17 : DECLARE_OOXMLEXPORT_TEST(testChartInFooter, "chart-in-footer.docx")
     382             : {
     383             :     // fdo#73872: document contains chart in footer.
     384             :     // The problem was that  footer1.xml.rels files for footer1.xml
     385             :     // files were missing from docx file after roundtrip.
     386           2 :     xmlDocPtr pXmlDoc = parseExport("word/_rels/footer1.xml.rels");
     387           2 :     if(!pXmlDoc)
     388           3 :         return;
     389             : 
     390             :     // Check footer1.xml.rels contains in doc after roundtrip.
     391             :     // Check Id = rId1 in footer1.xml.rels
     392           1 :     assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship","Id","rId1");
     393             : 
     394           1 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
     395           1 :     if (xDrawPageSupplier.is())
     396             :     {
     397             :         // If xDrawPage->getCount()==1, then document conatins one shape.
     398           1 :         uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
     399           1 :         CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount()); // One shape in the doc
     400           1 :     }
     401             : }
     402             : 
     403          16 : DECLARE_OOXMLEXPORT_TEST(testNestedTextFrames, "nested-text-frames.odt")
     404             : {
     405             :     // First problem was LO crashed during export (crash test)
     406             : 
     407             :     // Second problem was LO made file corruption, writing out nested text boxes, which can't be handled by Word.
     408             :     // Test that all three exported text boxes are anchored to the same paragraph and not each other.
     409           1 :     uno::Reference<text::XTextContent> xTextContent(getShape(1), uno::UNO_QUERY);
     410           2 :     uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY);
     411           2 :     uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY);
     412           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
     413             : 
     414           1 :     xTextContent.set(getShape(2), uno::UNO_QUERY);
     415           1 :     xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY);
     416           1 :     xText.set(xRange->getText(), uno::UNO_QUERY);
     417           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
     418             : 
     419           1 :     xTextContent.set(getShape(3), uno::UNO_QUERY);
     420           1 :     xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY);
     421           1 :     xText.set(xRange->getText(), uno::UNO_QUERY);
     422           2 :     CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
     423           1 : }
     424             : 
     425          17 : DECLARE_OOXMLEXPORT_TEST(testFloatingTablePosition, "floating-table-position.docx")
     426             : {
     427             :     // Position of shape was wrong, because some conversion was missing.
     428           2 :     uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY);
     429             :     // This was 3295.
     430           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(5964), getProperty<sal_Int32>(xShape, "HoriOrientPosition"));
     431             :     // This was 4611.
     432           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(8133), getProperty<sal_Int32>(xShape, "VertOrientPosition"));
     433           2 : }
     434             : 
     435          17 : DECLARE_OOXMLEXPORT_TEST(testAbi11739, "abi11739.docx")
     436             : {
     437             :     // Validation test: order of elements were wrong.
     438           2 :     xmlDocPtr pXmlDoc = parseExport("word/styles.xml");
     439           2 :     if (!pXmlDoc)
     440           3 :         return;
     441             :     // Order was: uiPriority, link, basedOn.
     442           1 :     CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "basedOn") < getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "link"));
     443           1 :     CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "link") < getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "uiPriority"));
     444             :     // Order was: qFormat, unhideWhenUsed.
     445           1 :     CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "unhideWhenUsed") < getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "qFormat"));
     446             : }
     447             : 
     448          17 : DECLARE_OOXMLEXPORT_TEST(testEmbeddedXlsx, "embedded-xlsx.docx")
     449             : {
     450             :     // check there are two objects and they are FrameShapes
     451           2 :     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
     452           3 :     uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
     453           2 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
     454           2 :     CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(1)->getShapeType());
     455           2 :     CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(2)->getShapeType());
     456             : 
     457             :     // check the objects are present in the exported document.xml
     458           2 :     xmlDocPtr pXmlDocument = parseExport("word/document.xml");
     459           2 :     if (!pXmlDocument)
     460           3 :         return;
     461           1 :     assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/w:object", 2);
     462             : 
     463             :     // finally check the embedded files are present in the zipped document
     464           2 :     uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL());
     465           2 :     uno::Sequence<OUString> names = xNameAccess->getElementNames();
     466           1 :     int nSheetFiles = 0;
     467           1 :     int nImageFiles = 0;
     468          16 :     for (int i=0; i<names.getLength(); i++)
     469             :     {
     470          15 :         if(names[i].startsWith("word/embeddings/oleObject"))
     471           2 :             nSheetFiles++;
     472          15 :         if(names[i].startsWith("word/media/image"))
     473           2 :             nImageFiles++;
     474             :     }
     475           1 :     CPPUNIT_ASSERT_EQUAL(2, nSheetFiles);
     476           2 :     CPPUNIT_ASSERT_EQUAL(2, nImageFiles);
     477             : }
     478             : 
     479          17 : DECLARE_OOXMLEXPORT_TEST(testNumberedLists_StartingWithZero, "FDO74105.docx")
     480             : {
     481             :     /* Issue : Numbered lists Starting with value '0' is not preserved after RT.
     482             :      * In numbering.xml, an XML tag <w:start> is optional. If not mentioned,
     483             :      * the Numbered list should start from 0.
     484             :      * Problem was LO was writing <w:start> for all levels 0-8 with default value "1".
     485             :      */
     486           2 :     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
     487           2 :     if (!pXmlDoc)
     488           3 :       return;
     489             : 
     490             :     // Check that we do _not_ export w:start for <w:lvl w:ilvl="0">.
     491           1 :     assertXPath(pXmlDoc, "w:numbering/w:abstractNum[1]/w:lvl[1]/w:start", 0);
     492             : }
     493             : 
     494          17 : DECLARE_OOXMLEXPORT_TEST(testPageBreak,"fdo74566.docx")
     495             : {
     496             :     /*  Break to next page was written into wrong paragraph as <w:pageBreakBefore />.
     497             :      *  LO was not preserving Page Break as <w:br w:type="page" />.
     498             :      *  Now after fix , LO writes Page Break as the new paragraph and also
     499             :      *  preserves the xml tag <w:br>.
     500             :      */
     501           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     502           2 :     if (!pXmlDoc)
     503           3 :         return;
     504             : 
     505           1 :     uno::Reference<text::XTextRange> xParagraph2 = getParagraph(2);
     506           2 :     uno::Reference<text::XTextRange> xParagraph4 = getParagraph(4);
     507             : 
     508           1 :     getRun(xParagraph2, 1, "First Page Second Line");
     509           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[2]/w:br","type","page");
     510           2 :     getRun(xParagraph4, 1, "Second Page First line after Page Break");
     511             : }
     512             : 
     513          17 : DECLARE_OOXMLEXPORT_TEST(testOleObject, "test_ole_object.docx")
     514             : {
     515           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     516           2 :     if (!pXmlDoc)
     517           3 :         return;
     518             : 
     519           1 :      assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata", "o:title", "");
     520             : }
     521             : 
     522          17 : DECLARE_OOXMLEXPORT_TEST(testFdo74792, "fdo74792.docx")
     523             : {
     524             :     /*
     525             :      * fdo#74792 : The images associated with smart-art data[i].xml
     526             :      * were not preserved on exporting to DOCX format
     527             :      * Added support to grabbag the rels, with associated images.
     528             :      */
     529           2 :     xmlDocPtr pXmlDoc = parseExport("word/diagrams/_rels/data1.xml.rels");
     530           2 :     if(!pXmlDoc)
     531           3 :         return;
     532           1 :     assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship", 4);
     533             :     uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(
     534           1 :                          comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL());
     535             : 
     536             :     //check that images are also saved
     537           2 :     OUString sImageFile( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name
     538           2 :     uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName( sImageFile ), uno::UNO_QUERY);
     539           2 :     CPPUNIT_ASSERT( xInputStream.is() );
     540             : }
     541             : 
     542          17 : DECLARE_OOXMLEXPORT_TEST(testFdo77718, "fdo77718.docx")
     543             : {
     544             :     //in case of multiple smart arts the names for images were getting
     545             :     //repeated and thereby causing a data loss as the binary stream was
     546             :     //getting over written. This test case ensures that unique names are
     547             :     //given for images in different smart arts.
     548           2 :     xmlDocPtr pXmlDataRels1 = parseExport("word/diagrams/_rels/data1.xml.rels");
     549           2 :     if( !pXmlDataRels1 )
     550           2 :         return;
     551             : 
     552           1 :     xmlDocPtr pXmlDataRels2 = parseExport("word/diagrams/_rels/data2.xml.rels");
     553           1 :     if( !pXmlDataRels2 )
     554           0 :         return;
     555             : 
     556             :     //ensure that the rels file is present.
     557           1 :     assertXPath(pXmlDataRels1,"/rels:Relationships/rels:Relationship", 4);
     558           1 :     assertXPath(pXmlDataRels2,"/rels:Relationships/rels:Relationship", 4);
     559             : 
     560             :     uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(
     561           1 :                          comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL());
     562             : 
     563             :     //check that images are also saved
     564           2 :     OUString sImageFile1( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name
     565           2 :     uno::Reference<io::XInputStream> xInputStream1(xNameAccess->getByName( sImageFile1 ), uno::UNO_QUERY);
     566           1 :     CPPUNIT_ASSERT( xInputStream1.is() );
     567             : 
     568             :     //check that images are saved for other smart-arts as well.
     569           2 :     OUString sImageFile2( "word/media/OOXDiagramDataRels2_0.jpeg" ); //added anchor id to form a uniqe name
     570           2 :     uno::Reference<io::XInputStream> xInputStream2(xNameAccess->getByName( sImageFile2 ), uno::UNO_QUERY);
     571           2 :     CPPUNIT_ASSERT( xInputStream2.is() );
     572             : }
     573             : 
     574          17 : DECLARE_OOXMLEXPORT_TEST(testTableCurruption, "tableCurrupt.docx")
     575             : {
     576           2 :     xmlDocPtr pXmlDoc = parseExport("word/header2.xml");
     577           2 :     if (!pXmlDoc)
     578           3 :         return;
     579           1 :     CPPUNIT_ASSERT(pXmlDoc) ;
     580           1 :     assertXPath(pXmlDoc, "/w:hdr/w:tbl[1]/w:tr[1]/w:tc[1]",1);
     581             : }
     582             : 
     583          17 : DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx")
     584             : {
     585             :     // check XML
     586           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     587           2 :     if (!pXmlDoc)
     588           3 :         return;
     589           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date", "fullDate", "2014-03-05T00:00:00Z");
     590           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:dateFormat", "val", "dddd, dd' de 'MMMM' de 'yyyy");
     591           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:lid", "val", "es-ES");
     592           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", OUString::fromUtf8("mi\xC3\xA9rcoles, 05 de marzo de 2014"));
     593             : 
     594             :     // check imported control
     595           1 :     uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY);
     596           1 :     util::Date aDate = getProperty<util::Date>(xControl->getControl(), "Date");
     597           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(5),    sal_Int32(aDate.Day));
     598           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(3),    sal_Int32(aDate.Month));
     599           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2014), sal_Int32(aDate.Year));
     600             : }
     601             : 
     602          17 : DECLARE_OOXMLEXPORT_TEST(test_OpeningBrace, "2120112713_OpenBrace.docx")
     603             : {
     604           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     605           2 :     if (!pXmlDoc)
     606           3 :         return;
     607             :     // Checking for OpeningBrace tag
     608           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[1]/m:dPr[1]/m:begChr[1]","val","");
     609             : }
     610             : 
     611          17 : DECLARE_OOXMLEXPORT_TEST(testFDO76312, "FDO76312.docx")
     612             : {
     613           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     614           2 :     if (!pXmlDoc)
     615           3 :         return;
     616             : 
     617           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]");
     618             : }
     619             : 
     620          17 : DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx")
     621             : {
     622             :     // check XML
     623           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     624           2 :     if (!pXmlDoc)
     625           3 :         return;
     626           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[1]", "value", "manolo");
     627           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[2]", "value", "pepito");
     628           1 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "Manolo");
     629             : 
     630             :     // check imported control
     631           1 :     uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY);
     632             : 
     633           1 :     CPPUNIT_ASSERT_EQUAL(OUString("Manolo"), getProperty<OUString>(xControl->getControl(), "Text"));
     634             : 
     635           2 :     uno::Sequence<OUString> aItems = getProperty< uno::Sequence<OUString> >(xControl->getControl(), "StringItemList");
     636           1 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), sal_Int32(aItems.getLength()));
     637           1 :     CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems[0]);
     638           2 :     CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]);
     639             : }
     640             : 
     641          17 : DECLARE_OOXMLEXPORT_TEST(testCheckBoxControl, "checkbox-control.docx")
     642             : {
     643             :     // check XML
     644           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     645           2 :     if (!pXmlDoc)
     646           3 :         return;
     647           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:checked", "val", "1");
     648           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:checkedState", "val", "2612");
     649           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:uncheckedState", "val", "2610");
     650             : 
     651             :     // TODO: import control and add a check here
     652             : }
     653             : 
     654          17 : DECLARE_OOXMLEXPORT_TEST(testParagraphWithComments, "paragraphWithComments.docx")
     655             : {
     656             :     /* Comment id's were getting overwritten for annotation mark(s),
     657             :        which was causing a mismatch in the relationship for comment id's
     658             :        in document.xml and comment.xml
     659             :     */
     660           2 :     xmlDocPtr pXmlDoc  = parseExport("word/document.xml");
     661           2 :     xmlDocPtr pXmlComm = parseExport("word/comments.xml");
     662           2 :     if(!pXmlDoc)
     663           3 :         return;
     664             : 
     665           1 :     sal_Int32 idInDocXml     = 0;
     666           1 :     sal_Int32 idInCommentXml = -1; //intentionally assigning -1 so that it differs from idInDocXml
     667             :     //and also because getXpath does not assert.
     668           1 :     idInDocXml     = getXPath(pXmlDoc,"/w:document/w:body/w:p[3]/w:commentRangeEnd[1]","id").toInt32();
     669           1 :     idInCommentXml = getXPath(pXmlComm,"/w:comments/w:comment[1]","id").toInt32();
     670           1 :     CPPUNIT_ASSERT_EQUAL( idInDocXml, idInCommentXml );
     671             : }
     672             : 
     673          17 : DECLARE_OOXMLEXPORT_TEST(testOLEObjectinHeader, "2129393649.docx")
     674             : {
     675             :     // fdo#76015 : Document contains oleobject in header xml.
     676             :     // Problem was relationship entry for oleobject from header was
     677             :     // exported into document.xml.rels file because of this rels file
     678             :     // for headers were missing from document/word/rels.
     679           2 :     xmlDocPtr pXmlDoc = parseExport("word/_rels/header1.xml.rels");
     680           2 :     if(!pXmlDoc)
     681           3 :         return;
     682             : 
     683           1 :     assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship[1]","Id","rId1");
     684             : }
     685             : 
     686          17 : DECLARE_OOXMLEXPORT_TEST(test_ClosingBrace, "2120112713.docx")
     687             : {
     688           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     689           2 :     if (!pXmlDoc)
     690           3 :         return;
     691             :     // Checking for ClosingBrace tag
     692           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[2]/m:dPr[1]/m:endChr[1]","val","");
     693             : }
     694             : 
     695          17 : DECLARE_OOXMLEXPORT_TEST(testlvlPicBulletId, "lvlPicBulletId.docx")
     696             : {
     697           2 :     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
     698           2 :     if (!pXmlDoc)
     699           3 :        return;
     700           1 :     assertXPath(pXmlDoc, "/w:numbering[1]/w:abstractNum[1]/w:lvl[1]/w:lvlPicBulletId[1]", 0);
     701             : }
     702             : 
     703          17 : DECLARE_OOXMLEXPORT_TEST(testSdtContent, "SdtContent.docx")
     704             : {
     705           2 :     xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
     706           2 :     if (!pXmlDoc)
     707           3 :        return;
     708           1 :     assertXPath(pXmlDoc, "/w:hdr[1]/w:sdt[1]/w:sdtContent[1]/w:p[1]/w:del[1]");
     709             : }
     710             : 
     711             : #if 0
     712             : // Currently LibreOffice exports custom geometry for this up arrow, not preset shape.
     713             : // When LibreOffice can export preset shape with correct modifiers, then this test can be re-enabled.
     714             : 
     715             : DECLARE_OOXMLEXPORT_TEST(testFdo76016, "fdo76016.docx")
     716             : {
     717             :     // check XML
     718             :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     719             :     if (!pXmlDoc)
     720             :         return;
     721             :     assertXPath(pXmlDoc, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]", "name", "adj1");
     722             :     assertXPath(pXmlDoc, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]", "name", "adj2");
     723             : }
     724             : #endif
     725             : 
     726          17 : DECLARE_OOXMLEXPORT_TEST(testFileWithInvalidImageLink, "FileWithInvalidImageLink.docx")
     727             : {
     728             :     /* In case if the original file has an image whose link is
     729             :        invalid, then the RT file used to result in corruption
     730             :        since the exported image would be an empty image.
     731             :      */
     732           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     733           2 :     if (!pXmlDoc)
     734           3 :       return;
     735             : 
     736           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", "");
     737             : }
     738             : 
     739          17 : DECLARE_OOXMLEXPORT_TEST(testContentTypeDOCX, "fdo80410.docx")
     740             : {
     741           2 :     xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     742             : 
     743           2 :     if (!pXmlDoc) // only test the export, not initial import
     744           3 :        return;
     745             : 
     746             :     assertXPath(pXmlDoc,
     747             :         "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.docx']",
     748             :         "ContentType",
     749           1 :         "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
     750             : }
     751             : 
     752          17 : DECLARE_OOXMLEXPORT_TEST(testContentTypeXLSM, "fdo76098.docx")
     753             : {
     754           2 :     xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     755             : 
     756           2 :     if (!pXmlDoc)
     757           3 :        return;
     758             : 
     759           1 :     assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "ContentType", "application/vnd.ms-excel.sheet.macroEnabled.12");
     760             : }
     761             : 
     762          17 : DECLARE_OOXMLEXPORT_TEST(test76108, "test76108.docx")
     763             : {
     764           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     765           4 :     if (!pXmlDoc) return;
     766             :     //docx file after RT is getting corrupted.
     767           1 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:fldChar[1]", "fldCharType", "begin");
     768             : }
     769             : 
     770          17 : DECLARE_OOXMLEXPORT_TEST(testTCTagMisMatch, "TCTagMisMatch.docx")
     771             : {
     772             :    // TCTagMisMatch.docx : This document contains a empty table with borders.
     773             :    // there was a TC tag mismatch which resulted into a crash.
     774             : 
     775           2 :    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     776           2 :    if(!pXmlDoc)
     777           3 :       return;
     778           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);
     779           1 :    assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]", 1);
     780             : }
     781             : 
     782          17 : DECLARE_OOXMLEXPORT_TEST(testFDO78292, "FDO78292.docx")
     783             : {
     784             :    //text node is a leaf node, it should not have any children
     785           2 :    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     786           2 :    if(!pXmlDoc)
     787           3 :       return;
     788           1 :    assertXPath(pXmlDoc,"/w:document/w:body/w:p[14]/w:sdt[3]/w:sdtPr[1]/w:text/w14:checked",0);
     789             : }
     790             : 
     791          17 : DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx")
     792             : {
     793           2 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     794             : 
     795           2 :     if (!pXmlDoc)
     796           3 :        return;
     797             : 
     798           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:text", 1);
     799           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:id", 3);
     800           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:picture", 1);
     801           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:group", 1);
     802           1 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:citation", 1);
     803             : 
     804             : }
     805             : 
     806           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     807             : 
     808             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11