diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2014-08-19 17:20:08 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2014-08-19 17:25:00 +0200 |
commit | 869a3e1b7f269053b4fed6d768939c0ab595bc76 (patch) | |
tree | 4e549a3616760ea0ac3886f0fc98d13a78c7b020 /sw/qa | |
parent | 36490fff3f4d1b4a7e4b7902a866abb177a0bf54 (diff) |
split CppunitTest_sw_ooxmlexport into several tests
In order to allow running them in parallel. There are already enough
tests to make it run for a couple of minutes and it's annoying to
see only once core busy with it.
I intentionally left the original file at the same name, without 1
appended, in order to avoid merge problems.
Change-Id: I097c45c34797cc68f5d1790cf31eefc96fbaf44e
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 3317 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport2.cxx | 1118 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport3.cxx | 1048 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 803 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 677 |
5 files changed, 3646 insertions, 3317 deletions
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 593358ecf16c..f843c24b8d27 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -76,3323 +76,6 @@ protected: } }; -#if !defined(WNT) - -DECLARE_OOXMLEXPORT_TEST(testZoom, "zoom.docx") -{ - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings()); - sal_Int16 nValue = 0; - xPropertySet->getPropertyValue("ZoomValue") >>= nValue; - CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue); - - // Validation test: order of elements were wrong. - xmlDocPtr pXmlDoc = parseExport("word/styles.xml"); - if (!pXmlDoc) - return; - // Order was: rsid, next. - int nNext = getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "next"); - int nRsid = getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "rsid"); - CPPUNIT_ASSERT(nNext < nRsid); - - pXmlDoc = parseExport("docProps/app.xml"); - // One paragraph in the document. - assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Paragraphs", "1"); - assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Company", "Example Ltd"); -} - -DECLARE_OOXMLEXPORT_TEST(defaultTabStopNotInStyles, "empty.odt") -{ -// The default tab stop was mistakenly exported to a style. -// xray ThisComponent.StyleFamilies(1)(0).ParaTabStop - uno::Reference< container::XNameAccess > paragraphStyles = getStyles( "ParagraphStyles" ); - uno::Reference< beans::XPropertySet > properties( paragraphStyles->getByName( "Standard" ), uno::UNO_QUERY ); - uno::Sequence< style::TabStop > stops = getProperty< uno::Sequence< style::TabStop > >( - paragraphStyles->getByName( "Standard" ), "ParaTabStops" ); -// There actually be be one tab stop, but it will be the default. - CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(1), stops.getLength()); - CPPUNIT_ASSERT_EQUAL( style::TabAlign_DEFAULT, stops[ 0 ].Alignment ); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo38244, "fdo38244.docx") -{ - /* - * Comments attached to a range was imported without the range, check for the annotation mark start/end positions. - * - * oParas = ThisComponent.Text.createEnumeration - * oPara = oParas.nextElement - * oRuns = oPara.createEnumeration - * oRun = oRuns.nextElement - * oRun = oRuns.nextElement 'Annotation - * oRun = oRuns.nextElement - * oRun = oRuns.nextElement 'AnnotationEnd - * xray oRun.TextPortionType - */ - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); - uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); - xRunEnum->nextElement(); - uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(xPropertySet, "TextPortionType")); - xRunEnum->nextElement(); - xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(xPropertySet, "TextPortionType")); - - /* - * Initials were not imported. - * - * oFields = ThisComponent.TextFields.createEnumeration - * oField = oFields.nextElement - * xray oField.Initials - */ - uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); - uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); - xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials")); - - /* - * There was a fake empty paragraph at the end of the comment text. - * - * oFields = ThisComponent.TextFields.createEnumeration - * oField = oFields.nextElement - * oParas = oField.TextRange.createEnumeration - * oPara = oParas.nextElement - * oPara = oParas.nextElement - */ - - xParaEnumAccess.set(getProperty< uno::Reference<container::XEnumerationAccess> >(xPropertySet, "TextRange"), uno::UNO_QUERY); - xParaEnum = xParaEnumAccess->createEnumeration(); - xParaEnum->nextElement(); - bool bCaught = false; - try - { - xParaEnum->nextElement(); - } - catch (container::NoSuchElementException&) - { - bCaught = true; - } - CPPUNIT_ASSERT_EQUAL(true, bCaught); -} - -DECLARE_OOXMLEXPORT_TEST(testCommentsNested, "comments-nested.odt") -{ - uno::Reference<beans::XPropertySet> xOuter(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Outer"), getProperty<OUString>(xOuter, "Content")); - - uno::Reference<beans::XPropertySet> xInner(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 4), "TextField"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content")); -} - -DECLARE_OOXMLEXPORT_TEST(testMathEscape, "math-escape.docx") -{ - CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"), getFormula(getRun(getParagraph(1), 1))); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo51034, "fdo51034.odt") -{ - // The problem was that the 'l' param of the HYPERLINK field was parsed with = "#", not += "#". - CPPUNIT_ASSERT_EQUAL(OUString("http://Www.google.com/#a"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL")); -} - -// Construct the expected formula from UTF8, as there may be such characters. -// Remove all spaces, as LO export/import may change that. -// Replace symbol - (i.e. U+2212) with ASCII - , LO does this change and it shouldn't matter. -#define CHECK_FORMULA( expected, actual ) \ - CPPUNIT_ASSERT_EQUAL( \ - OUString( expected, strlen( expected ), RTL_TEXTENCODING_UTF8 ) \ - .replaceAll( " ", "" ).replaceAll( OUString( "\xe2\x88\x92", strlen( "\xe2\x88\x92" ), RTL_TEXTENCODING_UTF8 ), "-" ), \ - OUString( actual ).replaceAll( " ", "" ).replaceAll( OUString( "\xe2\x88\x92", strlen( "\xe2\x88\x92" ), RTL_TEXTENCODING_UTF8 ), "-" )) - -DECLARE_OOXMLEXPORT_TEST(testMathAccents, "math-accents.docx") -{ - CHECK_FORMULA( - "acute {a} grave {a} check {a} breve {a} circle {a} widevec {a} widetilde {a}" - " widehat {a} dot {a} widevec {a} widevec {a} widetilde {a} underline {a}", - getFormula( getRun( getParagraph( 1 ), 1 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathD, "math-d.docx") -{ - CHECK_FORMULA( "left (x mline y mline z right )", getFormula( getRun( getParagraph( 1 ), 1 ))); - CHECK_FORMULA( "left (1 right )", getFormula( getRun( getParagraph( 1 ), 2 ))); - CHECK_FORMULA( "left [2 right ]", getFormula( getRun( getParagraph( 1 ), 3 ))); - CHECK_FORMULA( "left ldbracket 3 right rdbracket", getFormula( getRun( getParagraph( 1 ), 4 ))); - CHECK_FORMULA( "left lline 4 right rline", getFormula( getRun( getParagraph( 1 ), 5 ))); - CHECK_FORMULA( "left ldline 5 right rdline", getFormula( getRun( getParagraph( 1 ), 6 ))); - CHECK_FORMULA( "left langle 6 right rangle", getFormula( getRun( getParagraph( 1 ), 7 ))); - CHECK_FORMULA( "left langle a mline b right rangle", getFormula( getRun( getParagraph( 1 ), 8 ))); - CHECK_FORMULA( "left ({x} over {y} right )", getFormula( getRun( getParagraph( 1 ), 9 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathEscaping, "math-escaping.docx") -{ - CHECK_FORMULA( "\xe2\x88\x92 \xe2\x88\x9e < x < \xe2\x88\x9e", getFormula( getRun( getParagraph( 1 ), 1 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathLim, "math-lim.docx") -{ - CHECK_FORMULA( "lim from {x \xe2\x86\x92 1} {x}", getFormula( getRun( getParagraph( 1 ), 1 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathMalformedXml, "math-malformed_xml.docx") -{ - CPPUNIT_ASSERT_EQUAL( 0, getLength()); -} - -DECLARE_OOXMLEXPORT_TEST(testMathMatrix, "math-matrix.docx") -{ - CHECK_FORMULA( "left [matrix {1 # 2 ## 3 # 4} right ]", getFormula( getRun( getParagraph( 1 ), 1 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathMso2k7, "math-mso2k7.docx") -{ - CHECK_FORMULA( "A = \xcf\x80 {r} ^ {2}", getFormula( getRun( getParagraph( 1 ), 1 ))); -// TODO check the stack/binom difference -// CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (binom {n} {k} right ) {x} ^ {k} {a} ^ {n-k}}", - CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (stack {n # k} right ) {x} ^ {k} {a} ^ {n-k}}", - getFormula( getRun( getParagraph( 2 ), 1 ))); - CHECK_FORMULA( "{left (1+x right )} ^ {n} =1+ {nx} over {1!} + {n left (n-1 right ) {x} ^ {2}} over {2!} +\xe2\x80\xa6", - getFormula( getRun( getParagraph( 3 ), 1 ))); -// TODO check (cos/sin miss {}) -// CHECK_FORMULA( "f left (x right ) = {a} rsub {0} + sum from {n=1} to {\xe2\x88\x9e} {left ({a} rsub {n} cos {{n\xcf\x80x} over {L}} + {b} rsub {n} sin {{n\xcf\x80x} over {L}} right )}", - CHECK_FORMULA( "f left (x right ) = {a} rsub {0} + sum from {n=1} to {\xe2\x88\x9e} {left ({a} rsub {n} cos {n\xcf\x80x} over {L} + {b} rsub {n} sin {n\xcf\x80x} over {L} right )}", - getFormula( getRun( getParagraph( 4 ), 1 ))); - CHECK_FORMULA( "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}", getFormula( getRun( getParagraph( 5 ), 1 ))); - CHECK_FORMULA( "x = {- b \xc2\xb1 sqrt {{b} ^ {2} -4 ac}} over {2 a}", - getFormula( getRun( getParagraph( 6 ), 1 ))); - CHECK_FORMULA( - "{e} ^ {x} =1+ {x} over {1!} + {{x} ^ {2}} over {2!} + {{x} ^ {3}} over {3!} +\xe2\x80\xa6, -\xe2\x88\x9e<x<\xe2\x88\x9e", - getFormula( getRun( getParagraph( 7 ), 1 ))); - CHECK_FORMULA( -// "sin {\xce\xb1} \xc2\xb1 sin {\xce\xb2} =2 sin {{1} over {2} left (\xce\xb1\xc2\xb1\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1\xe2\x88\x93\xce\xb2 right )}", -// TODO check (cos/in miss {}) - "sin \xce\xb1 \xc2\xb1 sin \xce\xb2 =2 sin {1} over {2} left (\xce\xb1\xc2\xb1\xce\xb2 right ) cos {1} over {2} left (\xce\xb1\xe2\x88\x93\xce\xb2 right )", - getFormula( getRun( getParagraph( 8 ), 1 ))); - CHECK_FORMULA( -// "cos {\xce\xb1} + cos {\xce\xb2} =2 cos {{1} over {2} left (\xce\xb1+\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1-\xce\xb2 right )}", -// TODO check (cos/sin miss {}) - "cos \xce\xb1 + cos \xce\xb2 =2 cos {1} over {2} left (\xce\xb1+\xce\xb2 right ) cos {1} over {2} left (\xce\xb1-\xce\xb2 right )", - getFormula( getRun( getParagraph( 9 ), 1 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathNary, "math-nary.docx") -{ - CHECK_FORMULA( "lllint from {1} to {2} {x + 1}", getFormula( getRun( getParagraph( 1 ), 1 ))); - CHECK_FORMULA( "prod from {a} {b}", getFormula( getRun( getParagraph( 1 ), 2 ))); - CHECK_FORMULA( "sum to {2} {x}", getFormula( getRun( getParagraph( 1 ), 3 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathOverbraceUnderbrace, "math-overbrace_underbrace.docx") -{ - CHECK_FORMULA( "{abcd} overbrace {4}", getFormula( getRun( getParagraph( 1 ), 1 ))); - CHECK_FORMULA( "{xyz} underbrace {3}", getFormula( getRun( getParagraph( 2 ), 1 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathOverstrike, "math-overstrike.docx") -{ - CHECK_FORMULA( "overstrike {abc}", getFormula( getRun( getParagraph( 1 ), 1 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathPlaceholders, "math-placeholders.docx") -{ - CHECK_FORMULA( "sum from <?> to <?> <?>", getFormula( getRun( getParagraph( 1 ), 1 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathRad, "math-rad.docx") -{ - CHECK_FORMULA( "sqrt {4}", getFormula( getRun( getParagraph( 1 ), 1 ))); - CHECK_FORMULA( "nroot {3} {x + 1}", getFormula( getRun( getParagraph( 1 ), 2 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathSubscripts, "math-subscripts.docx") -{ - CHECK_FORMULA( "{x} ^ {y} + {e} ^ {x}", getFormula( getRun( getParagraph( 1 ), 1 ))); - CHECK_FORMULA( "{x} ^ {b}", getFormula( getRun( getParagraph( 1 ), 2 ))); - CHECK_FORMULA( "{x} rsub {b}", getFormula( getRun( getParagraph( 1 ), 3 ))); - CHECK_FORMULA( "{a} rsub {c} rsup {b}", getFormula( getRun( getParagraph( 1 ), 4 ))); - CHECK_FORMULA( "{x} lsub {2} lsup {1}", getFormula( getRun( getParagraph( 1 ), 5 ))); - CHECK_FORMULA( "{{x csup {6} csub {3}} lsub {4} lsup {5}} rsub {2} rsup {1}", - getFormula( getRun( getParagraph( 1 ), 6 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testMathVerticalStacks, "math-vertical_stacks.docx") -{ - CHECK_FORMULA( "{a} over {b}", getFormula( getRun( getParagraph( 1 ), 1 ))); - CHECK_FORMULA( "{a} / {b}", getFormula( getRun( getParagraph( 2 ), 1 ))); -// TODO check these -// CHECK_FORMULA( "binom {a} {b}", getFormula( getRun( getParagraph( 3 ), 1 ))); -// CHECK_FORMULA( "binom {a} {binom {b} {c}}", getFormula( getRun( getParagraph( 4 ), 1 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testTable, "table.odt") -{ - // Validation test: order of elements were wrong. - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - // Order was: insideH, end, insideV. - int nEnd = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "end"); - int nInsideH = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "insideH"); - int nInsideV = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "insideV"); - CPPUNIT_ASSERT(nEnd < nInsideH); - CPPUNIT_ASSERT(nInsideH < nInsideV); - - // Make sure we write qFormat for well-known style names. - assertXPath(parseExport("word/styles.xml"), "//w:style[@w:styleId='Normal']/w:qFormat", 1); -} - -DECLARE_OOXMLEXPORT_TEST(testTablePosition, "table-position.docx") -{ - sal_Int32 xCoordsFromOffice[] = { 2500, -1000, 0, 0 }; - sal_Int32 cellLeftMarginFromOffice[] = { 250, 100, 0, 0 }; - - uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); - - for (int i=0; i<4; i++) { - uno::Reference<text::XTextTable> xTable1 (xTables->getByIndex(i), uno::UNO_QUERY); - // Verify X coord - uno::Reference<view::XSelectionSupplier> xCtrl(xModel->getCurrentController(), uno::UNO_QUERY); - xCtrl->select(uno::makeAny(xTable1)); - uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xCtrl, uno::UNO_QUERY); - uno::Reference<text::XTextViewCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); - awt::Point pos = xCursor->getPosition(); - CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Incorrect X coord computed from docx", - xCoordsFromOffice[i], pos.X, 1); - - // Verify left margin of 1st cell : - // * Office left margins are measured relative to the right of the border - // * LO left spacing is measured from the center of the border - uno::Reference<table::XCell> xCell = xTable1->getCellByName("A1"); - uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW); - sal_Int32 aLeftMargin = -1; - xPropSet->getPropertyValue("LeftBorderDistance") >>= aLeftMargin; - uno::Any aLeftBorder = xPropSet->getPropertyValue("LeftBorder"); - table::BorderLine2 aLeftBorderLine; - aLeftBorder >>= aLeftBorderLine; - CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Incorrect left spacing computed from docx cell margin", - cellLeftMarginFromOffice[i], aLeftMargin - 0.5 * aLeftBorderLine.LineWidth, 1); - } -} - -struct SingleLineBorders { - sal_Int16 top, bottom, left, right; - SingleLineBorders(int t=0, int b=0, int l=0, int r=0) - : top(t), bottom(b), left(l), right(r) {} - sal_Int16 getBorder(int i) const - { - switch (i) { - case 0: return top; - case 1: return bottom; - case 2: return left; - case 3: return right; - default: assert(false); return 0; - } - } -}; -DECLARE_OOXMLEXPORT_TEST(testTableBorders, "table-borders.docx") -{ - uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); - uno::Reference<text::XTextTable> xTextTable (xTables->getByIndex(0), uno::UNO_QUERY); - - std::map<OUString, SingleLineBorders> cellBorders; - cellBorders[OUString("A1")] = SingleLineBorders(106, 106, 106, 106); - cellBorders[OUString("B1")] = SingleLineBorders(106, 0, 106, 35); - cellBorders[OUString("C1")] = SingleLineBorders(106, 106, 35, 106); - cellBorders[OUString("A2")] = SingleLineBorders(106, 35, 106, 0); - cellBorders[OUString("B2")] = SingleLineBorders(0, 0, 0, 0); - cellBorders[OUString("C2")] = SingleLineBorders(106, 106, 0, 106); - cellBorders[OUString("A3")] = SingleLineBorders(35, 35, 106, 106); - cellBorders[OUString("B3")] = SingleLineBorders(0, 106, 106, 106); - cellBorders[OUString("C3")] = SingleLineBorders(106, 106, 106, 106); - cellBorders[OUString("A4")] = SingleLineBorders(35, 106, 106, 35); - cellBorders[OUString("B4")] = SingleLineBorders(106, 106, 35, 106); - cellBorders[OUString("C4")] = SingleLineBorders(106, 106, 106, 106); - - const OUString borderNames[] = { - OUString("TopBorder"), - OUString("BottomBorder"), - OUString("LeftBorder"), - OUString("RightBorder"), - }; - - uno::Sequence<OUString> const cells = xTextTable->getCellNames(); - sal_Int32 nLength = cells.getLength(); - CPPUNIT_ASSERT_EQUAL((sal_Int32)cellBorders.size(), nLength); - - for (sal_Int32 i = 0; i < nLength; ++i) - { - uno::Reference<table::XCell> xCell = xTextTable->getCellByName(cells[i]); - uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW); - const SingleLineBorders& borders = cellBorders[cells[i]]; - - for (sal_Int32 j = 0; j < 4; ++j) - { - uno::Any aBorder = xPropSet->getPropertyValue(borderNames[j]); - table::BorderLine aBorderLine; - if (aBorder >>= aBorderLine) - { - std::stringstream message; - message << cells[i] << "'s " << borderNames[j] << " is incorrect"; - CPPUNIT_ASSERT_EQUAL_MESSAGE(message.str(), - borders.getBorder(j), aBorderLine.OuterLineWidth); - } - } - } -} - -DECLARE_OOXMLEXPORT_TEST(testFdo51550, "fdo51550.odt") -{ - // The problem was that we lacked the fallback to export the replacement graphic for OLE objects. - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); -} - -/* - * doesn't work on openSUSE12.2 at least -DECLARE_OOXMLEXPORT_TEST(test1Table1Page, "1-table-1-page.docx") -{ - // 2 problem for this document after export: - // - invalid sectPr inserted at the beginning of the page - // - font of empty cell is not preserved, leading to change in rows height - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); - uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); - xCursor->jumpToLastPage(); - CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage()); -} -*/ - -DECLARE_OOXMLEXPORT_TEST(testTextFrames, "textframes.odt") -{ - // The frames were simply missing, so let's check if all 3 frames were imported back. - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount()); -} - -DECLARE_OOXMLEXPORT_TEST(testTextFrameBorders, "textframe-borders.docx") -{ - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); - if (xIndexAccess->getCount()) - { - // After import, a TextFrame is created by the VML import. - uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xFrame, "BackColor")); - - table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aBorder.Color); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth); - - table::ShadowFormat aShadowFormat = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat"); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location); - CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aShadowFormat.Color); - } - else - { - // After export and import, the result is a shape. - uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xShape, "FillColor")); - - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), getProperty<sal_Int32>(xShape, "LineColor")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(35), getProperty<sal_Int32>(xShape, "LineWidth")); - - CPPUNIT_ASSERT_EQUAL(sal_Int32(48), getProperty<sal_Int32>(xShape, "ShadowXDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(48), getProperty<sal_Int32>(xShape, "ShadowYDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), getProperty<sal_Int32>(xShape, "ShadowColor")); - } -} - -DECLARE_OOXMLEXPORT_TEST(testTextframeGradient, "textframe-gradient.docx") -{ - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); - - uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle")); - awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor); - CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style); - - xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle")); - aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor); - CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style); - - // Left / right margin was incorrect: the attribute was missing and we - // didn't have the right default (had 0 instead of the below one). - CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xFrame, "LeftMargin")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xFrame, "RightMargin")); -} - -DECLARE_OOXMLEXPORT_TEST(testCellBtlr, "cell-btlr.docx") -{ - /* - * The problem was that the exporter didn't mirror the workaround of the - * importer, regarding the btLr text direction: the <w:textDirection - * w:val="btLr"/> token was completely missing in the output. - */ - - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:textDirection", "val", "btLr"); -} - -DECLARE_OOXMLEXPORT_TEST(testTableStylerPrSz, "table-style-rPr-sz.docx") -{ - // Verify that font size inside the table is 20pt, despite the sz attribute in the table size. - // Also check that other rPr attribute are used: italic, bold, underline - // Office has the same behavior - uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); - uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); - uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); - uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); - - CPPUNIT_ASSERT_EQUAL(20.f, getProperty<float>(getRun(xPara, 1), "CharHeight")); -// CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<short>(getRun(xPara, 1), "CharUnderline")); -// CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xPara, 1), "CharWeight")); -// CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, getProperty<awt::FontSlant>(getRun(xPara, 1), "CharPosture")); -} - -DECLARE_OOXMLEXPORT_TEST(testMathLiteral, "math-literal.docx") -{ - CHECK_FORMULA( "iiint from {V} to <?> {\"div\" \"F\"} dV= llint from {S} to <?> {\"F\" \xe2\x88\x99 \"n \" dS}", - getFormula( getRun( getParagraph( 1 ), 1 ))); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo48557, "fdo48557.odt") -{ - // Inner margins of the textframe wasn't exported. - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextLeftDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextRightDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextUpperDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextLowerDistance")); -} - -DECLARE_OOXMLEXPORT_TEST(testI120928, "i120928.docx") -{ - // w:numPicBullet was ignored, leading to missing graphic bullet in numbering. - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aProps; - xLevels->getByIndex(0) >>= aProps; // 1st level - - bool bIsGraphic = false; - for (int i = 0; i < aProps.getLength(); ++i) - { - const beans::PropertyValue& rProp = aProps[i]; - - if (rProp.Name == "NumberingType") - CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>()); - else if (rProp.Name == "GraphicURL") - bIsGraphic = true; - } - CPPUNIT_ASSERT_EQUAL(true, bIsGraphic); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo64826, "fdo64826.docx") -{ - // 'Track-Changes' (Track Revisions) wasn't exported. - CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(mxComponent, "RecordChanges"))); -} - -DECLARE_OOXMLEXPORT_TEST(testPageBackground, "page-background.docx") -{ - // 'Document Background' wasn't exported. - uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor")); -} - -DECLARE_OOXMLEXPORT_TEST(testPageGraphicBackground, "page-graphic-background.odt") -{ - // No idea how the graphic background should be exported (seems there is no - // way to do a non-tiling export to OOXML), but at least the background - // color shouldn't be black. - uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xPageStyle, "BackColor")); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo65265, "fdo65265.docx") -{ - // Redline (tracked changes) of text formatting were not exported - uno::Reference<text::XTextRange> xParagraph1 = getParagraph(1); - uno::Reference<text::XTextRange> xParagraph2 = getParagraph(2); - - CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty<OUString>(getRun(xParagraph1, 3), "RedlineType")); - CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty<OUString>(getRun(xParagraph2, 2), "RedlineType")); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo65655, "fdo65655.docx") -{ - // The problem was that the DOCX had a non-blank odd footer and a blank even footer - // The 'Different Odd & Even Pages' was turned on - // However - LO assumed that because the 'even' footer is blank - it should ignore the 'Different Odd & Even Pages' flag - // So it did not import it and did not export it - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); - bool bValue = false; - xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue; - CPPUNIT_ASSERT_EQUAL(false, bool(bValue)); - xPropertySet->getPropertyValue("FooterIsShared") >>= bValue; - CPPUNIT_ASSERT_EQUAL(false, bool(bValue)); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO63053, "fdo63053.docx") -{ - uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties(); - CPPUNIT_ASSERT_EQUAL(OUString("test1&test2"), xDocumentProperties->getTitle()); - CPPUNIT_ASSERT_EQUAL(OUString("test1&test2"), xDocumentProperties->getSubject()); -} - -DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx") -{ - uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY); - // 1st problem: last character was missing - CPPUNIT_ASSERT_EQUAL(OUString("SAMPLE"), xShape->getString()); - - uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xShape, "CustomShapeGeometry"); - bool bFound = false; - for (int i = 0; i < aProps.getLength(); ++i) - if (aProps[i].Name == "TextPath") - bFound = true; - // 2nd problem: v:textpath wasn't imported - CPPUNIT_ASSERT_EQUAL(true, bFound); - - // 3rd problem: rotation angle was 315, not 45. - CPPUNIT_ASSERT_EQUAL(sal_Int32(45 * 100), getProperty<sal_Int32>(xShape, "RotateAngle")); - - // 4th problem: mso-position-vertical-relative:margin was ignored, VertOrientRelation was text::RelOrientation::FRAME. - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xShape, "VertOrientRelation")); - - // These problems were in the exporter - // The textpath wasn't semi-transparent. - CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty<sal_Int16>(xShape, "FillTransparence")); - // The textpath had a stroke. - CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, getProperty<drawing::LineStyle>(xShape, "LineStyle")); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo43093, "fdo43093.docx") -{ - // The problem was that the alignment are not exchange when the paragraph are RTL. - uno::Reference<uno::XInterface> xParaRtlLeft(getParagraph( 1, "RTL Left")); - sal_Int32 nRtlLeft = getProperty< sal_Int32 >( xParaRtlLeft, "ParaAdjust" ); - // test the text Direction value for the pragraph - sal_Int16 nRLDir = getProperty< sal_Int32 >( xParaRtlLeft, "WritingMode" ); - - uno::Reference<uno::XInterface> xParaRtlRight(getParagraph( 3, "RTL Right")); - sal_Int32 nRtlRight = getProperty< sal_Int32 >( xParaRtlRight, "ParaAdjust" ); - sal_Int16 nRRDir = getProperty< sal_Int32 >( xParaRtlRight, "WritingMode" ); - - uno::Reference<uno::XInterface> xParaLtrLeft(getParagraph( 5, "LTR Left")); - sal_Int32 nLtrLeft = getProperty< sal_Int32 >( xParaLtrLeft, "ParaAdjust" ); - sal_Int16 nLLDir = getProperty< sal_Int32 >( xParaLtrLeft, "WritingMode" ); - - uno::Reference<uno::XInterface> xParaLtrRight(getParagraph( 7, "LTR Right")); - sal_Int32 nLtrRight = getProperty< sal_Int32 >( xParaLtrRight, "ParaAdjust" ); - sal_Int16 nLRDir = getProperty< sal_Int32 >( xParaLtrRight, "WritingMode" ); - - // this will test the both the text direction and alignment for each paragraph - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nRtlLeft); - CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRLDir); - - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nRtlRight); - CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRRDir); - - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLtrLeft); - CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir); - - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nLtrRight); - CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo64238_a, "fdo64238_a.docx") -{ - // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled* - // then LO would still import the Even footer and concatenate it to to the odd footer. - // This case specifically is for : - // 'Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word - // In this case the imported footer in LO was supposed to be blank, but instead was the 'even' footer - uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText"); - uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText ); - uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); - sal_Int32 numOfRuns = 0; - while (xRunEnum->hasMoreElements()) - { - uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY); - numOfRuns++; - } - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), numOfRuns); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo64238_b, "fdo64238_b.docx") -{ - // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled* - // then LO would still import the Even footer and concatenate it to to the odd footer. - // This case specifically is for : - // 'Non-Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word - // In this case the imported footer in LO was supposed to be just the odd footer, but instead was the 'odd' and 'even' footers concatenated - uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText"); - uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText ); - uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); - sal_Int32 numOfRuns = 0; - while (xRunEnum->hasMoreElements()) - { - uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY); - numOfRuns++; - } - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), numOfRuns); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo56679, "fdo56679.docx") -{ - // The problem was that the DOCX importer and exporter did not handle the 'color' of an underline - // (not the color of the text, the color of the underline itself) - uno::Reference< text::XTextRange > xParagraph = getParagraph( 1 ); - uno::Reference< text::XTextRange > xText = getRun( xParagraph, 2, "This is a simple sentence."); - - CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xText, "CharUnderlineHasColor"))); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), getProperty<sal_Int32>(xText, "CharUnderlineColor")); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo65400, "fdo65400.docx") -{ - // The problem was that if in Word you choose 'Character Shading' - then the text portion - // is marked with 'w:shd val=pct15'. LO did not store this value and so when importing and exporting - // this value was lost (and so Word did not show 'Character Shading' was on) - uno::Reference< text::XTextRange > paragraph1 = getParagraph( 1 ); - uno::Reference< text::XTextRange > shaded = getRun( paragraph1, 2, "normal" ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 0x0026 ), getProperty< sal_Int32 >( shaded, "CharShadingValue" )); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 0xd8d8d8 ), getProperty< sal_Int32 >( shaded, "CharBackColor" )); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo66543, "fdo66543.docx") -{ - // The problem was that when importing DOCX with 'line numbers' - the 'start value' was imported - // but nothing was done with it. - - uno::Reference< text::XTextRange > paragraph1 = getParagraph( 1 ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 1 ), getProperty< sal_Int32 >( paragraph1, "ParaLineNumberStartValue" )); -} - -DECLARE_OOXMLEXPORT_TEST(testN822175, "n822175.odt") -{ - uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY); - // Was text::WrapTextMode_THROUGH, due to missing Surround handling in the exporter. - CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_PARALLEL, getProperty<text::WrapTextMode>(xFrame, "Surround")); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo66688, "fdo66688.docx") -{ - // The problem was that TextFrame imported and exported the wrong value for transparency - // (was stored as 'FillTransparence' instead of 'BackColorTransparency' - uno::Reference<beans::XPropertySet> xFrame(getShape(2), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 80 ), getProperty< sal_Int32 >( xFrame, "FillTransparence" ) ); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo66773, "fdo66773.docx") -{ - // The problem was the line spacing was interpreted by Word as 'Multiple 1.08' if no default settings were written. - // Now after the 'docDefaults' section is written in <styles.xml> - there is no more problem. - // (Word does not try to calculate some arbitrary value for line spacing). - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); - CPPUNIT_ASSERT(xParaEnum->hasMoreElements()); - - style::LineSpacing alineSpacing = getProperty<style::LineSpacing>(xParaEnum->nextElement(), "ParaLineSpacing"); - CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP, alineSpacing.Mode); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(100), static_cast<sal_Int32>(alineSpacing.Height)); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo58577, "fdo58577.odt") -{ - // The second frame was simply missing, so let's check if both frames were imported back. - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); -} - -DECLARE_OOXMLEXPORT_TEST(testBnc581614, "bnc581614.doc") -{ - uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xFrame, "FillStyle")); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo66929, "fdo66929.docx") -{ - // The problem was that the default 'inset' attribute of the 'textbox' node was exported incorrectly. - // A node like '<v:textbox inset="0">' was exported back as '<v:textbox inset="0pt,0pt,0pt,0pt">' - // This is wrong because the original node denotes a specific 'left' inset, and a default 'top','right','bottom' inset - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); - if (xIndexAccess->getCount()) - { - // VML import -> TextFrame - uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ) , getProperty< sal_Int32 >( xFrame, "LeftBorderDistance" ) ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty< sal_Int32 >( xFrame, "TopBorderDistance" ) ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 254 ), getProperty< sal_Int32 >( xFrame, "RightBorderDistance" ) ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty< sal_Int32 >( xFrame, "BottomBorderDistance" ) ); - } - else - { - // drawingML import -> shape with TextBox - uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xShape, "TextLeftDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(127), getProperty<sal_Int32>(xShape, "TextUpperDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(254), getProperty<sal_Int32>(xShape, "TextRightDistance")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(127), getProperty<sal_Int32>(xShape, "TextLowerDistance")); - } -} - -DECLARE_OOXMLEXPORT_TEST(testPageBorderSpacingExportCase2, "page-borders-export-case-2.docx") -{ - // The problem was that the exporter didn't mirror the workaround of the - // importer, regarding the page border's spacing : the <w:pgBorders w:offsetFrom="page"> - // and the inner nodes like <w:top w:space="24" .... /> - // - // The exporter ALWAYS exported 'w:offsetFrom="text"' even when the spacing values where too large - // for Word to handle (larger than 31 points) - - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - - // Assert the XPath expression - page borders - assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgBorders", "offsetFrom", "page"); - - // Assert the XPath expression - 'left' border - assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgBorders/w:left", "space", "24"); - - // Assert the XPath expression - 'right' border - assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgBorders/w:right", "space", "24"); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo66145, "fdo66145.docx") -{ - // The Writer ignored the 'First Is Shared' flag - CPPUNIT_ASSERT_EQUAL(OUString("This is the FIRST page header."), - parseDump("/root/page[1]/header/txt/text()")); - CPPUNIT_ASSERT_EQUAL( - OUString("This is the header for the REST OF THE FILE."), - parseDump("/root/page[2]/header/txt/text()")); - CPPUNIT_ASSERT_EQUAL( - OUString("This is the header for the REST OF THE FILE."), - parseDump("/root/page[3]/header/txt/text()")); -} - -DECLARE_OOXMLEXPORT_TEST(testGrabBag, "grabbag.docx") -{ - // w:mirrorIndents was lost on roundtrip, now should be handled as a grab bag property - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:mirrorIndents"); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo66781, "fdo66781.docx") -{ - // The problem was that bullets with level=0 were shown in LO as normal bullets, - // and when saved back to DOCX were saved with level=1 (so hidden bullets became visible) - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aProps; - xLevels->getByIndex(0) >>= aProps; // 1st level - - for (int i = 0; i < aProps.getLength(); ++i) - { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "BulletChar") - { - CPPUNIT_ASSERT_EQUAL(OUString("\x0", 1, RTL_TEXTENCODING_UTF8), rProp.Value.get<OUString>()); - return; - } - } - - // Shouldn't reach here - CPPUNIT_FAIL("Did not find bullet with level 0"); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo60990, "fdo60990.odt") -{ - // The shape had no background, no paragraph adjust and no font color. - uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00CFE7F5), getProperty<sal_Int32>(xShape, "FillColor")); - uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText(); - uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText); - CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust"))); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF00), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor")); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo65718, "fdo65718.docx") -{ - // The problem was that the exporter always exported values of "0" for an images distance from text. - // the actual attributes where 'distT', 'distB', 'distL', 'distR' - uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY); - - CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(0) ), getProperty<sal_Int32>(xPropertySet, "TopMargin") ); - CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(0) ), getProperty<sal_Int32>(xPropertySet, "BottomMargin") ); - - // Going to do '+1' because the 'getProperty' return 318 (instead of 317.5) - // I think this is because it returns an integer, instead of a float. - // The actual exporting to DOCX exports the correct value (114300 = 317.5 * 360) - // The exporting to DOCX uses the 'SvxLRSpacing' that stores the value in TWIPS (180 TWIPS) - // However, the 'LeftMargin' property is an integer property that holds that value in 'MM100' (should hold 317.5, but it is 318) - // So I had to add the hack of the '+1' to make the test-case pass - CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(114300) + 1 ), getProperty<sal_Int32>(xPropertySet, "LeftMargin") ); - CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(114300) + 1), getProperty<sal_Int32>(xPropertySet, "RightMargin") ); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo64350, "fdo64350.docx") -{ - // The problem was that page border shadows were not exported - table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "ShadowFormat"); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo67013, "fdo67013.docx") -{ - /* - * The problem was that borders inside headers \ footers were not exported - * This was checked in xray using these commands: - * - * xHeaderText = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Standard").HeaderText - * xHeaderEnum = xHeaderText.createEnumeration() - * xHeaderFirstParagraph = xHeaderEnum.nextElement() - * xHeaderBottomBorder = xHeaderFirstParagraph.BottomBorder - * - * xFooterText = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Standard").FooterText - * xFooterEnum = xFooterText.createEnumeration() - * xFooterFirstParagraph = xFooterEnum.nextElement() - * xFooterTopBorder = xFooterFirstParagraph.TopBorder - */ - uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText"); - uno::Reference< text::XTextRange > xHeaderParagraph = getParagraphOfText( 1, xHeaderText ); - table::BorderLine2 aHeaderBottomBorder = getProperty<table::BorderLine2>(xHeaderParagraph, "BottomBorder"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aHeaderBottomBorder.Color); - CPPUNIT_ASSERT_EQUAL(sal_Int16(106), aHeaderBottomBorder.InnerLineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aHeaderBottomBorder.LineDistance); - CPPUNIT_ASSERT_EQUAL(sal_Int16(7), aHeaderBottomBorder.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aHeaderBottomBorder.LineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aHeaderBottomBorder.OuterLineWidth); - - uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText"); - uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText ); - table::BorderLine2 aFooterTopBorder = getProperty<table::BorderLine2>(xFooterParagraph, "TopBorder"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aFooterTopBorder.Color); - CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aFooterTopBorder.InnerLineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aFooterTopBorder.LineDistance); - CPPUNIT_ASSERT_EQUAL(sal_Int16(4), aFooterTopBorder.LineStyle); - CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aFooterTopBorder.LineWidth); - CPPUNIT_ASSERT_EQUAL(sal_Int16(106), aFooterTopBorder.OuterLineWidth); -} - -DECLARE_OOXMLEXPORT_TEST(testParaShadow, "para-shadow.docx") -{ - // The problem was that in w:pBdr, child elements had a w:shadow attribute, but that was ignored. - table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getParagraph(2), "ParaShadowFormat"); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color)); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); - // w:sz="48" is in eights of a point, 1 pt is 20 twips. - CPPUNIT_ASSERT_EQUAL(sal_Int16(convertTwipToMm100(24/8*20)), aShadow.ShadowWidth); -} - -DECLARE_OOXMLEXPORT_TEST(testTableFloating, "table-floating.docx") -{ - // Both the size and the position of the table was incorrect. - uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); - // Second table was too wide: 16249, i.e. as wide as the first table. - CPPUNIT_ASSERT_EQUAL(sal_Int32(11248), getProperty<sal_Int32>(xTables->getByIndex(1), "Width")); - - uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); - if (xIndexAccess->getCount()) - { - // After import, table is inside a TextFrame. - uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - // This was 0, should be the the opposite of (left margin + half of the border width). - CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty<sal_Int32>(xFrame, "HoriOrientPosition")); - // Was 0 as well, should be the right margin. - CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xFrame, "RightMargin")); - } - else - { - // After import, table is inside a TextFrame. - uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); - // This was 0, should be the the opposite of (left margin + half of the border width). - CPPUNIT_ASSERT_EQUAL(sal_Int32(-198), getProperty<sal_Int32>(xShape, "HoriOrientPosition")); - // Was 0 as well, should be the right margin. - CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xShape, "RightMargin")); - } -} - -DECLARE_OOXMLEXPORT_TEST(testFdo44689_start_page_0, "fdo44689_start_page_0.docx") -{ - // The problem was that the import & export process did not analyze the 'start from page' attribute of a section - uno::Reference<beans::XPropertySet> xPara(getParagraph(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xPara, "PageNumberOffset")); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo44689_start_page_7, "fdo44689_start_page_7.docx") -{ - // The problem was that the import & export process did not analyze the 'start from page' attribute of a section - uno::Reference<beans::XPropertySet> xPara(getParagraph(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int16(7), getProperty<sal_Int16>(xPara, "PageNumberOffset")); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo67737, "fdo67737.docx") -{ - // The problem was that imported shapes did not import and render the 'flip:x' and 'flip:y' attributes - uno::Reference<drawing::XShape> xArrow = getShape(1); - uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xArrow, "CustomShapeGeometry"); - for (int i = 0; i < aProps.getLength(); ++i) - { - const beans::PropertyValue& rProp = aProps[i]; - if (rProp.Name == "MirroredY") - { - CPPUNIT_ASSERT_EQUAL( true, bool(rProp.Value.get<sal_Bool>()) ); - return; - } - } - - // Shouldn't reach here - CPPUNIT_FAIL("Did not find MirroredY=true property"); -} - -DECLARE_OOXMLEXPORT_TEST(testTransparentShadow, "transparent-shadow.docx") -{ - uno::Reference<drawing::XShape> xPicture = getShape(1); - sal_Int32 nShadowColor = getProperty<sal_Int32>(xPicture, "ShadowColor"); - sal_Int16 nShadowTransparence = getProperty<sal_Int16>(xPicture, "ShadowTransparence"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x808080), nShadowColor); - CPPUNIT_ASSERT_EQUAL(sal_Int16(50), nShadowTransparence); -} - -DECLARE_OOXMLEXPORT_TEST(testBnc837302, "bnc837302.docx") -{ - // The problem was that text with empty author was not inserted as a redline - uno::Reference<text::XTextRange> xParagraph = getParagraph(1); - - // previously 'AAA' was not an own run - getRun(xParagraph, 3, "AAA"); - // interestingly the 'Insert' is set on the _previous_ run - CPPUNIT_ASSERT_EQUAL(OUString("Insert"), getProperty<OUString>(getRun(xParagraph, 2), "RedlineType")); - - // make sure we don't introduce a redlined delete in the 2nd paragraph - xParagraph = getParagraph(2); - CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(xParagraph, 1), "RedlineType")); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo68418, "fdo68418.docx") -{ - // The problem was that in 'MSWordExportBase::SectionProperties' function in 'wrt8sty.cxx' - // it checked if it 'IsPlausableSingleWordSection'. - // The 'IsPlausableSingleWordSection' compared different aspects of 2 'SwFrmFmt' objects. - // One of the checks was 'do both formats have the same distance from the top and bottom ?' - // This check is correct if both have headers or both don't have headers. - // However - if one has a header, and the other one has an empty header (no header) - it is not correct to compare - // between them (same goes for 'footer'). - uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText"); - uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText ); - - // First page footer is empty, second page footer is 'aaaa' - CPPUNIT_ASSERT_EQUAL(OUString("aaaa"), xFooterParagraph->getString()); // I get an error that it expects '' -} - -DECLARE_OOXMLEXPORT_TEST(testA4AndBorders, "a4andborders.docx") -{ - /* - * The problem was that in case of a document with borders, the pgSz attribute - * was exported as a child of pgBorders, thus being ignored on reload. - * We assert dimension against A4 size in mm (to avoid minor rounding errors) - */ - uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect Page Width (mm)", sal_Int32(210), getProperty<sal_Int32>(xPageStyle, "Width") / 100); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect Page Height (mm)", sal_Int32(297), getProperty<sal_Int32>(xPageStyle, "Height") / 100); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo68787, "fdo68787.docx") -{ - uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); - // This was 25, the 'lack of w:separator' <-> '0 line width' mapping was missing. - CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth")); -} - -DECLARE_OOXMLEXPORT_TEST(testCharacterBorder, "charborder.odt") -{ - uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); - // OOXML has just one border attribute (<w:bdr>) for text border so all side has - // the same border with the same padding - // Border - { - const table::BorderLine2 aTopBorder = getProperty<table::BorderLine2>(xRun,"CharTopBorder"); - CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF6600,0,318,0,0,318), aTopBorder); - CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharLeftBorder")); - CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharBottomBorder")); - CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharRightBorder")); - } - - // Padding (w:space) - { - const sal_Int32 nTopPadding = getProperty<sal_Int32>(xRun,"CharTopBorderDistance"); - // In the original ODT the padding is 150, but the unit conversion round it down. - CPPUNIT_ASSERT_EQUAL(sal_Int32(141), nTopPadding); - CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharLeftBorderDistance")); - CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharBottomBorderDistance")); - CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharRightBorderDistance")); - } - - // Shadow (w:shadow) - /* OOXML use just one bool value for shadow so the next conversions - are made during an export-import round - color: any -> black - location: any -> bottom-right - width: any -> border width */ - { - const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat"); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color)); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); - CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth); - } - - // Also check shadow when it is in middle of the paragraph - // (problem can be during export with SwWW8AttrIter::HasTextItem()) - { - uno::Reference<beans::XPropertySet> xMiddleRun(getRun(getParagraph(2),2), uno::UNO_QUERY); - const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xMiddleRun, "CharShadowFormat"); - CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color)); - CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); - CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth); - } - - if (xmlDocPtr pXmlStyles = parseExport("word/styles.xml")) - { - // Make sure we write qFormat for custom style names. - assertXPath(pXmlStyles, "//w:style[@w:styleId='Heading']/w:qFormat", 1); - } -} - -DECLARE_OOXMLEXPORT_TEST(testStyleInheritance, "style-inheritance.docx") -{ - // Check that now styleId's are more like what MSO produces - xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); - if (!pXmlStyles) - return; - // the 1st style always must be Normal - assertXPath(pXmlStyles, "/w:styles/w:style[1]", "styleId", "Normal"); - // some random style later - assertXPath(pXmlStyles, "/w:styles/w:style[4]", "styleId", "Heading3"); - - // Check that we do _not_ export w:next for styles that point to themselves. - assertXPath(pXmlStyles, "/w:styles/w:style[1]/w:next", 0); - - // Check that we roundtrip <w:next> correctly - on XML level - assertXPath(pXmlStyles, "/w:styles/w:style[2]/w:next", "val", "Normal"); - // And to be REALLY sure, check it on the API level too ;-) - uno::Reference< container::XNameAccess > paragraphStyles = getStyles("ParagraphStyles"); - uno::Reference< beans::XPropertySet > properties(paragraphStyles->getByName("Heading 1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty<OUString>(properties, "FollowStyle")); - - // This was 0, as export of w:outlineLvl was missing. - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(properties, "OutlineLevel")); - - properties = uno::Reference< beans::XPropertySet >(paragraphStyles->getByName("Heading 11"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty<OUString>(properties, "FollowStyle")); - - // Make sure style #2 is Heading 1. - assertXPath(pXmlStyles, "/w:styles/w:style[2]", "styleId", "Heading1"); - // w:ind was copied from the parent (Normal) style without a good reason. - assertXPath(pXmlStyles, "/w:styles/w:style[2]/w:pPr/w:ind", 0); - - // We output exactly 2 properties in rPrDefault, nothing else was - // introduced as an additional default - assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/*", 2); - // Check that we output real content of rPrDefault - assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "ascii", "Times New Roman"); - assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:lang", "bidi", "ar-SA"); - // pPrDefault is empty - assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:pPrDefault/w:pPr/*", 0); - - // Check latent styles - uno::Sequence<beans::PropertyValue> aGrabBag = getProperty< uno::Sequence<beans::PropertyValue> >(mxComponent, "InteropGrabBag"); - uno::Sequence<beans::PropertyValue> aLatentStyles; - for (sal_Int32 i = 0; i < aGrabBag.getLength(); ++i) - if (aGrabBag[i].Name == "latentStyles") - aGrabBag[i].Value >>= aLatentStyles; - CPPUNIT_ASSERT(aLatentStyles.getLength()); // document should have latent styles - - // Check latent style default attributes - OUString aCount; - uno::Sequence<beans::PropertyValue> aLatentStyleExceptions; - for (sal_Int32 i = 0; i < aLatentStyles.getLength(); ++i) - { - if (aLatentStyles[i].Name == "count") - aCount = aLatentStyles[i].Value.get<OUString>(); - else if (aLatentStyles[i].Name == "lsdExceptions") - aLatentStyles[i].Value >>= aLatentStyleExceptions; - } - CPPUNIT_ASSERT_EQUAL(OUString("371"), aCount); // This check the "count" attribute. - - // Check exceptions to the latent style defaults. - uno::Sequence<beans::PropertyValue> aLatentStyleException; - aLatentStyleExceptions[0].Value >>= aLatentStyleException; - OUString aName; - for (sal_Int32 i = 0; i < aLatentStyleException.getLength(); ++i) - if (aLatentStyleException[i].Name == "name") - aName = aLatentStyleException[i].Value.get<OUString>(); - CPPUNIT_ASSERT_EQUAL(OUString("Normal"), aName); // This checks the "name" attribute of the first exception. - - // This numbering style wasn't roundtripped. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='NoList']/w:name", "val", "No List"); - - // Table style wasn't roundtripped. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:tblPr/w:tblCellMar/w:left", "w", "108"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:semiHidden", 1); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:unhideWhenUsed", 1); - - // Additional para style properties should be also roundtripped. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='ListParagraph']/w:uiPriority", "val", "34"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']/w:qFormat", 1); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']/w:rsid", "val", "00780346"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']", "default", "1"); - - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:link", "val", "Heading1Char"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:locked", 1); - - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading11']", "customStyle", "1"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading11']/w:autoRedefine", 1); - - // Additional char style properties should be also roundtripped. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='DefaultParagraphFont']", "default", "1"); - - // Finally check the same for numbering styles. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='NoList']", "default", "1"); -} - -DECLARE_OOXMLEXPORT_TEST(testCalendar1, "calendar1.docx") -{ - // Document has a non-trivial table style, test the roundtrip of it. - xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); - if (!pXmlStyles) - return; - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:basedOn", "val", "TableNormal"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:rsid", "val", "00903003"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblPr/w:tblStyleColBandSize", "val", "1"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tcPr/w:shd", "val", "clear"); - - // Table style lost its paragraph / run properties. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:pPr/w:spacing", "lineRule", "auto"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:rPr/w:lang", "eastAsia", "ja-JP"); - - // Table style lost its conditional table formatting properties. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:pPr/w:wordWrap", 1); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:rFonts", "hAnsiTheme", "minorHAnsi"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:tblPr", 1); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:tcPr/w:vAlign", "val", "bottom"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='lastRow']/w:tcPr/w:tcBorders/w:tr2bl", "val", "nil"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='band2Horz']/w:tcPr/w:tcBorders/w:top", "themeColor", "text1"); - - // w:tblLook element and its attributes were missing. - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "firstRow", "1"); - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "lastRow", "0"); - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "lastColumn", "0"); - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "firstColumn", "1"); - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "noHBand", "0"); - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "noVBand", "1"); - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "val", "04a0"); -} - -DECLARE_OOXMLEXPORT_TEST(testCalendar2, "calendar2.docx") -{ - // Problem was that CharCaseMap was style::CaseMap::NONE. - uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY); - uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE, getProperty<sal_Int16>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharCaseMap")); - // Font size in the second row was 11. - xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(16.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight")); - // Font size in the third row was 11 as well. - xCell.set(xTable->getCellByName("B3"), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(14.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight")); - - // This paragraph property was missing in table style. - xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); - if (!pXmlStyles) - return; - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:pPr/w:jc", "val", "center"); - - // These run properties were missing - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:rPr/w:lang", "val", "en-US"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:rPr/w:lang", "bidi", "ar-SA"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:caps", 1); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:smallCaps", "val", "0"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:color", "themeColor", "accent1"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:spacing", "val", "20"); - - // Table borders were also missing - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblPr/w:tblBorders/w:insideV", "themeTint", "99"); -} - -DECLARE_OOXMLEXPORT_TEST(testTcBorders, "testTcBorders.docx") -{ - //fdo#76635 : Table borders are not getting preserved. - - xmlDocPtr pXmlDocument = parseExport("word/document.xml"); - if (!pXmlDocument) - return; - - assertXPath(pXmlDocument, "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tcPr[1]/w:tcBorders[1]/w:bottom[1][@w:val = 'single']",1); - assertXPath(pXmlDocument, "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tcPr[1]/w:tcBorders[1]/w:bottom[1][@w:sz = 4]", 1); - assertXPath(pXmlDocument, "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tcPr[1]/w:tcBorders[1]/w:bottom[1][@w:space = 0]", 1); - assertXPath(pXmlDocument, "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tcPr[1]/w:tcBorders[1]/w:bottom[1][@w:color = 808080]", 1); - -} - -DECLARE_OOXMLEXPORT_TEST(testQuicktables, "quicktables.docx") -{ - xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); - if (!pXmlStyles) - return; - - // These were missing in the Calendar3 table style. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:rPr/w:rFonts", "cstheme", "majorBidi"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:rPr/w:color", "themeTint", "80"); - CPPUNIT_ASSERT(getXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:color", "themeShade").equalsIgnoreAsciiCase("BF")); - - // Calendar4. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:pPr/w:snapToGrid", "val", "0"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:rPr/w:bCs", 1); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tcPr/w:shd", "themeFill", "accent1"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tcPr/w:shd", "themeFillShade", "80"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='firstCol']/w:pPr/w:ind", "rightChars", "0"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='firstCol']/w:pPr/w:ind", "right", "144"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='band2Horz']/w:tcPr/w:tcMar/w:bottom", "w", "86"); - - // LightList. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='LightList']/w:tblStylePr[@w:type='firstRow']/w:pPr/w:spacing", "before", "0"); - - // MediumList2-Accent1. - CPPUNIT_ASSERT(getXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='MediumList2-Accent1']/w:tblStylePr[@w:type='band1Vert']/w:tcPr/w:shd", "themeFillTint").equalsIgnoreAsciiCase("3F")); - - // MediumShading2-Accent5. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='MediumShading2-Accent5']/w:tblStylePr[@w:type='firstRow']/w:tcPr/w:tcBorders/w:top", "color", "auto"); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo71302, "fdo71302.docx") -{ - xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); - if (!pXmlStyles) - return; - - // This got renamed to "Strong Emphasis" without a good reason. - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Strong']", 1); -} - - - - - -DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx") -{ - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aGrabBag(0); - xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; - CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty - - bool bTheme = false; - for(int i = 0; i < aGrabBag.getLength(); ++i) - { - if (aGrabBag[i].Name == "OOXTheme") - { - bTheme = true; - uno::Reference<xml::dom::XDocument> aThemeDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aThemeDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aThemeDom.get()); // Reference not empty - } - } - CPPUNIT_ASSERT(bTheme); // Grab Bag has all the expected elements - - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc - - uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xGroup->getCount()); // 1 rendered bitmap from the original shapes - - uno::Reference<beans::XPropertySet> xGroupPropertySet(getShape(1), uno::UNO_QUERY); - xGroupPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; - CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty - - bool bData = false, bLayout = false, bQStyle = false, bColor = false, bDrawing = false; - for(int i = 0; i < aGrabBag.getLength(); ++i) - { - if (aGrabBag[i].Name == "OOXData") - { - bData = true; - uno::Reference<xml::dom::XDocument> aDataDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aDataDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aDataDom.get()); // Reference not empty - } - else if (aGrabBag[i].Name == "OOXLayout") - { - bLayout = true; - uno::Reference<xml::dom::XDocument> aLayoutDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aLayoutDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aLayoutDom.get()); // Reference not empty - } - else if (aGrabBag[i].Name == "OOXStyle") - { - bQStyle = true; - uno::Reference<xml::dom::XDocument> aStyleDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aStyleDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aStyleDom.get()); // Reference not empty - } - else if (aGrabBag[i].Name == "OOXColor") - { - bColor = true; - uno::Reference<xml::dom::XDocument> aColorDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aColorDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aColorDom.get()); // Reference not empty - } - else if (aGrabBag[i].Name == "OOXDrawing") - { - bDrawing = true; - uno::Sequence< uno::Any > diagramDrawing; - uno::Reference<xml::dom::XDocument> aDrawingDom; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= diagramDrawing); - CPPUNIT_ASSERT(diagramDrawing[0] >>= aDrawingDom); // PropertyValue of proper type - CPPUNIT_ASSERT(aDrawingDom.get()); // Reference not empty - } - } - CPPUNIT_ASSERT(bData && bLayout && bQStyle && bColor && bDrawing); // Grab Bag has all the expected elements - - uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(0), uno::UNO_QUERY); - OUString nValue; - xPropertySet->getPropertyValue("Name") >>= nValue; - CPPUNIT_ASSERT_EQUAL(OUString("RenderedShapes"), nValue); // Rendered bitmap has the proper name -} - -/* -DECLARE_OOXMLEXPORT_TEST(testCharHighlight, "char_highlight.docx") -{ - const uno::Reference< text::XTextRange > xPara = getParagraph(1); - // Both highlight and background - const sal_Int32 nBackColor(0x4F81BD); - for( int nRun = 1; nRun <= 16; ++nRun ) - { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,nRun), uno::UNO_QUERY); - sal_Int32 nHighlightColor = 0; - switch( nRun ) - { - case 1: nHighlightColor = 0x000000; break; //black - case 2: nHighlightColor = 0x0000ff; break; //blue - case 3: nHighlightColor = 0x00ffff; break; //cyan - case 4: nHighlightColor = 0x00ff00; break; //green - case 5: nHighlightColor = 0xff00ff; break; //magenta - case 6: nHighlightColor = 0xff0000; break; //red - case 7: nHighlightColor = 0xffff00; break; //yellow - case 8: nHighlightColor = 0xffffff; break; //white - case 9: nHighlightColor = 0x000080; break;//dark blue - case 10: nHighlightColor = 0x008080; break; //dark cyan - case 11: nHighlightColor = 0x008000; break; //dark green - case 12: nHighlightColor = 0x800080; break; //dark magenta - case 13: nHighlightColor = 0x800000; break; //dark red - case 14: nHighlightColor = 0x808000; break; //dark yellow - case 15: nHighlightColor = 0x808080; break; //dark gray - case 16: nHighlightColor = 0xC0C0C0; break; //light gray - } - CPPUNIT_ASSERT_EQUAL(nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor")); - } - - // Only highlight - { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); - } - - // Only background - { - const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); - } -} -*/ - -DECLARE_OOXMLEXPORT_TEST(testFontNameIsEmpty, "font-name-is-empty.docx") -{ - // Check no empty font name is exported - // This test does not fail, if the document contains a font with empty name. - - xmlDocPtr pXmlFontTable = parseExport("word/fontTable.xml"); - if (!pXmlFontTable) - return; - xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlFontTable, "/w:fonts/w:font"); - xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; - sal_Int32 length = xmlXPathNodeSetGetLength(pXmlNodes); - for(sal_Int32 index = 0; index < length; index++){ - xmlNodePtr pXmlNode = pXmlNodes->nodeTab[index]; - OUString attrVal = OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST("name"))); - if (attrVal == ""){ - CPPUNIT_FAIL("Font name is empty."); - } - } - xmlXPathFreeObject(pXmlObj); -} - -DECLARE_OOXMLEXPORT_TEST(testMultiColumnLineSeparator, "multi-column-line-separator-SAVED.docx") -{ - // Check for the Column Separator value.It should be FALSE as the document doesnt contains separator line. - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:sectPr/w:cols","sep","false"); -} - -DECLARE_OOXMLEXPORT_TEST(testCustomXmlGrabBag, "customxml.docx") -{ - // The problem was that item[n].xml and itemProps[n].xml and .rels files for item[n].xml - // files were missing from docx file after saving file. - // This test case tests whether customxml files grabbagged properly in correct object. - - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aGrabBag(0); - xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; - CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty - bool CustomXml = false; - for(int i = 0; i < aGrabBag.getLength(); ++i) - { - if (aGrabBag[i].Name == "OOXCustomXml" || aGrabBag[i].Name == "OOXCustomXmlProps") - { - CustomXml = true; - uno::Reference<xml::dom::XDocument> aCustomXmlDom; - uno::Sequence<uno::Reference<xml::dom::XDocument> > aCustomXmlDomList; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aCustomXmlDomList); // PropertyValue of proper type - sal_Int32 length = aCustomXmlDomList.getLength(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), length); - aCustomXmlDom = aCustomXmlDomList[0]; - CPPUNIT_ASSERT(aCustomXmlDom.get()); // Reference not empty - } - } - CPPUNIT_ASSERT(CustomXml); // Grab Bag has all the expected elements -} - -DECLARE_OOXMLEXPORT_TEST(testActiveXGrabBag, "activex.docx") -{ - // The problem was that activeX.xml files were missing from docx file after saving file. - // This test case tests whether activex files grabbagged properly in correct object. - - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aGrabBag(0); - xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; - CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty - bool bActiveX = false; - for(int i = 0; i < aGrabBag.getLength(); ++i) - { - if (aGrabBag[i].Name == "OOXActiveX") - { - bActiveX = true; - uno::Reference<xml::dom::XDocument> aActiveXDom; - uno::Sequence<uno::Reference<xml::dom::XDocument> > aActiveXDomList; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aActiveXDomList); // PropertyValue of proper type - sal_Int32 length = aActiveXDomList.getLength(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), length); - aActiveXDom = aActiveXDomList[0]; - CPPUNIT_ASSERT(aActiveXDom.get()); // Reference not empty - } - } - CPPUNIT_ASSERT(bActiveX); // Grab Bag has all the expected elements -} - -DECLARE_OOXMLEXPORT_TEST(testActiveXBinGrabBag, "activexbin.docx") -{ - // The problem was that activeX.bin files were missing from docx file after saving file. - // This test case tests whether activex bin files grabbagged properly in correct object. - - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aGrabBag(0); - xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; - CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty - bool bActiveX = false; - for(int i = 0; i < aGrabBag.getLength(); ++i) - { - if (aGrabBag[i].Name == "OOXActiveXBin") - { - bActiveX = true; - uno::Reference<io::XInputStream> aActiveXBin; - uno::Sequence<uno::Reference<io::XInputStream> > aActiveXBinList; - CPPUNIT_ASSERT(aGrabBag[i].Value >>= aActiveXBinList); // PropertyValue of proper type - sal_Int32 length = aActiveXBinList.getLength(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), length); - aActiveXBin = aActiveXBinList[0]; - CPPUNIT_ASSERT(aActiveXBin.get()); // Reference not empty - } - } - CPPUNIT_ASSERT(bActiveX); // Grab Bag has all the expected elements -} - -DECLARE_OOXMLEXPORT_TEST(testFdo69644, "fdo69644.docx") -{ - // The problem was that the exporter exported the table definition - // with only 3 columns, instead of 5 columns. - // Check that the table grid is exported with 5 columns - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol", 5); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo70812, "fdo70812.docx") -{ - // Import just crashed. - getParagraph(1, "Sample pages document."); -} - -DECLARE_OOXMLEXPORT_TEST(testPgMargin, "testPgMargin.docx") -{ - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgMar", "left", "1440"); -} - -DECLARE_OOXMLEXPORT_TEST(testImageCrop, "ImageCrop.docx") -{ - uno::Reference<drawing::XShape> image = getShape(1); - uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY); - ::com::sun::star::text::GraphicCrop aGraphicCropStruct; - - imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct; - - CPPUNIT_ASSERT_EQUAL( sal_Int32( 2955 ), aGraphicCropStruct.Left ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 5477 ), aGraphicCropStruct.Right ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 2856 ), aGraphicCropStruct.Top ); - // FIXME import test is disabled (we only check after import-export-import) - // The reason is that after import this is 2291 -- rounding error? - CPPUNIT_ASSERT_EQUAL( sal_Int32( 2290 ), aGraphicCropStruct.Bottom ); -} - -DECLARE_OOXMLEXPORT_TEST(testLineSpacingexport, "test_line_spacing.docx") -{ - // The Problem was that the w:line attribute value in w:spacing tag was incorrect - uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); - CPPUNIT_ASSERT(xParaEnum->hasMoreElements()); - - // FIXME The test passes on most machines (including Linux x86_64 with gcc-4.7), but fails on various configs: - // Linux arm, Linux x86_64 with gcc-4.8 and Mac. Need to figure out what goes wrong and fix that. -#if 0 - style::LineSpacing alineSpacing = getProperty<style::LineSpacing>(xParaEnum->nextElement(), "ParaLineSpacing"); - CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(13200), static_cast<sal_Int16>(alineSpacing.Height)); - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "line", "31680"); -#endif -} - -DECLARE_OOXMLEXPORT_TEST(testTextBoxGradientAngle, "fdo65295.docx") -{ - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xIndexAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xIndexAccess->getCount()); - - // Angle of frame#1 is 135 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree - uno::Reference<beans::XPropertySet> xFrame1(xIndexAccess->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame1, "FillStyle")); - awt::Gradient aGradient1 = getProperty<awt::Gradient>(xFrame1, "FillGradient"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(135 * 10), aGradient1.Angle); - - // Angle of frame#2 is 180 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree - uno::Reference<beans::XPropertySet> xFrame2(xIndexAccess->getByIndex(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame2, "FillStyle")); - awt::Gradient aGradient2 = getProperty<awt::Gradient>(xFrame2, "FillGradient"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(180 * 10), aGradient2.Angle); - - // Angle of frame#3 is 90 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree - uno::Reference<beans::XPropertySet> xFrame3(xIndexAccess->getByIndex(2), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame3, "FillStyle")); - awt::Gradient aGradient3 = getProperty<awt::Gradient>(xFrame3, "FillGradient"); - CPPUNIT_ASSERT_EQUAL(sal_Int16( 90 * 10), aGradient3.Angle); - - // Angle of frame#4 is 225 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree - uno::Reference<beans::XPropertySet> xFrame4(xIndexAccess->getByIndex(3), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame4, "FillStyle")); - awt::Gradient aGradient4 = getProperty<awt::Gradient>(xFrame4, "FillGradient"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(225 * 10), aGradient4.Angle); - - // Angle of frame#5 is 270 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree - uno::Reference<beans::XPropertySet> xFrame5(xIndexAccess->getByIndex(4), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame5, "FillStyle")); - awt::Gradient aGradient5 = getProperty<awt::Gradient>(xFrame5, "FillGradient"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(270 * 10), aGradient5.Angle); - - // Angle of frame#6 is 315 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree - uno::Reference<beans::XPropertySet> xFrame6(xIndexAccess->getByIndex(5), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame6, "FillStyle")); - awt::Gradient aGradient6 = getProperty<awt::Gradient>(xFrame6, "FillGradient"); - CPPUNIT_ASSERT_EQUAL(sal_Int16(315 * 10), aGradient6.Angle); - - // Angle of frame#7 is 0 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree - uno::Reference<beans::XPropertySet> xFrame7(xIndexAccess->getByIndex(6), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame7, "FillStyle")); - awt::Gradient aGradient7 = getProperty<awt::Gradient>(xFrame7, "FillGradient"); - CPPUNIT_ASSERT_EQUAL(sal_Int16( 0 * 10), aGradient7.Angle); - - // Angle of frame#8 is 45 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree - uno::Reference<beans::XPropertySet> xFrame8(xIndexAccess->getByIndex(7), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame8, "FillStyle")); - awt::Gradient aGradient8 = getProperty<awt::Gradient>(xFrame8, "FillGradient"); - CPPUNIT_ASSERT_EQUAL(sal_Int16( 45 * 10), aGradient8.Angle); -} - -DECLARE_OOXMLEXPORT_TEST(testCellGridSpan, "cell-grid-span.docx") -{ - // The problem was during export gridSpan value for 1st & 2nd cells for test document - // used to get set wrongly to 5 and 65532 respectively which was the reason for crash during save operation - // Varifying gridSpan element is not present in RoundTriped Document (As it's Default value is 1). - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:tcPr/w:gridSpan",0); - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[2]/w:tcPr/w:gridSpan",0); -} -DECLARE_OOXMLEXPORT_TEST(testFdo71646, "fdo71646.docx") -{ - // The problem was after save file created by MS the direction changed to RTL. - uno::Reference<uno::XInterface> xParaLTRLeft(getParagraph( 1, "LTR LEFT")); - sal_Int32 nLTRLeft = getProperty< sal_Int32 >( xParaLTRLeft, "ParaAdjust" ); - // test the text Direction value for the pragraph - sal_Int16 nLRDir = getProperty< sal_Int32 >( xParaLTRLeft, "WritingMode" ); - - // this will test the both the text direction and alignment for paragraph - CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLTRLeft); - CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir); -} - -DECLARE_OOXMLEXPORT_TEST(testParaAutoSpacing, "para-auto-spacing.docx") -{ - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "beforeAutospacing","1"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "afterAutospacing","1"); - - assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "beforeAutospacing",""); - assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "afterAutospacing",""); - assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "before","400"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "after","400"); -} - -DECLARE_OOXMLEXPORT_TEST(testGIFImageCrop, "test_GIF_ImageCrop.docx") -{ - // FIXME why does this fail on Mac? -#if !defined(MACOSX) - uno::Reference<drawing::XShape> image = getShape(1); - uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY); - ::com::sun::star::text::GraphicCrop aGraphicCropStruct; - - imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct; - - // FIXME import test is disabled (we only check after import-export-import) - // The reason is that after import this is 1171 -- why? - CPPUNIT_ASSERT_EQUAL( sal_Int32( 1265 ), aGraphicCropStruct.Left ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 4256 ), aGraphicCropStruct.Right ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 1109 ), aGraphicCropStruct.Top ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 1448 ), aGraphicCropStruct.Bottom ); -#endif -} - -DECLARE_OOXMLEXPORT_TEST(testPNGImageCrop, "test_PNG_ImageCrop.docx") -{ - // FIXME why does this fail on Mac? -#if !defined(MACOSX) - /* The problem was image cropping information was not getting saved - * after roundtrip. - * Check for presenece of cropping parameters in exported file. - */ - uno::Reference<drawing::XShape> image = getShape(1); - uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY); - ::com::sun::star::text::GraphicCrop aGraphicCropStruct; - - imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct; - - // FIXME import test is disabled (we only check after import-export-import) - // The reason is that after import this is 1141 -- why? - CPPUNIT_ASSERT_EQUAL( sal_Int32( 1231 ), aGraphicCropStruct.Left ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 1295 ), aGraphicCropStruct.Right ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 1358 ), aGraphicCropStruct.Top ); - CPPUNIT_ASSERT_EQUAL( sal_Int32( 737 ), aGraphicCropStruct.Bottom ); -#endif -} - -DECLARE_OOXMLEXPORT_TEST(testFootnoteParagraphTag, "testFootnote.docx") -{ - /* In footnotes.xml, the paragraph tag inside <w:footnote w:id="2"> was getting written into document.xml. - * Check for, paragraph tag is correctly written into footnotes.xml. - */ - xmlDocPtr pXmlFootnotes = parseExport("word/footnotes.xml"); - if (!pXmlFootnotes) - return; - assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]","id","2"); - assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]/w:p/w:r/w:rPr/w:rStyle","val","Footnotereference"); -} - -DECLARE_OOXMLEXPORT_TEST(testSpacingLineRule,"table_lineRule.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:spacing", "lineRule", "auto"); -} - -DECLARE_OOXMLEXPORT_TEST(testTableLineSpacing, "table_atleast.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:pPr/w:spacing", "line", "320"); -} - -DECLARE_OOXMLEXPORT_TEST(testOoxmlTriangle, "ooxml-triangle.docx") -{ - // The problem was that ooxml-triangle shape type wasn't handled by VML - // export (only isosceles-triangle), leading to a missing shape. - getShape(1); -} - -DECLARE_OOXMLEXPORT_TEST(testMce, "mce.docx") -{ - // The shape is red in Word2007, green in Word2010. Check that our import follows the later. - CPPUNIT_ASSERT_EQUAL(sal_Int32(0x9bbb59), getProperty<sal_Int32>(getShape(1), "FillColor")); -} - -DECLARE_OOXMLEXPORT_TEST(testThemePreservation, "theme-preservation.docx") -{ - // check default font theme values have been preserved - xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); - if (!pXmlStyles) - return; - assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "asciiTheme", "minorHAnsi"); - assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "cstheme", "minorBidi"); - - // check the font theme values in style definitions - assertXPath(pXmlStyles, "/w:styles/w:style[1]/w:rPr/w:rFonts", "eastAsiaTheme", "minorEastAsia"); - - // check the color theme values in style definitions - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Custom1']/w:rPr/w:color", "themeColor", "accent1"); - assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Custom1']/w:rPr/w:color", "themeTint", "99"); - - // check direct format font theme values have been preserved - xmlDocPtr pXmlDocument = parseExport("word/document.xml"); - if (!pXmlDocument) - return; - assertXPath(pXmlDocument, "/w:document/w:body/w:p[5]/w:r[1]/w:rPr/w:rFonts", "hAnsiTheme", "majorHAnsi"); - assertXPath(pXmlDocument, "/w:document/w:body/w:p[5]/w:r[1]/w:rPr/w:rFonts", "asciiTheme", "majorHAnsi"); - - // check theme font color value has been preserved - assertXPath(pXmlDocument, "/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeColor", "accent3"); - OUString sThemeShade = getXPath(pXmlDocument, "/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeShade"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(0xbf), sThemeShade.toInt32(16)); - - // check the themeFontLang values in settings file - xmlDocPtr pXmlSettings = parseExport("word/settings.xml"); - if (!pXmlSettings) - return; - assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "val", "en-US"); - assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "eastAsia", "zh-CN"); - assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "bidi", "he-IL"); - - // check fonts have been applied properly - sal_Unicode fontName[2]; //represents the string "宋体" - fontName[0] = 0x5b8b; - fontName[1] = 0x4f53; - CPPUNIT_ASSERT_EQUAL(OUString(fontName, 2), getProperty<OUString>(getParagraph(1), "CharFontNameAsian")); - CPPUNIT_ASSERT_EQUAL(OUString("Arial"), - getProperty<OUString>(getParagraph(2), "CharFontNameComplex")); - CPPUNIT_ASSERT_EQUAL(OUString("Trebuchet MS"), - getProperty<OUString>(getParagraph(3, "Default style theme font"), "CharFontName")); - CPPUNIT_ASSERT_EQUAL(OUString("Arial Black"), - getProperty<OUString>(getRun(getParagraph(4, "Direct format font"), 1), "CharFontName")); - CPPUNIT_ASSERT_EQUAL(OUString("Trebuchet MS"), - getProperty<OUString>(getParagraph(5, "Major theme font"), "CharFontName")); - - // check the paragraph background pattern has been preserved including theme colors - assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "val", "thinHorzStripe"); - assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeFill", "text2"); - assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeFillTint", "33"); - assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeColor", "accent1"); - assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeShade", "80"); -} - -DECLARE_OOXMLEXPORT_TEST(testTableThemePreservation, "table-theme-preservation.docx") -{ - xmlDocPtr pXmlDocument = parseExport("word/document.xml"); - if (!pXmlDocument) - return; - - // check cell theme colors have been preserved - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFill", "accent6"); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFillShade", ""); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFillTint", "33"); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFill", "accent6"); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFillShade", ""); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFillTint", ""); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFill", "accent6"); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFillShade", "80"); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFillTint", ""); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "val", "horzStripe"); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeColor", "accent3"); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeTint", "33"); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "color", "E7EEEE"); - - // check table style has been preserved - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tblPr/w:tblStyle", "val", "Sombreadoclaro-nfasis1"); - // check table style is not overwritten by other properties - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:tcPr/w:tcBorders/*", 0); - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[3]/w:tcPr/w:tcBorders/*", 0); - // check that one cell attribute present in the original document has been preserved - assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/*", 1); - - // Check that w:cnfStyle row, cell and paragraph property is preserved. - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:trPr/w:cnfStyle", "val", "100000000000"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:trPr/w:cnfStyle", "firstRow", "1"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:trPr/w:cnfStyle", "lastRow", "0"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:trPr/w:cnfStyle", "firstColumn", "0"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:trPr/w:cnfStyle", "lastColumn", "0"); - - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc/w:tcPr/w:cnfStyle", "val", "001000000000"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc/w:tcPr/w:cnfStyle", "oddVBand", "0"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc/w:tcPr/w:cnfStyle", "evenVBand", "0"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc/w:tcPr/w:cnfStyle", "oddHBand", "0"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc/w:tcPr/w:cnfStyle", "evenHBand", "0"); - - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:cnfStyle", "val", "100000000000"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:cnfStyle", "firstRowFirstColumn", "0"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:cnfStyle", "firstRowLastColumn", "0"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:cnfStyle", "lastRowFirstColumn", "0"); - assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:cnfStyle", "lastRowLastColumn", "0"); - -} - -DECLARE_OOXMLEXPORT_TEST(testcantSplit, "2_table_doc.docx") -{ - // if Split table value is true for a table then during export do not write <w:cantSplit w:val="false"/> - // in table row property,As default row prop is allow row to break across page. - // writing <w:cantSplit w:val="false"/> during export was causing problem that all the cell data used to come on same page - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr/w:trPr/w:cantSplit",0); - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[2]/w:tr/w:trPr/w:cantSplit","val","true"); -} - -DECLARE_OOXMLEXPORT_TEST(testExtraSectionBreak, "1_page.docx") -{ - // There was a problem for some documents during export.Invalid sectPr getting added - // because of faulty calculation of PageDesc value - // This was the reason for increasing number of pages after RT - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); - uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); - xCursor->jumpToLastPage(); - CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage()); -} - -DECLARE_OOXMLEXPORT_TEST(testcolumnbreak, "columnbreak.docx") -{ - CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(5, "This is first line after col brk."), "BreakType")); - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[1]/w:br", "type", "column"); -} - -DECLARE_OOXMLEXPORT_TEST(testGlossary, "testGlossary.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/glossary/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:glossaryDocument", "Ignorable", "w14 wp14"); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo71785, "fdo71785.docx") -{ - // crashtest -} - -DECLARE_OOXMLEXPORT_TEST(testCrashWhileSave, "testCrashWhileSave.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/footer1.xml"); - if (!pXmlDoc) - return; - CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:ftr/w:tbl/w:tr/w:tc[1]/w:p[1]/w:pPr/w:pStyle", "val").match("Normal")); -} - -DECLARE_OOXMLEXPORT_TEST(testFileOpenInputOutputError,"floatingtbl_with_formula.docx") -{ - // Docx containing Floating table with formula was giving "General input/output error" while opening in LibreOffice - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pStyle", "val", "Normal"); -} - -#endif - -DECLARE_OOXMLEXPORT_TEST(testRelorientation, "relorientation.docx") -{ - uno::Reference<drawing::XShape> xShape = getShape(1); - // This was text::RelOrientation::FRAME, when handling relativeFrom=page, align=right - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_RIGHT, getProperty<sal_Int16>(xShape, "HoriOrientRelation")); - - uno::Reference<drawing::XShapes> xGroup(xShape, uno::UNO_QUERY); - // This resulted in lang::IndexOutOfBoundsException, as nested groupshapes weren't handled. - uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), xShapeDescriptor->getShapeType()); - - // Right after import we get a rounding error: 8662 vs 8664. - if (mbExported) - { - uno::Reference<drawing::XShape> xYear(xGroup->getByIndex(1), uno::UNO_QUERY); - // This was 2, due to incorrect handling of parent transformations inside DML groupshapes. - CPPUNIT_ASSERT_EQUAL(sal_Int32(8664), xYear->getSize().Width); - } -} - -DECLARE_OOXMLEXPORT_TEST(testBezier, "bezier.odt") -{ - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - // Check that no shape got lost: a bezier, a line and a text shape. - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xDraws->getCount()); -} - -DECLARE_OOXMLEXPORT_TEST(testGroupshapeTextbox, "groupshape-textbox.docx") -{ - uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY); - uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY); - // The VML export lost text on textboxes inside groupshapes. - // The DML export does not, make sure it stays that way. - CPPUNIT_ASSERT_EQUAL(OUString("first"), xShape->getString()); - // This was 16, i.e. inheriting doc default char height didn't work. - CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight")); -} - -DECLARE_OOXMLEXPORT_TEST(testGroupshapePicture, "groupshape-picture.docx") -{ - // Picture in the groupshape got lost, groupshape had only one child. - uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY); - uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GraphicObjectShape"), xShapeDescriptor->getShapeType()); -} - -DECLARE_OOXMLEXPORT_TEST(testAutofit, "autofit.docx") -{ - CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(getShape(1), "TextAutoGrowHeight"))); - CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(getShape(2), "TextAutoGrowHeight"))); -} - -DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedParagraphMark, "testTrackChangesDeletedParagraphMark.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:del"); -} - -DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedParagraphMark, "testTrackChangesInsertedParagraphMark.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:ins"); -} - -DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedTableRow, "testTrackChangesDeletedTableRow.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:del"); -} - -DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedTableRow, "testTrackChangesInsertedTableRow.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:ins"); -} - -DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedTableCell, "testTrackChangesDeletedTableCell.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellDel"); -} - -DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedTableCell, "testTrackChangesInsertedTableCell.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellIns"); -} - -DECLARE_OOXMLEXPORT_TEST(testTextBoxPictureFill, "textbox_picturefill.docx") -{ - uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xFrame, "FillStyle")); - CPPUNIT_ASSERT(!(getProperty<OUString>(xFrame,"FillBitmapURL")).isEmpty()); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO73034, "FDO73034.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:u", "val").match("single")); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO71834, "fdo71834.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[2]/w:tc[1]/w:tcPr[1]/w:tcW[1]","type", "dxa"); -} - -DECLARE_OOXMLEXPORT_TEST(testTrackChangesParagraphProperties, "testTrackChangesParagraphProperties.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPathChildren(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pPrChange", 0); -} - -DECLARE_OOXMLEXPORT_TEST(testMsoSpt180, "mso-spt180.docx") -{ - if (!mbExported) - return; - - uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xGroup->getByIndex(0), "CustomShapeGeometry"); - OUString aType; - for (int i = 0; i < aProps.getLength(); ++i) - if (aProps[i].Name == "Type") - aType = aProps[i].Value.get<OUString>(); - // This was exported as borderCallout90, which is an invalid drawingML preset shape string. - CPPUNIT_ASSERT_EQUAL(OUString("ooxml-borderCallout1"), aType); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo73550, "fdo73550.docx") -{ - xmlDocPtr pXmlDocument = parseExport("word/document.xml"); - if (!pXmlDocument) - return; - // This was wrap="none". - assertXPath(pXmlDocument, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:rFonts"); -} - -DECLARE_OOXMLEXPORT_TEST(testPageRelSize, "pagerelsize.docx") -{ - // First shape: width is relative from page, but not height. - uno::Reference<drawing::XShape> xShape = getShape(1); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation")); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation")); - - // Second shape: height is relative from page, but not height. - xShape = getShape(2); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation")); - CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation")); -} - -DECLARE_OOXMLEXPORT_TEST(testRelSizeRound, "rel-size-round.docx") -{ - // This was 9: 9.8 was imported as 9 instead of being rounded to 10. - CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty<sal_Int16>(getShape(1), "RelativeHeight")); -} - -DECLARE_OOXMLEXPORT_TEST(testTestTitlePage, "testTitlePage.docx") -{ - CPPUNIT_ASSERT_EQUAL(OUString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), parseDump("/root/page[2]/footer/txt/text()")); -} - -DECLARE_OOXMLEXPORT_TEST(testTableRowDataDisplayedTwice,"table-row-data-displayed-twice.docx") -{ - // fdo#73534: There was a problem for some documents during export.Invalid sectPr getting added - // because of wrong condition in code. - // This was the reason for increasing number of pages after RT - uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); - uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); - uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); - xCursor->jumpToLastPage(); - CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage()); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo73556,"fdo73556.docx") -{ - /* - * The file contains a table with 3 columns - * the girdcols are as follows: {1210, 1331, 1210} - * whereas the individual cells have {1210, 400, 1210} - * The table column separators were taken from the Grid, while - * the table width was calculated as 2820 from cells instead - * of 3751 from the Grid. - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol", 3); - sal_Int32 tableWidth = 0; - tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[1]", "w").toInt32(); - tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32(); - tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[3]", "w").toInt32(); - CPPUNIT_ASSERT_EQUAL(sal_Int32(3751), tableWidth); -} - -DECLARE_OOXMLEXPORT_TEST(testSegFaultWhileSave, "test_segfault_while_save.docx") -{ - // fdo#74499 - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").match("6138")); -} - -DECLARE_OOXMLEXPORT_TEST(fdo69656, "Table_cell_auto_width_fdo69656.docx") -{ - // Changed the UT to check "dxa" instead of "auto" - // For this particular issue file few cells have width type "auto" - // LO supports VARIABLE and FIXED width type. - // If type is VARIABLE LO calculates width as percent of PageSize - // Else if the width is fixed it uses the width value. - // After changes for fdo76741 the fixed width is exported as "dxa" for DOCX - - // Check for the width type of table and its cells. - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblW","type","dxa"); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo76741, "fdo76741.docx") -{ - - // There are two issue related to table in the saved(exported) file - // - the table alignment in saved file is "left" instead of "center" - // - the table width type in properties is "auto" instead of "dxa" - - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "//w:jc", "val", "center"); - assertXPath(pXmlDoc, "//w:tblW", "w", "10081"); - assertXPath(pXmlDoc, "//w:tblW", "type", "dxa"); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo73541,"fdo73541.docx") -{ - // fdo#73541: The mirrored margins were not imported and mapped correctly in Page Layout - // Hence <w:mirrorMargins /> tag was not exported back in settings.xml - xmlDocPtr pXmlDoc = parseExport("word/settings.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:settings/w:mirrorMargins"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO74106, "FDO74106.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:numFmt", "val","hebrew1"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO74215, "FDO74215.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style", "width:6.4pt;height:6.4pt"); -} - -DECLARE_OOXMLEXPORT_TEST(testColumnBreak_ColumnCountIsZero,"fdo74153.docx") -{ - /* fdo73545: Column Break with Column_count = 0 was not getting preserved. - * The <w:br w:type="column" /> was missing after roundtrip - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/w:br","type","column"); -} - -DECLARE_OOXMLEXPORT_TEST(testIndentation, "test_indentation.docx") -{ - // fdo#74141 :There was a problem that in style.xml and document.xml in <w:ind> tag "right" & "left" margin - // attributes gets added(w:right=0 & w:left=0) if these attributes are not set in original document. - // This test is to verify <w:ind> does not contain w:right attribute. - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:ind", "end", ""); -} - -DECLARE_OOXMLEXPORT_TEST(testChartInFooter, "chart-in-footer.docx") -{ - // fdo#73872: document contains chart in footer. - // The problem was that footer1.xml.rels files for footer1.xml - // files were missing from docx file after roundtrip. - xmlDocPtr pXmlDoc = parseExport("word/_rels/footer1.xml.rels"); - if(!pXmlDoc) - return; - - // Check footer1.xml.rels contains in doc after roundtrip. - // Check Id = rId1 in footer1.xml.rels - assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship","Id","rId1"); - - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - if (xDrawPageSupplier.is()) - { - // If xDrawPage->getCount()==1, then document conatins one shape. - uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount()); // One shape in the doc - } -} - -DECLARE_OOXMLEXPORT_TEST(testNestedTextFrames, "nested-text-frames.odt") -{ - // First problem was LO crashed during export (crash test) - - // Second problem was LO made file corruption, writing out nested text boxes, which can't be handled by Word. - // Test that all three exported text boxes are anchored to the same paragraph and not each other. - uno::Reference<text::XTextContent> xTextContent(getShape(1), uno::UNO_QUERY); - uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY); - uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString()); - - xTextContent.set(getShape(2), uno::UNO_QUERY); - xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY); - xText.set(xRange->getText(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString()); - - xTextContent.set(getShape(3), uno::UNO_QUERY); - xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY); - xText.set(xRange->getText(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString()); -} - -DECLARE_OOXMLEXPORT_TEST(testFloatingTablePosition, "floating-table-position.docx") -{ - // Position of shape was wrong, because some conversion was missing. - uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); - // This was 3295. - CPPUNIT_ASSERT_EQUAL(sal_Int32(5964), getProperty<sal_Int32>(xShape, "HoriOrientPosition")); - // This was 4611. - CPPUNIT_ASSERT_EQUAL(sal_Int32(8133), getProperty<sal_Int32>(xShape, "VertOrientPosition")); -} - -DECLARE_OOXMLEXPORT_TEST(testAbi11739, "abi11739.docx") -{ - // Validation test: order of elements were wrong. - xmlDocPtr pXmlDoc = parseExport("word/styles.xml"); - if (!pXmlDoc) - return; - // Order was: uiPriority, link, basedOn. - CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "basedOn") < getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "link")); - CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "link") < getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "uiPriority")); - // Order was: qFormat, unhideWhenUsed. - CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "unhideWhenUsed") < getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "qFormat")); -} - -DECLARE_OOXMLEXPORT_TEST(testEmbeddedXlsx, "embedded-xlsx.docx") -{ - // check there are two objects and they are FrameShapes - uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount()); - CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(1)->getShapeType()); - CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(2)->getShapeType()); - - // check the objects are present in the exported document.xml - xmlDocPtr pXmlDocument = parseExport("word/document.xml"); - if (!pXmlDocument) - return; - assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/w:object", 2); - - // finally check the embedded files are present in the zipped document - uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); - uno::Sequence<OUString> names = xNameAccess->getElementNames(); - int nSheetFiles = 0; - int nImageFiles = 0; - for (int i=0; i<names.getLength(); i++) - { - if(names[i].startsWith("word/embeddings/oleObject")) - nSheetFiles++; - if(names[i].startsWith("word/media/image")) - nImageFiles++; - } - CPPUNIT_ASSERT_EQUAL(2, nSheetFiles); - CPPUNIT_ASSERT_EQUAL(2, nImageFiles); -} - -DECLARE_OOXMLEXPORT_TEST(testNumberedLists_StartingWithZero, "FDO74105.docx") -{ - /* Issue : Numbered lists Starting with value '0' is not preserved after RT. - * In numbering.xml, an XML tag <w:start> is optional. If not mentioned, - * the Numbered list should start from 0. - * Problem was LO was writing <w:start> for all levels 0-8 with default value "1". - */ - xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); - if (!pXmlDoc) - return; - - // Check that we do _not_ export w:start for <w:lvl w:ilvl="0">. - assertXPath(pXmlDoc, "w:numbering/w:abstractNum[1]/w:lvl[1]/w:start", 0); -} - -DECLARE_OOXMLEXPORT_TEST(testPageBreak,"fdo74566.docx") -{ - /* Break to next page was written into wrong paragraph as <w:pageBreakBefore />. - * LO was not preserving Page Break as <w:br w:type="page" />. - * Now after fix , LO writes Page Break as the new paragraph and also - * preserves the xml tag <w:br>. - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - - uno::Reference<text::XTextRange> xParagraph2 = getParagraph(2); - uno::Reference<text::XTextRange> xParagraph4 = getParagraph(4); - - getRun(xParagraph2, 1, "First Page Second Line"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[2]/w:br","type","page"); - getRun(xParagraph4, 1, "Second Page First line after Page Break"); -} - -DECLARE_OOXMLEXPORT_TEST(testOleObject, "test_ole_object.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata", "o:title", ""); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo74792, "fdo74792.docx") -{ - /* - * fdo#74792 : The images associated with smart-art data[i].xml - * were not preserved on exporting to DOCX format - * Added support to grabbag the rels, with associated images. - */ - xmlDocPtr pXmlDoc = parseExport("word/diagrams/_rels/data1.xml.rels"); - if(!pXmlDoc) - return; - assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship", 4); - uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL( - comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); - - //check that images are also saved - OUString sImageFile( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name - uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName( sImageFile ), uno::UNO_QUERY); - CPPUNIT_ASSERT( xInputStream.is() ); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo77718, "fdo77718.docx") -{ - //in case of multiple smart arts the names for images were getting - //repeated and thereby causing a data loss as the binary stream was - //getting over written. This test case ensures that unique names are - //given for images in different smart arts. - xmlDocPtr pXmlDataRels1 = parseExport("word/diagrams/_rels/data1.xml.rels"); - if( !pXmlDataRels1 ) - return; - - xmlDocPtr pXmlDataRels2 = parseExport("word/diagrams/_rels/data2.xml.rels"); - if( !pXmlDataRels2 ) - return; - - //ensure that the rels file is present. - assertXPath(pXmlDataRels1,"/rels:Relationships/rels:Relationship", 4); - assertXPath(pXmlDataRels2,"/rels:Relationships/rels:Relationship", 4); - - uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL( - comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); - - //check that images are also saved - OUString sImageFile1( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name - uno::Reference<io::XInputStream> xInputStream1(xNameAccess->getByName( sImageFile1 ), uno::UNO_QUERY); - CPPUNIT_ASSERT( xInputStream1.is() ); - - //check that images are saved for other smart-arts as well. - OUString sImageFile2( "word/media/OOXDiagramDataRels2_0.jpeg" ); //added anchor id to form a uniqe name - uno::Reference<io::XInputStream> xInputStream2(xNameAccess->getByName( sImageFile2 ), uno::UNO_QUERY); - CPPUNIT_ASSERT( xInputStream2.is() ); -} - -DECLARE_OOXMLEXPORT_TEST(testTableCurruption, "tableCurrupt.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/header2.xml"); - if (!pXmlDoc) - return; - CPPUNIT_ASSERT(pXmlDoc) ; - assertXPath(pXmlDoc, "/w:hdr/w:tbl[1]/w:tr[1]/w:tc[1]",1); -} - -DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx") -{ - // check XML - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date", "fullDate", "2014-03-05T00:00:00Z"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:dateFormat", "val", "dddd, dd' de 'MMMM' de 'yyyy"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:lid", "val", "es-ES"); - assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "miércoles, 05 de marzo de 2014"); - - // check imported control - uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY); - util::Date aDate = getProperty<util::Date>(xControl->getControl(), "Date"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(5), sal_Int32(aDate.Day)); - CPPUNIT_ASSERT_EQUAL(sal_Int32(3), sal_Int32(aDate.Month)); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2014), sal_Int32(aDate.Year)); -} - -DECLARE_OOXMLEXPORT_TEST(test_OpeningBrace, "2120112713_OpenBrace.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - // Checking for OpeningBrace tag - assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[1]/m:dPr[1]/m:begChr[1]","val",""); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO76312, "FDO76312.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]"); -} - -DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx") -{ - // check XML - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[1]", "value", "manolo"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[2]", "value", "pepito"); - assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "Manolo"); - - // check imported control - uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY); - - CPPUNIT_ASSERT_EQUAL(OUString("Manolo"), getProperty<OUString>(xControl->getControl(), "Text")); - - uno::Sequence<OUString> aItems = getProperty< uno::Sequence<OUString> >(xControl->getControl(), "StringItemList"); - CPPUNIT_ASSERT_EQUAL(sal_Int32(2), sal_Int32(aItems.getLength())); - CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems[0]); - CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]); -} - -DECLARE_OOXMLEXPORT_TEST(testCheckBoxControl, "checkbox-control.docx") -{ - // check XML - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:checked", "val", "1"); - assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:checkedState", "val", "2612"); - assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:uncheckedState", "val", "2610"); - - // TODO: import control and add a check here -} - -DECLARE_OOXMLEXPORT_TEST(testParagraphWithComments, "paragraphWithComments.docx") -{ - /* Comment id's were getting overwritten for annotation mark(s), - which was causing a mismatch in the relationship for comment id's - in document.xml and comment.xml - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - xmlDocPtr pXmlComm = parseExport("word/comments.xml"); - if(!pXmlDoc) - return; - - sal_Int32 idInDocXml = 0; - sal_Int32 idInCommentXml = -1; //intentionally assigning -1 so that it differs from idInDocXml - //and also because getXpath does not assert. - idInDocXml = getXPath(pXmlDoc,"/w:document/w:body/w:p[3]/w:commentRangeEnd[1]","id").toInt32(); - idInCommentXml = getXPath(pXmlComm,"/w:comments/w:comment[1]","id").toInt32(); - CPPUNIT_ASSERT_EQUAL( idInDocXml, idInCommentXml ); -} - -DECLARE_OOXMLEXPORT_TEST(testOLEObjectinHeader, "2129393649.docx") -{ - // fdo#76015 : Document contains oleobject in header xml. - // Problem was relationship entry for oleobject from header was - // exported into document.xml.rels file because of this rels file - // for headers were missing from document/word/rels. - xmlDocPtr pXmlDoc = parseExport("word/_rels/header1.xml.rels"); - if(!pXmlDoc) - return; - - assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship[1]","Id","rId1"); -} - -DECLARE_OOXMLEXPORT_TEST(test_ClosingBrace, "2120112713.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - // Checking for ClosingBrace tag - assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[2]/m:dPr[1]/m:endChr[1]","val",""); -} - -DECLARE_OOXMLEXPORT_TEST(testlvlPicBulletId, "lvlPicBulletId.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:numbering[1]/w:abstractNum[1]/w:lvl[1]/w:lvlPicBulletId[1]", 0); -} - -DECLARE_OOXMLEXPORT_TEST(testSdtContent, "SdtContent.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/header1.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:hdr[1]/w:sdt[1]/w:sdtContent[1]/w:p[1]/w:del[1]"); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo76016, "fdo76016.docx") -{ - // check XML - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]", "name", "adj1"); - assertXPath(pXmlDoc, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]", "name", "adj2"); -} - -DECLARE_OOXMLEXPORT_TEST(testFileWithInvalidImageLink, "FileWithInvalidImageLink.docx") -{ - /* In case if the original file has an image whose link is - invalid, then the RT file used to result in corruption - since the exported image would be an empty image. - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - - 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", ""); -} - -DECLARE_OOXMLEXPORT_TEST(testContentTypeDOCX, "fdo80410.docx") -{ - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) // only test the export, not initial import - return; - - assertXPath(pXmlDoc, - "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.docx']", - "ContentType", - "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); -} - -DECLARE_OOXMLEXPORT_TEST(testContentTypeXLSM, "fdo76098.docx") -{ - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "ContentType", "application/vnd.ms-excel.sheet.macroEnabled.12"); -} - -DECLARE_OOXMLEXPORT_TEST(test76108, "test76108.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) return; - //docx file after RT is getting corrupted. - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:fldChar[1]", "fldCharType", "begin"); -} - -DECLARE_OOXMLEXPORT_TEST(testTCTagMisMatch, "TCTagMisMatch.docx") -{ - // TCTagMisMatch.docx : This document contains a empty table with borders. - // there was a TC tag mismatch which resulted into a crash. - - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if(!pXmlDoc) - return; - 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); - assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]", 1); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO78292, "FDO78292.docx") -{ - //text node is a leaf node, it should not have any children - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if(!pXmlDoc) - return; - assertXPath(pXmlDoc,"/w:document/w:body/w:p[14]/w:sdt[3]/w:sdtPr[1]/w:text/w14:checked",0); -} - -DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:text", 1); - assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:id", 3); - assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:picture", 1); - assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:group", 1); - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:citation", 1); - -} - -DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - // In two cases the a:graphicData elements had no children, which is invalid. - assertXPath(pXmlDoc, "//a:graphicData[not(*)]", 0); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo76589 , "fdo76589.docx") -{ - /* Numbered list was not preserve after RT. - * In numbering.xml, when NumberingType is "decimal" and level is zero, - * w:val of w:lvlText was empty. - * It should be <w:lvlText w:val="%1" /> - */ - xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); - if (!pXmlDoc) - return; - - assertXPath ( pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val","%1" ); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo79008, "fdo79008.docx") -{ - /* File getting crash while saving in LO. - * Checking if document.xml file is getting created after fix - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; -} - -DECLARE_OOXMLEXPORT_TEST(testAuthorPropertySdt, "author-property.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns1:coreProperties[1]/ns0:creator[1]"); - assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "storeItemID","{6C3C8BC8-F283-45AE-878A-BAB7291924A1}"); - // FIXME: the next property doesn't match, though it's correct in theory. A bug in assertXPath? - // assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "prefixMappings", - // "xmlns:ns0='http://purl.org/dc/elements/1.1/' xmlns:ns1='http://schemas.openxmlformats.org/package/2006/metadata/core-properties'"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO76586, "fdo76586.docx") -{ - /* - * In the test file gridCol had only one value for entire table width - * while there are two cells in a table row. - * So the table was not imported with the correct cell widths - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if (!pXmlDoc) - return; - - // there is only one table in the test file - assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[1]", "w", "1601"); - assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[2]", "w", "7843"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO76587 , "fdo76587.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/styles.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:styles/w:style[8]/w:pPr/w:spacing", "line", "240"); - assertXPath(pXmlDoc, "/w:styles/w:style[8]/w:pPr/w:spacing", "lineRule", "auto"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO77890 , "fdo77890.docx") -{ - /* - Ensure that the page break is preserved i.e it should not be converted to a section break, in case - if the different first page is set for the pages in the document. - For additional comments pls refer https://www.libreoffice.org/bugzilla/show_bug.cgi?id=77890#c2 - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:br", "type", "page"); -} - -DECLARE_OOXMLEXPORT_TEST(testNumberedList,"NumberedList.docx") -{ - //fdo74150:In document.xml, for pStyle = "NumberedList1", iLvl and numId was not preserved - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr[1]/w:pStyle", "val", "NumberedList1"); - 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"); - 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"); - - 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"); - 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"); - 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"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO76597, "fdo76597.docx") -{ - // check XML - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "before", "96"); - assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "after", "120"); -} - -DECLARE_OOXMLEXPORT_TEST(testContentTypeTIF, "fdo77476.docx") -{ - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@ContentType='image/tif']", "PartName", "/word/media/image1.tif"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO77117, "fdo77117.docx") -{ - uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY); - uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY); - // This checks textbox textrun size of font which is in group shape. - CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight")); -} - -DECLARE_OOXMLEXPORT_TEST(testFloatingTable, "fdo77887.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "horzAnchor", "margin"); - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "leftFromText", "141"); - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "rightFromText", "141"); - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpXSpec", "center"); - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpY", "2266"); - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "vertAnchor", "page"); - -} - - -DECLARE_OOXMLEXPORT_TEST(testTablePreferredWidth, "tablePreferredWidth.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if(!pXmlDoc) - return; - - // Problem :If the table preferred width is in percent, then after RT it changes to 0 & width type changes - // to 'auto' instead of 'pct'. - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "w", "3000"); - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "type","pct"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO75431, "fdo75431.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, "//w:tbl", 2); - assertXPath(pXmlDoc, "//w:p/w:pPr/w:sectPr/w:type", "val", "nextPage"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO77725, "fdo77725.docx") -{ - xmlDocPtr pXmlFootnotes = parseExport("word/footnotes.xml"); - if (!pXmlFootnotes) - return; - - assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[1]", 0); - assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[2]", 0); - assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[3]", 0); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO77812, "fdo77812.docx") -{ - /* Additional sectPr was getting inserted and hence Column properties - * were getting added into this additional sectPr instead of Default setPr. - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - - // Check no additional section break is inserted. - assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:pPr/w:sectPr", 0); - - // Check w:cols comes under Default sectPr - assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols", "num", "2"); - assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols/w:col[1]", 1); - assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols/w:col[2]", 1); -} - -DECLARE_OOXMLEXPORT_TEST(testContentTypeOLE, "fdo77759.docx") -{ - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, - "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']", - "PartName", - "/word/embeddings/oleObject1.xlsx"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo78420, "fdo78420.docx") -{ - xmlDocPtr pXmlHeader = parseExport("word/header2.xml"); - - if (!pXmlHeader) - return; - - xmlDocPtr pXmlHeaderRels = parseExport("word/_rels/header2.xml.rels"); - if(!pXmlHeaderRels) - return; - - assertXPath(pXmlHeaderRels,"/rels:Relationships/rels:Relationship[1]","Id","rId1"); -} - - -DECLARE_OOXMLEXPORT_TEST(testPageBreakInFirstPara,"fdo77727.docx") -{ - /* Break to next page was not exported if it is in first paragraph of the section. - * Now after fix , LO writes Next Page Break and also preserves <w:br> tag. - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br","type","page"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO78284, "fdo78284.docx") -{ - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - assertXPath(pXmlDoc,"/ContentType:Types/ContentType:Override[@PartName='/word/media/OOXDiagramDataRels1_0.png']", - "ContentType", - "image/png"); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO78384,"fdo78384.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[1]/w:rPr/w:rFonts","ascii","Wingdings"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo78469, "fdo78469.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/header1.xml"); - if (!pXmlDoc) - return; - // make sure dataBinding & text tags not presernt in sdtcontent - 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); - 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); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO78887, "fdo78887.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[1]", 1); - assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:t[1]", "Lyrics: "); - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[2]", 1); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo78651, "fdo78651.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if (!pXmlDoc) - return; - // ensure that there are only two tables - assertXPath(pXmlDoc, "//w:tbl", 2); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo78882, "fdo78882.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if (!pXmlDoc) - return; - - // Ensure that Section Break is getting written inside second paragraph - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:pPr[1]/w:sectPr[1]",1); - - // Ensure that no dummy paragarph gets created inside second paragraph for Section Break - assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:p[1]/w:pPr[1]/w:sectPr[1]",0); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo76934, "fdo76934.docx") -{ - /* Issue was, AuoSpacing property if present inside styles.xml, LO was not able to - * preserve it. - */ - - xmlDocPtr pXmlDoc = parseExport("word/styles.xml"); - - if (!pXmlDoc) - return; - - // Ensure that after fix LO is preserving AutoSpacing property in styles.xml - assertXPath ( pXmlDoc, "/w:styles[1]/w:style[36]/w:pPr[1]/w:spacing[1]", "beforeAutospacing", "1" ); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo79540, "fdo79540.docx") -{ - /* Issue was, <w:drawing> was getting written inside <w:drawing>. - * So Postone the writing of Inner Drawing tag. - * MS Office does not allow Nestimg of drawing tags. - */ - - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if (!pXmlDoc) - return; - - // Ensure that two separate w:drawing tags are written after the code changes. - assertXPath ( pXmlDoc, "/w:document/w:body/w:p/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing",1); - assertXPath ( pXmlDoc, "/w:document/w:body/w:p/w:r[3]/mc:AlternateContent/mc:Choice/w:drawing",1); -} - -DECLARE_OOXMLEXPORT_TEST(testFDO79062, "fdo79062.docx") -{ - xmlDocPtr pXmlFootNotes = parseExport("word/footnotes.xml"); - if (!pXmlFootNotes) - return; - assertXPath(pXmlFootNotes, "/w:footnotes", "Ignorable", "w14 wp14"); - - xmlDocPtr pXmlEndNotes = parseExport("word/endnotes.xml"); - if (!pXmlEndNotes) - return; - assertXPath(pXmlEndNotes, "/w:endnotes", "Ignorable", "w14 wp14"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo79668,"fdo79668.docx") -{ - // fdo#79668: Document was Crashing on DebugUtil build while Saving - // because of repeated attribute value in same element. - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - // w:pPr's w:shd attributes were getting added to w:pPrChange/w:pPr's w:shd hence checking - // w:fill for both shd elements - assertXPath ( pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:shd", "fill", "FFFFFF" ); - assertXPath ( pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:pPrChange/w:pPr/w:shd", "fill", "FFFFFF" ); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo78907,"fdo78907.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br", "type", "page" ); - - xmlDocPtr pXmlDoc1 = parseExport("word/footer1.xml"); - if (!pXmlDoc1) - return; - 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 ); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo79822, "fdo79822.docx") -{ - /* File getting crash while saving in LO. - * The Docx contain smartart and the file was created in ms word 2007 - */ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; -} - -DECLARE_OOXMLEXPORT_TEST(testFDO79915, "fdo79915.docx") -{ - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - - assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[8]/w:t", "How much buoyancy does the water provide?"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo79817, "fdo79817.docx") -{ - if (xmlDocPtr pXmlDoc = parseExport("word/document.xml")) - { - assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "storeItemID", "{9222E47B-A68B-4AEB-9855-21C912B9D3D2}"); - 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]"); - } -} - - -DECLARE_OOXMLEXPORT_TEST(testfdo79968_sldx, "fdo79968.docx") -{ - // This UT for DOCX embedded with powerpoint slide - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, - "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.presentationml.slide']", - "PartName", - "/word/embeddings/oleObject1.sldx"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo79969_xlsb, "fdo79969_xlsb.docx") -{ - // This UT for DOCX embedded with binary excel work sheet. - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, - "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-excel.sheet.binary.macroEnabled.12']", - "PartName", - "/word/embeddings/oleObject1.xlsb"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo80097, "fdo80097.docx") -{ - //fdo#76635 : Table borders are not getting preserved. - - xmlDocPtr pXmlDocument = parseExport("word/document.xml"); - if (!pXmlDocument) - return; - - //Table Borders - 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); - 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); - 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); - 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); - - 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); - 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); - 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); - 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); - - 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); - 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); - 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); - 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); - - 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); - 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); - 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); - 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); - - //Table Cell Borders - 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); - 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); - 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); - 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); - - 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); - 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); - 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); - 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); - - 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); - 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); - 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); - 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); - - 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); - 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); - 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); - 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); -} - -DECLARE_OOXMLEXPORT_TEST(testFdo77129, "fdo77129.docx") -{ - // The problem was that text after TOC field was missing if footer reference comes in field. - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - - if (!pXmlDoc) - return; - - // Data was lost from this paragraph. - assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[1]/w:t", "Abstract"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo79969_xlsm, "fdo79969_xlsm.docx") -{ - // This UT for DOCX embedded with excel work sheet. - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, - "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-excel.sheet.macroEnabled.12']", - "PartName", - "/word/embeddings/oleObject1.xlsm"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo80522,"fdo80522.docx") -{ - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, - "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-word.document.macroEnabled.12']", - "PartName", - "/word/embeddings/oleObject1.docm"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo80523_pptm,"fdo80523_pptm.docx") -{ - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, - "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-powerpoint.presentation.macroEnabled.12']", - "PartName", - "/word/embeddings/oleObject1.pptm"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo80523_sldm,"fdo80523_sldm.docx") -{ - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, - "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-powerpoint.slide.macroEnabled.12']", - "PartName", - "/word/embeddings/oleObject1.sldm"); -} - -DECLARE_OOXMLEXPORT_TEST(testfdo80898, "fdo80898.docx") -{ - // This UT for DOCX embedded with binary excel work sheet. - xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); - - if (!pXmlDoc) - return; - - assertXPath(pXmlDoc, - "/ContentType:Types/ContentType:Override[@ContentType='application/msword']", - "PartName", - "/word/embeddings/oleObject1.doc"); -} - -DECLARE_OOXMLEXPORT_TEST(testTableCellWithDirectFormatting, "fdo80800.docx") -{ - // Issue was Direct Foramatting for non-first Table cells was not getting preserved. - - xmlDocPtr pXmlDoc = parseExport("word/document.xml"); - if (!pXmlDoc) - return; - - // Ensure that for Third Table cell Direct Formatting is preserved. - // In file, Direct Formatting used for Third Table cell is Line Spacing="1.5 lines" - // For Line Spacing "1.5 lines" w:line equals 360 - assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc[3]/w:p/w:pPr/w:spacing","line","360"); - -} - -DECLARE_OOXMLEXPORT_TEST(test2colHeader, "2col-header.docx") -{ - // Header was lost on export when the document had multiple columns. - uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, "HeaderIsOn")); -} - -DECLARE_OOXMLEXPORT_TEST(testSdt2Run, "sdt-2-run.docx") -{ - xmlDocPtr pXmlDoc = parseExport(); - if (!pXmlDoc) - return; - - // The problem was that <w:sdt> was closed after "first", not after "second", so the second assert failed. - assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r[1]/w:t", "first"); - assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r[2]/w:t", "second"); - // Make sure the third portion is still outside <w:sdt>. - assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/w:t", "third"); -} - DECLARE_OOXMLEXPORT_TEST(testfdo81381, "fdo81381.docx") { if (xmlDocPtr pXmlDoc = parseExport("word/document.xml")) diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx new file mode 100644 index 000000000000..fcb5c8a9a770 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/ooxmlexport2.cxx @@ -0,0 +1,1118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/LineJoint.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/drawing/XControlShape.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/style/TabStop.hpp> +#include <com/sun/star/view/XViewSettingsSupplier.hpp> +#include <com/sun/star/text/RelOrientation.hpp> +#include <com/sun/star/text/XTextFrame.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XTextSection.hpp> +#include <com/sun/star/style/CaseMap.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/style/LineSpacingMode.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/table/BorderLine2.hpp> +#include <com/sun/star/table/ShadowFormat.hpp> +#include <com/sun/star/text/GraphicCrop.hpp> +#include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/text/WrapTextMode.hpp> +#include <com/sun/star/xml/dom/XDocument.hpp> +#include <com/sun/star/style/BreakType.hpp> +#include <unotools/tempfile.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <com/sun/star/text/XDocumentIndex.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/Hatch.hpp> + +#include <string> + +class Test : public SwModelTestBase +{ +public: + Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {} + +protected: + /** + * Blacklist handling + */ + bool mustTestImportOf(const char* filename) const SAL_OVERRIDE { + const char* aBlacklist[] = { + "math-escape.docx", + "math-mso2k7.docx", + "ImageCrop.docx", + "test_GIF_ImageCrop.docx", + "test_PNG_ImageCrop.docx" + }; + std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist)); + + // If the testcase is stored in some other format, it's pointless to test. + return (OString(filename).endsWith(".docx") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end()); + } +}; + +#if !defined(WNT) + +DECLARE_OOXMLEXPORT_TEST(testPageGraphicBackground, "page-graphic-background.odt") +{ + // No idea how the graphic background should be exported (seems there is no + // way to do a non-tiling export to OOXML), but at least the background + // color shouldn't be black. + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xPageStyle, "BackColor")); +} + +DECLARE_OOXMLEXPORT_TEST(testZoom, "zoom.docx") +{ + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<view::XViewSettingsSupplier> xViewSettingsSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xPropertySet(xViewSettingsSupplier->getViewSettings()); + sal_Int16 nValue = 0; + xPropertySet->getPropertyValue("ZoomValue") >>= nValue; + CPPUNIT_ASSERT_EQUAL(sal_Int16(42), nValue); + + // Validation test: order of elements were wrong. + xmlDocPtr pXmlDoc = parseExport("word/styles.xml"); + if (!pXmlDoc) + return; + // Order was: rsid, next. + int nNext = getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "next"); + int nRsid = getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "rsid"); + CPPUNIT_ASSERT(nNext < nRsid); + + pXmlDoc = parseExport("docProps/app.xml"); + // One paragraph in the document. + assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Paragraphs", "1"); + assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Company", "Example Ltd"); +} + +DECLARE_OOXMLEXPORT_TEST(defaultTabStopNotInStyles, "empty.odt") +{ +// The default tab stop was mistakenly exported to a style. +// xray ThisComponent.StyleFamilies(1)(0).ParaTabStop + uno::Reference< container::XNameAccess > paragraphStyles = getStyles( "ParagraphStyles" ); + uno::Reference< beans::XPropertySet > properties( paragraphStyles->getByName( "Standard" ), uno::UNO_QUERY ); + uno::Sequence< style::TabStop > stops = getProperty< uno::Sequence< style::TabStop > >( + paragraphStyles->getByName( "Standard" ), "ParaTabStops" ); +// There actually be be one tab stop, but it will be the default. + CPPUNIT_ASSERT_EQUAL( static_cast<sal_Int32>(1), stops.getLength()); + CPPUNIT_ASSERT_EQUAL( style::TabAlign_DEFAULT, stops[ 0 ].Alignment ); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo38244, "fdo38244.docx") +{ + /* + * Comments attached to a range was imported without the range, check for the annotation mark start/end positions. + * + * oParas = ThisComponent.Text.createEnumeration + * oPara = oParas.nextElement + * oRuns = oPara.createEnumeration + * oRun = oRuns.nextElement + * oRun = oRuns.nextElement 'Annotation + * oRun = oRuns.nextElement + * oRun = oRuns.nextElement 'AnnotationEnd + * xray oRun.TextPortionType + */ + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + xRunEnum->nextElement(); + uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Annotation"), getProperty<OUString>(xPropertySet, "TextPortionType")); + xRunEnum->nextElement(); + xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("AnnotationEnd"), getProperty<OUString>(xPropertySet, "TextPortionType")); + + /* + * Initials were not imported. + * + * oFields = ThisComponent.TextFields.createEnumeration + * oField = oFields.nextElement + * xray oField.Initials + */ + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials")); + + /* + * There was a fake empty paragraph at the end of the comment text. + * + * oFields = ThisComponent.TextFields.createEnumeration + * oField = oFields.nextElement + * oParas = oField.TextRange.createEnumeration + * oPara = oParas.nextElement + * oPara = oParas.nextElement + */ + + xParaEnumAccess.set(getProperty< uno::Reference<container::XEnumerationAccess> >(xPropertySet, "TextRange"), uno::UNO_QUERY); + xParaEnum = xParaEnumAccess->createEnumeration(); + xParaEnum->nextElement(); + bool bCaught = false; + try + { + xParaEnum->nextElement(); + } + catch (container::NoSuchElementException&) + { + bCaught = true; + } + CPPUNIT_ASSERT_EQUAL(true, bCaught); +} + +DECLARE_OOXMLEXPORT_TEST(testCommentsNested, "comments-nested.odt") +{ + uno::Reference<beans::XPropertySet> xOuter(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 2), "TextField"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Outer"), getProperty<OUString>(xOuter, "Content")); + + uno::Reference<beans::XPropertySet> xInner(getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(1), 4), "TextField"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Inner"), getProperty<OUString>(xInner, "Content")); +} + +DECLARE_OOXMLEXPORT_TEST(testMathEscape, "math-escape.docx") +{ + CPPUNIT_ASSERT_EQUAL(OUString("\\{ left [ right ] left ( right ) \\}"), getFormula(getRun(getParagraph(1), 1))); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo51034, "fdo51034.odt") +{ + // The problem was that the 'l' param of the HYPERLINK field was parsed with = "#", not += "#". + CPPUNIT_ASSERT_EQUAL(OUString("http://Www.google.com/#a"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL")); +} + +// Construct the expected formula from UTF8, as there may be such characters. +// Remove all spaces, as LO export/import may change that. +// Replace symbol - (i.e. U+2212) with ASCII - , LO does this change and it shouldn't matter. +#define CHECK_FORMULA( expected, actual ) \ + CPPUNIT_ASSERT_EQUAL( \ + OUString( expected, strlen( expected ), RTL_TEXTENCODING_UTF8 ) \ + .replaceAll( " ", "" ).replaceAll( OUString( "\xe2\x88\x92", strlen( "\xe2\x88\x92" ), RTL_TEXTENCODING_UTF8 ), "-" ), \ + OUString( actual ).replaceAll( " ", "" ).replaceAll( OUString( "\xe2\x88\x92", strlen( "\xe2\x88\x92" ), RTL_TEXTENCODING_UTF8 ), "-" )) + +DECLARE_OOXMLEXPORT_TEST(testMathAccents, "math-accents.docx") +{ + CHECK_FORMULA( + "acute {a} grave {a} check {a} breve {a} circle {a} widevec {a} widetilde {a}" + " widehat {a} dot {a} widevec {a} widevec {a} widetilde {a} underline {a}", + getFormula( getRun( getParagraph( 1 ), 1 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathD, "math-d.docx") +{ + CHECK_FORMULA( "left (x mline y mline z right )", getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA( "left (1 right )", getFormula( getRun( getParagraph( 1 ), 2 ))); + CHECK_FORMULA( "left [2 right ]", getFormula( getRun( getParagraph( 1 ), 3 ))); + CHECK_FORMULA( "left ldbracket 3 right rdbracket", getFormula( getRun( getParagraph( 1 ), 4 ))); + CHECK_FORMULA( "left lline 4 right rline", getFormula( getRun( getParagraph( 1 ), 5 ))); + CHECK_FORMULA( "left ldline 5 right rdline", getFormula( getRun( getParagraph( 1 ), 6 ))); + CHECK_FORMULA( "left langle 6 right rangle", getFormula( getRun( getParagraph( 1 ), 7 ))); + CHECK_FORMULA( "left langle a mline b right rangle", getFormula( getRun( getParagraph( 1 ), 8 ))); + CHECK_FORMULA( "left ({x} over {y} right )", getFormula( getRun( getParagraph( 1 ), 9 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathEscaping, "math-escaping.docx") +{ + CHECK_FORMULA( "\xe2\x88\x92 \xe2\x88\x9e < x < \xe2\x88\x9e", getFormula( getRun( getParagraph( 1 ), 1 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathLim, "math-lim.docx") +{ + CHECK_FORMULA( "lim from {x \xe2\x86\x92 1} {x}", getFormula( getRun( getParagraph( 1 ), 1 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathMalformedXml, "math-malformed_xml.docx") +{ + CPPUNIT_ASSERT_EQUAL( 0, getLength()); +} + +DECLARE_OOXMLEXPORT_TEST(testMathMatrix, "math-matrix.docx") +{ + CHECK_FORMULA( "left [matrix {1 # 2 ## 3 # 4} right ]", getFormula( getRun( getParagraph( 1 ), 1 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathMso2k7, "math-mso2k7.docx") +{ + CHECK_FORMULA( "A = \xcf\x80 {r} ^ {2}", getFormula( getRun( getParagraph( 1 ), 1 ))); +// TODO check the stack/binom difference +// CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (binom {n} {k} right ) {x} ^ {k} {a} ^ {n-k}}", + CHECK_FORMULA( "{left (x+a right )} ^ {n} = sum from {k=0} to {n} {left (stack {n # k} right ) {x} ^ {k} {a} ^ {n-k}}", + getFormula( getRun( getParagraph( 2 ), 1 ))); + CHECK_FORMULA( "{left (1+x right )} ^ {n} =1+ {nx} over {1!} + {n left (n-1 right ) {x} ^ {2}} over {2!} +\xe2\x80\xa6", + getFormula( getRun( getParagraph( 3 ), 1 ))); +// TODO check (cos/sin miss {}) +// CHECK_FORMULA( "f left (x right ) = {a} rsub {0} + sum from {n=1} to {\xe2\x88\x9e} {left ({a} rsub {n} cos {{n\xcf\x80x} over {L}} + {b} rsub {n} sin {{n\xcf\x80x} over {L}} right )}", + CHECK_FORMULA( "f left (x right ) = {a} rsub {0} + sum from {n=1} to {\xe2\x88\x9e} {left ({a} rsub {n} cos {n\xcf\x80x} over {L} + {b} rsub {n} sin {n\xcf\x80x} over {L} right )}", + getFormula( getRun( getParagraph( 4 ), 1 ))); + CHECK_FORMULA( "{a} ^ {2} + {b} ^ {2} = {c} ^ {2}", getFormula( getRun( getParagraph( 5 ), 1 ))); + CHECK_FORMULA( "x = {- b \xc2\xb1 sqrt {{b} ^ {2} -4 ac}} over {2 a}", + getFormula( getRun( getParagraph( 6 ), 1 ))); + CHECK_FORMULA( + "{e} ^ {x} =1+ {x} over {1!} + {{x} ^ {2}} over {2!} + {{x} ^ {3}} over {3!} +\xe2\x80\xa6, -\xe2\x88\x9e<x<\xe2\x88\x9e", + getFormula( getRun( getParagraph( 7 ), 1 ))); + CHECK_FORMULA( +// "sin {\xce\xb1} \xc2\xb1 sin {\xce\xb2} =2 sin {{1} over {2} left (\xce\xb1\xc2\xb1\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1\xe2\x88\x93\xce\xb2 right )}", +// TODO check (cos/in miss {}) + "sin \xce\xb1 \xc2\xb1 sin \xce\xb2 =2 sin {1} over {2} left (\xce\xb1\xc2\xb1\xce\xb2 right ) cos {1} over {2} left (\xce\xb1\xe2\x88\x93\xce\xb2 right )", + getFormula( getRun( getParagraph( 8 ), 1 ))); + CHECK_FORMULA( +// "cos {\xce\xb1} + cos {\xce\xb2} =2 cos {{1} over {2} left (\xce\xb1+\xce\xb2 right )} cos {{1} over {2} left (\xce\xb1-\xce\xb2 right )}", +// TODO check (cos/sin miss {}) + "cos \xce\xb1 + cos \xce\xb2 =2 cos {1} over {2} left (\xce\xb1+\xce\xb2 right ) cos {1} over {2} left (\xce\xb1-\xce\xb2 right )", + getFormula( getRun( getParagraph( 9 ), 1 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathNary, "math-nary.docx") +{ + CHECK_FORMULA( "lllint from {1} to {2} {x + 1}", getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA( "prod from {a} {b}", getFormula( getRun( getParagraph( 1 ), 2 ))); + CHECK_FORMULA( "sum to {2} {x}", getFormula( getRun( getParagraph( 1 ), 3 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathOverbraceUnderbrace, "math-overbrace_underbrace.docx") +{ + CHECK_FORMULA( "{abcd} overbrace {4}", getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA( "{xyz} underbrace {3}", getFormula( getRun( getParagraph( 2 ), 1 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathOverstrike, "math-overstrike.docx") +{ + CHECK_FORMULA( "overstrike {abc}", getFormula( getRun( getParagraph( 1 ), 1 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathPlaceholders, "math-placeholders.docx") +{ + CHECK_FORMULA( "sum from <?> to <?> <?>", getFormula( getRun( getParagraph( 1 ), 1 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathRad, "math-rad.docx") +{ + CHECK_FORMULA( "sqrt {4}", getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA( "nroot {3} {x + 1}", getFormula( getRun( getParagraph( 1 ), 2 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathSubscripts, "math-subscripts.docx") +{ + CHECK_FORMULA( "{x} ^ {y} + {e} ^ {x}", getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA( "{x} ^ {b}", getFormula( getRun( getParagraph( 1 ), 2 ))); + CHECK_FORMULA( "{x} rsub {b}", getFormula( getRun( getParagraph( 1 ), 3 ))); + CHECK_FORMULA( "{a} rsub {c} rsup {b}", getFormula( getRun( getParagraph( 1 ), 4 ))); + CHECK_FORMULA( "{x} lsub {2} lsup {1}", getFormula( getRun( getParagraph( 1 ), 5 ))); + CHECK_FORMULA( "{{x csup {6} csub {3}} lsub {4} lsup {5}} rsub {2} rsup {1}", + getFormula( getRun( getParagraph( 1 ), 6 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testMathVerticalStacks, "math-vertical_stacks.docx") +{ + CHECK_FORMULA( "{a} over {b}", getFormula( getRun( getParagraph( 1 ), 1 ))); + CHECK_FORMULA( "{a} / {b}", getFormula( getRun( getParagraph( 2 ), 1 ))); +// TODO check these +// CHECK_FORMULA( "binom {a} {b}", getFormula( getRun( getParagraph( 3 ), 1 ))); +// CHECK_FORMULA( "binom {a} {binom {b} {c}}", getFormula( getRun( getParagraph( 4 ), 1 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testTable, "table.odt") +{ + // Validation test: order of elements were wrong. + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + // Order was: insideH, end, insideV. + int nEnd = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "end"); + int nInsideH = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "insideH"); + int nInsideV = getXPathPosition(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblBorders", "insideV"); + CPPUNIT_ASSERT(nEnd < nInsideH); + CPPUNIT_ASSERT(nInsideH < nInsideV); + + // Make sure we write qFormat for well-known style names. + assertXPath(parseExport("word/styles.xml"), "//w:style[@w:styleId='Normal']/w:qFormat", 1); +} + +DECLARE_OOXMLEXPORT_TEST(testTablePosition, "table-position.docx") +{ + sal_Int32 xCoordsFromOffice[] = { 2500, -1000, 0, 0 }; + sal_Int32 cellLeftMarginFromOffice[] = { 250, 100, 0, 0 }; + + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); + + for (int i=0; i<4; i++) { + uno::Reference<text::XTextTable> xTable1 (xTables->getByIndex(i), uno::UNO_QUERY); + // Verify X coord + uno::Reference<view::XSelectionSupplier> xCtrl(xModel->getCurrentController(), uno::UNO_QUERY); + xCtrl->select(uno::makeAny(xTable1)); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xCtrl, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + awt::Point pos = xCursor->getPosition(); + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Incorrect X coord computed from docx", + xCoordsFromOffice[i], pos.X, 1); + + // Verify left margin of 1st cell : + // * Office left margins are measured relative to the right of the border + // * LO left spacing is measured from the center of the border + uno::Reference<table::XCell> xCell = xTable1->getCellByName("A1"); + uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW); + sal_Int32 aLeftMargin = -1; + xPropSet->getPropertyValue("LeftBorderDistance") >>= aLeftMargin; + uno::Any aLeftBorder = xPropSet->getPropertyValue("LeftBorder"); + table::BorderLine2 aLeftBorderLine; + aLeftBorder >>= aLeftBorderLine; + CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE("Incorrect left spacing computed from docx cell margin", + cellLeftMarginFromOffice[i], aLeftMargin - 0.5 * aLeftBorderLine.LineWidth, 1); + } +} + +struct SingleLineBorders { + sal_Int16 top, bottom, left, right; + SingleLineBorders(int t=0, int b=0, int l=0, int r=0) + : top(t), bottom(b), left(l), right(r) {} + sal_Int16 getBorder(int i) const + { + switch (i) { + case 0: return top; + case 1: return bottom; + case 2: return left; + case 3: return right; + default: assert(false); return 0; + } + } +}; + +DECLARE_OOXMLEXPORT_TEST(testTableBorders, "table-borders.docx") +{ + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xTables->getCount()); + uno::Reference<text::XTextTable> xTextTable (xTables->getByIndex(0), uno::UNO_QUERY); + + std::map<OUString, SingleLineBorders> cellBorders; + cellBorders[OUString("A1")] = SingleLineBorders(106, 106, 106, 106); + cellBorders[OUString("B1")] = SingleLineBorders(106, 0, 106, 35); + cellBorders[OUString("C1")] = SingleLineBorders(106, 106, 35, 106); + cellBorders[OUString("A2")] = SingleLineBorders(106, 35, 106, 0); + cellBorders[OUString("B2")] = SingleLineBorders(0, 0, 0, 0); + cellBorders[OUString("C2")] = SingleLineBorders(106, 106, 0, 106); + cellBorders[OUString("A3")] = SingleLineBorders(35, 35, 106, 106); + cellBorders[OUString("B3")] = SingleLineBorders(0, 106, 106, 106); + cellBorders[OUString("C3")] = SingleLineBorders(106, 106, 106, 106); + cellBorders[OUString("A4")] = SingleLineBorders(35, 106, 106, 35); + cellBorders[OUString("B4")] = SingleLineBorders(106, 106, 35, 106); + cellBorders[OUString("C4")] = SingleLineBorders(106, 106, 106, 106); + + const OUString borderNames[] = { + OUString("TopBorder"), + OUString("BottomBorder"), + OUString("LeftBorder"), + OUString("RightBorder"), + }; + + uno::Sequence<OUString> const cells = xTextTable->getCellNames(); + sal_Int32 nLength = cells.getLength(); + CPPUNIT_ASSERT_EQUAL((sal_Int32)cellBorders.size(), nLength); + + for (sal_Int32 i = 0; i < nLength; ++i) + { + uno::Reference<table::XCell> xCell = xTextTable->getCellByName(cells[i]); + uno::Reference< beans::XPropertySet > xPropSet(xCell, uno::UNO_QUERY_THROW); + const SingleLineBorders& borders = cellBorders[cells[i]]; + + for (sal_Int32 j = 0; j < 4; ++j) + { + uno::Any aBorder = xPropSet->getPropertyValue(borderNames[j]); + table::BorderLine aBorderLine; + if (aBorder >>= aBorderLine) + { + std::stringstream message; + message << cells[i] << "'s " << borderNames[j] << " is incorrect"; + CPPUNIT_ASSERT_EQUAL_MESSAGE(message.str(), + borders.getBorder(j), aBorderLine.OuterLineWidth); + } + } + } +} + +DECLARE_OOXMLEXPORT_TEST(testFdo51550, "fdo51550.odt") +{ + // The problem was that we lacked the fallback to export the replacement graphic for OLE objects. + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); +} + +/* + * doesn't work on openSUSE12.2 at least +DECLARE_OOXMLEXPORT_TEST(test1Table1Page, "1-table-1-page.docx") +{ + // 2 problem for this document after export: + // - invalid sectPr inserted at the beginning of the page + // - font of empty cell is not preserved, leading to change in rows height + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage()); +} +*/ + +DECLARE_OOXMLEXPORT_TEST(testTextFrames, "textframes.odt") +{ + // The frames were simply missing, so let's check if all 3 frames were imported back. + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xIndexAccess->getCount()); +} + +DECLARE_OOXMLEXPORT_TEST(testTextFrameBorders, "textframe-borders.docx") +{ + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + if (xIndexAccess->getCount()) + { + // After import, a TextFrame is created by the VML import. + uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xFrame, "BackColor")); + + table::BorderLine2 aBorder = getProperty<table::BorderLine2>(xFrame, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aBorder.Color); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(35), aBorder.LineWidth); + + table::ShadowFormat aShadowFormat = getProperty<table::ShadowFormat>(xFrame, "ShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadowFormat.Location); + CPPUNIT_ASSERT_EQUAL(sal_Int16(48), aShadowFormat.ShadowWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aShadowFormat.Color); + } + else + { + // After export and import, the result is a shape. + uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), getProperty<sal_Int32>(xShape, "FillColor")); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), getProperty<sal_Int32>(xShape, "LineColor")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(35), getProperty<sal_Int32>(xShape, "LineWidth")); + + CPPUNIT_ASSERT_EQUAL(sal_Int32(48), getProperty<sal_Int32>(xShape, "ShadowXDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(48), getProperty<sal_Int32>(xShape, "ShadowYDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), getProperty<sal_Int32>(xShape, "ShadowColor")); + } +} + +DECLARE_OOXMLEXPORT_TEST(testTextframeGradient, "textframe-gradient.docx") +{ + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); + + uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle")); + awt::Gradient aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0504D), aGradient.StartColor); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xD99594), aGradient.EndColor); + CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style); + + xFrame.set(xIndexAccess->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame, "FillStyle")); + aGradient = getProperty<awt::Gradient>(xFrame, "FillGradient"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x000000), aGradient.StartColor); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x666666), aGradient.EndColor); + CPPUNIT_ASSERT_EQUAL(awt::GradientStyle_AXIAL, aGradient.Style); + + // Left / right margin was incorrect: the attribute was missing and we + // didn't have the right default (had 0 instead of the below one). + CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xFrame, "LeftMargin")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xFrame, "RightMargin")); +} + +DECLARE_OOXMLEXPORT_TEST(testCellBtlr, "cell-btlr.docx") +{ + /* + * The problem was that the exporter didn't mirror the workaround of the + * importer, regarding the btLr text direction: the <w:textDirection + * w:val="btLr"/> token was completely missing in the output. + */ + + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:tcPr/w:textDirection", "val", "btLr"); +} + +DECLARE_OOXMLEXPORT_TEST(testTableStylerPrSz, "table-style-rPr-sz.docx") +{ + // Verify that font size inside the table is 20pt, despite the sz attribute in the table size. + // Also check that other rPr attribute are used: italic, bold, underline + // Office has the same behavior + uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTextTablesSupplier->getTextTables(), uno::UNO_QUERY); + uno::Reference<text::XTextTable> xTable(xTables->getByIndex(0), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xCell->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + uno::Reference<text::XTextRange> xPara(xParaEnum->nextElement(), uno::UNO_QUERY); + + CPPUNIT_ASSERT_EQUAL(20.f, getProperty<float>(getRun(xPara, 1), "CharHeight")); +// CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<short>(getRun(xPara, 1), "CharUnderline")); +// CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, getProperty<float>(getRun(xPara, 1), "CharWeight")); +// CPPUNIT_ASSERT_EQUAL(awt::FontSlant_ITALIC, getProperty<awt::FontSlant>(getRun(xPara, 1), "CharPosture")); +} + +DECLARE_OOXMLEXPORT_TEST(testMathLiteral, "math-literal.docx") +{ + CHECK_FORMULA( "iiint from {V} to <?> {\"div\" \"F\"} dV= llint from {S} to <?> {\"F\" \xe2\x88\x99 \"n \" dS}", + getFormula( getRun( getParagraph( 1 ), 1 ))); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo48557, "fdo48557.odt") +{ + // Inner margins of the textframe wasn't exported. + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextLeftDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextRightDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextUpperDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "TextLowerDistance")); +} + +DECLARE_OOXMLEXPORT_TEST(testI120928, "i120928.docx") +{ + // w:numPicBullet was ignored, leading to missing graphic bullet in numbering. + uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aProps; + xLevels->getByIndex(0) >>= aProps; // 1st level + + bool bIsGraphic = false; + for (int i = 0; i < aProps.getLength(); ++i) + { + const beans::PropertyValue& rProp = aProps[i]; + + if (rProp.Name == "NumberingType") + CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>()); + else if (rProp.Name == "GraphicURL") + bIsGraphic = true; + } + CPPUNIT_ASSERT_EQUAL(true, bIsGraphic); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo64826, "fdo64826.docx") +{ + // 'Track-Changes' (Track Revisions) wasn't exported. + CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(mxComponent, "RecordChanges"))); +} + +DECLARE_OOXMLEXPORT_TEST(testPageBackground, "page-background.docx") +{ + // 'Document Background' wasn't exported. + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x92D050), getProperty<sal_Int32>(xPageStyle, "BackColor")); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo65265, "fdo65265.docx") +{ + // Redline (tracked changes) of text formatting were not exported + uno::Reference<text::XTextRange> xParagraph1 = getParagraph(1); + uno::Reference<text::XTextRange> xParagraph2 = getParagraph(2); + + CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty<OUString>(getRun(xParagraph1, 3), "RedlineType")); + CPPUNIT_ASSERT_EQUAL(OUString("Format"), getProperty<OUString>(getRun(xParagraph2, 2), "RedlineType")); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo65655, "fdo65655.docx") +{ + // The problem was that the DOCX had a non-blank odd footer and a blank even footer + // The 'Different Odd & Even Pages' was turned on + // However - LO assumed that because the 'even' footer is blank - it should ignore the 'Different Odd & Even Pages' flag + // So it did not import it and did not export it + uno::Reference<beans::XPropertySet> xPropertySet(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); + bool bValue = false; + xPropertySet->getPropertyValue("HeaderIsShared") >>= bValue; + CPPUNIT_ASSERT_EQUAL(false, bool(bValue)); + xPropertySet->getPropertyValue("FooterIsShared") >>= bValue; + CPPUNIT_ASSERT_EQUAL(false, bool(bValue)); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO63053, "fdo63053.docx") +{ + uno::Reference<document::XDocumentPropertiesSupplier> xDocumentPropertiesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<document::XDocumentProperties> xDocumentProperties = xDocumentPropertiesSupplier->getDocumentProperties(); + CPPUNIT_ASSERT_EQUAL(OUString("test1&test2"), xDocumentProperties->getTitle()); + CPPUNIT_ASSERT_EQUAL(OUString("test1&test2"), xDocumentProperties->getSubject()); +} + +DECLARE_OOXMLEXPORT_TEST(testWatermark, "watermark.docx") +{ + uno::Reference<text::XTextRange> xShape(getShape(1), uno::UNO_QUERY); + // 1st problem: last character was missing + CPPUNIT_ASSERT_EQUAL(OUString("SAMPLE"), xShape->getString()); + + uno::Reference<beans::XPropertySet> xPropertySet(xShape, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xShape, "CustomShapeGeometry"); + bool bFound = false; + for (int i = 0; i < aProps.getLength(); ++i) + if (aProps[i].Name == "TextPath") + bFound = true; + // 2nd problem: v:textpath wasn't imported + CPPUNIT_ASSERT_EQUAL(true, bFound); + + // 3rd problem: rotation angle was 315, not 45. + CPPUNIT_ASSERT_EQUAL(sal_Int32(45 * 100), getProperty<sal_Int32>(xShape, "RotateAngle")); + + // 4th problem: mso-position-vertical-relative:margin was ignored, VertOrientRelation was text::RelOrientation::FRAME. + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_PRINT_AREA, getProperty<sal_Int16>(xShape, "VertOrientRelation")); + + // These problems were in the exporter + // The textpath wasn't semi-transparent. + CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty<sal_Int16>(xShape, "FillTransparence")); + // The textpath had a stroke. + CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, getProperty<drawing::LineStyle>(xShape, "LineStyle")); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo43093, "fdo43093.docx") +{ + // The problem was that the alignment are not exchange when the paragraph are RTL. + uno::Reference<uno::XInterface> xParaRtlLeft(getParagraph( 1, "RTL Left")); + sal_Int32 nRtlLeft = getProperty< sal_Int32 >( xParaRtlLeft, "ParaAdjust" ); + // test the text Direction value for the pragraph + sal_Int16 nRLDir = getProperty< sal_Int32 >( xParaRtlLeft, "WritingMode" ); + + uno::Reference<uno::XInterface> xParaRtlRight(getParagraph( 3, "RTL Right")); + sal_Int32 nRtlRight = getProperty< sal_Int32 >( xParaRtlRight, "ParaAdjust" ); + sal_Int16 nRRDir = getProperty< sal_Int32 >( xParaRtlRight, "WritingMode" ); + + uno::Reference<uno::XInterface> xParaLtrLeft(getParagraph( 5, "LTR Left")); + sal_Int32 nLtrLeft = getProperty< sal_Int32 >( xParaLtrLeft, "ParaAdjust" ); + sal_Int16 nLLDir = getProperty< sal_Int32 >( xParaLtrLeft, "WritingMode" ); + + uno::Reference<uno::XInterface> xParaLtrRight(getParagraph( 7, "LTR Right")); + sal_Int32 nLtrRight = getProperty< sal_Int32 >( xParaLtrRight, "ParaAdjust" ); + sal_Int16 nLRDir = getProperty< sal_Int32 >( xParaLtrRight, "WritingMode" ); + + // this will test the both the text direction and alignment for each paragraph + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nRtlLeft); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRLDir); + + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nRtlRight); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::RL_TB, nRRDir); + + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLtrLeft); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLLDir); + + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_RIGHT), nLtrRight); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo64238_a, "fdo64238_a.docx") +{ + // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled* + // then LO would still import the Even footer and concatenate it to to the odd footer. + // This case specifically is for : + // 'Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word + // In this case the imported footer in LO was supposed to be blank, but instead was the 'even' footer + uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText"); + uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText ); + uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + sal_Int32 numOfRuns = 0; + while (xRunEnum->hasMoreElements()) + { + uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY); + numOfRuns++; + } + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), numOfRuns); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo64238_b, "fdo64238_b.docx") +{ + // The problem was that when 'Show Only Odd Footer' was marked in Word and the Even footer *was filled* + // then LO would still import the Even footer and concatenate it to to the odd footer. + // This case specifically is for : + // 'Non-Blank Odd Footer' with 'Non-Blank Even Footer' when 'Show Only Odd Footer' is marked in Word + // In this case the imported footer in LO was supposed to be just the odd footer, but instead was the 'odd' and 'even' footers concatenated + uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText"); + uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText ); + uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xFooterParagraph, uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + sal_Int32 numOfRuns = 0; + while (xRunEnum->hasMoreElements()) + { + uno::Reference<text::XTextRange> xRun(xRunEnum->nextElement(), uno::UNO_QUERY); + numOfRuns++; + } + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), numOfRuns); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo56679, "fdo56679.docx") +{ + // The problem was that the DOCX importer and exporter did not handle the 'color' of an underline + // (not the color of the text, the color of the underline itself) + uno::Reference< text::XTextRange > xParagraph = getParagraph( 1 ); + uno::Reference< text::XTextRange > xText = getRun( xParagraph, 2, "This is a simple sentence."); + + CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xText, "CharUnderlineHasColor"))); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xFF0000), getProperty<sal_Int32>(xText, "CharUnderlineColor")); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo65400, "fdo65400.docx") +{ + // The problem was that if in Word you choose 'Character Shading' - then the text portion + // is marked with 'w:shd val=pct15'. LO did not store this value and so when importing and exporting + // this value was lost (and so Word did not show 'Character Shading' was on) + uno::Reference< text::XTextRange > paragraph1 = getParagraph( 1 ); + uno::Reference< text::XTextRange > shaded = getRun( paragraph1, 2, "normal" ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0x0026 ), getProperty< sal_Int32 >( shaded, "CharShadingValue" )); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0xd8d8d8 ), getProperty< sal_Int32 >( shaded, "CharBackColor" )); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo66543, "fdo66543.docx") +{ + // The problem was that when importing DOCX with 'line numbers' - the 'start value' was imported + // but nothing was done with it. + + uno::Reference< text::XTextRange > paragraph1 = getParagraph( 1 ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 1 ), getProperty< sal_Int32 >( paragraph1, "ParaLineNumberStartValue" )); +} + +DECLARE_OOXMLEXPORT_TEST(testN822175, "n822175.odt") +{ + uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY); + // Was text::WrapTextMode_THROUGH, due to missing Surround handling in the exporter. + CPPUNIT_ASSERT_EQUAL(text::WrapTextMode_PARALLEL, getProperty<text::WrapTextMode>(xFrame, "Surround")); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo66688, "fdo66688.docx") +{ + // The problem was that TextFrame imported and exported the wrong value for transparency + // (was stored as 'FillTransparence' instead of 'BackColorTransparency' + uno::Reference<beans::XPropertySet> xFrame(getShape(2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 80 ), getProperty< sal_Int32 >( xFrame, "FillTransparence" ) ); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo66773, "fdo66773.docx") +{ + // The problem was the line spacing was interpreted by Word as 'Multiple 1.08' if no default settings were written. + // Now after the 'docDefaults' section is written in <styles.xml> - there is no more problem. + // (Word does not try to calculate some arbitrary value for line spacing). + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + CPPUNIT_ASSERT(xParaEnum->hasMoreElements()); + + style::LineSpacing alineSpacing = getProperty<style::LineSpacing>(xParaEnum->nextElement(), "ParaLineSpacing"); + CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::PROP, alineSpacing.Mode); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(100), static_cast<sal_Int32>(alineSpacing.Height)); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo58577, "fdo58577.odt") +{ + // The second frame was simply missing, so let's check if both frames were imported back. + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xIndexAccess->getCount()); +} + +DECLARE_OOXMLEXPORT_TEST(testBnc581614, "bnc581614.doc") +{ + uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE, getProperty<drawing::FillStyle>(xFrame, "FillStyle")); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo66929, "fdo66929.docx") +{ + // The problem was that the default 'inset' attribute of the 'textbox' node was exported incorrectly. + // A node like '<v:textbox inset="0">' was exported back as '<v:textbox inset="0pt,0pt,0pt,0pt">' + // This is wrong because the original node denotes a specific 'left' inset, and a default 'top','right','bottom' inset + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + if (xIndexAccess->getCount()) + { + // VML import -> TextFrame + uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 0 ) , getProperty< sal_Int32 >( xFrame, "LeftBorderDistance" ) ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty< sal_Int32 >( xFrame, "TopBorderDistance" ) ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 254 ), getProperty< sal_Int32 >( xFrame, "RightBorderDistance" ) ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty< sal_Int32 >( xFrame, "BottomBorderDistance" ) ); + } + else + { + // drawingML import -> shape with TextBox + uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xShape, "TextLeftDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(127), getProperty<sal_Int32>(xShape, "TextUpperDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(254), getProperty<sal_Int32>(xShape, "TextRightDistance")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(127), getProperty<sal_Int32>(xShape, "TextLowerDistance")); + } +} + +DECLARE_OOXMLEXPORT_TEST(testPageBorderSpacingExportCase2, "page-borders-export-case-2.docx") +{ + // The problem was that the exporter didn't mirror the workaround of the + // importer, regarding the page border's spacing : the <w:pgBorders w:offsetFrom="page"> + // and the inner nodes like <w:top w:space="24" .... /> + // + // The exporter ALWAYS exported 'w:offsetFrom="text"' even when the spacing values where too large + // for Word to handle (larger than 31 points) + + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + + // Assert the XPath expression - page borders + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgBorders", "offsetFrom", "page"); + + // Assert the XPath expression - 'left' border + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgBorders/w:left", "space", "24"); + + // Assert the XPath expression - 'right' border + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgBorders/w:right", "space", "24"); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo66145, "fdo66145.docx") +{ + // The Writer ignored the 'First Is Shared' flag + CPPUNIT_ASSERT_EQUAL(OUString("This is the FIRST page header."), + parseDump("/root/page[1]/header/txt/text()")); + CPPUNIT_ASSERT_EQUAL( + OUString("This is the header for the REST OF THE FILE."), + parseDump("/root/page[2]/header/txt/text()")); + CPPUNIT_ASSERT_EQUAL( + OUString("This is the header for the REST OF THE FILE."), + parseDump("/root/page[3]/header/txt/text()")); +} + +DECLARE_OOXMLEXPORT_TEST(testGrabBag, "grabbag.docx") +{ + // w:mirrorIndents was lost on roundtrip, now should be handled as a grab bag property + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:mirrorIndents"); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo66781, "fdo66781.docx") +{ + // The problem was that bullets with level=0 were shown in LO as normal bullets, + // and when saved back to DOCX were saved with level=1 (so hidden bullets became visible) + uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aProps; + xLevels->getByIndex(0) >>= aProps; // 1st level + + for (int i = 0; i < aProps.getLength(); ++i) + { + const beans::PropertyValue& rProp = aProps[i]; + if (rProp.Name == "BulletChar") + { + CPPUNIT_ASSERT_EQUAL(OUString("\x0", 1, RTL_TEXTENCODING_UTF8), rProp.Value.get<OUString>()); + return; + } + } + + // Shouldn't reach here + CPPUNIT_FAIL("Did not find bullet with level 0"); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo60990, "fdo60990.odt") +{ + // The shape had no background, no paragraph adjust and no font color. + uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00CFE7F5), getProperty<sal_Int32>(xShape, "FillColor")); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY)->getText(); + uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText); + CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, "ParaAdjust"))); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x00FF00), getProperty<sal_Int32>(getRun(xParagraph, 1), "CharColor")); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo65718, "fdo65718.docx") +{ + // The problem was that the exporter always exported values of "0" for an images distance from text. + // the actual attributes where 'distT', 'distB', 'distL', 'distR' + uno::Reference<beans::XPropertySet> xPropertySet(getShape(1), uno::UNO_QUERY); + + CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(0) ), getProperty<sal_Int32>(xPropertySet, "TopMargin") ); + CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(0) ), getProperty<sal_Int32>(xPropertySet, "BottomMargin") ); + + // Going to do '+1' because the 'getProperty' return 318 (instead of 317.5) + // I think this is because it returns an integer, instead of a float. + // The actual exporting to DOCX exports the correct value (114300 = 317.5 * 360) + // The exporting to DOCX uses the 'SvxLRSpacing' that stores the value in TWIPS (180 TWIPS) + // However, the 'LeftMargin' property is an integer property that holds that value in 'MM100' (should hold 317.5, but it is 318) + // So I had to add the hack of the '+1' to make the test-case pass + CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(114300) + 1 ), getProperty<sal_Int32>(xPropertySet, "LeftMargin") ); + CPPUNIT_ASSERT_EQUAL(sal_Int32( EMU_TO_MM100(114300) + 1), getProperty<sal_Int32>(xPropertySet, "RightMargin") ); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo64350, "fdo64350.docx") +{ + // The problem was that page border shadows were not exported + table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "ShadowFormat"); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo67013, "fdo67013.docx") +{ + /* + * The problem was that borders inside headers \ footers were not exported + * This was checked in xray using these commands: + * + * xHeaderText = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Standard").HeaderText + * xHeaderEnum = xHeaderText.createEnumeration() + * xHeaderFirstParagraph = xHeaderEnum.nextElement() + * xHeaderBottomBorder = xHeaderFirstParagraph.BottomBorder + * + * xFooterText = ThisComponent.getStyleFamilies().getByName("PageStyles").getByName("Standard").FooterText + * xFooterEnum = xFooterText.createEnumeration() + * xFooterFirstParagraph = xFooterEnum.nextElement() + * xFooterTopBorder = xFooterFirstParagraph.TopBorder + */ + uno::Reference<text::XText> xHeaderText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "HeaderText"); + uno::Reference< text::XTextRange > xHeaderParagraph = getParagraphOfText( 1, xHeaderText ); + table::BorderLine2 aHeaderBottomBorder = getProperty<table::BorderLine2>(xHeaderParagraph, "BottomBorder"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aHeaderBottomBorder.Color); + CPPUNIT_ASSERT_EQUAL(sal_Int16(106), aHeaderBottomBorder.InnerLineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aHeaderBottomBorder.LineDistance); + CPPUNIT_ASSERT_EQUAL(sal_Int16(7), aHeaderBottomBorder.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aHeaderBottomBorder.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aHeaderBottomBorder.OuterLineWidth); + + uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText"); + uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText ); + table::BorderLine2 aFooterTopBorder = getProperty<table::BorderLine2>(xFooterParagraph, "TopBorder"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x622423), aFooterTopBorder.Color); + CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aFooterTopBorder.InnerLineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int16(26), aFooterTopBorder.LineDistance); + CPPUNIT_ASSERT_EQUAL(sal_Int16(4), aFooterTopBorder.LineStyle); + CPPUNIT_ASSERT_EQUAL(sal_uInt32(159), aFooterTopBorder.LineWidth); + CPPUNIT_ASSERT_EQUAL(sal_Int16(106), aFooterTopBorder.OuterLineWidth); +} + +DECLARE_OOXMLEXPORT_TEST(testParaShadow, "para-shadow.docx") +{ + // The problem was that in w:pBdr, child elements had a w:shadow attribute, but that was ignored. + table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getParagraph(2), "ParaShadowFormat"); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color)); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + // w:sz="48" is in eights of a point, 1 pt is 20 twips. + CPPUNIT_ASSERT_EQUAL(sal_Int16(convertTwipToMm100(24/8*20)), aShadow.ShadowWidth); +} + +DECLARE_OOXMLEXPORT_TEST(testTableFloating, "table-floating.docx") +{ + // Both the size and the position of the table was incorrect. + uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables(), uno::UNO_QUERY); + // Second table was too wide: 16249, i.e. as wide as the first table. + CPPUNIT_ASSERT_EQUAL(sal_Int32(11248), getProperty<sal_Int32>(xTables->getByIndex(1), "Width")); + + uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY); + if (xIndexAccess->getCount()) + { + // After import, table is inside a TextFrame. + uno::Reference<beans::XPropertySet> xFrame(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + // This was 0, should be the the opposite of (left margin + half of the border width). + CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty<sal_Int32>(xFrame, "HoriOrientPosition")); + // Was 0 as well, should be the right margin. + CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xFrame, "RightMargin")); + } + else + { + // After import, table is inside a TextFrame. + uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); + // This was 0, should be the the opposite of (left margin + half of the border width). + CPPUNIT_ASSERT_EQUAL(sal_Int32(-198), getProperty<sal_Int32>(xShape, "HoriOrientPosition")); + // Was 0 as well, should be the right margin. + CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xShape, "RightMargin")); + } +} + +DECLARE_OOXMLEXPORT_TEST(testFdo44689_start_page_0, "fdo44689_start_page_0.docx") +{ + // The problem was that the import & export process did not analyze the 'start from page' attribute of a section + uno::Reference<beans::XPropertySet> xPara(getParagraph(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xPara, "PageNumberOffset")); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo44689_start_page_7, "fdo44689_start_page_7.docx") +{ + // The problem was that the import & export process did not analyze the 'start from page' attribute of a section + uno::Reference<beans::XPropertySet> xPara(getParagraph(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int16(7), getProperty<sal_Int16>(xPara, "PageNumberOffset")); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo67737, "fdo67737.docx") +{ + // The problem was that imported shapes did not import and render the 'flip:x' and 'flip:y' attributes + uno::Reference<drawing::XShape> xArrow = getShape(1); + uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xArrow, "CustomShapeGeometry"); + for (int i = 0; i < aProps.getLength(); ++i) + { + const beans::PropertyValue& rProp = aProps[i]; + if (rProp.Name == "MirroredY") + { + CPPUNIT_ASSERT_EQUAL( true, bool(rProp.Value.get<sal_Bool>()) ); + return; + } + } + + // Shouldn't reach here + CPPUNIT_FAIL("Did not find MirroredY=true property"); +} + +DECLARE_OOXMLEXPORT_TEST(testTransparentShadow, "transparent-shadow.docx") +{ + uno::Reference<drawing::XShape> xPicture = getShape(1); + sal_Int32 nShadowColor = getProperty<sal_Int32>(xPicture, "ShadowColor"); + sal_Int16 nShadowTransparence = getProperty<sal_Int16>(xPicture, "ShadowTransparence"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x808080), nShadowColor); + CPPUNIT_ASSERT_EQUAL(sal_Int16(50), nShadowTransparence); +} + +DECLARE_OOXMLEXPORT_TEST(testBnc837302, "bnc837302.docx") +{ + // The problem was that text with empty author was not inserted as a redline + uno::Reference<text::XTextRange> xParagraph = getParagraph(1); + + // previously 'AAA' was not an own run + getRun(xParagraph, 3, "AAA"); + // interestingly the 'Insert' is set on the _previous_ run + CPPUNIT_ASSERT_EQUAL(OUString("Insert"), getProperty<OUString>(getRun(xParagraph, 2), "RedlineType")); + + // make sure we don't introduce a redlined delete in the 2nd paragraph + xParagraph = getParagraph(2); + CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(xParagraph, 1), "RedlineType")); +} + +#endif + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx new file mode 100644 index 000000000000..dcace7731ad8 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx @@ -0,0 +1,1048 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/LineJoint.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/drawing/XControlShape.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/style/TabStop.hpp> +#include <com/sun/star/view/XViewSettingsSupplier.hpp> +#include <com/sun/star/text/RelOrientation.hpp> +#include <com/sun/star/text/XTextFrame.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XTextSection.hpp> +#include <com/sun/star/style/CaseMap.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/style/LineSpacingMode.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/table/BorderLine2.hpp> +#include <com/sun/star/table/ShadowFormat.hpp> +#include <com/sun/star/text/GraphicCrop.hpp> +#include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/text/WrapTextMode.hpp> +#include <com/sun/star/xml/dom/XDocument.hpp> +#include <com/sun/star/style/BreakType.hpp> +#include <unotools/tempfile.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <com/sun/star/text/XDocumentIndex.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/Hatch.hpp> + +#include <string> + +class Test : public SwModelTestBase +{ +public: + Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {} + +protected: + /** + * Blacklist handling + */ + bool mustTestImportOf(const char* filename) const SAL_OVERRIDE { + const char* aBlacklist[] = { + "math-escape.docx", + "math-mso2k7.docx", + "ImageCrop.docx", + "test_GIF_ImageCrop.docx", + "test_PNG_ImageCrop.docx" + }; + std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist)); + + // If the testcase is stored in some other format, it's pointless to test. + return (OString(filename).endsWith(".docx") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end()); + } +}; + +#if !defined(WNT) + +DECLARE_OOXMLEXPORT_TEST(testFdo68418, "fdo68418.docx") +{ + // The problem was that in 'MSWordExportBase::SectionProperties' function in 'wrt8sty.cxx' + // it checked if it 'IsPlausableSingleWordSection'. + // The 'IsPlausableSingleWordSection' compared different aspects of 2 'SwFrmFmt' objects. + // One of the checks was 'do both formats have the same distance from the top and bottom ?' + // This check is correct if both have headers or both don't have headers. + // However - if one has a header, and the other one has an empty header (no header) - it is not correct to compare + // between them (same goes for 'footer'). + uno::Reference<text::XText> xFooterText = getProperty< uno::Reference<text::XText> >(getStyles("PageStyles")->getByName(DEFAULT_STYLE), "FooterText"); + uno::Reference< text::XTextRange > xFooterParagraph = getParagraphOfText( 1, xFooterText ); + + // First page footer is empty, second page footer is 'aaaa' + CPPUNIT_ASSERT_EQUAL(OUString("aaaa"), xFooterParagraph->getString()); // I get an error that it expects '' +} + +DECLARE_OOXMLEXPORT_TEST(testA4AndBorders, "a4andborders.docx") +{ + /* + * The problem was that in case of a document with borders, the pgSz attribute + * was exported as a child of pgBorders, thus being ignored on reload. + * We assert dimension against A4 size in mm (to avoid minor rounding errors) + */ + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect Page Width (mm)", sal_Int32(210), getProperty<sal_Int32>(xPageStyle, "Width") / 100); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Incorrect Page Height (mm)", sal_Int32(297), getProperty<sal_Int32>(xPageStyle, "Height") / 100); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo68787, "fdo68787.docx") +{ + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); + // This was 25, the 'lack of w:separator' <-> '0 line width' mapping was missing. + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPageStyle, "FootnoteLineRelativeWidth")); +} + +DECLARE_OOXMLEXPORT_TEST(testCharacterBorder, "charborder.odt") +{ + uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY); + // OOXML has just one border attribute (<w:bdr>) for text border so all side has + // the same border with the same padding + // Border + { + const table::BorderLine2 aTopBorder = getProperty<table::BorderLine2>(xRun,"CharTopBorder"); + CPPUNIT_ASSERT_BORDER_EQUAL(table::BorderLine2(0xFF6600,0,318,0,0,318), aTopBorder); + CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharLeftBorder")); + CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharBottomBorder")); + CPPUNIT_ASSERT_BORDER_EQUAL(aTopBorder, getProperty<table::BorderLine2>(xRun,"CharRightBorder")); + } + + // Padding (w:space) + { + const sal_Int32 nTopPadding = getProperty<sal_Int32>(xRun,"CharTopBorderDistance"); + // In the original ODT the padding is 150, but the unit conversion round it down. + CPPUNIT_ASSERT_EQUAL(sal_Int32(141), nTopPadding); + CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharLeftBorderDistance")); + CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharBottomBorderDistance")); + CPPUNIT_ASSERT_EQUAL(nTopPadding, getProperty<sal_Int32>(xRun,"CharRightBorderDistance")); + } + + // Shadow (w:shadow) + /* OOXML use just one bool value for shadow so the next conversions + are made during an export-import round + color: any -> black + location: any -> bottom-right + width: any -> border width */ + { + const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xRun, "CharShadowFormat"); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color)); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth); + } + + // Also check shadow when it is in middle of the paragraph + // (problem can be during export with SwWW8AttrIter::HasTextItem()) + { + uno::Reference<beans::XPropertySet> xMiddleRun(getRun(getParagraph(2),2), uno::UNO_QUERY); + const table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(xMiddleRun, "CharShadowFormat"); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, sal_uInt32(aShadow.Color)); + CPPUNIT_ASSERT_EQUAL(table::ShadowLocation_BOTTOM_RIGHT, aShadow.Location); + CPPUNIT_ASSERT_EQUAL(sal_Int16(318), aShadow.ShadowWidth); + } + + if (xmlDocPtr pXmlStyles = parseExport("word/styles.xml")) + { + // Make sure we write qFormat for custom style names. + assertXPath(pXmlStyles, "//w:style[@w:styleId='Heading']/w:qFormat", 1); + } +} + +DECLARE_OOXMLEXPORT_TEST(testStyleInheritance, "style-inheritance.docx") +{ + // Check that now styleId's are more like what MSO produces + xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); + if (!pXmlStyles) + return; + // the 1st style always must be Normal + assertXPath(pXmlStyles, "/w:styles/w:style[1]", "styleId", "Normal"); + // some random style later + assertXPath(pXmlStyles, "/w:styles/w:style[4]", "styleId", "Heading3"); + + // Check that we do _not_ export w:next for styles that point to themselves. + assertXPath(pXmlStyles, "/w:styles/w:style[1]/w:next", 0); + + // Check that we roundtrip <w:next> correctly - on XML level + assertXPath(pXmlStyles, "/w:styles/w:style[2]/w:next", "val", "Normal"); + // And to be REALLY sure, check it on the API level too ;-) + uno::Reference< container::XNameAccess > paragraphStyles = getStyles("ParagraphStyles"); + uno::Reference< beans::XPropertySet > properties(paragraphStyles->getByName("Heading 1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Standard"), getProperty<OUString>(properties, "FollowStyle")); + + // This was 0, as export of w:outlineLvl was missing. + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), getProperty<sal_Int32>(properties, "OutlineLevel")); + + properties = uno::Reference< beans::XPropertySet >(paragraphStyles->getByName("Heading 11"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"), getProperty<OUString>(properties, "FollowStyle")); + + // Make sure style #2 is Heading 1. + assertXPath(pXmlStyles, "/w:styles/w:style[2]", "styleId", "Heading1"); + // w:ind was copied from the parent (Normal) style without a good reason. + assertXPath(pXmlStyles, "/w:styles/w:style[2]/w:pPr/w:ind", 0); + + // We output exactly 2 properties in rPrDefault, nothing else was + // introduced as an additional default + assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/*", 2); + // Check that we output real content of rPrDefault + assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "ascii", "Times New Roman"); + assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:lang", "bidi", "ar-SA"); + // pPrDefault is empty + assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:pPrDefault/w:pPr/*", 0); + + // Check latent styles + uno::Sequence<beans::PropertyValue> aGrabBag = getProperty< uno::Sequence<beans::PropertyValue> >(mxComponent, "InteropGrabBag"); + uno::Sequence<beans::PropertyValue> aLatentStyles; + for (sal_Int32 i = 0; i < aGrabBag.getLength(); ++i) + if (aGrabBag[i].Name == "latentStyles") + aGrabBag[i].Value >>= aLatentStyles; + CPPUNIT_ASSERT(aLatentStyles.getLength()); // document should have latent styles + + // Check latent style default attributes + OUString aCount; + uno::Sequence<beans::PropertyValue> aLatentStyleExceptions; + for (sal_Int32 i = 0; i < aLatentStyles.getLength(); ++i) + { + if (aLatentStyles[i].Name == "count") + aCount = aLatentStyles[i].Value.get<OUString>(); + else if (aLatentStyles[i].Name == "lsdExceptions") + aLatentStyles[i].Value >>= aLatentStyleExceptions; + } + CPPUNIT_ASSERT_EQUAL(OUString("371"), aCount); // This check the "count" attribute. + + // Check exceptions to the latent style defaults. + uno::Sequence<beans::PropertyValue> aLatentStyleException; + aLatentStyleExceptions[0].Value >>= aLatentStyleException; + OUString aName; + for (sal_Int32 i = 0; i < aLatentStyleException.getLength(); ++i) + if (aLatentStyleException[i].Name == "name") + aName = aLatentStyleException[i].Value.get<OUString>(); + CPPUNIT_ASSERT_EQUAL(OUString("Normal"), aName); // This checks the "name" attribute of the first exception. + + // This numbering style wasn't roundtripped. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='NoList']/w:name", "val", "No List"); + + // Table style wasn't roundtripped. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:tblPr/w:tblCellMar/w:left", "w", "108"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:semiHidden", 1); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='TableNormal']/w:unhideWhenUsed", 1); + + // Additional para style properties should be also roundtripped. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='ListParagraph']/w:uiPriority", "val", "34"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']/w:qFormat", 1); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']/w:rsid", "val", "00780346"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Normal']", "default", "1"); + + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:link", "val", "Heading1Char"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading1']/w:locked", 1); + + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading11']", "customStyle", "1"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Heading11']/w:autoRedefine", 1); + + // Additional char style properties should be also roundtripped. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='DefaultParagraphFont']", "default", "1"); + + // Finally check the same for numbering styles. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='NoList']", "default", "1"); +} + +DECLARE_OOXMLEXPORT_TEST(testCalendar1, "calendar1.docx") +{ + // Document has a non-trivial table style, test the roundtrip of it. + xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); + if (!pXmlStyles) + return; + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:basedOn", "val", "TableNormal"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:rsid", "val", "00903003"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblPr/w:tblStyleColBandSize", "val", "1"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tcPr/w:shd", "val", "clear"); + + // Table style lost its paragraph / run properties. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:pPr/w:spacing", "lineRule", "auto"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:rPr/w:lang", "eastAsia", "ja-JP"); + + // Table style lost its conditional table formatting properties. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:pPr/w:wordWrap", 1); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:rFonts", "hAnsiTheme", "minorHAnsi"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:tblPr", 1); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='firstRow']/w:tcPr/w:vAlign", "val", "bottom"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='lastRow']/w:tcPr/w:tcBorders/w:tr2bl", "val", "nil"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar1']/w:tblStylePr[@w:type='band2Horz']/w:tcPr/w:tcBorders/w:top", "themeColor", "text1"); + + // w:tblLook element and its attributes were missing. + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "firstRow", "1"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "lastRow", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "lastColumn", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "firstColumn", "1"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "noHBand", "0"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "noVBand", "1"); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblLook", "val", "04a0"); +} + +DECLARE_OOXMLEXPORT_TEST(testCalendar2, "calendar2.docx") +{ + // Problem was that CharCaseMap was style::CaseMap::NONE. + uno::Reference<text::XTextTable> xTable(getParagraphOrTable(1), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xCell(xTable->getCellByName("A1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(style::CaseMap::UPPERCASE, getProperty<sal_Int16>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharCaseMap")); + // Font size in the second row was 11. + xCell.set(xTable->getCellByName("A2"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(16.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight")); + // Font size in the third row was 11 as well. + xCell.set(xTable->getCellByName("B3"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(14.f, getProperty<float>(getRun(getParagraphOfText(1, xCell->getText()), 1), "CharHeight")); + + // This paragraph property was missing in table style. + xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); + if (!pXmlStyles) + return; + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:pPr/w:jc", "val", "center"); + + // These run properties were missing + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:rPr/w:lang", "val", "en-US"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:rPr/w:lang", "bidi", "ar-SA"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:caps", 1); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:smallCaps", "val", "0"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:color", "themeColor", "accent1"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:spacing", "val", "20"); + + // Table borders were also missing + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar2']/w:tblPr/w:tblBorders/w:insideV", "themeTint", "99"); +} + +DECLARE_OOXMLEXPORT_TEST(testTcBorders, "testTcBorders.docx") +{ + //fdo#76635 : Table borders are not getting preserved. + + xmlDocPtr pXmlDocument = parseExport("word/document.xml"); + if (!pXmlDocument) + return; + + assertXPath(pXmlDocument, "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tcPr[1]/w:tcBorders[1]/w:bottom[1][@w:val = 'single']",1); + assertXPath(pXmlDocument, "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tcPr[1]/w:tcBorders[1]/w:bottom[1][@w:sz = 4]", 1); + assertXPath(pXmlDocument, "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tcPr[1]/w:tcBorders[1]/w:bottom[1][@w:space = 0]", 1); + assertXPath(pXmlDocument, "/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]/w:tcPr[1]/w:tcBorders[1]/w:bottom[1][@w:color = 808080]", 1); + +} + +DECLARE_OOXMLEXPORT_TEST(testQuicktables, "quicktables.docx") +{ + xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); + if (!pXmlStyles) + return; + + // These were missing in the Calendar3 table style. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:rPr/w:rFonts", "cstheme", "majorBidi"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:rPr/w:color", "themeTint", "80"); + CPPUNIT_ASSERT(getXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar3']/w:tblStylePr[@w:type='firstRow']/w:rPr/w:color", "themeShade").equalsIgnoreAsciiCase("BF")); + + // Calendar4. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:pPr/w:snapToGrid", "val", "0"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:rPr/w:bCs", 1); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tcPr/w:shd", "themeFill", "accent1"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tcPr/w:shd", "themeFillShade", "80"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='firstCol']/w:pPr/w:ind", "rightChars", "0"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='firstCol']/w:pPr/w:ind", "right", "144"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Calendar4']/w:tblStylePr[@w:type='band2Horz']/w:tcPr/w:tcMar/w:bottom", "w", "86"); + + // LightList. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='LightList']/w:tblStylePr[@w:type='firstRow']/w:pPr/w:spacing", "before", "0"); + + // MediumList2-Accent1. + CPPUNIT_ASSERT(getXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='MediumList2-Accent1']/w:tblStylePr[@w:type='band1Vert']/w:tcPr/w:shd", "themeFillTint").equalsIgnoreAsciiCase("3F")); + + // MediumShading2-Accent5. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='MediumShading2-Accent5']/w:tblStylePr[@w:type='firstRow']/w:tcPr/w:tcBorders/w:top", "color", "auto"); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo71302, "fdo71302.docx") +{ + xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); + if (!pXmlStyles) + return; + + // This got renamed to "Strong Emphasis" without a good reason. + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Strong']", 1); +} + + + + + +DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx") +{ + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aGrabBag(0); + xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; + CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty + + bool bTheme = false; + for(int i = 0; i < aGrabBag.getLength(); ++i) + { + if (aGrabBag[i].Name == "OOXTheme") + { + bTheme = true; + uno::Reference<xml::dom::XDocument> aThemeDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aThemeDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aThemeDom.get()); // Reference not empty + } + } + CPPUNIT_ASSERT(bTheme); // Grab Bag has all the expected elements + + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDraws->getCount()); // One groupshape in the doc + + uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xGroup->getCount()); // 1 rendered bitmap from the original shapes + + uno::Reference<beans::XPropertySet> xGroupPropertySet(getShape(1), uno::UNO_QUERY); + xGroupPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; + CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty + + bool bData = false, bLayout = false, bQStyle = false, bColor = false, bDrawing = false; + for(int i = 0; i < aGrabBag.getLength(); ++i) + { + if (aGrabBag[i].Name == "OOXData") + { + bData = true; + uno::Reference<xml::dom::XDocument> aDataDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aDataDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aDataDom.get()); // Reference not empty + } + else if (aGrabBag[i].Name == "OOXLayout") + { + bLayout = true; + uno::Reference<xml::dom::XDocument> aLayoutDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aLayoutDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aLayoutDom.get()); // Reference not empty + } + else if (aGrabBag[i].Name == "OOXStyle") + { + bQStyle = true; + uno::Reference<xml::dom::XDocument> aStyleDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aStyleDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aStyleDom.get()); // Reference not empty + } + else if (aGrabBag[i].Name == "OOXColor") + { + bColor = true; + uno::Reference<xml::dom::XDocument> aColorDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aColorDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aColorDom.get()); // Reference not empty + } + else if (aGrabBag[i].Name == "OOXDrawing") + { + bDrawing = true; + uno::Sequence< uno::Any > diagramDrawing; + uno::Reference<xml::dom::XDocument> aDrawingDom; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= diagramDrawing); + CPPUNIT_ASSERT(diagramDrawing[0] >>= aDrawingDom); // PropertyValue of proper type + CPPUNIT_ASSERT(aDrawingDom.get()); // Reference not empty + } + } + CPPUNIT_ASSERT(bData && bLayout && bQStyle && bColor && bDrawing); // Grab Bag has all the expected elements + + uno::Reference<beans::XPropertySet> xPropertySet(xGroup->getByIndex(0), uno::UNO_QUERY); + OUString nValue; + xPropertySet->getPropertyValue("Name") >>= nValue; + CPPUNIT_ASSERT_EQUAL(OUString("RenderedShapes"), nValue); // Rendered bitmap has the proper name +} + +/* +DECLARE_OOXMLEXPORT_TEST(testCharHighlight, "char_highlight.docx") +{ + const uno::Reference< text::XTextRange > xPara = getParagraph(1); + // Both highlight and background + const sal_Int32 nBackColor(0x4F81BD); + for( int nRun = 1; nRun <= 16; ++nRun ) + { + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,nRun), uno::UNO_QUERY); + sal_Int32 nHighlightColor = 0; + switch( nRun ) + { + case 1: nHighlightColor = 0x000000; break; //black + case 2: nHighlightColor = 0x0000ff; break; //blue + case 3: nHighlightColor = 0x00ffff; break; //cyan + case 4: nHighlightColor = 0x00ff00; break; //green + case 5: nHighlightColor = 0xff00ff; break; //magenta + case 6: nHighlightColor = 0xff0000; break; //red + case 7: nHighlightColor = 0xffff00; break; //yellow + case 8: nHighlightColor = 0xffffff; break; //white + case 9: nHighlightColor = 0x000080; break;//dark blue + case 10: nHighlightColor = 0x008080; break; //dark cyan + case 11: nHighlightColor = 0x008000; break; //dark green + case 12: nHighlightColor = 0x800080; break; //dark magenta + case 13: nHighlightColor = 0x800000; break; //dark red + case 14: nHighlightColor = 0x808000; break; //dark yellow + case 15: nHighlightColor = 0x808080; break; //dark gray + case 16: nHighlightColor = 0xC0C0C0; break; //light gray + } + CPPUNIT_ASSERT_EQUAL(nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL(nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor")); + } + + // Only highlight + { + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor")); + } + + // Only background + { + const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor")); + } +} +*/ + +DECLARE_OOXMLEXPORT_TEST(testFontNameIsEmpty, "font-name-is-empty.docx") +{ + // Check no empty font name is exported + // This test does not fail, if the document contains a font with empty name. + + xmlDocPtr pXmlFontTable = parseExport("word/fontTable.xml"); + if (!pXmlFontTable) + return; + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlFontTable, "/w:fonts/w:font"); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + sal_Int32 length = xmlXPathNodeSetGetLength(pXmlNodes); + for(sal_Int32 index = 0; index < length; index++){ + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[index]; + OUString attrVal = OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST("name"))); + if (attrVal == ""){ + CPPUNIT_FAIL("Font name is empty."); + } + } + xmlXPathFreeObject(pXmlObj); +} + +DECLARE_OOXMLEXPORT_TEST(testMultiColumnLineSeparator, "multi-column-line-separator-SAVED.docx") +{ + // Check for the Column Separator value.It should be FALSE as the document doesnt contains separator line. + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:sectPr/w:cols","sep","false"); +} + +DECLARE_OOXMLEXPORT_TEST(testCustomXmlGrabBag, "customxml.docx") +{ + // The problem was that item[n].xml and itemProps[n].xml and .rels files for item[n].xml + // files were missing from docx file after saving file. + // This test case tests whether customxml files grabbagged properly in correct object. + + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aGrabBag(0); + xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; + CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty + bool CustomXml = false; + for(int i = 0; i < aGrabBag.getLength(); ++i) + { + if (aGrabBag[i].Name == "OOXCustomXml" || aGrabBag[i].Name == "OOXCustomXmlProps") + { + CustomXml = true; + uno::Reference<xml::dom::XDocument> aCustomXmlDom; + uno::Sequence<uno::Reference<xml::dom::XDocument> > aCustomXmlDomList; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aCustomXmlDomList); // PropertyValue of proper type + sal_Int32 length = aCustomXmlDomList.getLength(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), length); + aCustomXmlDom = aCustomXmlDomList[0]; + CPPUNIT_ASSERT(aCustomXmlDom.get()); // Reference not empty + } + } + CPPUNIT_ASSERT(CustomXml); // Grab Bag has all the expected elements +} + +DECLARE_OOXMLEXPORT_TEST(testActiveXGrabBag, "activex.docx") +{ + // The problem was that activeX.xml files were missing from docx file after saving file. + // This test case tests whether activex files grabbagged properly in correct object. + + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aGrabBag(0); + xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; + CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty + bool bActiveX = false; + for(int i = 0; i < aGrabBag.getLength(); ++i) + { + if (aGrabBag[i].Name == "OOXActiveX") + { + bActiveX = true; + uno::Reference<xml::dom::XDocument> aActiveXDom; + uno::Sequence<uno::Reference<xml::dom::XDocument> > aActiveXDomList; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aActiveXDomList); // PropertyValue of proper type + sal_Int32 length = aActiveXDomList.getLength(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), length); + aActiveXDom = aActiveXDomList[0]; + CPPUNIT_ASSERT(aActiveXDom.get()); // Reference not empty + } + } + CPPUNIT_ASSERT(bActiveX); // Grab Bag has all the expected elements +} + +DECLARE_OOXMLEXPORT_TEST(testActiveXBinGrabBag, "activexbin.docx") +{ + // The problem was that activeX.bin files were missing from docx file after saving file. + // This test case tests whether activex bin files grabbagged properly in correct object. + + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aGrabBag(0); + xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag; + CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty + bool bActiveX = false; + for(int i = 0; i < aGrabBag.getLength(); ++i) + { + if (aGrabBag[i].Name == "OOXActiveXBin") + { + bActiveX = true; + uno::Reference<io::XInputStream> aActiveXBin; + uno::Sequence<uno::Reference<io::XInputStream> > aActiveXBinList; + CPPUNIT_ASSERT(aGrabBag[i].Value >>= aActiveXBinList); // PropertyValue of proper type + sal_Int32 length = aActiveXBinList.getLength(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), length); + aActiveXBin = aActiveXBinList[0]; + CPPUNIT_ASSERT(aActiveXBin.get()); // Reference not empty + } + } + CPPUNIT_ASSERT(bActiveX); // Grab Bag has all the expected elements +} + +DECLARE_OOXMLEXPORT_TEST(testFdo69644, "fdo69644.docx") +{ + // The problem was that the exporter exported the table definition + // with only 3 columns, instead of 5 columns. + // Check that the table grid is exported with 5 columns + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol", 5); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo70812, "fdo70812.docx") +{ + // Import just crashed. + getParagraph(1, "Sample pages document."); +} + +DECLARE_OOXMLEXPORT_TEST(testPgMargin, "testPgMargin.docx") +{ + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:pgMar", "left", "1440"); +} + +DECLARE_OOXMLEXPORT_TEST(testImageCrop, "ImageCrop.docx") +{ + uno::Reference<drawing::XShape> image = getShape(1); + uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY); + ::com::sun::star::text::GraphicCrop aGraphicCropStruct; + + imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct; + + CPPUNIT_ASSERT_EQUAL( sal_Int32( 2955 ), aGraphicCropStruct.Left ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 5477 ), aGraphicCropStruct.Right ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 2856 ), aGraphicCropStruct.Top ); + // FIXME import test is disabled (we only check after import-export-import) + // The reason is that after import this is 2291 -- rounding error? + CPPUNIT_ASSERT_EQUAL( sal_Int32( 2290 ), aGraphicCropStruct.Bottom ); +} + +DECLARE_OOXMLEXPORT_TEST(testLineSpacingexport, "test_line_spacing.docx") +{ + // The Problem was that the w:line attribute value in w:spacing tag was incorrect + uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration(); + CPPUNIT_ASSERT(xParaEnum->hasMoreElements()); + + // FIXME The test passes on most machines (including Linux x86_64 with gcc-4.7), but fails on various configs: + // Linux arm, Linux x86_64 with gcc-4.8 and Mac. Need to figure out what goes wrong and fix that. +#if 0 + style::LineSpacing alineSpacing = getProperty<style::LineSpacing>(xParaEnum->nextElement(), "ParaLineSpacing"); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(13200), static_cast<sal_Int16>(alineSpacing.Height)); + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "line", "31680"); +#endif +} + +DECLARE_OOXMLEXPORT_TEST(testTextBoxGradientAngle, "fdo65295.docx") +{ + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xIndexAccess(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(8), xIndexAccess->getCount()); + + // Angle of frame#1 is 135 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree + uno::Reference<beans::XPropertySet> xFrame1(xIndexAccess->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame1, "FillStyle")); + awt::Gradient aGradient1 = getProperty<awt::Gradient>(xFrame1, "FillGradient"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(135 * 10), aGradient1.Angle); + + // Angle of frame#2 is 180 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree + uno::Reference<beans::XPropertySet> xFrame2(xIndexAccess->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame2, "FillStyle")); + awt::Gradient aGradient2 = getProperty<awt::Gradient>(xFrame2, "FillGradient"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(180 * 10), aGradient2.Angle); + + // Angle of frame#3 is 90 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree + uno::Reference<beans::XPropertySet> xFrame3(xIndexAccess->getByIndex(2), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame3, "FillStyle")); + awt::Gradient aGradient3 = getProperty<awt::Gradient>(xFrame3, "FillGradient"); + CPPUNIT_ASSERT_EQUAL(sal_Int16( 90 * 10), aGradient3.Angle); + + // Angle of frame#4 is 225 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree + uno::Reference<beans::XPropertySet> xFrame4(xIndexAccess->getByIndex(3), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame4, "FillStyle")); + awt::Gradient aGradient4 = getProperty<awt::Gradient>(xFrame4, "FillGradient"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(225 * 10), aGradient4.Angle); + + // Angle of frame#5 is 270 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree + uno::Reference<beans::XPropertySet> xFrame5(xIndexAccess->getByIndex(4), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame5, "FillStyle")); + awt::Gradient aGradient5 = getProperty<awt::Gradient>(xFrame5, "FillGradient"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(270 * 10), aGradient5.Angle); + + // Angle of frame#6 is 315 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree + uno::Reference<beans::XPropertySet> xFrame6(xIndexAccess->getByIndex(5), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame6, "FillStyle")); + awt::Gradient aGradient6 = getProperty<awt::Gradient>(xFrame6, "FillGradient"); + CPPUNIT_ASSERT_EQUAL(sal_Int16(315 * 10), aGradient6.Angle); + + // Angle of frame#7 is 0 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree + uno::Reference<beans::XPropertySet> xFrame7(xIndexAccess->getByIndex(6), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame7, "FillStyle")); + awt::Gradient aGradient7 = getProperty<awt::Gradient>(xFrame7, "FillGradient"); + CPPUNIT_ASSERT_EQUAL(sal_Int16( 0 * 10), aGradient7.Angle); + + // Angle of frame#8 is 45 degrees, but 'aGradient.Angle' holds value in 1/10 of a degree + uno::Reference<beans::XPropertySet> xFrame8(xIndexAccess->getByIndex(7), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT, getProperty<drawing::FillStyle>(xFrame8, "FillStyle")); + awt::Gradient aGradient8 = getProperty<awt::Gradient>(xFrame8, "FillGradient"); + CPPUNIT_ASSERT_EQUAL(sal_Int16( 45 * 10), aGradient8.Angle); +} + +DECLARE_OOXMLEXPORT_TEST(testCellGridSpan, "cell-grid-span.docx") +{ + // The problem was during export gridSpan value for 1st & 2nd cells for test document + // used to get set wrongly to 5 and 65532 respectively which was the reason for crash during save operation + // Varifying gridSpan element is not present in RoundTriped Document (As it's Default value is 1). + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[1]/w:tcPr/w:gridSpan",0); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc[2]/w:tcPr/w:gridSpan",0); +} +DECLARE_OOXMLEXPORT_TEST(testFdo71646, "fdo71646.docx") +{ + // The problem was after save file created by MS the direction changed to RTL. + uno::Reference<uno::XInterface> xParaLTRLeft(getParagraph( 1, "LTR LEFT")); + sal_Int32 nLTRLeft = getProperty< sal_Int32 >( xParaLTRLeft, "ParaAdjust" ); + // test the text Direction value for the pragraph + sal_Int16 nLRDir = getProperty< sal_Int32 >( xParaLTRLeft, "WritingMode" ); + + // this will test the both the text direction and alignment for paragraph + CPPUNIT_ASSERT_EQUAL( sal_Int32 (style::ParagraphAdjust_LEFT), nLTRLeft); + CPPUNIT_ASSERT_EQUAL(text::WritingMode2::LR_TB, nLRDir); +} + +DECLARE_OOXMLEXPORT_TEST(testParaAutoSpacing, "para-auto-spacing.docx") +{ + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "beforeAutospacing","1"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", "afterAutospacing","1"); + + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "beforeAutospacing",""); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "afterAutospacing",""); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "before","400"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", "after","400"); +} + +DECLARE_OOXMLEXPORT_TEST(testGIFImageCrop, "test_GIF_ImageCrop.docx") +{ + // FIXME why does this fail on Mac? +#if !defined(MACOSX) + uno::Reference<drawing::XShape> image = getShape(1); + uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY); + ::com::sun::star::text::GraphicCrop aGraphicCropStruct; + + imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct; + + // FIXME import test is disabled (we only check after import-export-import) + // The reason is that after import this is 1171 -- why? + CPPUNIT_ASSERT_EQUAL( sal_Int32( 1265 ), aGraphicCropStruct.Left ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 4256 ), aGraphicCropStruct.Right ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 1109 ), aGraphicCropStruct.Top ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 1448 ), aGraphicCropStruct.Bottom ); +#endif +} + +DECLARE_OOXMLEXPORT_TEST(testPNGImageCrop, "test_PNG_ImageCrop.docx") +{ + // FIXME why does this fail on Mac? +#if !defined(MACOSX) + /* The problem was image cropping information was not getting saved + * after roundtrip. + * Check for presenece of cropping parameters in exported file. + */ + uno::Reference<drawing::XShape> image = getShape(1); + uno::Reference<beans::XPropertySet> imageProperties(image, uno::UNO_QUERY); + ::com::sun::star::text::GraphicCrop aGraphicCropStruct; + + imageProperties->getPropertyValue( "GraphicCrop" ) >>= aGraphicCropStruct; + + // FIXME import test is disabled (we only check after import-export-import) + // The reason is that after import this is 1141 -- why? + CPPUNIT_ASSERT_EQUAL( sal_Int32( 1231 ), aGraphicCropStruct.Left ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 1295 ), aGraphicCropStruct.Right ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 1358 ), aGraphicCropStruct.Top ); + CPPUNIT_ASSERT_EQUAL( sal_Int32( 737 ), aGraphicCropStruct.Bottom ); +#endif +} + +DECLARE_OOXMLEXPORT_TEST(testFootnoteParagraphTag, "testFootnote.docx") +{ + /* In footnotes.xml, the paragraph tag inside <w:footnote w:id="2"> was getting written into document.xml. + * Check for, paragraph tag is correctly written into footnotes.xml. + */ + xmlDocPtr pXmlFootnotes = parseExport("word/footnotes.xml"); + if (!pXmlFootnotes) + return; + assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]","id","2"); + assertXPath(pXmlFootnotes, "/w:footnotes/w:footnote[3]/w:p/w:r/w:rPr/w:rStyle","val","Footnotereference"); +} + +DECLARE_OOXMLEXPORT_TEST(testSpacingLineRule,"table_lineRule.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p/w:pPr/w:spacing", "lineRule", "auto"); +} + +DECLARE_OOXMLEXPORT_TEST(testTableLineSpacing, "table_atleast.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:pPr/w:spacing", "line", "320"); +} + +DECLARE_OOXMLEXPORT_TEST(testOoxmlTriangle, "ooxml-triangle.docx") +{ + // The problem was that ooxml-triangle shape type wasn't handled by VML + // export (only isosceles-triangle), leading to a missing shape. + getShape(1); +} + +DECLARE_OOXMLEXPORT_TEST(testMce, "mce.docx") +{ + // The shape is red in Word2007, green in Word2010. Check that our import follows the later. + CPPUNIT_ASSERT_EQUAL(sal_Int32(0x9bbb59), getProperty<sal_Int32>(getShape(1), "FillColor")); +} + +DECLARE_OOXMLEXPORT_TEST(testThemePreservation, "theme-preservation.docx") +{ + // check default font theme values have been preserved + xmlDocPtr pXmlStyles = parseExport("word/styles.xml"); + if (!pXmlStyles) + return; + assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "asciiTheme", "minorHAnsi"); + assertXPath(pXmlStyles, "/w:styles/w:docDefaults/w:rPrDefault/w:rPr/w:rFonts", "cstheme", "minorBidi"); + + // check the font theme values in style definitions + assertXPath(pXmlStyles, "/w:styles/w:style[1]/w:rPr/w:rFonts", "eastAsiaTheme", "minorEastAsia"); + + // check the color theme values in style definitions + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Custom1']/w:rPr/w:color", "themeColor", "accent1"); + assertXPath(pXmlStyles, "/w:styles/w:style[@w:styleId='Custom1']/w:rPr/w:color", "themeTint", "99"); + + // check direct format font theme values have been preserved + xmlDocPtr pXmlDocument = parseExport("word/document.xml"); + if (!pXmlDocument) + return; + assertXPath(pXmlDocument, "/w:document/w:body/w:p[5]/w:r[1]/w:rPr/w:rFonts", "hAnsiTheme", "majorHAnsi"); + assertXPath(pXmlDocument, "/w:document/w:body/w:p[5]/w:r[1]/w:rPr/w:rFonts", "asciiTheme", "majorHAnsi"); + + // check theme font color value has been preserved + assertXPath(pXmlDocument, "/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeColor", "accent3"); + OUString sThemeShade = getXPath(pXmlDocument, "/w:document/w:body/w:p[4]/w:r[1]/w:rPr/w:color", "themeShade"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0xbf), sThemeShade.toInt32(16)); + + // check the themeFontLang values in settings file + xmlDocPtr pXmlSettings = parseExport("word/settings.xml"); + if (!pXmlSettings) + return; + assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "val", "en-US"); + assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "eastAsia", "zh-CN"); + assertXPath(pXmlSettings, "/w:settings/w:themeFontLang", "bidi", "he-IL"); + + // check fonts have been applied properly + sal_Unicode fontName[2]; //represents the string "宋体" + fontName[0] = 0x5b8b; + fontName[1] = 0x4f53; + CPPUNIT_ASSERT_EQUAL(OUString(fontName, 2), getProperty<OUString>(getParagraph(1), "CharFontNameAsian")); + CPPUNIT_ASSERT_EQUAL(OUString("Arial"), + getProperty<OUString>(getParagraph(2), "CharFontNameComplex")); + CPPUNIT_ASSERT_EQUAL(OUString("Trebuchet MS"), + getProperty<OUString>(getParagraph(3, "Default style theme font"), "CharFontName")); + CPPUNIT_ASSERT_EQUAL(OUString("Arial Black"), + getProperty<OUString>(getRun(getParagraph(4, "Direct format font"), 1), "CharFontName")); + CPPUNIT_ASSERT_EQUAL(OUString("Trebuchet MS"), + getProperty<OUString>(getParagraph(5, "Major theme font"), "CharFontName")); + + // check the paragraph background pattern has been preserved including theme colors + assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "val", "thinHorzStripe"); + assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeFill", "text2"); + assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeFillTint", "33"); + assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeColor", "accent1"); + assertXPath(pXmlDocument, "/w:document/w:body/w:p[6]/w:pPr/w:shd", "themeShade", "80"); +} + +DECLARE_OOXMLEXPORT_TEST(testTableThemePreservation, "table-theme-preservation.docx") +{ + xmlDocPtr pXmlDocument = parseExport("word/document.xml"); + if (!pXmlDocument) + return; + + // check cell theme colors have been preserved + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFill", "accent6"); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFillShade", ""); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFillTint", "33"); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFill", "accent6"); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFillShade", ""); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFillTint", ""); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFill", "accent6"); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFillShade", "80"); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFillTint", ""); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "val", "horzStripe"); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeColor", "accent3"); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeTint", "33"); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "color", "E7EEEE"); + + // check table style has been preserved + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tblPr/w:tblStyle", "val", "Sombreadoclaro-nfasis1"); + // check table style is not overwritten by other properties + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[2]/w:tcPr/w:tcBorders/*", 0); + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[3]/w:tcPr/w:tcBorders/*", 0); + // check that one cell attribute present in the original document has been preserved + assertXPath(pXmlDocument, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tcPr/w:tcBorders/*", 1); + + // Check that w:cnfStyle row, cell and paragraph property is preserved. + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:trPr/w:cnfStyle", "val", "100000000000"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:trPr/w:cnfStyle", "firstRow", "1"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:trPr/w:cnfStyle", "lastRow", "0"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:trPr/w:cnfStyle", "firstColumn", "0"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:trPr/w:cnfStyle", "lastColumn", "0"); + + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc/w:tcPr/w:cnfStyle", "val", "001000000000"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc/w:tcPr/w:cnfStyle", "oddVBand", "0"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc/w:tcPr/w:cnfStyle", "evenVBand", "0"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc/w:tcPr/w:cnfStyle", "oddHBand", "0"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc/w:tcPr/w:cnfStyle", "evenHBand", "0"); + + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:cnfStyle", "val", "100000000000"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:cnfStyle", "firstRowFirstColumn", "0"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:cnfStyle", "firstRowLastColumn", "0"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:cnfStyle", "lastRowFirstColumn", "0"); + assertXPath(pXmlDocument, "//w:tbl/w:tr[1]/w:tc[2]/w:p/w:pPr/w:cnfStyle", "lastRowLastColumn", "0"); + +} + +DECLARE_OOXMLEXPORT_TEST(testcantSplit, "2_table_doc.docx") +{ + // if Split table value is true for a table then during export do not write <w:cantSplit w:val="false"/> + // in table row property,As default row prop is allow row to break across page. + // writing <w:cantSplit w:val="false"/> during export was causing problem that all the cell data used to come on same page + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr/w:trPr/w:cantSplit",0); + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[2]/w:tr/w:trPr/w:cantSplit","val","true"); +} + +DECLARE_OOXMLEXPORT_TEST(testExtraSectionBreak, "1_page.docx") +{ + // There was a problem for some documents during export.Invalid sectPr getting added + // because of faulty calculation of PageDesc value + // This was the reason for increasing number of pages after RT + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(1), xCursor->getPage()); +} + +DECLARE_OOXMLEXPORT_TEST(testcolumnbreak, "columnbreak.docx") +{ + CPPUNIT_ASSERT_EQUAL(style::BreakType_COLUMN_BEFORE, getProperty<style::BreakType>(getParagraph(5, "This is first line after col brk."), "BreakType")); + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[1]/w:br", "type", "column"); +} + +DECLARE_OOXMLEXPORT_TEST(testGlossary, "testGlossary.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/glossary/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:glossaryDocument", "Ignorable", "w14 wp14"); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo71785, "fdo71785.docx") +{ + // crashtest +} + +DECLARE_OOXMLEXPORT_TEST(testCrashWhileSave, "testCrashWhileSave.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/footer1.xml"); + if (!pXmlDoc) + return; + CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:ftr/w:tbl/w:tr/w:tc[1]/w:p[1]/w:pPr/w:pStyle", "val").match("Normal")); +} + +DECLARE_OOXMLEXPORT_TEST(testFileOpenInputOutputError,"floatingtbl_with_formula.docx") +{ + // Docx containing Floating table with formula was giving "General input/output error" while opening in LibreOffice + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pStyle", "val", "Normal"); +} + +#endif + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx new file mode 100644 index 000000000000..3a8502b51e6d --- /dev/null +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -0,0 +1,803 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/LineJoint.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/drawing/XControlShape.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/style/TabStop.hpp> +#include <com/sun/star/view/XViewSettingsSupplier.hpp> +#include <com/sun/star/text/RelOrientation.hpp> +#include <com/sun/star/text/XTextFrame.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XTextSection.hpp> +#include <com/sun/star/style/CaseMap.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/style/LineSpacingMode.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/table/BorderLine2.hpp> +#include <com/sun/star/table/ShadowFormat.hpp> +#include <com/sun/star/text/GraphicCrop.hpp> +#include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/text/WrapTextMode.hpp> +#include <com/sun/star/xml/dom/XDocument.hpp> +#include <com/sun/star/style/BreakType.hpp> +#include <unotools/tempfile.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <com/sun/star/text/XDocumentIndex.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/Hatch.hpp> + +#include <string> + +class Test : public SwModelTestBase +{ +public: + Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {} + +protected: + /** + * Blacklist handling + */ + bool mustTestImportOf(const char* filename) const SAL_OVERRIDE { + const char* aBlacklist[] = { + "math-escape.docx", + "math-mso2k7.docx", + "ImageCrop.docx", + "test_GIF_ImageCrop.docx", + "test_PNG_ImageCrop.docx" + }; + std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist)); + + // If the testcase is stored in some other format, it's pointless to test. + return (OString(filename).endsWith(".docx") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end()); + } +}; + +DECLARE_OOXMLEXPORT_TEST(testRelorientation, "relorientation.docx") +{ + uno::Reference<drawing::XShape> xShape = getShape(1); + // This was text::RelOrientation::FRAME, when handling relativeFrom=page, align=right + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_RIGHT, getProperty<sal_Int16>(xShape, "HoriOrientRelation")); + + uno::Reference<drawing::XShapes> xGroup(xShape, uno::UNO_QUERY); + // This resulted in lang::IndexOutOfBoundsException, as nested groupshapes weren't handled. + uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(0), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GroupShape"), xShapeDescriptor->getShapeType()); + + // Right after import we get a rounding error: 8662 vs 8664. + if (mbExported) + { + uno::Reference<drawing::XShape> xYear(xGroup->getByIndex(1), uno::UNO_QUERY); + // This was 2, due to incorrect handling of parent transformations inside DML groupshapes. + CPPUNIT_ASSERT_EQUAL(sal_Int32(8664), xYear->getSize().Width); + } +} + +DECLARE_OOXMLEXPORT_TEST(testBezier, "bezier.odt") +{ + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + // Check that no shape got lost: a bezier, a line and a text shape. + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), xDraws->getCount()); +} + +DECLARE_OOXMLEXPORT_TEST(testGroupshapeTextbox, "groupshape-textbox.docx") +{ + uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY); + // The VML export lost text on textboxes inside groupshapes. + // The DML export does not, make sure it stays that way. + CPPUNIT_ASSERT_EQUAL(OUString("first"), xShape->getString()); + // This was 16, i.e. inheriting doc default char height didn't work. + CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight")); +} + +DECLARE_OOXMLEXPORT_TEST(testGroupshapePicture, "groupshape-picture.docx") +{ + // Picture in the groupshape got lost, groupshape had only one child. + uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY); + uno::Reference<drawing::XShapeDescriptor> xShapeDescriptor(xGroup->getByIndex(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("com.sun.star.drawing.GraphicObjectShape"), xShapeDescriptor->getShapeType()); +} + +DECLARE_OOXMLEXPORT_TEST(testAutofit, "autofit.docx") +{ + CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(getShape(1), "TextAutoGrowHeight"))); + CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(getShape(2), "TextAutoGrowHeight"))); +} + +DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedParagraphMark, "testTrackChangesDeletedParagraphMark.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:del"); +} + +DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedParagraphMark, "testTrackChangesInsertedParagraphMark.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:ins"); +} + +DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedTableRow, "testTrackChangesDeletedTableRow.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:del"); +} + +DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedTableRow, "testTrackChangesInsertedTableRow.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:ins"); +} + +DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedTableCell, "testTrackChangesDeletedTableCell.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellDel"); +} + +DECLARE_OOXMLEXPORT_TEST(testTrackChangesInsertedTableCell, "testTrackChangesInsertedTableCell.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:tc/w:tcPr/w:cellIns"); +} + +DECLARE_OOXMLEXPORT_TEST(testTextBoxPictureFill, "textbox_picturefill.docx") +{ + uno::Reference<beans::XPropertySet> xFrame(getShape(1), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP, getProperty<drawing::FillStyle>(xFrame, "FillStyle")); + CPPUNIT_ASSERT(!(getProperty<OUString>(xFrame,"FillBitmapURL")).isEmpty()); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO73034, "FDO73034.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:rPr/w:u", "val").match("single")); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO71834, "fdo71834.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[2]/w:tc[1]/w:tcPr[1]/w:tcW[1]","type", "dxa"); +} + +DECLARE_OOXMLEXPORT_TEST(testTrackChangesParagraphProperties, "testTrackChangesParagraphProperties.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPathChildren(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:pPrChange", 0); +} + +DECLARE_OOXMLEXPORT_TEST(testMsoSpt180, "mso-spt180.docx") +{ + if (!mbExported) + return; + + uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xGroup->getByIndex(0), "CustomShapeGeometry"); + OUString aType; + for (int i = 0; i < aProps.getLength(); ++i) + if (aProps[i].Name == "Type") + aType = aProps[i].Value.get<OUString>(); + // This was exported as borderCallout90, which is an invalid drawingML preset shape string. + CPPUNIT_ASSERT_EQUAL(OUString("ooxml-borderCallout1"), aType); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo73550, "fdo73550.docx") +{ + xmlDocPtr pXmlDocument = parseExport("word/document.xml"); + if (!pXmlDocument) + return; + // This was wrap="none". + assertXPath(pXmlDocument, "/w:document/w:body/w:p[2]/w:pPr/w:rPr/w:rFonts"); +} + +DECLARE_OOXMLEXPORT_TEST(testPageRelSize, "pagerelsize.docx") +{ + // First shape: width is relative from page, but not height. + uno::Reference<drawing::XShape> xShape = getShape(1); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation")); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation")); + + // Second shape: height is relative from page, but not height. + xShape = getShape(2); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::PAGE_FRAME, getProperty<sal_Int16>(xShape, "RelativeHeightRelation")); + CPPUNIT_ASSERT_EQUAL(text::RelOrientation::FRAME, getProperty<sal_Int16>(xShape, "RelativeWidthRelation")); +} + +DECLARE_OOXMLEXPORT_TEST(testRelSizeRound, "rel-size-round.docx") +{ + // This was 9: 9.8 was imported as 9 instead of being rounded to 10. + CPPUNIT_ASSERT_EQUAL(sal_Int16(10), getProperty<sal_Int16>(getShape(1), "RelativeHeight")); +} + +DECLARE_OOXMLEXPORT_TEST(testTestTitlePage, "testTitlePage.docx") +{ + CPPUNIT_ASSERT_EQUAL(OUString("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), parseDump("/root/page[2]/footer/txt/text()")); +} + +DECLARE_OOXMLEXPORT_TEST(testTableRowDataDisplayedTwice,"table-row-data-displayed-twice.docx") +{ + // fdo#73534: There was a problem for some documents during export.Invalid sectPr getting added + // because of wrong condition in code. + // This was the reason for increasing number of pages after RT + uno::Reference<frame::XModel> xModel(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextViewCursorSupplier> xTextViewCursorSupplier(xModel->getCurrentController(), uno::UNO_QUERY); + uno::Reference<text::XPageCursor> xCursor(xTextViewCursorSupplier->getViewCursor(), uno::UNO_QUERY); + xCursor->jumpToLastPage(); + CPPUNIT_ASSERT_EQUAL(sal_Int16(2), xCursor->getPage()); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo73556,"fdo73556.docx") +{ + /* + * The file contains a table with 3 columns + * the girdcols are as follows: {1210, 1331, 1210} + * whereas the individual cells have {1210, 400, 1210} + * The table column separators were taken from the Grid, while + * the table width was calculated as 2820 from cells instead + * of 3751 from the Grid. + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol", 3); + sal_Int32 tableWidth = 0; + tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[1]", "w").toInt32(); + tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").toInt32(); + tableWidth += getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[3]", "w").toInt32(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3751), tableWidth); +} + +DECLARE_OOXMLEXPORT_TEST(testSegFaultWhileSave, "test_segfault_while_save.docx") +{ + // fdo#74499 + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblGrid/w:gridCol[2]", "w").match("6138")); +} + +DECLARE_OOXMLEXPORT_TEST(fdo69656, "Table_cell_auto_width_fdo69656.docx") +{ + // Changed the UT to check "dxa" instead of "auto" + // For this particular issue file few cells have width type "auto" + // LO supports VARIABLE and FIXED width type. + // If type is VARIABLE LO calculates width as percent of PageSize + // Else if the width is fixed it uses the width value. + // After changes for fdo76741 the fixed width is exported as "dxa" for DOCX + + // Check for the width type of table and its cells. + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tblPr/w:tblW","type","dxa"); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo76741, "fdo76741.docx") +{ + + // There are two issue related to table in the saved(exported) file + // - the table alignment in saved file is "left" instead of "center" + // - the table width type in properties is "auto" instead of "dxa" + + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "//w:jc", "val", "center"); + assertXPath(pXmlDoc, "//w:tblW", "w", "10081"); + assertXPath(pXmlDoc, "//w:tblW", "type", "dxa"); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo73541,"fdo73541.docx") +{ + // fdo#73541: The mirrored margins were not imported and mapped correctly in Page Layout + // Hence <w:mirrorMargins /> tag was not exported back in settings.xml + xmlDocPtr pXmlDoc = parseExport("word/settings.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:settings/w:mirrorMargins"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO74106, "FDO74106.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:numFmt", "val","hebrew1"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO74215, "FDO74215.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:numbering/w:numPicBullet[2]/w:pict/v:shape", "style", "width:6.4pt;height:6.4pt"); +} + +DECLARE_OOXMLEXPORT_TEST(testColumnBreak_ColumnCountIsZero,"fdo74153.docx") +{ + /* fdo73545: Column Break with Column_count = 0 was not getting preserved. + * The <w:br w:type="column" /> was missing after roundtrip + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[1]/w:br","type","column"); +} + +DECLARE_OOXMLEXPORT_TEST(testIndentation, "test_indentation.docx") +{ + // fdo#74141 :There was a problem that in style.xml and document.xml in <w:ind> tag "right" & "left" margin + // attributes gets added(w:right=0 & w:left=0) if these attributes are not set in original document. + // This test is to verify <w:ind> does not contain w:right attribute. + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:ind", "end", ""); +} + +DECLARE_OOXMLEXPORT_TEST(testChartInFooter, "chart-in-footer.docx") +{ + // fdo#73872: document contains chart in footer. + // The problem was that footer1.xml.rels files for footer1.xml + // files were missing from docx file after roundtrip. + xmlDocPtr pXmlDoc = parseExport("word/_rels/footer1.xml.rels"); + if(!pXmlDoc) + return; + + // Check footer1.xml.rels contains in doc after roundtrip. + // Check Id = rId1 in footer1.xml.rels + assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship","Id","rId1"); + + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + if (xDrawPageSupplier.is()) + { + // If xDrawPage->getCount()==1, then document conatins one shape. + uno::Reference<container::XIndexAccess> xDrawPage(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xDrawPage->getCount()); // One shape in the doc + } +} + +DECLARE_OOXMLEXPORT_TEST(testNestedTextFrames, "nested-text-frames.odt") +{ + // First problem was LO crashed during export (crash test) + + // Second problem was LO made file corruption, writing out nested text boxes, which can't be handled by Word. + // Test that all three exported text boxes are anchored to the same paragraph and not each other. + uno::Reference<text::XTextContent> xTextContent(getShape(1), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xRange(xTextContent->getAnchor(), uno::UNO_QUERY); + uno::Reference<text::XText> xText(xRange->getText(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString()); + + xTextContent.set(getShape(2), uno::UNO_QUERY); + xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY); + xText.set(xRange->getText(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString()); + + xTextContent.set(getShape(3), uno::UNO_QUERY); + xRange.set(xTextContent->getAnchor(), uno::UNO_QUERY); + xText.set(xRange->getText(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString()); +} + +DECLARE_OOXMLEXPORT_TEST(testFloatingTablePosition, "floating-table-position.docx") +{ + // Position of shape was wrong, because some conversion was missing. + uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); + // This was 3295. + CPPUNIT_ASSERT_EQUAL(sal_Int32(5964), getProperty<sal_Int32>(xShape, "HoriOrientPosition")); + // This was 4611. + CPPUNIT_ASSERT_EQUAL(sal_Int32(8133), getProperty<sal_Int32>(xShape, "VertOrientPosition")); +} + +DECLARE_OOXMLEXPORT_TEST(testAbi11739, "abi11739.docx") +{ + // Validation test: order of elements were wrong. + xmlDocPtr pXmlDoc = parseExport("word/styles.xml"); + if (!pXmlDoc) + return; + // Order was: uiPriority, link, basedOn. + CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "basedOn") < getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "link")); + CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "link") < getXPathPosition(pXmlDoc, "/w:styles/w:style[3]", "uiPriority")); + // Order was: qFormat, unhideWhenUsed. + CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "unhideWhenUsed") < getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "qFormat")); +} + +DECLARE_OOXMLEXPORT_TEST(testEmbeddedXlsx, "embedded-xlsx.docx") +{ + // check there are two objects and they are FrameShapes + uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount()); + CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(1)->getShapeType()); + CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(2)->getShapeType()); + + // check the objects are present in the exported document.xml + xmlDocPtr pXmlDocument = parseExport("word/document.xml"); + if (!pXmlDocument) + return; + assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/w:object", 2); + + // finally check the embedded files are present in the zipped document + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); + uno::Sequence<OUString> names = xNameAccess->getElementNames(); + int nSheetFiles = 0; + int nImageFiles = 0; + for (int i=0; i<names.getLength(); i++) + { + if(names[i].startsWith("word/embeddings/oleObject")) + nSheetFiles++; + if(names[i].startsWith("word/media/image")) + nImageFiles++; + } + CPPUNIT_ASSERT_EQUAL(2, nSheetFiles); + CPPUNIT_ASSERT_EQUAL(2, nImageFiles); +} + +DECLARE_OOXMLEXPORT_TEST(testNumberedLists_StartingWithZero, "FDO74105.docx") +{ + /* Issue : Numbered lists Starting with value '0' is not preserved after RT. + * In numbering.xml, an XML tag <w:start> is optional. If not mentioned, + * the Numbered list should start from 0. + * Problem was LO was writing <w:start> for all levels 0-8 with default value "1". + */ + xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); + if (!pXmlDoc) + return; + + // Check that we do _not_ export w:start for <w:lvl w:ilvl="0">. + assertXPath(pXmlDoc, "w:numbering/w:abstractNum[1]/w:lvl[1]/w:start", 0); +} + +DECLARE_OOXMLEXPORT_TEST(testPageBreak,"fdo74566.docx") +{ + /* Break to next page was written into wrong paragraph as <w:pageBreakBefore />. + * LO was not preserving Page Break as <w:br w:type="page" />. + * Now after fix , LO writes Page Break as the new paragraph and also + * preserves the xml tag <w:br>. + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + uno::Reference<text::XTextRange> xParagraph2 = getParagraph(2); + uno::Reference<text::XTextRange> xParagraph4 = getParagraph(4); + + getRun(xParagraph2, 1, "First Page Second Line"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:r[2]/w:br","type","page"); + getRun(xParagraph4, 1, "Second Page First line after Page Break"); +} + +DECLARE_OOXMLEXPORT_TEST(testOleObject, "test_ole_object.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata", "o:title", ""); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo74792, "fdo74792.docx") +{ + /* + * fdo#74792 : The images associated with smart-art data[i].xml + * were not preserved on exporting to DOCX format + * Added support to grabbag the rels, with associated images. + */ + xmlDocPtr pXmlDoc = parseExport("word/diagrams/_rels/data1.xml.rels"); + if(!pXmlDoc) + return; + assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship", 4); + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL( + comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); + + //check that images are also saved + OUString sImageFile( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name + uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName( sImageFile ), uno::UNO_QUERY); + CPPUNIT_ASSERT( xInputStream.is() ); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo77718, "fdo77718.docx") +{ + //in case of multiple smart arts the names for images were getting + //repeated and thereby causing a data loss as the binary stream was + //getting over written. This test case ensures that unique names are + //given for images in different smart arts. + xmlDocPtr pXmlDataRels1 = parseExport("word/diagrams/_rels/data1.xml.rels"); + if( !pXmlDataRels1 ) + return; + + xmlDocPtr pXmlDataRels2 = parseExport("word/diagrams/_rels/data2.xml.rels"); + if( !pXmlDataRels2 ) + return; + + //ensure that the rels file is present. + assertXPath(pXmlDataRels1,"/rels:Relationships/rels:Relationship", 4); + assertXPath(pXmlDataRels2,"/rels:Relationships/rels:Relationship", 4); + + uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL( + comphelper::getComponentContext(m_xSFactory), maTempFile.GetURL()); + + //check that images are also saved + OUString sImageFile1( "word/media/OOXDiagramDataRels1_0.jpeg" ); //added anchor id to form a uniqe name + uno::Reference<io::XInputStream> xInputStream1(xNameAccess->getByName( sImageFile1 ), uno::UNO_QUERY); + CPPUNIT_ASSERT( xInputStream1.is() ); + + //check that images are saved for other smart-arts as well. + OUString sImageFile2( "word/media/OOXDiagramDataRels2_0.jpeg" ); //added anchor id to form a uniqe name + uno::Reference<io::XInputStream> xInputStream2(xNameAccess->getByName( sImageFile2 ), uno::UNO_QUERY); + CPPUNIT_ASSERT( xInputStream2.is() ); +} + +DECLARE_OOXMLEXPORT_TEST(testTableCurruption, "tableCurrupt.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/header2.xml"); + if (!pXmlDoc) + return; + CPPUNIT_ASSERT(pXmlDoc) ; + assertXPath(pXmlDoc, "/w:hdr/w:tbl[1]/w:tr[1]/w:tc[1]",1); +} + +DECLARE_OOXMLEXPORT_TEST(testDateControl, "date-control.docx") +{ + // check XML + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date", "fullDate", "2014-03-05T00:00:00Z"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:dateFormat", "val", "dddd, dd' de 'MMMM' de 'yyyy"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:date/w:lid", "val", "es-ES"); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "miércoles, 05 de marzo de 2014"); + + // check imported control + uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY); + util::Date aDate = getProperty<util::Date>(xControl->getControl(), "Date"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(5), sal_Int32(aDate.Day)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), sal_Int32(aDate.Month)); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2014), sal_Int32(aDate.Year)); +} + +DECLARE_OOXMLEXPORT_TEST(test_OpeningBrace, "2120112713_OpenBrace.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + // Checking for OpeningBrace tag + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[1]/m:dPr[1]/m:begChr[1]","val",""); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO76312, "FDO76312.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl[1]/w:tr[1]/w:tc[1]"); +} + +DECLARE_OOXMLEXPORT_TEST(testComboBoxControl, "combobox-control.docx") +{ + // check XML + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[1]", "value", "manolo"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dropDownList/w:listItem[2]", "value", "pepito"); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r/w:t", "Manolo"); + + // check imported control + uno::Reference<drawing::XControlShape> xControl(getShape(1), uno::UNO_QUERY); + + CPPUNIT_ASSERT_EQUAL(OUString("Manolo"), getProperty<OUString>(xControl->getControl(), "Text")); + + uno::Sequence<OUString> aItems = getProperty< uno::Sequence<OUString> >(xControl->getControl(), "StringItemList"); + CPPUNIT_ASSERT_EQUAL(sal_Int32(2), sal_Int32(aItems.getLength())); + CPPUNIT_ASSERT_EQUAL(OUString("manolo"), aItems[0]); + CPPUNIT_ASSERT_EQUAL(OUString("pepito"), aItems[1]); +} + +DECLARE_OOXMLEXPORT_TEST(testCheckBoxControl, "checkbox-control.docx") +{ + // check XML + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:checked", "val", "1"); + assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:checkedState", "val", "2612"); + assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w14:checkbox/w14:uncheckedState", "val", "2610"); + + // TODO: import control and add a check here +} + +DECLARE_OOXMLEXPORT_TEST(testParagraphWithComments, "paragraphWithComments.docx") +{ + /* Comment id's were getting overwritten for annotation mark(s), + which was causing a mismatch in the relationship for comment id's + in document.xml and comment.xml + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + xmlDocPtr pXmlComm = parseExport("word/comments.xml"); + if(!pXmlDoc) + return; + + sal_Int32 idInDocXml = 0; + sal_Int32 idInCommentXml = -1; //intentionally assigning -1 so that it differs from idInDocXml + //and also because getXpath does not assert. + idInDocXml = getXPath(pXmlDoc,"/w:document/w:body/w:p[3]/w:commentRangeEnd[1]","id").toInt32(); + idInCommentXml = getXPath(pXmlComm,"/w:comments/w:comment[1]","id").toInt32(); + CPPUNIT_ASSERT_EQUAL( idInDocXml, idInCommentXml ); +} + +DECLARE_OOXMLEXPORT_TEST(testOLEObjectinHeader, "2129393649.docx") +{ + // fdo#76015 : Document contains oleobject in header xml. + // Problem was relationship entry for oleobject from header was + // exported into document.xml.rels file because of this rels file + // for headers were missing from document/word/rels. + xmlDocPtr pXmlDoc = parseExport("word/_rels/header1.xml.rels"); + if(!pXmlDoc) + return; + + assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship[1]","Id","rId1"); +} + +DECLARE_OOXMLEXPORT_TEST(test_ClosingBrace, "2120112713.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + // Checking for ClosingBrace tag + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/m:oMath[1]/m:d[2]/m:dPr[1]/m:endChr[1]","val",""); +} + +DECLARE_OOXMLEXPORT_TEST(testlvlPicBulletId, "lvlPicBulletId.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:numbering[1]/w:abstractNum[1]/w:lvl[1]/w:lvlPicBulletId[1]", 0); +} + +DECLARE_OOXMLEXPORT_TEST(testSdtContent, "SdtContent.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/header1.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:hdr[1]/w:sdt[1]/w:sdtContent[1]/w:p[1]/w:del[1]"); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo76016, "fdo76016.docx") +{ + // check XML + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[1]", "name", "adj1"); + assertXPath(pXmlDoc, "//a:graphic/a:graphicData/wps:wsp/wps:spPr/a:prstGeom/a:avLst/a:gd[2]", "name", "adj2"); +} + +DECLARE_OOXMLEXPORT_TEST(testFileWithInvalidImageLink, "FileWithInvalidImageLink.docx") +{ + /* In case if the original file has an image whose link is + invalid, then the RT file used to result in corruption + since the exported image would be an empty image. + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + 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", ""); +} + +DECLARE_OOXMLEXPORT_TEST(testContentTypeDOCX, "fdo80410.docx") +{ + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) // only test the export, not initial import + return; + + assertXPath(pXmlDoc, + "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.docx']", + "ContentType", + "application/vnd.openxmlformats-officedocument.wordprocessingml.document"); +} + +DECLARE_OOXMLEXPORT_TEST(testContentTypeXLSM, "fdo76098.docx") +{ + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "ContentType", "application/vnd.ms-excel.sheet.macroEnabled.12"); +} + +DECLARE_OOXMLEXPORT_TEST(test76108, "test76108.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) return; + //docx file after RT is getting corrupted. + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:fldChar[1]", "fldCharType", "begin"); +} + +DECLARE_OOXMLEXPORT_TEST(testTCTagMisMatch, "TCTagMisMatch.docx") +{ + // TCTagMisMatch.docx : This document contains a empty table with borders. + // there was a TC tag mismatch which resulted into a crash. + + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if(!pXmlDoc) + return; + 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); + assertXPath(pXmlDoc,"/w:document[1]/w:body[1]/w:tbl[1]/w:tr[1]/w:tc[1]", 1); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO78292, "FDO78292.docx") +{ + //text node is a leaf node, it should not have any children + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if(!pXmlDoc) + return; + assertXPath(pXmlDoc,"/w:document/w:body/w:p[14]/w:sdt[3]/w:sdtPr[1]/w:text/w14:checked",0); +} + +DECLARE_OOXMLEXPORT_TEST(testSimpleSdts, "simple-sdts.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:text", 1); + assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:id", 3); + assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:picture", 1); + assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:group", 1); + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:citation", 1); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx new file mode 100644 index 000000000000..59ae8959886f --- /dev/null +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -0,0 +1,677 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <swmodeltestbase.hxx> + +#include <com/sun/star/awt/XBitmap.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/LineJoint.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> +#include <com/sun/star/drawing/XControlShape.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/style/TabStop.hpp> +#include <com/sun/star/view/XViewSettingsSupplier.hpp> +#include <com/sun/star/text/RelOrientation.hpp> +#include <com/sun/star/text/XTextFrame.hpp> +#include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextFramesSupplier.hpp> +#include <com/sun/star/text/XTextViewCursorSupplier.hpp> +#include <com/sun/star/text/XTextSection.hpp> +#include <com/sun/star/style/CaseMap.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> +#include <com/sun/star/style/LineSpacing.hpp> +#include <com/sun/star/style/LineSpacingMode.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/table/BorderLine2.hpp> +#include <com/sun/star/table/ShadowFormat.hpp> +#include <com/sun/star/text/GraphicCrop.hpp> +#include <com/sun/star/text/XPageCursor.hpp> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/FontUnderline.hpp> +#include <com/sun/star/awt/FontSlant.hpp> +#include <com/sun/star/text/WritingMode2.hpp> +#include <com/sun/star/text/WrapTextMode.hpp> +#include <com/sun/star/xml/dom/XDocument.hpp> +#include <com/sun/star/style/BreakType.hpp> +#include <unotools/tempfile.hxx> +#include <comphelper/sequenceashashmap.hxx> +#include <com/sun/star/text/XDocumentIndex.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp> +#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp> +#include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/Hatch.hpp> + +#include <string> + +class Test : public SwModelTestBase +{ +public: + Test() : SwModelTestBase("/sw/qa/extras/ooxmlexport/data/", "Office Open XML Text") {} + +protected: + /** + * Blacklist handling + */ + bool mustTestImportOf(const char* filename) const SAL_OVERRIDE { + const char* aBlacklist[] = { + "math-escape.docx", + "math-mso2k7.docx", + "ImageCrop.docx", + "test_GIF_ImageCrop.docx", + "test_PNG_ImageCrop.docx" + }; + std::vector<const char*> vBlacklist(aBlacklist, aBlacklist + SAL_N_ELEMENTS(aBlacklist)); + + // If the testcase is stored in some other format, it's pointless to test. + return (OString(filename).endsWith(".docx") && std::find(vBlacklist.begin(), vBlacklist.end(), filename) == vBlacklist.end()); + } +}; + +DECLARE_OOXMLEXPORT_TEST(testFDO76248, "FDO76248.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + // In two cases the a:graphicData elements had no children, which is invalid. + assertXPath(pXmlDoc, "//a:graphicData[not(*)]", 0); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo76589 , "fdo76589.docx") +{ + /* Numbered list was not preserve after RT. + * In numbering.xml, when NumberingType is "decimal" and level is zero, + * w:val of w:lvlText was empty. + * It should be <w:lvlText w:val="%1" /> + */ + xmlDocPtr pXmlDoc = parseExport("word/numbering.xml"); + if (!pXmlDoc) + return; + + assertXPath ( pXmlDoc, "/w:numbering/w:abstractNum[1]/w:lvl[1]/w:lvlText","val","%1" ); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo79008, "fdo79008.docx") +{ + /* File getting crash while saving in LO. + * Checking if document.xml file is getting created after fix + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; +} + +DECLARE_OOXMLEXPORT_TEST(testAuthorPropertySdt, "author-property.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "xpath", "/ns1:coreProperties[1]/ns0:creator[1]"); + assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "storeItemID","{6C3C8BC8-F283-45AE-878A-BAB7291924A1}"); + // FIXME: the next property doesn't match, though it's correct in theory. A bug in assertXPath? + // assertXPath(pXmlDoc, "/w:document/w:body/w:sdt/w:sdtPr/w:dataBinding", "prefixMappings", + // "xmlns:ns0='http://purl.org/dc/elements/1.1/' xmlns:ns1='http://schemas.openxmlformats.org/package/2006/metadata/core-properties'"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO76586, "fdo76586.docx") +{ + /* + * In the test file gridCol had only one value for entire table width + * while there are two cells in a table row. + * So the table was not imported with the correct cell widths + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + + // there is only one table in the test file + assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[1]", "w", "1601"); + assertXPath(pXmlDoc, "//w:tblGrid/w:gridCol[2]", "w", "7843"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO76587 , "fdo76587.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/styles.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:styles/w:style[8]/w:pPr/w:spacing", "line", "240"); + assertXPath(pXmlDoc, "/w:styles/w:style[8]/w:pPr/w:spacing", "lineRule", "auto"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO77890 , "fdo77890.docx") +{ + /* + Ensure that the page break is preserved i.e it should not be converted to a section break, in case + if the different first page is set for the pages in the document. + For additional comments pls refer https://www.libreoffice.org/bugzilla/show_bug.cgi?id=77890#c2 + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[2]/w:br", "type", "page"); +} + +DECLARE_OOXMLEXPORT_TEST(testNumberedList,"NumberedList.docx") +{ + //fdo74150:In document.xml, for pStyle = "NumberedList1", iLvl and numId was not preserved + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:p[1]/w:pPr[1]/w:pStyle", "val", "NumberedList1"); + 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"); + 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"); + + 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"); + 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"); + 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"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO76597, "fdo76597.docx") +{ + // check XML + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "before", "96"); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[4]/w:pPr/w:spacing", "after", "120"); +} + +DECLARE_OOXMLEXPORT_TEST(testContentTypeTIF, "fdo77476.docx") +{ + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@ContentType='image/tif']", "PartName", "/word/media/image1.tif"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO77117, "fdo77117.docx") +{ + uno::Reference<drawing::XShapes> xGroup(getShape(1), uno::UNO_QUERY); + uno::Reference<text::XTextRange> xShape(xGroup->getByIndex(0), uno::UNO_QUERY); + // This checks textbox textrun size of font which is in group shape. + CPPUNIT_ASSERT_EQUAL(11.f, getProperty<float>(xShape, "CharHeight")); +} + +DECLARE_OOXMLEXPORT_TEST(testFloatingTable, "fdo77887.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "horzAnchor", "margin"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "leftFromText", "141"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "rightFromText", "141"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpXSpec", "center"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "tblpY", "2266"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblpPr[1]", "vertAnchor", "page"); + +} + + +DECLARE_OOXMLEXPORT_TEST(testTablePreferredWidth, "tablePreferredWidth.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if(!pXmlDoc) + return; + + // Problem :If the table preferred width is in percent, then after RT it changes to 0 & width type changes + // to 'auto' instead of 'pct'. + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "w", "3000"); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:tbl[1]/w:tblPr[1]/w:tblW[1]", "type","pct"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO75431, "fdo75431.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "//w:tbl", 2); + assertXPath(pXmlDoc, "//w:p/w:pPr/w:sectPr/w:type", "val", "nextPage"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO77725, "fdo77725.docx") +{ + xmlDocPtr pXmlFootnotes = parseExport("word/footnotes.xml"); + if (!pXmlFootnotes) + return; + + assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[1]", 0); + assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[2]", 0); + assertXPath(pXmlFootnotes, "//w:footnotes[1]/w:footnote[3]/w:p[3]/w:r[1]/w:br[3]", 0); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO77812, "fdo77812.docx") +{ + /* Additional sectPr was getting inserted and hence Column properties + * were getting added into this additional sectPr instead of Default setPr. + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + // Check no additional section break is inserted. + assertXPath(pXmlDoc, "/w:document/w:body/w:p[6]/w:pPr/w:sectPr", 0); + + // Check w:cols comes under Default sectPr + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols", "num", "2"); + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols/w:col[1]", 1); + assertXPath(pXmlDoc, "/w:document/w:body/w:sectPr/w:cols/w:col[2]", 1); +} + +DECLARE_OOXMLEXPORT_TEST(testContentTypeOLE, "fdo77759.docx") +{ + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, + "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet']", + "PartName", + "/word/embeddings/oleObject1.xlsx"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo78420, "fdo78420.docx") +{ + xmlDocPtr pXmlHeader = parseExport("word/header2.xml"); + + if (!pXmlHeader) + return; + + xmlDocPtr pXmlHeaderRels = parseExport("word/_rels/header2.xml.rels"); + if(!pXmlHeaderRels) + return; + + assertXPath(pXmlHeaderRels,"/rels:Relationships/rels:Relationship[1]","Id","rId1"); +} + + +DECLARE_OOXMLEXPORT_TEST(testPageBreakInFirstPara,"fdo77727.docx") +{ + /* Break to next page was not exported if it is in first paragraph of the section. + * Now after fix , LO writes Next Page Break and also preserves <w:br> tag. + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br","type","page"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO78284, "fdo78284.docx") +{ + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + assertXPath(pXmlDoc,"/ContentType:Types/ContentType:Override[@PartName='/word/media/OOXDiagramDataRels1_0.png']", + "ContentType", + "image/png"); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO78384,"fdo78384.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[1]/w:rPr/w:rFonts","ascii","Wingdings"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo78469, "fdo78469.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/header1.xml"); + if (!pXmlDoc) + return; + // make sure dataBinding & text tags not presernt in sdtcontent + 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); + 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); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO78887, "fdo78887.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[1]", 1); + assertXPathContent(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:t[1]", "Lyrics: "); + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[1]/w:r[1]/w:br[2]", 1); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo78651, "fdo78651.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + // ensure that there are only two tables + assertXPath(pXmlDoc, "//w:tbl", 2); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo78882, "fdo78882.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + + // Ensure that Section Break is getting written inside second paragraph + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:pPr[1]/w:sectPr[1]",1); + + // Ensure that no dummy paragarph gets created inside second paragraph for Section Break + assertXPath(pXmlDoc, "/w:document[1]/w:body[1]/w:p[2]/w:p[1]/w:pPr[1]/w:sectPr[1]",0); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo76934, "fdo76934.docx") +{ + /* Issue was, AuoSpacing property if present inside styles.xml, LO was not able to + * preserve it. + */ + + xmlDocPtr pXmlDoc = parseExport("word/styles.xml"); + + if (!pXmlDoc) + return; + + // Ensure that after fix LO is preserving AutoSpacing property in styles.xml + assertXPath ( pXmlDoc, "/w:styles[1]/w:style[36]/w:pPr[1]/w:spacing[1]", "beforeAutospacing", "1" ); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo79540, "fdo79540.docx") +{ + /* Issue was, <w:drawing> was getting written inside <w:drawing>. + * So Postone the writing of Inner Drawing tag. + * MS Office does not allow Nestimg of drawing tags. + */ + + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + + // Ensure that two separate w:drawing tags are written after the code changes. + assertXPath ( pXmlDoc, "/w:document/w:body/w:p/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing",1); + assertXPath ( pXmlDoc, "/w:document/w:body/w:p/w:r[3]/mc:AlternateContent/mc:Choice/w:drawing",1); +} + +DECLARE_OOXMLEXPORT_TEST(testFDO79062, "fdo79062.docx") +{ + xmlDocPtr pXmlFootNotes = parseExport("word/footnotes.xml"); + if (!pXmlFootNotes) + return; + assertXPath(pXmlFootNotes, "/w:footnotes", "Ignorable", "w14 wp14"); + + xmlDocPtr pXmlEndNotes = parseExport("word/endnotes.xml"); + if (!pXmlEndNotes) + return; + assertXPath(pXmlEndNotes, "/w:endnotes", "Ignorable", "w14 wp14"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo79668,"fdo79668.docx") +{ + // fdo#79668: Document was Crashing on DebugUtil build while Saving + // because of repeated attribute value in same element. + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + // w:pPr's w:shd attributes were getting added to w:pPrChange/w:pPr's w:shd hence checking + // w:fill for both shd elements + assertXPath ( pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:shd", "fill", "FFFFFF" ); + assertXPath ( pXmlDoc, "/w:document/w:body/w:p[9]/w:pPr/w:pPrChange/w:pPr/w:shd", "fill", "FFFFFF" ); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo78907,"fdo78907.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + assertXPath ( pXmlDoc, "/w:document/w:body/w:p[1]/w:r[2]/w:br", "type", "page" ); + + xmlDocPtr pXmlDoc1 = parseExport("word/footer1.xml"); + if (!pXmlDoc1) + return; + 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 ); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo79822, "fdo79822.docx") +{ + /* File getting crash while saving in LO. + * The Docx contain smartart and the file was created in ms word 2007 + */ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; +} + +DECLARE_OOXMLEXPORT_TEST(testFDO79915, "fdo79915.docx") +{ + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[2]/w:r[8]/w:t", "How much buoyancy does the water provide?"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo79817, "fdo79817.docx") +{ + if (xmlDocPtr pXmlDoc = parseExport("word/document.xml")) + { + assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtPr/w:dataBinding", "storeItemID", "{9222E47B-A68B-4AEB-9855-21C912B9D3D2}"); + 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]"); + } +} + + +DECLARE_OOXMLEXPORT_TEST(testfdo79968_sldx, "fdo79968.docx") +{ + // This UT for DOCX embedded with powerpoint slide + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, + "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.presentationml.slide']", + "PartName", + "/word/embeddings/oleObject1.sldx"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo79969_xlsb, "fdo79969_xlsb.docx") +{ + // This UT for DOCX embedded with binary excel work sheet. + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, + "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-excel.sheet.binary.macroEnabled.12']", + "PartName", + "/word/embeddings/oleObject1.xlsb"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo80097, "fdo80097.docx") +{ + //fdo#76635 : Table borders are not getting preserved. + + xmlDocPtr pXmlDocument = parseExport("word/document.xml"); + if (!pXmlDocument) + return; + + //Table Borders + 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); + 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); + 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); + 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); + + 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); + 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); + 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); + 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); + + 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); + 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); + 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); + 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); + + 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); + 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); + 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); + 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); + + //Table Cell Borders + 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); + 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); + 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); + 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); + + 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); + 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); + 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); + 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); + + 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); + 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); + 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); + 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); + + 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); + 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); + 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); + 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); +} + +DECLARE_OOXMLEXPORT_TEST(testFdo77129, "fdo77129.docx") +{ + // The problem was that text after TOC field was missing if footer reference comes in field. + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + + if (!pXmlDoc) + return; + + // Data was lost from this paragraph. + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[5]/w:r[1]/w:t", "Abstract"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo79969_xlsm, "fdo79969_xlsm.docx") +{ + // This UT for DOCX embedded with excel work sheet. + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, + "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-excel.sheet.macroEnabled.12']", + "PartName", + "/word/embeddings/oleObject1.xlsm"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo80522,"fdo80522.docx") +{ + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, + "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-word.document.macroEnabled.12']", + "PartName", + "/word/embeddings/oleObject1.docm"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo80523_pptm,"fdo80523_pptm.docx") +{ + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, + "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-powerpoint.presentation.macroEnabled.12']", + "PartName", + "/word/embeddings/oleObject1.pptm"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo80523_sldm,"fdo80523_sldm.docx") +{ + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, + "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.ms-powerpoint.slide.macroEnabled.12']", + "PartName", + "/word/embeddings/oleObject1.sldm"); +} + +DECLARE_OOXMLEXPORT_TEST(testfdo80898, "fdo80898.docx") +{ + // This UT for DOCX embedded with binary excel work sheet. + xmlDocPtr pXmlDoc = parseExport("[Content_Types].xml"); + + if (!pXmlDoc) + return; + + assertXPath(pXmlDoc, + "/ContentType:Types/ContentType:Override[@ContentType='application/msword']", + "PartName", + "/word/embeddings/oleObject1.doc"); +} + +DECLARE_OOXMLEXPORT_TEST(testTableCellWithDirectFormatting, "fdo80800.docx") +{ + // Issue was Direct Foramatting for non-first Table cells was not getting preserved. + + xmlDocPtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; + + // Ensure that for Third Table cell Direct Formatting is preserved. + // In file, Direct Formatting used for Third Table cell is Line Spacing="1.5 lines" + // For Line Spacing "1.5 lines" w:line equals 360 + assertXPath(pXmlDoc,"/w:document/w:body/w:tbl/w:tr/w:tc[3]/w:p/w:pPr/w:spacing","line","360"); + +} + +DECLARE_OOXMLEXPORT_TEST(test2colHeader, "2col-header.docx") +{ + // Header was lost on export when the document had multiple columns. + uno::Reference<beans::XPropertySet> xPageStyle(getStyles("PageStyles")->getByName(DEFAULT_STYLE), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xPageStyle, "HeaderIsOn")); +} + +DECLARE_OOXMLEXPORT_TEST(testSdt2Run, "sdt-2-run.docx") +{ + xmlDocPtr pXmlDoc = parseExport(); + if (!pXmlDoc) + return; + + // The problem was that <w:sdt> was closed after "first", not after "second", so the second assert failed. + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r[1]/w:t", "first"); + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p/w:sdt/w:sdtContent/w:r[2]/w:t", "second"); + // Make sure the third portion is still outside <w:sdt>. + assertXPathContent(pXmlDoc, "/w:document/w:body/w:p[1]/w:r/w:t", "third"); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |