From e09f22aa2626267e01b9e759c152f3a0d70ddc68 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 10 Jul 2021 12:35:44 +0300 Subject: editengine-columns: tdf#143258 Fix handling rotated text This reverts modifications to existing unit tests made in commit d0a1616ccad0dd5f5a02c1b0204f537b57d0b4b5. My idea that those changes were required because of more correct calculations was wrong, and in fact they were caused by off-by-1 error in height calculations. Change-Id: Ib94878a911238c977c35a8f8e3e5694cedc79a89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118705 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sd/qa/uitest/impress_tests/tdf91762.py | 8 +-- sd/qa/unit/data/odg/tb-rl-textbox.odg | Bin 0 -> 10002 bytes sd/qa/unit/data/xml/n593612_0.xml | 4 +- sd/qa/unit/data/xml/n758621_1.xml | 4 +- sd/qa/unit/layout-tests.cxx | 67 +++++++++++++++++++++++++- sd/qa/unit/tiledrendering/LOKitSearchTest.cxx | 4 +- 6 files changed, 75 insertions(+), 12 deletions(-) create mode 100644 sd/qa/unit/data/odg/tb-rl-textbox.odg (limited to 'sd') diff --git a/sd/qa/uitest/impress_tests/tdf91762.py b/sd/qa/uitest/impress_tests/tdf91762.py index 2abc1a6589f1..00f9dc084c5d 100644 --- a/sd/qa/uitest/impress_tests/tdf91762.py +++ b/sd/qa/uitest/impress_tests/tdf91762.py @@ -22,9 +22,9 @@ class tdf91762(UITestCase): self.assertEqual('5', get_state_as_dict(xDialog.getChild('columns'))['Text']) self.assertEqual('2', get_state_as_dict(xDialog.getChild('rows'))['Text']) - self.assertEqual(1931, document.DrawPages[0].getByIndex(1).BoundRect.Height) + self.assertEqual(1929, document.DrawPages[0].getByIndex(1).BoundRect.Height) self.assertEqual(25198, document.DrawPages[0].getByIndex(1).Size.Width) - self.assertEqual(1925, document.DrawPages[0].getByIndex(1).Size.Height) + self.assertEqual(1923, document.DrawPages[0].getByIndex(1).Size.Height) self.assertEqual(1400, document.DrawPages[0].getByIndex(1).Position.X) self.assertEqual(3685, document.DrawPages[0].getByIndex(1).Position.Y) @@ -36,8 +36,8 @@ class tdf91762(UITestCase): xEdit.executeAction("TYPE", mkPropertyValues({"KEYCODE": "RETURN"})) # tdf#138011: Without the fix in place, this test would have failed with - # AssertionError: 5496 != 3559 - self.assertEqual(5496, document.DrawPages[0].getByIndex(1).BoundRect.Height) + # AssertionError: 5494 != 3559 + self.assertEqual(5494, document.DrawPages[0].getByIndex(1).BoundRect.Height) # vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sd/qa/unit/data/odg/tb-rl-textbox.odg b/sd/qa/unit/data/odg/tb-rl-textbox.odg new file mode 100644 index 000000000000..95dda6208de9 Binary files /dev/null and b/sd/qa/unit/data/odg/tb-rl-textbox.odg differ diff --git a/sd/qa/unit/data/xml/n593612_0.xml b/sd/qa/unit/data/xml/n593612_0.xml index 51fb75eba050..7c93f494e3ca 100644 --- a/sd/qa/unit/data/xml/n593612_0.xml +++ b/sd/qa/unit/data/xml/n593612_0.xml @@ -1,6 +1,6 @@ - + @@ -10,7 +10,7 @@ - + diff --git a/sd/qa/unit/data/xml/n758621_1.xml b/sd/qa/unit/data/xml/n758621_1.xml index 92de100a09f1..556c18673065 100644 --- a/sd/qa/unit/data/xml/n758621_1.xml +++ b/sd/qa/unit/data/xml/n758621_1.xml @@ -1,6 +1,6 @@ - + @@ -10,7 +10,7 @@ - + diff --git a/sd/qa/unit/layout-tests.cxx b/sd/qa/unit/layout-tests.cxx index 8a2853693505..e4dfe0e3d47c 100644 --- a/sd/qa/unit/layout-tests.cxx +++ b/sd/qa/unit/layout-tests.cxx @@ -15,6 +15,7 @@ public: void testTdf136949(); void testTdf128212(); void testColumnsLayout(); + void tdf143258_testTbRlLayout(); CPPUNIT_TEST_SUITE(SdLayoutTest); @@ -22,6 +23,7 @@ public: CPPUNIT_TEST(testTdf136949); CPPUNIT_TEST(testTdf128212); CPPUNIT_TEST(testColumnsLayout); + CPPUNIT_TEST(tdf143258_testTbRlLayout); CPPUNIT_TEST_SUITE_END(); }; @@ -79,10 +81,10 @@ void SdLayoutTest::testTdf128212() CPPUNIT_ASSERT(pXmlDoc); // Without the fix in place, this test would have failed with - // - Expected: 7798 + // - Expected: 7797 // - Actual : 12068 assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray", "x", "4525"); - assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray", "y", "7798"); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray", "y", "7797"); xDocShRef->DoClose(); } @@ -188,6 +190,67 @@ void SdLayoutTest::testColumnsLayout() xDocShRef->DoClose(); } +void SdLayoutTest::tdf143258_testTbRlLayout() +{ + // This tests a 1-column and a 2-column text boxes' layout + + const OUString sText[] = { + "tb-rl text within a small text box", // Box 1 + "tb-rl text within a small 2-column text box", // Box 2 + }; + + // sentence#, index, length, x, y + const std::tuple strings[] = { + // Box 1 + { 0, 0, 11, 5346, 3250 }, + { 0, 11, 9, 4635, 3250 }, + { 0, 20, 6, 3924, 3250 }, + { 0, 26, 8, 3213, 3250 }, + // Box 2 column 1 + { 1, 0, 6, 5346, 7250 }, + { 1, 6, 5, 4635, 7250 }, + { 1, 11, 9, 3924, 7250 }, + { 1, 20, 6, 3213, 7250 }, + // Box 2 column 2 + { 1, 26, 2, 5346, 9600 }, + { 1, 28, 7, 4635, 9600 }, + { 1, 35, 5, 3924, 9600 }, + { 1, 40, 3, 3213, 9600 }, + }; + + sd::DrawDocShellRef xDocShRef + = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odg/tb-rl-textbox.odg"), ODG); + + std::shared_ptr xMetaFile = xDocShRef->GetPreviewMetaFile(); + MetafileXmlDump dumper; + + xmlDocUniquePtr pXmlDoc = XmlTestTools::dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/font", SAL_N_ELEMENTS(strings)); + assertXPath(pXmlDoc, "/metafile/push[1]/push[1]/textarray", SAL_N_ELEMENTS(strings)); + for (size_t i = 0; i < SAL_N_ELEMENTS(strings); ++i) + { + const auto & [ sentence, index, length, x, y ] = strings[i]; + OString sXPath = "/metafile/push[1]/push[1]/font[" + OString::number(i + 1) + "]"; + assertXPath(pXmlDoc, sXPath, "orientation", "-900"); + assertXPath(pXmlDoc, sXPath, "vertical", "true"); + sXPath = "/metafile/push[1]/push[1]/textarray[" + OString::number(i + 1) + "]"; + assertXPathContent(pXmlDoc, sXPath + "/text", sText[sentence]); + assertXPath(pXmlDoc, sXPath, "index", OUString::number(index)); + assertXPath(pXmlDoc, sXPath, "length", OUString::number(length)); + + // 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)); + } + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdLayoutTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx index 7232d59cc29d..762faaac1b56 100644 --- a/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx +++ b/sd/qa/unit/tiledrendering/LOKitSearchTest.cxx @@ -664,7 +664,7 @@ void LOKitSearchTest::testSearchIn2MixedObjects() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); - CPPUNIT_ASSERT_EQUAL(OString("3546, 3173, 738, 401"), + CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"), mpCallbackRecorder->m_aSearchResultSelection[0]); // Search next @@ -690,7 +690,7 @@ void LOKitSearchTest::testSearchIn2MixedObjects() CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultSelection.size()); CPPUNIT_ASSERT_EQUAL(size_t(1), mpCallbackRecorder->m_aSearchResultPart.size()); - CPPUNIT_ASSERT_EQUAL(OString("3546, 3173, 738, 401"), + CPPUNIT_ASSERT_EQUAL(OString("3546, 3174, 738, 402"), mpCallbackRecorder->m_aSearchResultSelection[0]); } -- cgit