diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:44:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 09:44:47 +0000 |
commit | 91fe6b97952aa6f7cef58327fd085a17db38ad95 (patch) | |
tree | 7a4412295bfb80e15a4936fe67d4bd7b96458ce8 /sw/qa/extras/odfexport | |
parent | Releasing progress-linux version 4:24.2.1-4~progress7.99u1. (diff) | |
download | libreoffice-91fe6b97952aa6f7cef58327fd085a17db38ad95.tar.xz libreoffice-91fe6b97952aa6f7cef58327fd085a17db38ad95.zip |
Merging upstream version 4:24.2.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sw/qa/extras/odfexport')
-rw-r--r-- | sw/qa/extras/odfexport/data/bookmark_order.fodt | 9 | ||||
-rw-r--r-- | sw/qa/extras/odfexport/odfexport2.cxx | 96 |
2 files changed, 105 insertions, 0 deletions
diff --git a/sw/qa/extras/odfexport/data/bookmark_order.fodt b/sw/qa/extras/odfexport/data/bookmark_order.fodt new file mode 100644 index 0000000000..c7eac58758 --- /dev/null +++ b/sw/qa/extras/odfexport/data/bookmark_order.fodt @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:body> + <office:text> + <text:p><text:bookmark-start text:name="bookmark1"/>foo<text:bookmark-end text:name="bookmark1"/><text:bookmark text:name="bookmark2"/><text:bookmark-start text:name="bookmark3"/>bar<text:bookmark-end text:name="bookmark3"/></text:p> + </office:text> + </office:body> +</office:document>
\ No newline at end of file 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<OUString>(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(run, "IsStart")); + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(run, "IsCollapsed")); + auto named = getProperty<uno::Reference<container::XNamed>>(run, "Bookmark"); + CPPUNIT_ASSERT_EQUAL(u"bookmark1"_ustr, named->getName()); + } + + { + auto run = getRun(xPara, 2); + CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(u"foo"_ustr, run->getString()); + } + + { + auto run = getRun(xPara, 3); + CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty<OUString>(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(run, "IsStart")); + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(run, "IsCollapsed")); + auto named = getProperty<uno::Reference<container::XNamed>>(run, "Bookmark"); + CPPUNIT_ASSERT_EQUAL(u"bookmark1"_ustr, named->getName()); + } + + { + auto run = getRun(xPara, 4); + CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty<OUString>(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(run, "IsStart")); + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(run, "IsCollapsed")); + auto named = getProperty<uno::Reference<container::XNamed>>(run, "Bookmark"); + CPPUNIT_ASSERT_EQUAL(u"bookmark2"_ustr, named->getName()); + } + + { + auto run = getRun(xPara, 5); + CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty<OUString>(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(run, "IsStart")); + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(run, "IsCollapsed")); + auto named = getProperty<uno::Reference<container::XNamed>>(run, "Bookmark"); + CPPUNIT_ASSERT_EQUAL(u"bookmark3"_ustr, named->getName()); + } + + { + auto run = getRun(xPara, 6); + CPPUNIT_ASSERT_EQUAL(u"Text"_ustr, getProperty<OUString>(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(u"bar"_ustr, run->getString()); + } + + { + auto run = getRun(xPara, 7); + CPPUNIT_ASSERT_EQUAL(u"Bookmark"_ustr, getProperty<OUString>(run, "TextPortionType")); + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(run, "IsStart")); + CPPUNIT_ASSERT_EQUAL(false, getProperty<bool>(run, "IsCollapsed")); + auto named = getProperty<uno::Reference<container::XNamed>>(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: */ |