LCOV - code coverage report
Current view: top level - sw/qa/extras/ooxmlexport - ooxmlexport.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 262 262 100.0 %
Date: 2014-11-03 Functions: 384 428 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/style/BreakType.hpp>
      15             : #include <com/sun/star/text/FontEmphasis.hpp>
      16             : #include <com/sun/star/text/HoriOrientation.hpp>
      17             : #include <com/sun/star/text/XTextRangeCompare.hpp>
      18             : 
      19             : #include <string>
      20             : 
      21         168 : class Test : public SwModelTestBase
      22             : {
      23             : public:
      24         168 :     Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {}
      25             : 
      26             : protected:
      27             :     /**
      28             :      * Blacklist handling
      29             :      */
      30          84 :     bool mustTestImportOf(const char* filename) const SAL_OVERRIDE {
      31             :         const char* aBlacklist[] = {
      32             :             "math-escape.docx",
      33             :             "math-mso2k7.docx",
      34             :             "ImageCrop.docx",
      35             :             "test_GIF_ImageCrop.docx",
      36             :             "test_PNG_ImageCrop.docx"
      37          84 :         };
      38          84 :         std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist));
      39             : 
      40             :         // If the testcase is stored in some other format, it's pointless to test.
      41          84 :         return (OString(filename).endsWith(".docx") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end());
      42             :     }
      43             : };
      44             : 
      45          28 : DECLARE_OOXMLEXPORT_TEST(testfdo81381, "fdo81381.docx")
      46             : {
      47           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
      48           2 :         assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[1]/w:object[1]/o:OLEObject[1]", "DrawAspect", "Icon");
      49           4 : }
      50             : 
      51          28 : DECLARE_OOXMLEXPORT_TEST(testSdtAlias, "sdt-alias.docx")
      52             : {
      53           4 :     xmlDocPtr pXmlDoc = parseExport();
      54           4 :     if (!pXmlDoc)
      55           6 :         return;
      56             : 
      57             :     // <w:alias> was completely missing.
      58           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:alias", "val", "Subtitle");
      59             : }
      60             : 
      61          28 : DECLARE_OOXMLEXPORT_TEST(testSdtDateCharformat, "sdt-date-charformat.docx")
      62             : {
      63           4 :     if (xmlDocPtr pXmlDoc = parseExport())
      64             :     {
      65             :         // character formatting (bold) was missing, this was 0
      66           2 :         assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:rPr/w:b", 1);
      67             :         // alias was also missing.
      68           2 :         assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:alias", 1);
      69             :     }
      70           4 : }
      71             : 
      72          28 : DECLARE_OOXMLEXPORT_TEST(testFooterBodyDistance, "footer-body-distance.docx")
      73             : {
      74           4 :     if (xmlDocPtr pXmlDoc = parseExport())
      75             :         // Page break was exported as section break, this was 0
      76           2 :         assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br", 1);
      77           4 : }
      78             : 
      79          28 : DECLARE_OOXMLEXPORT_TEST(testfdo81031, "fdo81031.docx")
      80             : {
      81             :     // vml image was not rendered
      82             :     // As there are also numPicBullets in the file,
      83             :     // the fragmentPath was not changed hence relationships were not resolved.
      84             : 
      85           4 :     uno::Reference<drawing::XShape> image = getShape(1);
      86           8 :     uno::Reference<beans::XPropertySet> xImage(image, uno::UNO_QUERY);
      87           8 :     uno::Reference<graphic::XGraphic> xGraphic = getProperty<uno::Reference<graphic::XGraphic> >(xImage, "Graphic");
      88           8 :     uno::Reference<awt::XBitmap> xBitmap(xGraphic, uno::UNO_QUERY);
      89           4 :     CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(381), xBitmap->getSize().Width );
      90           8 :     CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(148), xBitmap->getSize().Height );
      91           4 : }
      92             : 
      93          28 : DECLARE_OOXMLEXPORT_TEST(testPlausableBorder, "plausable-border.docx")
      94             : {
      95             :     // sw::util::IsPlausableSingleWordSection() did not merge two page styles due to borders.
      96           4 :     if (xmlDocPtr pXmlDoc = parseExport())
      97             :         // Page break was exported as section break, this was 0
      98           2 :         assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:br", 1);
      99           4 : }
     100             : 
     101          28 : DECLARE_OOXMLEXPORT_TEST(testUnwantedSectionBreak, "unwanted-section-break.docx")
     102             : {
     103           4 :     if (xmlDocPtr pXmlDoc = parseExport())
     104             :         // This was 2: an additional sectPr was added to the document.
     105           2 :         assertXPath(pXmlDoc, "//w:sectPr", 1);
     106           4 : }
     107             : 
     108          28 : DECLARE_OOXMLEXPORT_TEST(testfdo80897 , "fdo80897.docx")
     109             : {
     110           4 :     xmlDocPtr pXmlDoc = parseExport();
     111           4 :     if (!pXmlDoc)
     112           6 :         return;
     113           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:bodyPr/a:prstTxWarp", "prst", "textTriangle");
     114             : }
     115             : 
     116             : 
     117             : 
     118          28 : DECLARE_OOXMLEXPORT_TEST(testFdo80997, "fdo80997.docx")
     119             : {
     120             :     // The problem was that the DOCX exporter not able to export text behind textbox, if textbox has a wrap property.
     121           4 :     uno::Reference< text::XTextRange > xParagraph = getParagraph( 1 );
     122           4 :     uno::Reference< text::XTextRange > xText = getRun( xParagraph, 1, " text");
     123           4 : }
     124             : 
     125          28 : DECLARE_OOXMLEXPORT_TEST(testFdo80902, "fdo80902.docx")
     126             : {
     127             :     // The problem was that the docGrid type was set as default so fix it for other grid type
     128           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     129           4 :     if (!pXmlDoc)
     130           6 :        return;
     131             : 
     132           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:docGrid", "type", "lines");
     133             : }
     134             : 
     135          28 : DECLARE_OOXMLEXPORT_TEST(testParaShading, "para-shading.docx")
     136             : {
     137             :     // Make sure the themeColor attribute is not written when it would be empty.
     138           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     139           2 :         assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:shd", "themeColor");
     140           4 : }
     141             : 
     142          28 : DECLARE_OOXMLEXPORT_TEST(testFirstHeaderFooter, "first-header-footer.docx")
     143             : {
     144             :     // Test import and export of a section's headerf/footerf properties.
     145             :     // (copied from a ww8export test, with doc converted to docx using Word)
     146             : 
     147             :     // The document has 6 pages. Note that we don't test if 4 or just 2 page
     148             :     // styles are created, the point is that layout should be correct.
     149           4 :     CPPUNIT_ASSERT_EQUAL(OUString("First page header"),  parseDump("/root/page[1]/header/txt/text()"));
     150           4 :     CPPUNIT_ASSERT_EQUAL(OUString("First page footer"),  parseDump("/root/page[1]/footer/txt/text()"));
     151           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Even page header"),   parseDump("/root/page[2]/header/txt/text()"));
     152           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Even page footer"),   parseDump("/root/page[2]/footer/txt/text()"));
     153           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Odd page header"),  parseDump("/root/page[3]/header/txt/text()"));
     154           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer"),  parseDump("/root/page[3]/footer/txt/text()"));
     155           4 :     CPPUNIT_ASSERT_EQUAL(OUString("First page header2"), parseDump("/root/page[4]/header/txt/text()"));
     156           4 :     CPPUNIT_ASSERT_EQUAL(OUString("First page footer 2"), parseDump("/root/page[4]/footer/txt/text()"));
     157           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Odd page header 2"), parseDump("/root/page[5]/header/txt/text()"));
     158           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Odd page footer 2"), parseDump("/root/page[5]/footer/txt/text()"));
     159           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Even page header 2"),  parseDump("/root/page[6]/header/txt/text()"));
     160           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Even page footer 2"),  parseDump("/root/page[6]/footer/txt/text()"));
     161           4 : }
     162             : 
     163          28 : DECLARE_OOXMLEXPORT_TEST(testFDO83044, "fdo83044.docx")
     164             : {
     165           4 :     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     166             : 
     167           4 :     if (!pXmlDoc)
     168           6 :        return;
     169             : 
     170           2 :     assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:text", 1);
     171             : }
     172             : 
     173          28 : DECLARE_OOXMLEXPORT_TEST(testfdo83428, "fdo83428.docx")
     174             : {
     175           4 :      uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY);
     176           8 :      uno::Reference<document::XDocumentProperties> xProps(xDocumentPropertiesSupplier->getDocumentProperties());
     177           8 :      uno::Reference<beans::XPropertySet> xUDProps(xProps->getUserDefinedProperties(), uno::UNO_QUERY);
     178           8 :      CPPUNIT_ASSERT_EQUAL(OUString("Document"), getProperty<OUString>(xUDProps, "Testing"));
     179           4 : }
     180             : 
     181          28 : DECLARE_OOXMLEXPORT_TEST(testShapeInFloattable, "shape-in-floattable.docx")
     182             : {
     183           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     184             :     {
     185             :         // No nested drawingML w:txbxContent.
     186           2 :         assertXPath(pXmlDoc, "//mc:Choice//w:txbxContent//w:txbxContent", 0);
     187             :         // Instead, make sure we have a separate shape and group shape:
     188           2 :         assertXPath(pXmlDoc, "//mc:AlternateContent//mc:Choice[@Requires='wps']", 1);
     189           2 :         assertXPath(pXmlDoc, "//mc:AlternateContent//mc:Choice[@Requires='wpg']", 1);
     190             :     }
     191           4 : }
     192             : 
     193          28 : DECLARE_OOXMLEXPORT_TEST(testEmptyAnnotationMark, "empty-annotation-mark.docx")
     194             : {
     195           4 :     if (mbExported)
     196             :     {
     197             :         // Delete the word that is commented, and save again.
     198           2 :         uno::Reference<text::XTextRange> xRun = getRun(getParagraph(1), 3);
     199           2 :         CPPUNIT_ASSERT_EQUAL(OUString("with"), xRun->getString());
     200           2 :         xRun->setString("");
     201           4 :         uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
     202           2 :         xStorable->store();
     203             : 
     204             :         // Then inspect the OOXML markup of the modified document model.
     205           2 :         xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     206             :         // There were two commentReference nodes.
     207           2 :         assertXPath(pXmlDoc, "//w:commentReference", "id", "0");
     208             :         // Empty comment range was not ignored on export, this was 1.
     209           2 :         assertXPath(pXmlDoc, "//w:commentRangeStart", 0);
     210             :         // Ditto.
     211           4 :         assertXPath(pXmlDoc, "//w:commentRangeEnd", 0);
     212             :     }
     213           4 : }
     214             : 
     215          28 : DECLARE_OOXMLEXPORT_TEST(testDropdownInCell, "dropdown-in-cell.docx")
     216             : {
     217             :     // First problem: table was missing from the document, this was 0.
     218           4 :     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
     219           8 :     uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
     220           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount());
     221             : 
     222             :     // Second problem: dropdown shape wasn't anchored inside the B1 cell.
     223           8 :     uno::Reference<text::XTextContent> xShape(getShape(1), uno::UNO_QUERY);
     224           8 :     uno::Reference<text::XTextRange> xAnchor = xShape->getAnchor();
     225           8 :     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
     226           8 :     uno::Reference<text::XTextRange> xCell(xTable->getCellByName("B1"), uno::UNO_QUERY);
     227           8 :     uno::Reference<text::XTextRangeCompare> xTextRangeCompare(xCell, uno::UNO_QUERY);
     228           8 :     CPPUNIT_ASSERT_EQUAL(sal_Int16(0), xTextRangeCompare->compareRegionStarts(xAnchor, xCell));
     229           4 : }
     230             : 
     231          28 : DECLARE_OOXMLEXPORT_TEST(testTableAlignment, "table-alignment.docx")
     232             : {
     233           4 :     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
     234           8 :     uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
     235           8 :     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
     236             :     // This was LEFT_AND_WIDTH, i.e. table alignment wasn't imported correctly.
     237           8 :     CPPUNIT_ASSERT_EQUAL(text::HoriOrientation::RIGHT, getProperty<sal_Int16>(xTable, "HoriOrient"));
     238           4 : }
     239             : 
     240          28 : DECLARE_OOXMLEXPORT_TEST(testSdtIgnoredFooter, "sdt-ignored-footer.docx")
     241             : {
     242           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     243             :     {
     244             :         // This was 1, make sure no w:sdt sneaks into the main document from the footer.
     245           2 :         assertXPath(pXmlDoc, "//w:sdt", 0);
     246             :     }
     247           4 : }
     248             : 
     249          28 : DECLARE_OOXMLEXPORT_TEST(testSdtRunPicture, "sdt-run-picture.docx")
     250             : {
     251             :     // SDT around run was exported as SDT around paragraph
     252           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     253             :     {
     254             :         // This was 1: there was an SDT around w:p.
     255           2 :         assertXPath(pXmlDoc, "//w:body/w:sdt", 0);
     256             :         // This was 0: there were no SDT around w:r.
     257           2 :         assertXPath(pXmlDoc, "//w:body/w:p/w:sdt", 1);
     258             :     }
     259           4 : }
     260             : 
     261          28 : DECLARE_OOXMLEXPORT_TEST(testChartDupe, "chart-dupe.docx")
     262             : {
     263             :     // Single chart was exported back as two charts.
     264           4 :     uno::Reference<text::XTextEmbeddedObjectsSupplier> xTextEmbeddedObjectsSupplier(mxComponent, uno::UNO_QUERY);
     265           8 :     uno::Reference<container::XIndexAccess> xEmbeddedObjects(xTextEmbeddedObjectsSupplier->getEmbeddedObjects(), uno::UNO_QUERY);
     266             :     // This was 2, on second import we got a duplicated chart copy.
     267           8 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xEmbeddedObjects->getCount());
     268           4 : }
     269             : 
     270          28 : DECLARE_OOXMLEXPORT_TEST(testPositionAndRotation, "position-and-rotation.docx")
     271             : {
     272             :     // The document should look like: "This line is tricky, <image> because only 'This line is tricky,' is on the left."
     273             :     // But the image was pushed down, so it did not break the line into two text portions.
     274           4 :     uno::Reference<drawing::XShape> xShape = getShape(1);
     275             :     // Should be 1559, was -5639
     276           4 :     CPPUNIT_ASSERT(xShape->getPosition().X > 1500);
     277             :     // Should be 88, was 473
     278           4 :     CPPUNIT_ASSERT(xShape->getPosition().Y < 100);
     279           4 : }
     280             : 
     281          28 : DECLARE_OOXMLEXPORT_TEST(testNumberingFont, "numbering-font.docx")
     282             : {
     283           4 :     uno::Reference<beans::XPropertySet> xStyle(getStyles("CharacterStyles")->getByName("ListLabel 1"), uno::UNO_QUERY);
     284             :     // This was Calibri, i.e. custom font of the numbering itself ("1.\t") was lost on import.
     285           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Verdana"), getProperty<OUString>(xStyle, "CharFontName"));
     286           4 : }
     287             : 
     288          28 : DECLARE_OOXMLEXPORT_TEST(testDrawingmlFlipv, "drawingml-flipv.docx")
     289             : {
     290             :     // The problem was that the shape had vertical flip only, but then we added rotation as well on export.
     291           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     292           2 :         assertXPathNoAttribute(pXmlDoc, "//a:xfrm", "rot");
     293           4 : }
     294             : 
     295          28 : DECLARE_OOXMLEXPORT_TEST(testRot90Fliph, "rot90-fliph.docx")
     296             : {
     297             :     // The problem was that a shape rotation of 90° got turned into 270° after roundtrip.
     298           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     299             :     {
     300           2 :         assertXPath(pXmlDoc, "//a:xfrm", "flipH", "1");
     301             :         // This was 16200000 (270 * 60000).
     302           2 :         assertXPath(pXmlDoc, "//a:xfrm", "rot", "5400000");
     303             :     }
     304           4 : }
     305             : 
     306          28 : DECLARE_OOXMLEXPORT_TEST(testRot180Flipv, "rot180-flipv.docx")
     307             : {
     308             :     // 180° rotation got lost after roundtrip.
     309           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     310             :     {
     311           2 :         assertXPath(pXmlDoc, "//a:xfrm", "flipV", "1");
     312             :         // This attribute was completely missing.
     313           2 :         assertXPath(pXmlDoc, "//a:xfrm", "rot", "10800000");
     314             :     }
     315           4 : }
     316             : 
     317          28 : DECLARE_OOXMLEXPORT_TEST(testRot270Flipv, "rot270-flipv.docx")
     318             : {
     319             :     // 270° rotation got turned into 90° after roundtrip.
     320           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     321             :     {
     322           2 :         assertXPath(pXmlDoc, "//a:xfrm", "flipV", "1");
     323             :         // This was 5400000.
     324           2 :         assertXPath(pXmlDoc, "//a:xfrm", "rot", "16200000");
     325             :     }
     326           4 : }
     327             : 
     328          28 : DECLARE_OOXMLEXPORT_TEST(testMsoPosition, "bnc884615-mso-position.docx")
     329             : {
     330           4 :     if(xmlDocPtr doc = parseExport("word/footer1.xml"))
     331             :     {
     332             :         // We write the frames out in different order than they were read, so check it's the correct
     333             :         // textbox first by checking width. These tests may need reordering if that gets fixed.
     334           2 :         OUString style1 = getXPath(doc, "/w:ftr/w:p/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
     335           2 :         CPPUNIT_ASSERT( style1.indexOf( ";width:531pt;" ) >= 0 );
     336           2 :         CPPUNIT_ASSERT( style1.indexOf( ";mso-position-vertical-relative:page" ) >= 0 );
     337           2 :         CPPUNIT_ASSERT( style1.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 );
     338           4 :         OUString style2 = getXPath(doc, "/w:ftr/w:p/w:r[4]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
     339           2 :         CPPUNIT_ASSERT( style2.indexOf( ";width:549pt;" ) >= 0 );
     340           2 :         CPPUNIT_ASSERT( style2.indexOf( ";mso-position-vertical-relative:text" ) >= 0 );
     341           2 :         CPPUNIT_ASSERT( style2.indexOf( ";mso-position-horizontal:center" ) >= 0 );
     342           2 :         CPPUNIT_ASSERT( style2.indexOf( ";mso-position-horizontal-relative:text" ) >= 0 );
     343           4 :         OUString style3 = getXPath(doc, "/w:ftr/w:p/w:r[5]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
     344           2 :         CPPUNIT_ASSERT( style3.indexOf( ";width:36pt;" ) >= 0 );
     345           2 :         CPPUNIT_ASSERT( style3.indexOf( ";mso-position-horizontal-relative:text" ) >= 0 );
     346           4 :         CPPUNIT_ASSERT( style3.indexOf( ";mso-position-vertical-relative:text" ) >= 0 );
     347             :     }
     348           4 :     if(xmlDocPtr doc = parseExport("word/header1.xml"))
     349             :     {
     350           2 :         OUString style1 = getXPath(doc, "/w:hdr/w:p/w:r[2]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
     351           2 :         CPPUNIT_ASSERT( style1.indexOf( ";width:335.75pt;" ) >= 0 );
     352           2 :         CPPUNIT_ASSERT( style1.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 );
     353           2 :         CPPUNIT_ASSERT( style1.indexOf( ";mso-position-vertical-relative:page" ) >= 0 );
     354           4 :         OUString style2 = getXPath(doc, "/w:hdr/w:p/w:r[3]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
     355           2 :         CPPUNIT_ASSERT( style2.indexOf( ";width:138.15pt;" ) >= 0 );
     356           2 :         CPPUNIT_ASSERT( style2.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 );
     357           2 :         CPPUNIT_ASSERT( style2.indexOf( ";mso-position-vertical-relative:page" ) >= 0 );
     358           4 :         OUString style3 = getXPath(doc, "/w:hdr/w:p/w:r[4]/mc:AlternateContent/mc:Fallback/w:pict/v:rect", "style");
     359           2 :         CPPUNIT_ASSERT( style3.indexOf( ";width:163.8pt;" ) >= 0 );
     360           2 :         CPPUNIT_ASSERT( style3.indexOf( ";mso-position-horizontal-relative:page" ) >= 0 );
     361           4 :         CPPUNIT_ASSERT( style3.indexOf( ";mso-position-vertical-relative:page" ) >= 0 );
     362             :     }
     363           4 : }
     364             : 
     365          28 : DECLARE_OOXMLEXPORT_TEST(testWpsCharColor, "wps-char-color.docx")
     366             : {
     367           4 :     uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY);
     368             :     // This was -1, i.e. the character color was default (-1), not white.
     369           4 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0xffffff), getProperty<sal_Int32>(xShape->getStart(), "CharColor"));
     370           4 : }
     371             : 
     372          28 : DECLARE_OOXMLEXPORT_TEST(testTableStyleCellBackColor, "table-style-cell-back-color.docx")
     373             : {
     374             :     // The problem was that cell background was white, not green.
     375           4 :     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
     376           8 :     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
     377           8 :     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
     378           8 :     uno::Reference<table::XCell> xCell = xTable->getCellByName("A1");
     379             :     // This was 0xffffff.
     380           8 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00ff00), getProperty<sal_Int32>(xCell, "BackColor"));
     381           4 : }
     382             : 
     383          28 : DECLARE_OOXMLEXPORT_TEST(testTableStyleBorder, "table-style-border.docx")
     384             : {
     385           4 :     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
     386           8 :     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
     387           8 :     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
     388             : 
     389             :     // This was 0, the second cell was missing its right border.
     390           8 :     uno::Reference<table::XCell> xCell = xTable->getCellByName("A2");
     391           4 :     CPPUNIT_ASSERT(getProperty<table::BorderLine2>(xCell, "RightBorder").LineWidth > 0);
     392             : 
     393             :     // This was also 0 (even after fixing the previous problem), the first cell was missing its right border, too.
     394           4 :     xCell = xTable->getCellByName("A1");
     395           8 :     CPPUNIT_ASSERT(getProperty<table::BorderLine2>(xCell, "RightBorder").LineWidth > 0);
     396           4 : }
     397             : 
     398          28 : DECLARE_OOXMLEXPORT_TEST(testTableStyleBorderExport, "table-style-border-export.docx")
     399             : {
     400           4 :     uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
     401           8 :     uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY);
     402           8 :     uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY);
     403           8 :     uno::Reference<table::XCell> xCell = xTable->getCellByName("A3");
     404             :     // Bottom border was white, so this was 0xffffff.
     405           8 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(0x8064A2), getProperty<table::BorderLine2>(xCell, "BottomBorder").Color);
     406           4 : }
     407             : 
     408          28 : DECLARE_OOXMLEXPORT_TEST(testAnchorPosition, "anchor-position.docx")
     409             : {
     410             :     // The problem was that the at-char anchored picture was at the end of the
     411             :     // paragraph, so there were only two postions: a Text, then a Frame one.
     412           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(getRun(getParagraph(1), 1), "TextPortionType"));
     413           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Frame"), getProperty<OUString>(getRun(getParagraph(1), 2), "TextPortionType"));
     414           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Text"), getProperty<OUString>(getRun(getParagraph(1), 3), "TextPortionType"));
     415           4 : }
     416             : 
     417          28 : DECLARE_OOXMLEXPORT_TEST(testMultiPageToc, "multi-page-toc.docx")
     418             : {
     419             :     // Import of this document triggered an STL assertion.
     420             : 
     421             :     // Document has a ToC from its second paragraph.
     422           4 :     uno::Reference<container::XNamed> xTextSection = getProperty< uno::Reference<container::XNamed> >(getParagraph(2), "TextSection");
     423           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Table of Contents1"), xTextSection->getName());
     424             :     // There should be a field in the header as well.
     425           8 :     uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText");
     426           8 :     CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(getRun(getParagraphOfText(1, xHeaderText), 1), "TextPortionType"));
     427           4 : }
     428             : 
     429          28 : DECLARE_OOXMLEXPORT_TEST(testTextboxTable, "textbox-table.docx")
     430             : {
     431             :     // We wrote not-well-formed XML during export for this one:
     432             :     // Shape with textbox, having a table and also anchored inside a table.
     433             : 
     434             :     // Just make sure that we have both tables.
     435           4 :     uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
     436           8 :     uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY);
     437           8 :     CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTables->getCount());
     438           4 : }
     439             : 
     440          28 : DECLARE_OOXMLEXPORT_TEST(testCropPixel, "crop-pixel.docx")
     441             : {
     442             :     // If map mode of the graphic is in pixels, then we used to handle original
     443             :     // size of the graphic as mm100, but it was in pixels.
     444           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     445             :     {
     446             :         // This is 17667 in the original document, was 504666 (so the image
     447             :         // become invisible), now is around 19072.
     448             :         (void) pXmlDoc;
     449             : #ifndef MACOSX
     450           2 :         CPPUNIT_ASSERT(getXPath(pXmlDoc, "//a:srcRect", "l").toInt32() < 20000);
     451             : #endif
     452             :     }
     453           4 : }
     454             : 
     455          28 : DECLARE_OOXMLEXPORT_TEST(testEffectExtent, "effect-extent.docx")
     456             : {
     457             :     // The problem was that in case there were no shadows on the picture, we
     458             :     // wrote a <wp:effectExtent> full or zeros.
     459           4 :     if (xmlDocPtr pXmlDoc = parseExport("word/document.xml"))
     460             :         // E.g. this was 0.
     461           2 :         assertXPath(pXmlDoc, "//wp:effectExtent", "l", "114300");
     462           4 : }
     463             : 
     464          28 : DECLARE_OOXMLEXPORT_TEST(testEm, "em.docx")
     465             : {
     466             :     // Test all possible <w:em> arguments.
     467           4 :     CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::NONE, getProperty<sal_Int16>(getRun(getParagraph(1), 1), "CharEmphasis"));
     468             :     // This was ACCENT_ABOVE.
     469           4 :     CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_ABOVE, getProperty<sal_Int16>(getRun(getParagraph(1), 2), "CharEmphasis"));
     470             :     // This was DOT_ABOVE.
     471           4 :     CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::ACCENT_ABOVE, getProperty<sal_Int16>(getRun(getParagraph(1), 3), "CharEmphasis"));
     472           4 :     CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::CIRCLE_ABOVE, getProperty<sal_Int16>(getRun(getParagraph(1), 4), "CharEmphasis"));
     473           4 :     CPPUNIT_ASSERT_EQUAL(text::FontEmphasis::DOT_BELOW, getProperty<sal_Int16>(getRun(getParagraph(1), 5), "CharEmphasis"));
     474           4 : }
     475             : 
     476          28 : DECLARE_OOXMLEXPORT_TEST(testFdo77716, "fdo77716.docx")
     477             : {
     478             :     // The problem was that there should be 200 twips spacing between the two paragraphs, but there wasn't any.
     479           4 :     uno::Reference<beans::XPropertySet> xStyle(getStyles("ParagraphStyles")->getByName("Standard"), uno::UNO_QUERY);
     480             :     // This was 0.
     481           4 :     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(convertTwipToMm100(200)), getProperty<sal_Int32>(xStyle, "ParaBottomMargin"));
     482           4 : }
     483             : 
     484          28 : DECLARE_OOXMLEXPORT_TEST(testAfterlines, "afterlines.docx")
     485             : {
     486             :     // This was 353, i.e. the value of <w:spacing w:after="200"> from <w:pPrDefault>, instead of <w:spacing w:afterLines="100"/> from <w:pPr>.
     487           4 :     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(423), getProperty<sal_Int32>(getParagraph(1), "ParaBottomMargin"));
     488           4 : }
     489             : 
     490          28 : DECLARE_OOXMLEXPORT_TEST(testParagraphMark, "paragraph-mark.docx")
     491             : {
     492             :     // The problem was that we didn't handle the situation when an empty paragraph's marker had both a char style and some direct formatting.
     493             : 
     494             :     // This was 11.
     495           4 :     CPPUNIT_ASSERT_EQUAL(12.f, getProperty<float>(getParagraph(1), "CharHeight"));
     496             :     // This was empty.
     497           4 :     CPPUNIT_ASSERT_EQUAL(OUString("Emphasis"), getProperty<OUString>(getRun(getParagraph(1), 1), "CharStyleName"));
     498           4 : }
     499             : 
     500          28 : DECLARE_OOXMLEXPORT_TEST(testPageBreakBefore, "page-break-before.docx")
     501             : {
     502             :     // This was style::BreakType_PAGE_BEFORE, i.e. page break wasn't ignored, as it should have been.
     503           4 :     CPPUNIT_ASSERT_EQUAL(style::BreakType_NONE, getProperty<style::BreakType>(getParagraph(2), "BreakType"));
     504           4 : }
     505             : 
     506           8 : CPPUNIT_PLUGIN_IMPLEMENT();
     507             : 
     508             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10