/* -*- 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 <test/unoapixml_test.hxx>
// Without the fix in place, this would have failed with // - Expected: 2093 // - Actual : -10276
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]", "x", u"2093");
// Without the fix, the test fails with: // - Expected: 21165 // - Actual : 4218
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[5]/polyline[1]/point[1]", "x", u"21165");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[5]/polyline[1]/point[1]", "y", u"3866");
// Check the shape is inside the (5000,8500) - (11500,12500) area for (size_t i = 2; i < 4; ++i)
{ for (size_t j = 1; j < 6; ++j)
{ const OString xPath = "/metafile/push[1]/push[1]/push[" + OString::number(i)
+ "]/polyline/point[" + OString::number(j) + "]"; const sal_Int32 nX = getXPath(pXmlDoc, xPath, "x").toInt32(); const sal_Int32 nY = getXPath(pXmlDoc, xPath, "y").toInt32();
// Without the fix in place, this test would have failed with // - Expected greater or equal than: 5000 // - Actual : 0
CPPUNIT_ASSERT_GREATEREQUAL(sal_Int32(5000), nX);
CPPUNIT_ASSERT_LESSEQUAL(sal_Int32(11500), nX);
// Without the fix in place, this test would have failed with // - Expected: 13687 // - Actual : 2832
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[7]/polyline/point[1]", "x", u"13687");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[7]/polyline/point[2]", "x", u"24759");
}
// Without the fix in place, this test would have failed with // - Expected: 7795 // - Actual : 12068
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray", "x", u"4523");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray", "y", u"7795");
}
CPPUNIT_TEST_FIXTURE(SdLayoutTest, testColumnsLayout)
{ // This tests a 2-column text box's layout
const OUString sText[] = {
u"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat mi quis " "pretium semper. Proin luctus orci ac neque venenatis, quis commodo dolor posuere. " "Curabitur dignissim sapien quis cursus egestas. Donec blandit auctor arcu, nec " "pellentesque eros molestie eget. In consectetur aliquam hendrerit. Sed cursus mauris " "vitae ligula pellentesque, non pellentesque urna aliquet. Fusce placerat mauris enim, " "nec rutrum purus semper vel. Praesent tincidunt neque eu pellentesque pharetra. Fusce " "pellentesque est orci."_ustr,
u"Integer sodales tincidunt tristique. Sed a metus posuere, adipiscing nunc et, viverra " "odio. Donec auctor molestie sem, sit amet tristique lectus hendrerit sed. Cras sodales " "nisl sed orci mattis iaculis. Nunc eget dolor accumsan, pharetra risus a, vestibulum " "mauris. Nunc vulputate lobortis mollis. Vivamus nec tellus faucibus, tempor magna nec, " "facilisis felis. Donec commodo enim a vehicula pellentesque. Nullam vehicula vestibulum " "est vel ultricies."_ustr,
u"Aliquam velit massa, laoreet vel leo nec, volutpat facilisis eros. Donec consequat arcu " "ut diam tempor luctus. Cum sociis natoque penatibus et magnis dis parturient montes, " "nascetur ridiculus mus. Praesent vitae lacus vel leo sodales pharetra a a nibh. " "Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; " "Nam luctus tempus nibh, fringilla dictum augue consectetur eget. Curabitur at ante sit " "amet tortor pharetra molestie eu nec ante. Mauris tincidunt, nibh eu sollicitudin " "molestie, dolor sapien congue tortor, a pulvinar sapien turpis sed ante. Donec nec est " "elementum, euismod nulla in, mollis nunc."_ustr
};
// Without the fix in place, this would have failed with // - Expected: 5346 // - Actual : 503924 // - In <>, attribute 'x' of '/metafile/push[1]/push[1]/textarray[1]' incorrect value.
assertXPath(pXmlDoc, sXPath, "x", OUString::number(x));
assertXPath(pXmlDoc, sXPath, "y", OUString::number(y));
}
}
// Without the fix in place, this test would have failed with // - Expected: 30 // - Actual : 187
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[6]/polyline[1]", "width", u"30");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[7]/polyline[1]", "width", u"187");
}
CPPUNIT_TEST_FIXTURE(SdLayoutTest, testFitToFrameTextFitting)
{ // This test checks that the text fitting is working correctly when // the textbox is set to "fit to frame" by stretching the text to or // near the textbox boundary. The problem is especially complicated // when the font size is set to a higher number (like 999) // // The text fitting behaviour when "fit by frame" is enabled is to // always fit the text into the text box (without forcing the text // into new line) by shrinking or expanding the text horizontally // and vertically.
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]", "x", u"0");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]", "y", u"406");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]/dxarray", "first", u"114"); #ifndef _WIN32 // Windows seems to differ in text layouting, so ignore for now
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[1]/dxarray", "last", u"6984"); #endif
}
// Make sure text box has the right size - without the fix it was 2759.
assertXPath(pXmlDoc, "/metafile/push/push/textarray[5]", "y", u"3183");
}
CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf148966)
{ // Test related to IgnoreBreakAfterMultilineField compatibility flag.
{
xmlDocUniquePtr pXmlDoc = load("pptx/tdf148966.pptx"); // Without the accompanying fix, would fail with: // - Expected: 5952 // - Actual : 7814 // i.e. Line break after multiline field should have been ignored.
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "y", u"5952");
}
{
xmlDocUniquePtr pXmlDoc = load("odp/tdf148966-withflag.odp"); // Without the accompanying fix, would fail with: // - Expected: 5952 // - Actual : 7814 // i.e. When IgnoreBreakAfterMultilineField flag is set, line break // after multiline field should have been ignored.
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "y", u"5952");
}
{
xmlDocUniquePtr pXmlDoc = load("odp/tdf148966-withoutflag.odp");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "y", u"7814");
}
}
// Without the accompanying fix, would fail with: // - Expected: -900 // - Actual : 0 // - In <>, attribute 'orientation' of '//font[1]' incorrect value. // i.e. table cell text that was supposed to be vertical (rotated 90 // degrees) was not vertical.
assertXPath(pXmlDoc, "//font[1]", "orientation", u"-900");
assertXPath(pXmlDoc, "//font[2]", "orientation", u"900");
}
// Test that a NNBSP is grouped with the Mongolian characters after it, so // we have two text arrays, one covering the digits, and the other with the rest.
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "index", u"0");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]", "length", u"2");
assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/textarray[3]/text", u"11\u202f\u1824");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[4]", "index", u"2");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray[4]", "length", u"2");
assertXPathContent(pXmlDoc, "/metafile/push[1]/push[1]/textarray[4]/text", u"11\u202f\u1824");
}
CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf152906_AdjustToContour)
{ // Test that the text adjusts to contour properly
static constexpr OUString sText
= u"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consequat mi quis " "pretium semper. Proin luctus orci ac neque venenatis, quis commodo dolor posuere. " "Curabitur dignissim sapien quis cursus egestas. Donec blandit auctor arcu, nec " "pellentesque eros molestie eget. In consectetur aliquam hendrerit. Sed cursus mauris " "vitae ligula pellentesque, non pellentesque urna aliquet. Fusce placerat mauris enim, " "nec rutrum purus semper vel. Praesent tincidunt neque eu pellentesque pharetra. Fusce " "pellentesque est orci."_ustr;
// index, length, x, y const std::tuple<int, int, int, int> strings[] = {
{ 0, 6, 9600, 8647 }, // Lorem
{ 6, 22, 7570, 9358 }, // ipsum dolor sit amet,
{ 28, 29, 6776, 10069 }, // consectetur adipiscing elit.
{ 57, 29, 6299, 10780 }, // Vestibulum consequat mi quis
{ 86, 37, 5453, 11491 }, // pretium semper. Proin luctus orci ac
{ 123, 36, 5134, 12202 }, // neque venenatis, quis commodo dolor
{ 159, 41, 4764, 12913 }, // posuere. Curabitur dignissim sapien quis
{ 200, 43, 4481, 13624 }, // cursus egestas. Donec blandit auctor arcu,
{ 243, 40, 4975, 14335 }, // nec pellentesque eros molestie eget. In
{ 283, 42, 4552, 15046 }, // consectetur aliquam hendrerit. Sed cursus
{ 325, 38, 5363, 15757 }, // mauris vitae ligula pellentesque, non
{ 363, 42, 4693, 16468 }, // pellentesque urna aliquet. Fusce placerat
{ 405, 37, 5047, 17179 }, // mauris enim, nec rutrum purus semper
{ 442, 33, 5963, 17890 }, // vel. Praesent tincidunt neque eu
{ 475, 29, 6387, 18601 }, // pellentesque pharetra. Fusce
{ 504, 22, 7499, 19312 }, // pellentesque est orci.
};
// Without the fix, the test fails with: // - Expected: 8998 // - Actual : 892 // - In <>, attribute 'y' of '/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[4]'
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[1]", "x", u"7556");
assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/push[2]/push[1]/clipregion/polygon/point[1]", "y", u"892");
CPPUNIT_TEST_FIXTURE(SdLayoutTest, testTdf168010)
{ // Test UseTrailingEmptyLinesInLayout compatibility option. // The test documents have an auto-shrink text "textbox\n\n"; the box itself is positioned // identically in all cases; the text is aligned to bottom. // When "UseTrailingEmptyLinesInLayout" is set, "textbox" string is placed higher, than when // the setting is not set (y value ~6700 vs. ~8100).
// The existing ODPs have a standard draw:text-box. It produces three textarray elements, // in order from bottom to top. We need the topmost, third.
// 1. UseTrailingEmptyLinesInLayout must be enabled in an existing ODP with respective option // in settings.xml
loadFromFile(u"odp/trailing-paragraphs-compat.odp");
{
CPPUNIT_ASSERT(
getDoc()->GetCompatibilityFlag(SdrCompatibilityFlag::UseTrailingEmptyLinesInLayout));
xmlDocUniquePtr pXml = parseLayout();
sal_Int32 y = getXPath(pXml, "/metafile['1']/push/push/textarray[3]", "y").toInt32();
CPPUNIT_ASSERT_DOUBLES_EQUAL(6700, y, 100); // could be 6641 or 6760
assertXPathContent(pXml, "/metafile['1']/push/push/textarray[3]/text", u"textbox");
}
// 2. It must stay enabled after ODP round-trip
saveAndReload(u"impress8"_ustr);
{
CPPUNIT_ASSERT(
getDoc()->GetCompatibilityFlag(SdrCompatibilityFlag::UseTrailingEmptyLinesInLayout));
xmlDocUniquePtr pXml = parseLayout();
sal_Int32 y = getXPath(pXml, "/metafile['2']/push/push/textarray[3]", "y").toInt32();
CPPUNIT_ASSERT_DOUBLES_EQUAL(6700, y, 100);
assertXPathContent(pXml, "/metafile['2']/push/push/textarray[3]/text", u"textbox");
}
// 3. It must be disabled in an existing ODP without that option in settings.xml
loadFromFile(u"odp/trailing-paragraphs.odp");
{
CPPUNIT_ASSERT(
!getDoc()->GetCompatibilityFlag(SdrCompatibilityFlag::UseTrailingEmptyLinesInLayout));
xmlDocUniquePtr pXml = parseLayout();
sal_Int32 y = getXPath(pXml, "/metafile['3']/push/push/textarray[3]", "y").toInt32();
CPPUNIT_ASSERT_DOUBLES_EQUAL(8100, y, 100);
assertXPathContent(pXml, "/metafile['3']/push/push/textarray[3]/text", u"textbox");
}
// 4. It must stay disabled after ODP round-trip
saveAndReload(u"impress8"_ustr);
{
CPPUNIT_ASSERT(
!getDoc()->GetCompatibilityFlag(SdrCompatibilityFlag::UseTrailingEmptyLinesInLayout));
xmlDocUniquePtr pXml = parseLayout();
sal_Int32 y = getXPath(pXml, "/metafile['4']/push/push/textarray[3]", "y").toInt32();
CPPUNIT_ASSERT_DOUBLES_EQUAL(8100, y, 100);
assertXPathContent(pXml, "/metafile['4']/push/push/textarray[3]/text", u"textbox");
}
// Now test PPTX and its round-trip. The text there imports as draw:custom-shape; it generates // a single textarray element.
// 5. It must be enabled for PPTX documents unconditionally
loadFromFile(u"pptx/trailing-paragraphs.pptx");
{
CPPUNIT_ASSERT(
getDoc()->GetCompatibilityFlag(SdrCompatibilityFlag::UseTrailingEmptyLinesInLayout));
xmlDocUniquePtr pXml = parseLayout();
sal_Int32 y = getXPath(pXml, "/metafile['5']/push/push/textarray", "y").toInt32();
CPPUNIT_ASSERT_DOUBLES_EQUAL(6700, y, 100);
assertXPathContent(pXml, "/metafile['5']/push/push/textarray/text", u"textbox");
}
xmlDocUniquePtr pXml = parseLayout();
sal_Int32 y = getXPath(pXml, "/metafile['6']/push/push/textarray", "y").toInt32();
CPPUNIT_ASSERT_DOUBLES_EQUAL(6700, y, 100);
assertXPathContent(pXml, "/metafile['6']/push/push/textarray/text", u"textbox");
}
// For some reason, saving PPTX to ODT in step 7 below produces negative fo:padding-top, which // fails validation; that is unrelated, so disable validation for now.
skipValidation();
// 7. It must round-trip to ODP
saveAndReload(u"impress8"_ustr);
{
CPPUNIT_ASSERT(
getDoc()->GetCompatibilityFlag(SdrCompatibilityFlag::UseTrailingEmptyLinesInLayout));
xmlDocUniquePtr pXml = parseLayout();
sal_Int32 y = getXPath(pXml, "/metafile['7']/push/push/textarray", "y").toInt32();
CPPUNIT_ASSERT_DOUBLES_EQUAL(6700, y, 100);
assertXPathContent(pXml, "/metafile['7']/push/push/textarray/text", u"textbox");
}
}
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.