/* -*- 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/.
*/
namespace
{ class Test : public SwModelTestBase
{ public:
Test()
: SwModelTestBase(u"/sw/qa/extras/ooxmlexport/data/"_ustr, u"Office Open XML Text"_ustr)
{
}
};
// Without the fix in place, this test would have failed with // - Expected : Some text // - Actual:
CPPUNIT_ASSERT_EQUAL(u"Some text"_ustr, getParagraph(1)->getString());
if (bIsExport)
{ // tdf#164876 tdf#165117: don't add an empty paragraph every round-trip
xmlDocUniquePtr pXmlDoc1 = parseExport(u"word/footer2.xml"_ustr);
assertXPath(pXmlDoc1, "/w:ftr/w:p", 1);
}
};
DECLARE_OOXMLEXPORT_TEST(testTdf125469_singleSpacing, "tdf125469_singleSpacing.docx")
{ // Given a document with 4 paragraphs of varying strange line spacing definitions, // and a DocDefault of single line spacing (AUTO 240pt) (240pt is 0.423 cm)
// Paragraph 1 - DocDefaults specifies size 240 without a lineRule - default is AUTO(aka PROP) // Visually, this should clearly say "Single spacing" auto aSpacing = getProperty<style::LineSpacing>(getParagraph(1), u"ParaLineSpacing"_ustr);
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::PROP), aSpacing.Mode);
CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aSpacing.Height);
// Paragraph 2 - paragraph style specifies atLeast 240, para overrides with only -240. // The negative value (always) turns the (inherited) "atLeast" into an "exact". // Visually, this is hardly readable (36pt font forced into 12pt space)
aSpacing = getProperty<style::LineSpacing>(getParagraph(2), u"ParaLineSpacing"_ustr);
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::FIX), aSpacing.Mode);
CPPUNIT_ASSERT_EQUAL(sal_Int16(423), aSpacing.Height);
// Paragraph 3 - paragraph style specifies exact 240, para overrides with exact -240. // The negative value turns the non-inherited "exact" into an "atLeast". // Visually, this should clearly say "Negative exact"
aSpacing = getProperty<style::LineSpacing>(getParagraph(3), u"ParaLineSpacing"_ustr);
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::MINIMUM), aSpacing.Mode);
CPPUNIT_ASSERT_EQUAL(sal_Int16(423), aSpacing.Height);
// Paragraph 4 - paragraph style specifies exact 240, para overrides with only -240. // The negative value does nothing to the inherited "exact". // Visually, this is hardly readable (36pt font forced into 12pt space)
aSpacing = getProperty<style::LineSpacing>(getParagraph(4), u"ParaLineSpacing"_ustr);
CPPUNIT_ASSERT_EQUAL(sal_Int16(style::LineSpacingMode::FIX), aSpacing.Mode);
CPPUNIT_ASSERT_EQUAL(sal_Int16(423), aSpacing.Height);
// all of this ends up being squeezed onto a single page
CPPUNIT_ASSERT_EQUAL(1, getPages());
}
CPPUNIT_TEST_FIXTURE(Test, testTdf43767_caseMapNumbering)
{ auto verify = [this](bool bIsExport = false) { // given a document with 2 numbered Lists [each entry restarts numbering for visual comparison]
xmlDocUniquePtr pDump = parseLayoutDump();
// using the relative width difference between "A)" and "a)" as the test comparison // since ListLabelString etc. does not output the actual string that is displayed on the screen
// When the entire paragraph has a certain character attribute, that property is also applied // to the list numbering itself (with some differing exceptions) for both ODT and DOCX.
// ESTABLISH A BASELINE: these baseline paragraphs have no special character attributes. // Paragraph 1/list 1(uppercase): no formatting applied to list numbering. Width is 253 for me const sal_Int32 nUpperCaseWidth
= getXPath(pDump, "//body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion", "width")
.toInt32(); // Paragraph 4/list 2(lowercase): no formatting applied to list numbering. Width is 186 for me. const sal_Int32 nLowerCaseWidth
= getXPath(pDump, "//body/txt[5]/SwParaPortion/SwLineLayout/SwFieldPortion", "width")
.toInt32();
// UPPERCASE LIST // Paragraph 2: ODF should honour "lowercase". MSO doesn't know about lowercase
sal_Int32 nWidth
= getXPath(pDump, "//body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion", "width")
.toInt32();
CPPUNIT_ASSERT_EQUAL(bIsExport ? nUpperCaseWidth : nLowerCaseWidth, nWidth);
CPPUNIT_TEST_FIXTURE(Test, testTdf156105_percentSuffix)
{ auto verify = [this]() { // given a numbered list with a non-escaping percent symbol in the prefix and suffix
CPPUNIT_ASSERT_EQUAL(u"(%)[%]"_ustr,
getProperty<OUString>(getParagraph(3), u"ListLabelString"_ustr));
// tdf#149258 - NONE number should not export separator since LO doesn't currently show it
CPPUNIT_ASSERT_EQUAL_MESSAGE( "showing levels 1, 2, and 4", u"(%)1.1.1[%]"_ustr,
getProperty<OUString>(getParagraph(4), u"ListLabelString"_ustr));
};
xmlDocUniquePtr pXmlNum = parseExport(u"word/numbering.xml"_ustr); // The 3rd level is NONE. If we include the separator, MS Word will display it.
assertXPath(pXmlNum, "/w:numbering/w:abstractNum[1]/w:lvl[4]/w:lvlText", "val",
u"(%)%1.%2.%3%4[%]");
}
DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMarginVML, "tdf160049_anchorMarginVML.docx")
{ // given a VML (Word 2003) document with a LEFT "column/text" anchored image // (which will import as DML compat12 on the round-trip)
// The image takes into account the margin, so it looks like it is in the middle of the doc, // which is "Paragraph text area"/PRINT_AREA/1, not "Entire paragraph area"/FRAME/0
CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PRINT_AREA,
getProperty<sal_Int16>(getShape(1), u"HoriOrientRelation"_ustr));
}
DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMargin2, "tdf160049_anchorMargin2.docx")
{ // given a DML compat14 (Word 2010) document with a LEFT "column/text" anchored shape
// The shape takes into account the margin, so it looks like it is in the middle of the doc, // which is "Paragraph text area"/PRINT_AREA/1, not "Entire paragraph area"/FRAME/0
CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PRINT_AREA,
getProperty<sal_Int16>(getShape(1), u"HoriOrientRelation"_ustr));
// tdf#167770: emulate no text-wrap gap when left-aligned-to-paragraph-margin instead of 0.90cm
CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(getShape(1), u"LeftMargin"_ustr));
}
DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMargin14, "tdf160049_anchorMargin14.docx")
{ // given a DML compat14 (Word 2010) document with a LEFT "column/text" anchored image // followed by a RIGHT column/text anchored image (with a 2cm paragraph right margin) // followed by a CENTER column/text anchored image (with a large left margin) // followed by a LEFT FROM column/text anchored image (which ignores the left margin) // followed by a LEFT "margin" anchored image (which always ignores the left margin)
// The shape takes into account the left margin, looking like it is in the middle of the doc, // which is "Paragraph text area"/PRINT_AREA/1, not "Entire paragraph area"/FRAME/0
uno::Reference<drawing::XShape> xShape(getShapeByName(u"Picture 2"));
CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PRINT_AREA,
getProperty<sal_Int16>(xShape, u"HoriOrientRelation"_ustr)); // The shape takes into account the right margin, looking like it is in the middle of the doc,
xShape.set(getShapeByName(u"Picture 3"));
CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PRINT_AREA,
getProperty<sal_Int16>(xShape, u"HoriOrientRelation"_ustr)); // The third shape takes "center" very seriously, and ignores the margins
xShape.set(getShapeByName(u"Picture 4"));
CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::FRAME,
getProperty<sal_Int16>(xShape, u"HoriOrientRelation"_ustr)); // The fourth shape takes "left by 123", and ignores the margins, acting just like "margin"
xShape.set(getShapeByName(u"Picture 5"));
CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::FRAME,
getProperty<sal_Int16>(xShape, u"HoriOrientRelation"_ustr)); // The fifth shape shows how "left" works with "margin", which apparently means page margin
xShape.set(getShapeByName(u"Picture 6"));
CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PAGE_PRINT_AREA,
getProperty<sal_Int16>(xShape, u"HoriOrientRelation"_ustr));
}
DECLARE_OOXMLEXPORT_TEST(testTdf160049_anchorMargin15, "tdf160049_anchorMargin15.docx")
{ // given a DML compat15 (Word 2013) document with a LEFT "column/text" anchored image
// The image ignores the margin, so it is at the left for compat15 (but middle-ish for compat14)
CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::FRAME,
getProperty<sal_Int16>(getShape(1), u"HoriOrientRelation"_ustr));
}
DECLARE_OOXMLEXPORT_TEST(testTdf160077_layoutInCell, "tdf160077_layoutInCell.docx")
{ // given an in-table, slightly rotated image vertically aligned -1cm (above) the top page margin // (which is actually forced to layoutInCell, so that becomes 1cm above the cell margin instead)
// This document is particularly tricky. The image is in cell A1 with no special cell spacing // (no top/bottom margins), but Cell A2 has a custom top margin of 2cm, // so that effectively drops A1's print area down as well!
xmlDocUniquePtr pDump = parseLayoutDump(); const sal_Int32 nCellTop = getXPath(pDump, "//row[1]/cell[1]/infos/bounds", "top").toInt32(); const sal_Int32 nImageTop
= getXPath(pDump, "//row[1]/cell[1]/txt/anchored/SwAnchoredDrawObject/bounds", "top")
.toInt32(); // The image should be 1 cm above the 2cm cell margin (thus 1cm below the top of the cell) // 1cm is 567 twips. The numbers are not exactly what I would have expected, but close. // correct ImageTop: ~ 3588, while incorrect value was 1117. Cell top is 3051, ParaTop is 4195 const SwTwips n1cm = o3tl::convert(tools::Long(1), o3tl::Length::cm, o3tl::Length::twip);
CPPUNIT_ASSERT_DOUBLES_EQUAL(nCellTop + n1cm, nImageTop, 50); // +/- 4.4%
DECLARE_OOXMLEXPORT_TEST(testTdf160077_layoutInCellB, "tdf160077_layoutInCellB.docx")
{ // given an in-table, group-shape vertically aligned -1.35 cm (above) the top page margin // (which is actually forced to layoutInCell, so that turns into 1.35cm above the cell margin)
// This unit test is virtually the same idea as the previous one, with the main benefit being // that it causes an NS_ooxml::LN_Shape exception.
xmlDocUniquePtr pDump = parseLayoutDump(); const sal_Int32 nShapeTop
= getXPath(pDump, "//body/tab[1]/row[1]/cell[1]/txt[1]/anchored/SwAnchoredDrawObject/bounds", "top")
.toInt32(); // The shape is approximately 1 cm below the top of the page, and ~0.5cm above the cell // correct ShapeTop: 888 TWIPS, while incorrect value was -480. Cell top is 1148, PageTop is 284
CPPUNIT_ASSERT_DOUBLES_EQUAL(888, nShapeTop, 50);
// tdf#165492: the "column" headings should be across from each other
sal_Int32 nObjectiveBottom
= getXPath(pDump, "//body/tab[1]/row[1]/cell[1]/txt[2]/infos/bounds", "bottom").toInt32();
sal_Int32 nExperienceBottom
= getXPath(pDump, "//body/tab[1]/row[1]/cell[2]/txt[1]/infos/bounds", "bottom").toInt32(); // Headers: "Objective"'s vertical position (4905) is nearly identical to "Experience" (4891)
CPPUNIT_ASSERT_DOUBLES_EQUAL(nObjectiveBottom, nExperienceBottom, 20);
}
DECLARE_OOXMLEXPORT_TEST(testTdf160077_layoutInCellC, "tdf160077_layoutInCellC.docx")
{ // given an in-table, slightly rotated image vertically aligned to top page margin // (which is actually forced to layoutInCell, so that becomes the top of the cell text area). // This test anchors the image on paragraph 5 - proving vertical cannot change to FRAME.
xmlDocUniquePtr pDump = parseLayoutDump(); const sal_Int32 nPara1Top
= getXPath(pDump, "//row[1]/cell[2]/txt[1]/infos/bounds", "top").toInt32(); const sal_Int32 nPara1Bottom
= getXPath(pDump, "//row[1]/cell[2]/txt[1]/infos/bounds", "bottom").toInt32(); const sal_Int32 nImageTop
= getXPath(pDump, "//row[1]/cell[2]/txt[5]/anchored/SwAnchoredDrawObject/bounds", "top")
.toInt32(); // The image's top should be positioned at the start of the cell's text area (i.e. para1 top) // Before the fix, the image was positioned at the top of the cell.
CPPUNIT_ASSERT_LESS(nPara1Bottom, nImageTop); // Image shouldn't start lower than para 1 // The image must be limited to the top of the cell, not the page
CPPUNIT_ASSERT_GREATEREQUAL(nPara1Top, nImageTop); // Image shouldn't start higher than para 1
CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PAGE_PRINT_AREA,
getProperty<sal_Int16>(getShape(1), u"VertOrientRelation"_ustr)); // LayoutInCell must be enforced, to keep the image inside the cell boundaries
CPPUNIT_ASSERT(getProperty<bool>(getShape(1), u"IsFollowingTextFlow"_ustr));
}
DECLARE_OOXMLEXPORT_TEST(testTdf160077_layoutInCellD, "tdf160077_layoutInCellD.docx")
{ // given a table with two layoutInCell images, and cell A1 has 1/2 inch border padding (margin) // - A1 contains an image, vertically aligned to the bottom of the page (aka cell) // - B1 contains an image, vertically aligned to the bottom of the page margin (aka cell margin)
// In Microsoft's layoutInCell implementation, vertical "page" is identical to "margin", // and everything (including bottom) actually is oriented to the top of the margin.
xmlDocUniquePtr pDump = parseLayoutDump(); // Cell A1
sal_Int32 nShapeTop
= getXPath(pDump, "//tab/row[1]/cell[1]/txt[1]/anchored/fly/SwAnchoredObject/bounds", "top")
.toInt32();
sal_Int32 nShapeBottom
= getXPath(pDump, "//tab/row[1]/cell[1]/txt[1]/anchored/fly/SwAnchoredObject/bounds", "bottom")
.toInt32(); // use paragraph 1 to indicate where the cell spacing/padding ends, and the text starts.
sal_Int32 nPara1Top
= getXPath(pDump, "//tab/row[1]/cell[1]/txt[1]/infos/bounds", "top").toInt32(); // use paragraph 5 to prove the image is not at the bottom.
CPPUNIT_ASSERT_EQUAL(OUString("Below logo"),
getXPathContent(pDump, "//tab/row[1]/cell[1]/txt[5]"));
sal_Int32 nPara5Top
= getXPath(pDump, "//tab/row[1]/cell[1]/txt[5]/infos/bounds", "top").toInt32();
CPPUNIT_ASSERT_EQUAL(nShapeTop, nPara1Top);
CPPUNIT_ASSERT(nPara5Top > nShapeBottom); // ShapeBottom is higher than Para5Top
// In the file it is specified as "page" (PAGE_FRAME), but implemented as if it were "margin" // so on import we intentionally changed it to match the closest setting to the implementation. constauto xShape = getShapeByName(u"logo");
CPPUNIT_ASSERT_EQUAL(css::text::RelOrientation::PAGE_PRINT_AREA,
getProperty<sal_Int16>(xShape, u"VertOrientRelation"_ustr));
// Cell B1
nShapeTop
= getXPath(pDump, "//tab/row[1]/cell[2]/txt[1]/anchored/fly/SwAnchoredObject/bounds", "top")
.toInt32();
nShapeBottom
= getXPath(pDump, "//tab/row[1]/cell[2]/txt[1]/anchored/fly/SwAnchoredObject/bounds", "bottom")
.toInt32(); // use paragraph 1 to indicate where the cell spacing/padding ends, and the text starts.
nPara1Top = getXPath(pDump, "//tab/row[1]/cell[2]/txt[1]/infos/bounds", "top").toInt32(); // use paragraph 5 to prove the image is not at the bottom.
CPPUNIT_ASSERT_EQUAL(OUString("Below image"),
getXPathContent(pDump, "//tab/row[1]/cell[2]/txt[5]"));
nPara5Top = getXPath(pDump, "//tab[1]/row/cell[2]/txt[5]/infos/bounds", "top").toInt32();
CPPUNIT_ASSERT_EQUAL(nShapeTop, nPara1Top);
CPPUNIT_ASSERT(nPara5Top > nShapeBottom); // ShapeBottom is higher than Para5Top
DECLARE_OOXMLEXPORT_TEST(testTdf153909_followTextFlow, "tdf153909_followTextFlow.docx")
{ // given a compat12 VML document with wrap-through blue rect that doesn't mention allowInCell
// Although MSO's UI reports "layoutInCell" for the rectangle, it isn't specified or honored
CPPUNIT_ASSERT(getProperty<bool>(getShape(1), u"IsFollowingTextFlow"_ustr));
xmlDocUniquePtr pDump = parseLayoutDump();
sal_Int32 nRectBottom
= getXPath(pDump, "//anchored/SwAnchoredDrawObject/bounds", "bottom").toInt32();
sal_Int32 nTableTop = getXPath(pDump, "//tab/row/infos/bounds", "top").toInt32(); // The entire table must be below the rectangle
CPPUNIT_ASSERT(nTableTop > nRectBottom);
// pre-emptive test: rectangle "margin" offset against cell, not outside-table-paragraph. // Since layoutInCell is true (as a non-defined default), the cell is the fly reference, thus // the rectangle should start at the paper's edge, 1.3cm to the left of the start of the table.
sal_Int32 nRectLeft
= getXPath(pDump, "//anchored/SwAnchoredDrawObject/bounds", "left").toInt32();
sal_Int32 nTableLeft = getXPath(pDump, "//tab/row/infos/bounds", "left").toInt32();
CPPUNIT_ASSERT(nTableLeft > nRectLeft);
}
DECLARE_OOXMLEXPORT_TEST(testTdf162541, "tdf162541_notLayoutInCell_paraLeft.docx")
{ // given cell B2 with a para-left para-fromTop image that is NOT layoutInCell
xmlDocUniquePtr pDump = parseLayoutDump();
sal_Int32 nShapeLeft
= getXPath(pDump, "//tab/row[2]/cell[2]/txt[8]/anchored/fly/SwAnchoredObject/bounds", "left")
.toInt32();
sal_Int32 nParaLeft
= getXPath(pDump, "//tab/row[2]/cell[2]/txt[8]/infos/bounds", "left").toInt32();
sal_Int32 nTableLeft = getXPath(pDump, "//tab/infos/bounds", "left").toInt32(); // The image uses the table-paragraph to orient to the left (bizarre MSO layout anomaly)
CPPUNIT_ASSERT(nShapeLeft < nParaLeft); // shape is located in column A, not column B
CPPUNIT_ASSERT_EQUAL(nTableLeft, nShapeLeft);
// sal_Int32 nShapeBottom // = getXPath(pDump, "//tab/row[2]/cell[2]/txt[8]/anchored/fly/SwAnchoredObject/bounds", // "bottom") // .toInt32(); // sal_Int32 nPara8Top // = getXPath(pDump, "//tab/row[2]/cell[2]/txt[8]/infos/bounds", "top").toInt32(); // The image uses the table-paragraph to orient to the left (bizarre MSO layout anomaly) // CPPUNIT_ASSERT(nShapeBottom < nPara8Top); // shape is located at the top of the table para // tdf#133522
DECLARE_OOXMLEXPORT_TEST(testTdf162551, "tdf162551_notLayoutInCell_charLeft_fromTop.docx")
{ // given cell B2 with a para-fromTop, char-left image that is NOT layoutInCell // (but Microsoft sees the CHAR orientation and triggers a layoutInCell anyway)
xmlDocUniquePtr pDump = parseLayoutDump();
sal_Int32 nShapeTop
= getXPath(pDump, "//tab/row[2]/cell[2]/txt/anchored/fly/SwAnchoredObject/bounds", "top")
.toInt32();
sal_Int32 nPara1Top = getXPath(pDump, "//tab/row[2]/cell[2]/txt/infos/bounds", "top").toInt32(); // The image is limited by the cell margin
CPPUNIT_ASSERT_EQUAL(nPara1Top, nShapeTop); // tdf#162539
// since in fact layoutInCell is supposed to be applied, we mark (and export) as layoutInCell
CPPUNIT_ASSERT(getProperty<bool>(getShape(1), u"IsFollowingTextFlow"_ustr));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf159207_footerFramePrBorder)
{
createSwDoc("tdf159207_footerFramePrBorder.docx"); // re-imports as editeng Frame/Shape
// given a doc with footer paragraphs frame (with a top border, but no left border)
uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(),
uno::UNO_QUERY);
uno::Reference<beans::XPropertySet> xFrame0(xIndexAccess->getByIndex(0), uno::UNO_QUERY); auto aBorder = getProperty<table::BorderLine2>(xFrame0, u"LeftBorder"_ustr);
sal_uInt32 nBorderWidth
= aBorder.OuterLineWidth + aBorder.InnerLineWidth + aBorder.LineDistance; // Without patch it failed with Expected 0, Actual 26
CPPUNIT_ASSERT_EQUAL_MESSAGE("Left border:", static_cast<sal_uInt32>(0), nBorderWidth);
// TODO: there SHOULD BE a top border, and even if loaded, it would be lost on re-import...
}
CPPUNIT_TEST_FIXTURE(Test, testTdf160814_commentOrder)
{ // given a document with a comment and 5 replies
loadAndSave("tdf160814_commentOrder.docx");
// make sure the order of the comments is imported and exported correctly
xmlDocUniquePtr pXmlComments = parseExport(u"word/comments.xml"_ustr); // This really should be "1. First comment", the 1. being list numbering...
assertXPathContent(pXmlComments, "//w:comment[1]//w:t", u"First comment");
assertXPathContent(pXmlComments, "//w:comment[2]//w:t", u"1.1 first reply.");
assertXPathContent(pXmlComments, "//w:comment[4]//w:t", u"1.3");
assertXPathContent(pXmlComments, "//w:comment[6]//w:t", u"1.5");
}
CPPUNIT_TEST_FIXTURE(Test, testPersonalMetaData)
{ // 1. Remove all personal info auto pBatch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Security::Scripting::RemovePersonalInfoOnSaving::set(true, pBatch);
pBatch->commit();
loadAndSave("personalmetadata.docx");
// 2. Remove personal information, keep user information
officecfg::Office::Common::Security::Scripting::KeepDocUserInfoOnSaving::set(true, pBatch);
pBatch->commit();
loadAndSave("personalmetadata.docx");
CPPUNIT_TEST_FIXTURE(Test, testRemoveOnlyEditTimeMetaData)
{ // 1. Check we have the original edit time info
loadAndSave("personalmetadata.docx");
xmlDocUniquePtr pAppDoc = parseExport(u"docProps/app.xml"_ustr);
assertXPath(pAppDoc, "/extended-properties:Properties/extended-properties:TotalTime", 1);
// Set config RemoveEditingTimeOnSaving to true auto pBatch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Security::Scripting::RemoveEditingTimeOnSaving::set(true, pBatch);
pBatch->commit();
// 2. Check edit time info is removed
loadAndSave("personalmetadata.docx");
pAppDoc = parseExport(u"docProps/app.xml"_ustr);
assertXPath(pAppDoc, "/extended-properties:Properties/extended-properties:TotalTime", 0);
DECLARE_OOXMLEXPORT_TEST(testTdf126533_noPageBitmap, "tdf126533_noPageBitmap.docx")
{ // given a document with a v:background bitmap, but no w:background fillcolor
uno::Reference<beans::XPropertySet> xPageStyle(
getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY); // the image (or any fill for that matter) should be ignored.
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_NONE,
getProperty<drawing::FillStyle>(xPageStyle, u"FillStyle"_ustr));
}
DECLARE_OOXMLEXPORT_TEST(testTdf126533_pageGradient, "fill.docx")
{ // given a document with a gradient page background
uno::Reference<beans::XPropertySet> xPageStyle(
getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT,
getProperty<drawing::FillStyle>(xPageStyle, u"FillStyle"_ustr));
// LO and MS handle radials very differently, so it is hard to say what // color1 (fill) and color2 should be. This test is only interested in making sure // that the colors are not alternating back and forth on each round-trip.
CPPUNIT_ASSERT_EQUAL(Color(0xff8200), Color(ColorTransparency, aGradient.StartColor));
CPPUNIT_ASSERT_EQUAL(Color(0x000082), Color(ColorTransparency, aGradient.EndColor));
}
CPPUNIT_TEST_FIXTURE(Test, testTdf126533_pageBitmap)
{ auto verify = [this]() { // given a document with a page background image
uno::Reference<beans::XPropertySet> xPageStyle(
getStyles(u"PageStyles"_ustr)->getByName(u"Standard"_ustr), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_BITMAP,
getProperty<drawing::FillStyle>(xPageStyle, u"FillStyle"_ustr));
};
DECLARE_OOXMLEXPORT_TEST(testTdf131098_imageFill, "tdf131098_imageFill.docx")
{ // given a document with an image background transparency (blue-white)
CPPUNIT_ASSERT_EQUAL(drawing::FillStyle_GRADIENT,
getProperty<drawing::FillStyle>(getShape(1), u"FillStyle"_ustr));
CPPUNIT_ASSERT_EQUAL(Color(0x729fcf), getProperty<Color>(getShape(1), u"FillColor"_ustr));
}
DECLARE_OOXMLEXPORT_TEST(testTdf154369, "tdf154369.docx")
{ //Unit test for bug fix in tdf#154369 // Docx file contains ordered list formatted with Heading 1 style, font color set as Accent 1 from theme
xmlDocUniquePtr pXmlDoc = parseLayoutDump();
// Without the fix in place, this test would have failed with: // - Expected result: A & B bullets display same green color #527d55 as the paragraph // - Actual result: A & B bullets display black color, while the paragraph is green color #527d55
assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand", u"A.");
assertXPath(pXmlDoc, "/root/page[1]/body/txt[1]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color", u"00527d55");
assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion", "expand", u"B.");
assertXPath(pXmlDoc, "/root/page[1]/body/txt[2]/SwParaPortion/SwLineLayout/SwFieldPortion/SwFont", "color", u"00527d55");
}
// Hyperlink with ScreenTip
assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:hyperlink", "tooltip",
u"This is a hyperlink");
}
CPPUNIT_TEST_FIXTURE(Test, testEmptyObjectRange)
{ // Before the fix, this failed an assertion like this: // Assertion failed: isBetween(n, (SAL_MIN_INT64 + d / 2) / m, (SAL_MAX_INT64 - d / 2) / m), // file C:\lo\core\include\o3tl/unit_conversion.hxx, line 75
loadAndSave("cloud.docx");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf162370)
{ // This must not crash on save; without the fix, it would fail with // "Assertion failed: vector subscript out of range"
loadAndSave("too_many_styles.odt");
}
saveAndReload(u"Office Open XML Text"_ustr); // Without the fix in place, the third ASSERT fails with // Expected: text // Actual: // i.e. The second Field is blank when it should have the content of `text`
verify();
}
CPPUNIT_TEST_FIXTURE(Test, testTdf131288)
{ // Given a document with an embedded chart
createSwDoc("tdf131288.docx");
// Edit the document and save **twice**
uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
uno::Reference<text::XText> xText = xTextDocument->getText();
uno::Reference<text::XTextCursor> xCursor = xText->createTextCursor();
xText->insertString(xCursor, u"test"_ustr, false);
save(u"Office Open XML Text"_ustr);
// Without the fix we get a zero length(empty) word/embeddings/Microsoft_Excel-munkalap11.xlsx // With the fix in place word/embeddings/Microsoft_Excel-munkalap11.xlsx contains data
CPPUNIT_ASSERT_EQUAL(sal_uInt64(9041), pStream->remainingSize());
}
CPPUNIT_TEST_FIXTURE(Test, testTdf89731)
{ // Without the fix in place this crashes on opening
loadAndSave("tdf89731.docx");
}
CPPUNIT_TEST_FIXTURE(Test, testTdf162746)
{ // Without the fix in place this hangs (and eventually OOMs) on opening
loadAndSave("tdf162746.docx"); // tdf#162781: test the page body table vertical offset and width
xmlDocUniquePtr pDump = parseLayoutDump(); // Without the fix, this would be 0 - i.e., the page body table didn't shift down // below the header's floating table
assertXPath(pDump, "//page[1]/body/tab/infos/prtBounds", "top", u"35"); // Without the fix, this would be 100, because the page body table only used tiny space
--> --------------------
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.