From 91fe6b97952aa6f7cef58327fd085a17db38ad95 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 11:44:47 +0200 Subject: Merging upstream version 4:24.2.2. Signed-off-by: Daniel Baumann --- sw/qa/extras/odfexport/odfexport2.cxx | 96 +++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'sw/qa/extras/odfexport/odfexport2.cxx') diff --git a/sw/qa/extras/odfexport/odfexport2.cxx b/sw/qa/extras/odfexport/odfexport2.cxx index 37e744e9c8..4983608290 100644 --- a/sw/qa/extras/odfexport/odfexport2.cxx +++ b/sw/qa/extras/odfexport/odfexport2.cxx @@ -1247,6 +1247,102 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf159382) } } +CPPUNIT_TEST_FIXTURE(Test, testTdf159438) +{ + // Given a text with bookmarks, where an end of one bookmark is the position of another, + // and the start of a third + loadAndReload("bookmark_order.fodt"); + auto xPara = getParagraph(1); + + // Check that the order of runs is correct (bookmarks don't overlap) + + { + auto run = getRun(xPara, 1); + CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(true, getProperty(run, "IsStart")); + CPPUNIT_ASSERT_EQUAL(false, getProperty(run, "IsCollapsed")); + auto named = getProperty>(run, "Bookmark"); + CPPUNIT_ASSERT_EQUAL(u"bookmark1"_ustr, named->getName()); + } + + { + auto run = getRun(xPara, 2); + CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(u"foo"_ustr, run->getString()); + } + + { + auto run = getRun(xPara, 3); + CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(false, getProperty(run, "IsStart")); + CPPUNIT_ASSERT_EQUAL(false, getProperty(run, "IsCollapsed")); + auto named = getProperty>(run, "Bookmark"); + CPPUNIT_ASSERT_EQUAL(u"bookmark1"_ustr, named->getName()); + } + + { + auto run = getRun(xPara, 4); + CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(true, getProperty(run, "IsStart")); + CPPUNIT_ASSERT_EQUAL(true, getProperty(run, "IsCollapsed")); + auto named = getProperty>(run, "Bookmark"); + CPPUNIT_ASSERT_EQUAL(u"bookmark2"_ustr, named->getName()); + } + + { + auto run = getRun(xPara, 5); + CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(true, getProperty(run, "IsStart")); + CPPUNIT_ASSERT_EQUAL(false, getProperty(run, "IsCollapsed")); + auto named = getProperty>(run, "Bookmark"); + CPPUNIT_ASSERT_EQUAL(u"bookmark3"_ustr, named->getName()); + } + + { + auto run = getRun(xPara, 6); + CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(u"bar"_ustr, run->getString()); + } + + { + auto run = getRun(xPara, 7); + CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(false, getProperty(run, "IsStart")); + CPPUNIT_ASSERT_EQUAL(false, getProperty(run, "IsCollapsed")); + auto named = getProperty>(run, "Bookmark"); + CPPUNIT_ASSERT_EQUAL(u"bookmark3"_ustr, named->getName()); + } + + // Test that the markup stays at save-and-reload + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + + assertXPathNodeName(pXmlDoc, "//office:body/office:text/text:p/*[1]"_ostr, + "bookmark-start"_ostr); + assertXPath(pXmlDoc, "//office:body/office:text/text:p/*[1]"_ostr, "name"_ostr, + u"bookmark1"_ustr); + + // Without the fix in place, this would fail with + // - Expected: bookmark-end + // - Actual : bookmark-start + // - In XPath '//office:body/office:text/text:p/*[2]' name of node is incorrect + assertXPathNodeName(pXmlDoc, "//office:body/office:text/text:p/*[2]"_ostr, "bookmark-end"_ostr); + assertXPath(pXmlDoc, "//office:body/office:text/text:p/*[2]"_ostr, "name"_ostr, + u"bookmark1"_ustr); + + assertXPathNodeName(pXmlDoc, "//office:body/office:text/text:p/*[3]"_ostr, "bookmark"_ostr); + assertXPath(pXmlDoc, "//office:body/office:text/text:p/*[3]"_ostr, "name"_ostr, + u"bookmark2"_ustr); + + assertXPathNodeName(pXmlDoc, "//office:body/office:text/text:p/*[4]"_ostr, + "bookmark-start"_ostr); + assertXPath(pXmlDoc, "//office:body/office:text/text:p/*[4]"_ostr, "name"_ostr, + u"bookmark3"_ustr); + + assertXPathNodeName(pXmlDoc, "//office:body/office:text/text:p/*[5]"_ostr, "bookmark-end"_ostr); + assertXPath(pXmlDoc, "//office:body/office:text/text:p/*[5]"_ostr, "name"_ostr, + u"bookmark3"_ustr); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3