LCOV - code coverage report
Current view: top level - sw/qa/extras/ooxmlexport - ooxmlexport5.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 308 311 99.0 %
Date: 2014-11-03 Functions: 429 478 89.7 %
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         188 : class Test : public SwModelTestBase
      56             : {
      57             : public:
      58         188 :     Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
      59             : 
      60             : protected:
      61             :     /**
      62             :      * Blacklist handling
      63             :      */
      64          94 :     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          94 :         };
      72          94 :         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          94 :         return (OString(filename).endsWith(".docx") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end());
      76             :     }
      77             : };
      78             : 
      79          28 : DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx")
      80             : {
      81           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
      82           4 :     if (!pXmlDoc)
      83           6 :        return;
      84             :     // In two cases the a:graphicData elements had no children, which is invalid.
      85           2 :     assertXPath(pXmlDoc, "//a:graphicData[not(*)]", 0);
      86             : }
      87             : 
      88          28 : DECLARE_OOXMLEXPORT_TEST(testfdo76589 , "fdo76589.docx")
      89             : {
      90             :     /* Numbered list was not preserve after RT.
      91             :      * In numbering.xml, when NumberingType is "decimal" and level is zero,
      92             :      * w:val of w:lvlText was empty.
      93             :      * It should be <w:lvlText w:val="%1" />
      94             :      */
      95           4 :     xmlDocPtr pXmlDoc = parseExport("word/numbering.xml");
      96           4 :     if (!pXmlDoc)
      97           6 :         return;
      98             : 
      99           2 :     assertXPath ( pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val","%1" );
     100             : }
     101             : 
     102          28 : DECLARE_OOXMLEXPORT_TEST(testfdo79008, "fdo79008.docx")
     103             : {
     104             :     /* File getting crash while saving in LO.
     105             :      * Checking if document.xml file is getting created after fix
     106             :      */
     107           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     108           4 :     if (!pXmlDoc)
     109           2 :         return;
     110             : }
     111             : 
     112          28 : DECLARE_OOXMLEXPORT_TEST(testAuthorPropertySdt, "author-property.docx")
     113             : {
     114           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     115             : 
     116           4 :     if (!pXmlDoc)
     117           6 :        return;
     118             : 
     119           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns1:coreProperties[1]/ns0:creator[1]");
     120           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "storeItemID","{6C3C8BC8-F283-45AE-878A-BAB7291924A1}");
     121             :     // FIXME: the next property doesn't match, though it's correct in theory. A bug in assertXPath?
     122             :     // assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "prefixMappings",
     123             :     //            "xmlns:ns0='http://purl.org/dc/elements/1.1/' xmlns:ns1='http://schemas.openxmlformats.org/package/2006/metadata/core-properties'");
     124             : }
     125             : 
     126          28 : DECLARE_OOXMLEXPORT_TEST(testFDO76586, "fdo76586.docx")
     127             : {
     128             :     /*
     129             :      * In the test file gridCol had only one value for entire table width
     130             :      * while there are two cells in a table row.
     131             :      * So the table was not imported with the correct cell widths
     132             :      */
     133           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     134             : 
     135           4 :     if (!pXmlDoc)
     136           6 :        return;
     137             : 
     138             :     // there is only one table in the test file
     139           2 :     assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[1]", "w", "1601");
     140           2 :     assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[2]", "w", "7843");
     141             : }
     142             : 
     143          28 : DECLARE_OOXMLEXPORT_TEST(testFDO76587 , "fdo76587.docx")
     144             : {
     145           4 :     xmlDocPtr pXmlDoc = parseExport("word/styles.xml");
     146           4 :     if (!pXmlDoc)
     147           6 :         return;
     148           2 :     assertXPath(pXmlDoc, "/w:styles/w:style[8]/w:pPr/w:spacing", "line", "240");
     149           2 :     assertXPath(pXmlDoc, "/w:styles/w:style[8]/w:pPr/w:spacing", "lineRule", "auto");
     150             : }
     151             : 
     152          28 : DECLARE_OOXMLEXPORT_TEST(testFDO77890 , "fdo77890.docx")
     153             : {
     154             :     /*
     155             :     Ensure that the page break is preserved i.e it should not be converted to a section break, in case
     156             :     if the different first page is set for the pages in the document.
     157             :     For additional comments pls refer https://www.libreoffice.org/bugzilla/show_bug.cgi?id=77890#c2
     158             :     */
     159           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     160           4 :     if (!pXmlDoc)
     161           6 :         return;
     162           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:br", "type", "page");
     163             : }
     164             : 
     165          28 : DECLARE_OOXMLEXPORT_TEST(testNumberedList,"NumberedList.docx")
     166             : {
     167             :     //fdo74150:In document.xml, for pStyle = "NumberedList1", iLvl and numId was not preserved
     168           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     169           4 :     if (!pXmlDoc)
     170           6 :         return;
     171           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr[1]/w:pStyle", "val", "NumberedList1");
     172           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr[1]/w:numPr/w:ilvl","val", "0");
     173           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr[1]/w:numPr/w:numId","val", "0");
     174             : 
     175           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[3]/w:pPr[1]/w:pStyle","val", "NumberedList1");
     176           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[3]/w:pPr[1]/w:numPr/w:ilvl","val", "0");
     177           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]/w:p[3]/w:pPr[1]/w:numPr/w:numId","val", "0");
     178             : }
     179             : 
     180          28 : DECLARE_OOXMLEXPORT_TEST(testFDO76597, "fdo76597.docx")
     181             : {
     182             :     // check XML
     183           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     184           4 :     if (!pXmlDoc)
     185           6 :         return;
     186           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "before", "96");
     187           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "after", "120");
     188             : }
     189             : 
     190          28 : DECLARE_OOXMLEXPORT_TEST(testContentTypeTIF, "fdo77476.docx")
     191             : {
     192           4 :     xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     193             : 
     194           4 :     if (!pXmlDoc)
     195           6 :        return;
     196             : 
     197           2 :     assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@ContentType='image/tif']", "PartName", "/word/media/image1.tif");
     198             : }
     199             : 
     200          28 : DECLARE_OOXMLEXPORT_TEST(testFDO77117, "fdo77117.docx")
     201             : {
     202           4 :     uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY);
     203           8 :     uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY);
     204             :     // This checks textbox textrun size of font which is in group shape.
     205           8 :     CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight"));
     206           4 : }
     207             : 
     208          28 : DECLARE_OOXMLEXPORT_TEST(testFloatingTable, "fdo77887.docx")
     209             : {
     210           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     211             : 
     212           4 :     if (!pXmlDoc)
     213           6 :        return;
     214             : 
     215           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "horzAnchor", "margin");
     216           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "leftFromText", "141");
     217           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "rightFromText", "141");
     218           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpXSpec", "center");
     219           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpY", "2266");
     220           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "vertAnchor", "page");
     221             : 
     222             : }
     223             : 
     224             : 
     225          28 : DECLARE_OOXMLEXPORT_TEST(testTablePreferredWidth, "tablePreferredWidth.docx")
     226             : {
     227           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     228             : 
     229           4 :     if(!pXmlDoc)
     230           6 :         return;
     231             : 
     232             :     // Problem :If the table preferred width is in percent, then after RT it changes to 0 & width type changes
     233             :     // to 'auto' instead of 'pct'.
     234           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "w", "3000");
     235           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "type","pct");
     236             : }
     237             : 
     238          28 : DECLARE_OOXMLEXPORT_TEST(testFDO75431, "fdo75431.docx")
     239             : {
     240           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     241             : 
     242           4 :     if (!pXmlDoc)
     243           6 :        return;
     244             : 
     245           2 :     assertXPath(pXmlDoc, "//w:tbl", 2);
     246           2 :     assertXPath(pXmlDoc, "//w:p/w:pPr/w:sectPr/w:type", "val", "nextPage");
     247             : }
     248             : 
     249          28 : DECLARE_OOXMLEXPORT_TEST(testFDO77725, "fdo77725.docx")
     250             : {
     251           4 :     xmlDocPtr pXmlFootnotes = parseExport("word/footnotes.xml");
     252           4 :     if (!pXmlFootnotes)
     253           6 :         return;
     254             : 
     255           2 :     assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[1]", 0);
     256           2 :     assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[2]", 0);
     257           2 :     assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[3]", 0);
     258             : }
     259             : 
     260          28 : DECLARE_OOXMLEXPORT_TEST(testFDO77812, "fdo77812.docx")
     261             : {
     262             :     /* Additional sectPr was getting inserted and hence Column properties
     263             :      * were getting added into this additional sectPr instead of Default setPr.
     264             :      */
     265           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     266           4 :     if (!pXmlDoc)
     267           6 :         return;
     268             : 
     269             :     // Check no additional section break is inserted.
     270           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:pPr/w:sectPr", 0);
     271             : 
     272             :     // Check w:cols comes under Default sectPr
     273           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols", "num", "2");
     274           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols/w:col[1]", 1);
     275           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols/w:col[2]", 1);
     276             : }
     277             : 
     278          28 : DECLARE_OOXMLEXPORT_TEST(testContentTypeOLE, "fdo77759.docx")
     279             : {
     280           4 :     xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     281             : 
     282           4 :     if (!pXmlDoc)
     283           6 :        return;
     284             : 
     285             :     assertXPath(pXmlDoc,
     286             :                 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']",
     287             :                 "PartName",
     288           2 :                 "/word/embeddings/oleObject1.xlsx");
     289             : }
     290             : 
     291          28 : DECLARE_OOXMLEXPORT_TEST(testfdo78420, "fdo78420.docx")
     292             : {
     293           4 :     xmlDocPtr pXmlHeader = parseExport("word/header2.xml");
     294             : 
     295           4 :     if (!pXmlHeader)
     296           2 :        return;
     297             : 
     298           2 :     xmlDocPtr pXmlHeaderRels = parseExport("word/_rels/header2.xml.rels");
     299           2 :     if(!pXmlHeaderRels)
     300           0 :        return;
     301             : 
     302           2 :     assertXPath(pXmlHeaderRels,"/rels:Relationships/rels:Relationship[1]","Id","rId1");
     303             : }
     304             : 
     305             : 
     306          28 : DECLARE_OOXMLEXPORT_TEST(testPageBreakInFirstPara,"fdo77727.docx")
     307             : {
     308             :     /* Break to next page was not exported if it is in first paragraph of the section.
     309             :      * Now after fix , LO writes Next Page Break and also preserves <w:br> tag.
     310             :      */
     311           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     312           4 :     if (!pXmlDoc)
     313           6 :         return;
     314             : 
     315           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br","type","page");
     316             : }
     317             : 
     318          28 : DECLARE_OOXMLEXPORT_TEST(testFDO78284, "fdo78284.docx")
     319             : {
     320           4 :     xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     321             : 
     322           4 :     if (!pXmlDoc)
     323           6 :         return;
     324             :     assertXPath(pXmlDoc,"/ContentType:Types/ContentType:Override[@PartName='/word/media/OOXDiagramDataRels1_0.png']",
     325             :                         "ContentType",
     326           2 :                         "image/png");
     327             : }
     328             : 
     329          28 : DECLARE_OOXMLEXPORT_TEST(testFDO78384,"fdo78384.docx")
     330             : {
     331           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     332           4 :     if (!pXmlDoc)
     333           6 :         return;
     334           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[1]/w:rPr/w:rFonts","ascii","Wingdings");
     335             : }
     336             : 
     337          28 : DECLARE_OOXMLEXPORT_TEST(testfdo78469, "fdo78469.docx")
     338             : {
     339           4 :     xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
     340           4 :     if (!pXmlDoc)
     341           6 :        return;
     342             :     // make sure dataBinding & text tags not presernt in sdtcontent
     343           2 :     assertXPath(pXmlDoc, "/w:hdr[1]/w:tbl[1]/w:tr[1]/w:tc[2]/w:p[1]/w:sdt[2]/w:sdtPr[1]/w:dataBinding[1]",0);
     344           2 :     assertXPath(pXmlDoc, "/w:hdr[1]/w:tbl[1]/w:tr[1]/w:tc[2]/w:p[1]/w:sdt[2]/w:sdtPr[1]/w:text[1]",0);
     345             : }
     346             : 
     347          28 : DECLARE_OOXMLEXPORT_TEST(testFDO78887, "fdo78887.docx")
     348             : {
     349           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     350           4 :     if (!pXmlDoc)
     351           6 :         return;
     352             : 
     353           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[1]", 1);
     354           2 :     assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:t[1]", "Lyrics: ");
     355           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[2]", 1);
     356             : }
     357             : 
     358          28 : DECLARE_OOXMLEXPORT_TEST(testFdo78651, "fdo78651.docx")
     359             : {
     360           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     361             : 
     362           4 :     if (!pXmlDoc)
     363           6 :         return;
     364             :     // ensure that there are only two tables
     365           2 :     assertXPath(pXmlDoc, "//w:tbl", 2);
     366             : }
     367             : 
     368          28 : DECLARE_OOXMLEXPORT_TEST(testfdo78882, "fdo78882.docx")
     369             : {
     370           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     371             : 
     372           4 :     if (!pXmlDoc)
     373           6 :         return;
     374             : 
     375             :     // Ensure that Section Break is getting written inside second paragraph
     376           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:pPr[1]/w:sectPr[1]",1);
     377             : 
     378             :     // Ensure that no dummy paragarph gets created inside second paragraph for Section Break
     379           2 :     assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:p[1]/w:pPr[1]/w:sectPr[1]",0);
     380             : }
     381             : 
     382          28 : DECLARE_OOXMLEXPORT_TEST(testfdo76934, "fdo76934.docx")
     383             : {
     384             :     /* Issue was, AuoSpacing property if present inside styles.xml, LO was not able to
     385             :      * preserve it.
     386             :      */
     387             : 
     388           4 :     xmlDocPtr pXmlDoc = parseExport("word/styles.xml");
     389             : 
     390           4 :     if (!pXmlDoc)
     391           6 :         return;
     392             : 
     393             :     // Ensure that after fix LO is preserving AutoSpacing property in styles.xml
     394           2 :     assertXPath ( pXmlDoc, "/w:styles[1]/w:style[36]/w:pPr[1]/w:spacing[1]", "beforeAutospacing", "1" );
     395             : }
     396             : 
     397          28 : DECLARE_OOXMLEXPORT_TEST(testfdo79540, "fdo79540.docx")
     398             : {
     399             :     /* Issue was, <w:drawing> was getting written inside <w:drawing>.
     400             :      * So Postone the writing of Inner Drawing tag.
     401             :      * MS Office does not allow Nestimg of drawing tags.
     402             :      */
     403             : 
     404           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     405             : 
     406           4 :     if (!pXmlDoc)
     407           6 :         return;
     408             : 
     409             :     // Ensure that two separate w:drawing tags are written after the code changes.
     410           2 :     assertXPath ( pXmlDoc, "/w:document/w:body/w:p/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing",1);
     411           2 :     assertXPath ( pXmlDoc, "/w:document/w:body/w:p/w:r[3]/mc:AlternateContent/mc:Choice/w:drawing",1);
     412             : }
     413             : 
     414          28 : DECLARE_OOXMLEXPORT_TEST(testFDO79062, "fdo79062.docx")
     415             : {
     416           4 :     xmlDocPtr pXmlFootNotes = parseExport("word/footnotes.xml");
     417           4 :     if (!pXmlFootNotes)
     418           2 :         return;
     419           2 :     assertXPath(pXmlFootNotes, "/w:footnotes", "Ignorable", "w14 wp14");
     420             : 
     421           2 :     xmlDocPtr pXmlEndNotes = parseExport("word/endnotes.xml");
     422           2 :     if (!pXmlEndNotes)
     423           0 :         return;
     424           2 :     assertXPath(pXmlEndNotes, "/w:endnotes", "Ignorable", "w14 wp14");
     425             : }
     426             : 
     427          28 : DECLARE_OOXMLEXPORT_TEST(testfdo79668,"fdo79668.docx")
     428             : {
     429             :     // fdo#79668: Document was Crashing on DebugUtil build while Saving
     430             :     // because of repeated attribute value in same element.
     431           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     432           4 :     if (!pXmlDoc)
     433           6 :         return;
     434             :     // w:pPr's  w:shd attributes were getting added to w:pPrChange/w:pPr's w:shd hence checking
     435             :     // w:fill for both shd elements
     436           2 :     assertXPath ( pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:shd", "fill", "FFFFFF" );
     437           2 :     assertXPath ( pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:pPrChange/w:pPr/w:shd", "fill", "FFFFFF" );
     438             : }
     439             : 
     440          28 : DECLARE_OOXMLEXPORT_TEST(testfdo78907,"fdo78907.docx")
     441             : {
     442           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     443           4 :     if (!pXmlDoc)
     444           2 :         return;
     445           2 :     assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br", "type", "page" );
     446             : 
     447           2 :     xmlDocPtr pXmlDoc1 = parseExport("word/footer1.xml");
     448           2 :     if (!pXmlDoc1)
     449           0 :         return;
     450           2 :     assertXPath ( pXmlDoc1, "/w:ftr[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tbl", 0 );
     451             : }
     452             : 
     453          28 : DECLARE_OOXMLEXPORT_TEST(testfdo79822, "fdo79822.docx")
     454             : {
     455             :     /* File getting crash while saving in LO.
     456             :      * The Docx contain smartart and the file was created in ms word 2007
     457             :      */
     458           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     459           4 :     if (!pXmlDoc)
     460           2 :         return;
     461             : }
     462             : 
     463          28 : DECLARE_OOXMLEXPORT_TEST(testFDO79915, "fdo79915.docx")
     464             : {
     465           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     466           4 :     if (!pXmlDoc)
     467           6 :         return;
     468             : 
     469           2 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[10]/w:t", "How much buoyancy does the water provide?");
     470             : }
     471             : 
     472          28 : DECLARE_OOXMLEXPORT_TEST(testfdo79817, "fdo79817.docx")
     473             : {
     474           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     475             :     {
     476           2 :         assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "storeItemID", "{9222E47B-A68B-4AEB-9855-21C912B9D3D2}");
     477           2 :         assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns0:properties[1]/documentManagement[1]/ns2:Responsible_x0020_Officer_x0020_Title[1]");
     478             :     }
     479           4 : }
     480             : 
     481             : 
     482          28 : DECLARE_OOXMLEXPORT_TEST(testfdo79968_sldx, "fdo79968.docx")
     483             : {
     484             :     // This UT for DOCX embedded with powerpoint slide
     485           4 :     xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     486             : 
     487           4 :     if (!pXmlDoc)
     488           6 :        return;
     489             : 
     490             :     assertXPath(pXmlDoc,
     491             :                 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.presentationml.slide']",
     492             :                 "PartName",
     493           2 :                 "/word/embeddings/oleObject1.sldx");
     494             : }
     495             : 
     496          28 : DECLARE_OOXMLEXPORT_TEST(testfdo79969_xlsb, "fdo79969_xlsb.docx")
     497             : {
     498             :     // This UT for DOCX embedded with binary excel work sheet.
     499           4 :     xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     500             : 
     501           4 :     if (!pXmlDoc)
     502           6 :        return;
     503             : 
     504             :     assertXPath(pXmlDoc,
     505             :                 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-excel.sheet.binary.macroEnabled.12']",
     506             :                 "PartName",
     507           2 :                 "/word/embeddings/oleObject1.xlsb");
     508             : }
     509             : 
     510          28 : DECLARE_OOXMLEXPORT_TEST(testfdo80097, "fdo80097.docx")
     511             : {
     512             :     //fdo#76635 : Table borders are not getting preserved.
     513             : 
     514           4 :     xmlDocPtr pXmlDocument = parseExport("word/document.xml");
     515           4 :     if (!pXmlDocument)
     516           6 :         return;
     517             : 
     518             :     //Table Borders
     519           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:val = 'single']",1);
     520           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:sz = 4]", 1);
     521           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:space = 0]", 1);
     522           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:top[@w:color = '00000A']", 1);
     523             : 
     524           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:val = 'single']",1);
     525           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:sz = 4]", 1);
     526           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:space = 0]", 1);
     527           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:bottom[@w:color = '00000A']", 1);
     528             : 
     529           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:val = 'single']",1);
     530           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:sz = 4]", 1);
     531           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:space = 0]", 1);
     532           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideH[@w:color = '00000A']", 1);
     533             : 
     534           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:val = 'single']",1);
     535           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:sz = 4]", 1);
     536           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:space = 0]", 1);
     537           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblBorders/w:insideV[@w:color = '00000A']", 1);
     538             : 
     539             :     //Table Cell Borders
     540           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:val = 'single']",1);
     541           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:sz = 4]", 1);
     542           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:space = 0]", 1);
     543           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:top[@w:color = '00000A']", 1);
     544             : 
     545           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:val = 'single']",1);
     546           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:sz = 4]", 1);
     547           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:space = 0]", 1);
     548           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:bottom[@w:color = '00000A']", 1);
     549             : 
     550           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:val = 'single']",1);
     551           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:sz = 4]", 1);
     552           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:space = 0]", 1);
     553           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideH[@w:color = '00000A']", 1);
     554             : 
     555           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:val = 'single']",1);
     556           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:sz = 4]", 1);
     557           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:space = 0]", 1);
     558           2 :     assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/w:insideV[@w:color = '00000A']", 1);
     559             : }
     560             : 
     561          28 : DECLARE_OOXMLEXPORT_TEST(testFdo77129, "fdo77129.docx")
     562             : {
     563             :     // The problem was that text after TOC field was missing if footer reference  comes in field.
     564           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     565             : 
     566           4 :     if (!pXmlDoc)
     567           6 :        return;
     568             : 
     569             :     // Data was lost from this paragraph.
     570           2 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[1]/w:t", "Abstract");
     571             : }
     572             : 
     573          28 : DECLARE_OOXMLEXPORT_TEST(testfdo79969_xlsm, "fdo79969_xlsm.docx")
     574             : {
     575             :     // This UT for DOCX embedded with excel work sheet.
     576           4 :     xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     577             : 
     578           4 :     if (!pXmlDoc)
     579           6 :        return;
     580             : 
     581             :     assertXPath(pXmlDoc,
     582             :                 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-excel.sheet.macroEnabled.12']",
     583             :                 "PartName",
     584           2 :                 "/word/embeddings/oleObject1.xlsm");
     585             : }
     586             : 
     587          28 : DECLARE_OOXMLEXPORT_TEST(testfdo80522,"fdo80522.docx")
     588             : {
     589           4 :    xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     590             : 
     591           4 :     if (!pXmlDoc)
     592           6 :        return;
     593             : 
     594             :     assertXPath(pXmlDoc,
     595             :                 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-word.document.macroEnabled.12']",
     596             :                 "PartName",
     597           2 :                 "/word/embeddings/oleObject1.docm");
     598             : }
     599             : 
     600          28 : DECLARE_OOXMLEXPORT_TEST(testfdo80523_pptm,"fdo80523_pptm.docx")
     601             : {
     602           4 :    xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     603             : 
     604           4 :     if (!pXmlDoc)
     605           6 :        return;
     606             : 
     607             :     assertXPath(pXmlDoc,
     608             :                 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-powerpoint.presentation.macroEnabled.12']",
     609             :                 "PartName",
     610           2 :                 "/word/embeddings/oleObject1.pptm");
     611             : }
     612             : 
     613          28 : DECLARE_OOXMLEXPORT_TEST(testfdo80523_sldm,"fdo80523_sldm.docx")
     614             : {
     615           4 :    xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     616             : 
     617           4 :     if (!pXmlDoc)
     618           6 :        return;
     619             : 
     620             :     assertXPath(pXmlDoc,
     621             :                 "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-powerpoint.slide.macroEnabled.12']",
     622             :                 "PartName",
     623           2 :                 "/word/embeddings/oleObject1.sldm");
     624             : }
     625             : 
     626          28 : DECLARE_OOXMLEXPORT_TEST(testfdo80898, "fdo80898.docx")
     627             : {
     628             :     // This UT for DOCX embedded with binary excel work sheet.
     629           4 :     xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml");
     630             : 
     631           4 :     if (!pXmlDoc)
     632           6 :        return;
     633             : 
     634             :     assertXPath(pXmlDoc,
     635             :                 "/ContentType:Types/ContentType:Override[@ContentType='application/msword']",
     636             :                 "PartName",
     637           2 :                 "/word/embeddings/oleObject1.doc");
     638             : }
     639             : 
     640          28 : DECLARE_OOXMLEXPORT_TEST(testTableCellWithDirectFormatting, "fdo80800.docx")
     641             : {
     642             :     // Issue was Direct Foramatting for non-first Table cells was not getting preserved.
     643             : 
     644           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     645           4 :     if (!pXmlDoc)
     646           6 :        return;
     647             : 
     648             :     // Ensure that for Third Table cell Direct Formatting is preserved.
     649             :     // In file, Direct Formatting used for Third Table cell is Line Spacing="1.5 lines"
     650             :     // For Line Spacing "1.5 lines" w:line equals 360
     651           2 :     assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc[3]/w:p/w:pPr/w:spacing","line","360");
     652             : 
     653             : }
     654             : 
     655          28 : DECLARE_OOXMLEXPORT_TEST(test2colHeader, "2col-header.docx")
     656             : {
     657             :     // Header was lost on export when the document had multiple columns.
     658           4 :     uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY);
     659           4 :     CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, "HeaderIsOn"));
     660           4 : }
     661             : 
     662          28 : DECLARE_OOXMLEXPORT_TEST(testfdo83048, "fdo83048.docx")
     663             : {
     664             :     // Issue was wrong SDT properties were getting exported for Date SDT
     665           4 :     xmlDocPtr pXmlDoc = parseExport("word/footer1.xml");
     666           4 :     if (!pXmlDoc)
     667           6 :        return;
     668             : 
     669             :     // Make sure Date is inside SDT tag.
     670             :     // This will happen only if right SDT properties are exported.
     671           2 :     assertXPath(pXmlDoc, "/w:ftr/w:sdt/w:sdtContent/w:p[1]/w:sdt/w:sdtContent/w:r[1]/w:t", "1/2/2013");
     672             : }
     673             : 
     674          28 : DECLARE_OOXMLEXPORT_TEST(testSdt2Run, "sdt-2-run.docx")
     675             : {
     676           4 :     xmlDocPtr pXmlDoc = parseExport();
     677           4 :     if (!pXmlDoc)
     678           6 :         return;
     679             : 
     680             :     // The problem was that <w:sdt> was closed after "first", not after "second", so the second assert failed.
     681           2 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r[1]/w:t", "first");
     682           2 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r[2]/w:t", "second");
     683             :     // Make sure the third portion is still outside <w:sdt>.
     684           2 :     assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/w:t", "third");
     685             : }
     686             : 
     687          28 : DECLARE_OOXMLEXPORT_TEST(testFD083057, "fdo83057.docx")
     688             : {
     689           4 :     xmlDocPtr pXmlDoc = parseExport("word/header1.xml");
     690           4 :     if (!pXmlDoc)
     691           6 :         return;
     692             : 
     693             :     // A fly frame was attached to a para which started with a hint (run) containing an SDT.
     694             :     // This SDT was handled while exporting the FLYFRAME and also the text of the run.
     695             :     // So, eventhough the original file had only one sdt in the header, the RT file had two;
     696             :     // one for a separate run as expected, and one incorrectly exported in the alternateContent (FLYFRAME)
     697             : 
     698             :     // Assert that the file has only one sdt, in a separate run
     699           2 :     assertXPath(pXmlDoc, "//w:sdt", 1);
     700           2 :     assertXPath(pXmlDoc, "//mc:AlternateContent//w:sdt", 0);
     701             : }
     702             : 
     703           8 : CPPUNIT_PLUGIN_IMPLEMENT();
     704             : 
     705             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10