/* -*- 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/.
*/
class Test : public SwModelTestBase
{ public:
Test() : SwModelTestBase(u"/sw/qa/extras/ooxmlexport/data/"_ustr, u"Office Open XML Text"_ustr) {}
};
CPPUNIT_TEST_FIXTURE(Test, testPageGraphicBackground)
{
loadAndReload("page-graphic-background.odt");
validate(maTempFile.GetFileName(), mpFilter);
CPPUNIT_ASSERT_EQUAL(1, getPages()); // 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(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(xPageStyle, u"BackColor"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testCustomProperties)
{
loadAndSave("custom-properties.docx"); // tdf#133377 tdf#103987 FILESAVE XLSX: Make sure the custom/core/application // file properties are stored correctly after roundtrip to .docx
// Extended file properties - specific to Office package, // eg. docx - Number of Pages, pptx - Number of Slides
xmlDocUniquePtr pXmlDoc = parseExport(u"docProps/app.xml"_ustr);
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Paragraphs", u"1"); //assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Lines", "1");
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Pages", u"1");
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Words", u"3");
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Characters", u"22");
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:CharactersWithSpaces", u"24");
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Company", u"hhhhkompany");
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Manager", u"ffffmenadzer;iiiiisecondmanager");
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:HyperlinkBase", u"gggghiperlink"); //assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:DocSecurity", "2");
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:AppVersion", u"15.0000");
// Custom file properties - defined by user
xmlDocUniquePtr pCustomXml = parseExport(u"docProps/custom.xml"_ustr);
assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property", 9);
assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[1]", "name", u"testDateProperty");
assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[1]/vt:filetime",
u"1982-04-19T10:00:00Z");
assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[3]", "name", u"testNegativeNumberProperty");
assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[3]/vt:r8",
u"-100");
assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[4]", "name", u"testNumberProperty"); //assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[4]/vt:i4", // "256");
assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[5]", "name", u"testRealNumberProperty");
assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[5]/vt:r8",
u"-128.1");
assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[6]", "name", u"testScientificNumber");
assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[6]/vt:r8",
u"1.23456789E+023");
assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[7]", "name", u"testTextProperty");
assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[7]/vt:lpwstr",
u"testPropertyValue");
assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[8]", "name", u"testYesNoProperty");
assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[8]/vt:bool",
u"1"); // Hidden Custom File Property. With Final set, MS Office notifies recipients that the document is final, and sets the document to read-only.
assertXPath(pCustomXml, "/custom-properties:Properties/custom-properties:property[9]", "name", u"_MarkAsFinal");
assertXPathContent(pCustomXml, "/custom-properties:Properties/custom-properties:property[9]/vt:bool",
u"1");
// Validation test: order of elements were wrong.
validate(maTempFile.GetFileName(), mpFilter);
xmlDocUniquePtr pXmlDoc = parseExport(u"word/styles.xml"_ustr); // 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(u"docProps/app.xml"_ustr); // One paragraph in the document.
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Paragraphs", u"1");
assertXPathContent(pXmlDoc, "/extended-properties:Properties/extended-properties:Company", u"Example Ltd");
}
CPPUNIT_TEST_FIXTURE(Test, defaultTabStopNotInStyles)
{
loadAndReload("empty.odt");
validate(maTempFile.GetFileName(), mpFilter);
CPPUNIT_ASSERT_EQUAL(1, getPages()); // The default tab stop was mistakenly exported to a style. // xray ThisComponent.StyleFamilies(1)(0).ParaTabStop
uno::Reference< container::XNameAccess > paragraphStyles = getStyles( u"ParagraphStyles"_ustr );
uno::Sequence< style::TabStop > stops = getProperty< uno::Sequence< style::TabStop > >(
paragraphStyles->getByName( u"Standard"_ustr ), u"ParaTabStops"_ustr ); // There actually 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 );
}
CPPUNIT_TEST_FIXTURE(Test, testFdo38244)
{ auto verify = [this]() { /* * 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(u"Annotation"_ustr, getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr));
xRunEnum->nextElement();
xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(u"AnnotationEnd"_ustr, getProperty<OUString>(xPropertySet, u"TextPortionType"_ustr));
/* * 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
*/
// Saving left and right for parentheses when importing not from the m:t tag (docx)
CPPUNIT_TEST_FIXTURE(Test, testTdf158023Export)
{
loadAndReload("tdf158023_export.docx");
CPPUNIT_ASSERT_EQUAL(u"left [ right ] left ( right ) left lbrace right rbrace"_ustr, getFormula(getRun(getParagraph(1), 1)));
}
CPPUNIT_TEST_FIXTURE(Test, testFdo51034)
{
loadAndReload("fdo51034.odt");
CPPUNIT_ASSERT_EQUAL(1, getPages()); // The problem was that the 'l' param of the HYPERLINK field was parsed with = "#", not += "#".
CPPUNIT_ASSERT_EQUAL(u"http://Www.google.com/#a"_ustr, getProperty(getRun(getParagraph(1), 1), u"HyperLinkURL"_ustr));
}
// 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. staticvoid CHECK_FORMULA(OUString const & expected, OUString const & actual) {
CPPUNIT_ASSERT_EQUAL(
expected.replaceAll( " ", "" ).replaceAll( u"\u2212", "-" ),
actual.replaceAll( " ", "" ).replaceAll( u"\u2212", "-" ));
}
CPPUNIT_TEST_FIXTURE(Test, testMathMso2k7)
{
loadAndReload("math-mso2k7.docx");
CHECK_FORMULA(u"A \"=\" \u03C0 {r} ^ {2}"_ustr, 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(
u"{left (x\"+\"a right )} ^ {n} \"=\" sum from {k\"=\"0} to {n} {left (stack {n # k} right ) {x} ^ {k} {a} ^ {n\"-\"k}}"_ustr,
getFormula(getRun(getParagraph(2), 1)));
CHECK_FORMULA(
u"{left (1\"+\"x right )} ^ {n} \"=\"1\"+\" {nx} over {1!} \"+\" {n left (n\"-\"1 right ) {x} ^ {2}} over {2!} \"+\"\u2026"_ustr,
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(
u"f left (x right ) \"=\" {a} rsub {0} \"+\" sum from {n\"=\"1} to {\u221E} {left ({a} rsub {n} cos {n\u03C0x} over {L} \"+\" {b} rsub {n} sin {n\u03C0x} over {L} right )}"_ustr,
getFormula(getRun(getParagraph(4), 1)));
CHECK_FORMULA(u"{a} ^ {2} \"+\" {b} ^ {2} \"=\" {c} ^ {2}"_ustr,
getFormula(getRun(getParagraph(5), 1)));
CHECK_FORMULA(u"x \"=\" {\"-\" b \u00B1 sqrt {{b} ^ {2} \"-\"4 ac}} over {2 a}"_ustr,
getFormula(getRun(getParagraph(6), 1)));
CHECK_FORMULA(
u"{left (1\"+\"x right )} ^ {n} \"=\"1\"+\" {nx} over {1!} \"+\" {n left (n\"-\"1 right ) {x} ^ {2}} over {2!} \"+\"\u2026"_ustr,
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(
u"f left (x right ) \"=\" {a} rsub {0} \"+\" sum from {n\"=\"1} to {\u221E} {left ({a} rsub {n} cos {n\u03C0x} over {L} \"+\" {b} rsub {n} sin {n\u03C0x} over {L} right )}"_ustr,
getFormula(getRun(getParagraph(4), 1)));
CHECK_FORMULA("{a} ^ {2} \"+\" {b} ^ {2} \"=\" {c} ^ {2}",
getFormula(getRun(getParagraph(5), 1)));
CHECK_FORMULA(u"x \"=\" {\"-\" b \u00B1 sqrt {{b} ^ {2} \"-\"4 ac}} over {2 a}"_ustr,
getFormula(getRun(getParagraph(6), 1)));
CHECK_FORMULA(
u"{e} ^ {x} \"=\"1\"+\" {x} over {1!} \"+\" {{x} ^ {2}} over {2!} \"+\" {{x} ^ {3}} over {3!} \"+\"\u2026,\" \" \" \" \"-\"\u221E\"<\"x\"<\"\u221E"_ustr,
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 {})
u"sin \u03B1 \u00B1 sin \u03B2 \"=\"2 sin {1} over {2} left (\u03B1\u00B1\u03B2 right ) cos {1} over {2} left (\u03B1\u2213\u03B2 right )"_ustr,
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 {})
u"cos \u03B1 \"+\" cos \u03B2 \"=\"2 cos {1} over {2} left (\u03B1\"+\"\u03B2 right ) cos {1} over {2} left (\u03B1\"-\"\u03B2 right )"_ustr,
getFormula(getRun(getParagraph(9), 1)));
}
DECLARE_OOXMLEXPORT_TEST(testMathNary, "math-nary.docx")
{
CHECK_FORMULA(u"lllint from {1} to {2} {x \"+\" 1}"_ustr,
getFormula(getRun(getParagraph(1), 1)));
CHECK_FORMULA( u"prod from {a} {b}"_ustr, getFormula( getRun( getParagraph( 1 ), 2 )));
CHECK_FORMULA( u"sum to {2} {x}"_ustr, getFormula( getRun( getParagraph( 1 ), 3 )));
}
CPPUNIT_TEST_FIXTURE(Test, testFdo51550)
{
loadAndReload("fdo51550.odt");
CPPUNIT_ASSERT_EQUAL(1, getShapes());
CPPUNIT_ASSERT_EQUAL(1, getPages()); // The problem was that we lacked the fallback to export the replacement // graphic for OLE objects. But we can actually export the OLE itself now, // so check that instead.
uno::Reference<text::XTextEmbeddedObjectsSupplier> xTextEmbeddedObjectsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xEmbeddedObjects(xTextEmbeddedObjectsSupplier->getEmbeddedObjects(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xEmbeddedObjects->getCount());
// check the rels too
xmlDocUniquePtr pXmlDocRels = parseExport(u"word/_rels/document.xml.rels"_ustr);
assertXPath(pXmlDocRels, "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xlsx']", "Type",
u"http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); // check the content too
xmlDocUniquePtr pXmlDocContent = parseExport(u"word/document.xml"_ustr);
assertXPath(pXmlDocContent, "/w:document/w:body/w:p/w:r/w:object/o:OLEObject", "ProgID",
u"Excel.Sheet.12");
}
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
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
CPPUNIT_TEST_FIXTURE(Test, testTextFrames)
{
loadAndReload("textframes.odt");
CPPUNIT_ASSERT_EQUAL(1, getPages()); // The frames were simply missing, so let's check if all 3 frames were imported back.
CPPUNIT_ASSERT_EQUAL(3, getShapes());
}
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(Color(0xD99594), getProperty<Color>(xFrame, u"BackColor"_ustr));
// 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_DOUBLES_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xFrame, u"LeftMargin"_ustr), 2);
CPPUNIT_ASSERT_DOUBLES_EQUAL(sal_Int32(318), getProperty<sal_Int32>(xFrame, u"RightMargin"_ustr), 2);
}
CPPUNIT_TEST_FIXTURE(Test, testCellBtlr)
{
loadAndSave("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.
*/
//tdf#140967 frame border was too small. Expected 0 (hairline), actual was 2
CPPUNIT_ASSERT_EQUAL(sal_uInt32(0), getProperty<sal_uInt32>(xFrame, u"LineWidth"_ustr));
}
DECLARE_OOXMLEXPORT_TEST(testI120928, "i120928.docx")
{ // w:numPicBullet was ignored, leading to missing graphic bullet in numbering.
uno::Reference<beans::XPropertySet> xPropertySet(getStyles(u"NumberingStyles"_ustr)->getByName(u"WWNum1"_ustr), uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue(u"NumberingRules"_ustr), uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aProps;
xLevels->getByIndex(0) >>= aProps; // 1st level
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(u"SAMPLE"_ustr, xShape->getString());
// 3rd problem: rotation angle was 315, not 45.
CPPUNIT_ASSERT_EQUAL(sal_Int32(45 * 100), getProperty<sal_Int32>(xShape, u"RotateAngle"_ustr));
// 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, u"VertOrientRelation"_ustr));
// These problems were in the exporter // The textpath wasn't semi-transparent.
CPPUNIT_ASSERT_EQUAL(sal_Int16(50), getProperty<sal_Int16>(xShape, u"FillTransparence"_ustr)); // The textpath had a stroke.
CPPUNIT_ASSERT_EQUAL(drawing::LineStyle_NONE, getProperty<drawing::LineStyle>(xShape, u"LineStyle"_ustr));
}
// Check font family
CPPUNIT_ASSERT(xPropertySet->getPropertyValue(u"CharFontName"_ustr) >>= aFont);
CPPUNIT_ASSERT_EQUAL(u"DejaVu Serif"_ustr, aFont);
// Check font size
CPPUNIT_ASSERT(xPropertySet->getPropertyValue(u"CharHeight"_ustr) >>= nFontSize);
CPPUNIT_ASSERT_EQUAL(float(72), nFontSize);
}
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, u"RTL Left"_ustr));
sal_Int32 nRtlLeft = getProperty< sal_Int32 >( xParaRtlLeft, u"ParaAdjust"_ustr ); // test the text Direction value for the paragraph
sal_Int16 nRLDir = getProperty< sal_Int32 >( xParaRtlLeft, u"WritingMode"_ustr );
// 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);
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, u"This is a simple sentence."_ustr);
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, u"normal"_ustr );
CPPUNIT_ASSERT_EQUAL( sal_Int32( 0x0026 ), getProperty< sal_Int32 >( shaded, u"CharShadingValue"_ustr ));
CPPUNIT_ASSERT_EQUAL( sal_Int32( 0xd8d8d8 ), getProperty< sal_Int32 >( shaded, u"CharBackColor"_ustr ));
}
CPPUNIT_TEST_FIXTURE(Test, testFdo66543)
{ // The problem was that when importing DOCX with 'line numbers' - the 'start value' was imported // but nothing was done with it.
createSwDoc("fdo66543.docx");
// ensure unnecessary suppressLineNumbers entry is not created.
xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
assertXPath(pXmlDoc, "//w:p[1]/w:pPr/w:suppressLineNumbers", 0);
}
CPPUNIT_TEST_FIXTURE(Test, testN822175)
{
loadAndReload("n822175.odt");
CPPUNIT_ASSERT_EQUAL(1, getShapes());
CPPUNIT_ASSERT_EQUAL(1, getPages());
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, u"Surround"_ustr));
}
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, u"FillTransparence"_ustr ) );
}
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());
CPPUNIT_TEST_FIXTURE(Test, testFdo58577)
{
loadAndReload("fdo58577.odt");
CPPUNIT_ASSERT_EQUAL(1, getPages()); // The second frame was simply missing, so let's check if both frames were imported back.
CPPUNIT_ASSERT_EQUAL(2, getShapes());
}
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, u"LeftBorderDistance"_ustr ) );
CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty< sal_Int32 >( xFrame, u"TopBorderDistance"_ustr ) );
CPPUNIT_ASSERT_EQUAL( sal_Int32( 254 ), getProperty< sal_Int32 >( xFrame, u"RightBorderDistance"_ustr ) );
CPPUNIT_ASSERT_EQUAL( sal_Int32( 127 ), getProperty< sal_Int32 >( xFrame, u"BottomBorderDistance"_ustr ) );
} 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, u"TextLeftDistance"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_Int32(127), getProperty<sal_Int32>(xShape, u"TextUpperDistance"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_Int32(254), getProperty<sal_Int32>(xShape, u"TextRightDistance"_ustr));
CPPUNIT_ASSERT_EQUAL(sal_Int32(127), getProperty<sal_Int32>(xShape, u"TextLowerDistance"_ustr));
}
}
CPPUNIT_TEST_FIXTURE(Test, testPageBorderSpacingExportCase2)
{
loadAndSave("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)
CPPUNIT_TEST_FIXTURE(Test, testGrabBag)
{
loadAndSave("grabbag.docx"); // w:mirrorIndents was lost on roundtrip, now should be handled as a grab bag property
xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
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(u"NumberingStyles"_ustr)->getByName(u"WWNum1"_ustr), uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue(u"NumberingRules"_ustr), uno::UNO_QUERY);
uno::Sequence<beans::PropertyValue> aProps;
xLevels->getByIndex(0) >>= aProps; // 1st level
for (beans::PropertyValue const& rProp : aProps)
{ if (rProp.Name == "BulletChar")
{
CPPUNIT_ASSERT_EQUAL(OUString("\x0", 1, RTL_TEXTENCODING_ASCII_US), rProp.Value.get<OUString>()); return;
}
}
// Shouldn't reach here
CPPUNIT_FAIL("Did not find bullet with level 0");
}
CPPUNIT_TEST_FIXTURE(Test, testFdo60990)
{
loadAndReload("fdo60990.odt");
CPPUNIT_ASSERT_EQUAL(1, getShapes());
CPPUNIT_ASSERT_EQUAL(1, getPages()); // 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(Color(0x00CFE7F5), getProperty<Color>(xShape, u"FillColor"_ustr));
uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xShape, uno::UNO_QUERY_THROW)->getText();
uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText);
CPPUNIT_ASSERT_EQUAL(style::ParagraphAdjust_CENTER, static_cast<style::ParagraphAdjust>(getProperty<sal_Int16>(xParagraph, u"ParaAdjust"_ustr)));
CPPUNIT_ASSERT_EQUAL(COL_LIGHTGREEN, getProperty<Color>(getRun(xParagraph, 1), u"CharColor"_ustr));
}
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);
// '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)
CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(114300), getProperty<sal_Int32>(xPropertySet, u"LeftMargin"_ustr) );
CPPUNIT_ASSERT_EQUAL(oox::drawingml::convertEmuToHmm(114300), getProperty<sal_Int32>(xPropertySet, u"RightMargin"_ustr) );
}
DECLARE_OOXMLEXPORT_TEST(testFdo64350, "fdo64350.docx")
{ // The problem was that page border shadows were not exported
table::ShadowFormat aShadow = getProperty<table::ShadowFormat>(getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"ShadowFormat"_ustr);
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(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), u"HeaderText"_ustr);
uno::Reference< text::XTextRange > xHeaderParagraph = getParagraphOfText( 1, xHeaderText );
table::BorderLine2 aHeaderBottomBorder = getProperty<table::BorderLine2>(xHeaderParagraph, u"BottomBorder"_ustr);
CPPUNIT_ASSERT_EQUAL(Color(0x622423), Color(ColorTransparency, 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);
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), u"ParaShadowFormat"_ustr);
CPPUNIT_ASSERT_EQUAL(COL_BLACK, Color(ColorTransparency, 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), u"Width"_ustr));
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 opposite of (left margin + half of the border width).
CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty<sal_Int32>(xFrame, u"HoriOrientPosition"_ustr)); // Was 0 as well, should be the right margin.
CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xFrame, u"RightMargin"_ustr));
} else
{ // After import, table is inside a TextFrame.
uno::Reference<beans::XPropertySet> xShape(getShape(1), uno::UNO_QUERY); // This was 0, should be the opposite of (left margin + half of the border width).
CPPUNIT_ASSERT_EQUAL(sal_Int32(-199), getProperty<sal_Int32>(xShape, u"HoriOrientPosition"_ustr)); // Was 0 as well, should be the right margin.
CPPUNIT_ASSERT_EQUAL(sal_Int32(250), getProperty<sal_Int32>(xShape, u"RightMargin"_ustr));
}
}
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(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int16(0), getProperty<sal_Int16>(xPara, u"PageNumberOffset"_ustr));
}
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(1), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(sal_Int16(7), getProperty<sal_Int16>(xPara, u"PageNumberOffset"_ustr));
}
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); const uno::Sequence<beans::PropertyValue> aProps = getProperty< uno::Sequence<beans::PropertyValue> >(xArrow, u"CustomShapeGeometry"_ustr); for (beans::PropertyValue const & rProp : aProps)
{ if (rProp.Name == "MirroredY")
{
CPPUNIT_ASSERT_EQUAL( true, rProp.Value.get<bool>() ); return;
}
}
// Shouldn't reach here
CPPUNIT_FAIL("Did not find MirroredY=true property");
}
CPPUNIT_TEST_FIXTURE(Test, NoFillAttrInImagedata)
{
loadAndSave("NoFillAttrInImagedata.docx"); //problem was that type and color2 which are v:fill attributes were written in 'v:imagedata'. The //source file has v:fill and no v:imagedata. Same should be in the file written by LO.
xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
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, u"AAA"_ustr); // interestingly the 'Insert' is set on the _previous_ run
CPPUNIT_ASSERT_EQUAL(u"Insert"_ustr, getProperty<OUString>(getRun(xParagraph, 2), u"RedlineType"_ustr));
// make sure we don't introduce a redlined delete in the 2nd paragraph
xParagraph = getParagraph(2);
CPPUNIT_ASSERT_EQUAL(false, hasProperty(getRun(xParagraph, 1), u"RedlineType"_ustr));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.