From 97ac77f067910fa5e8206d75160fa63546a9358d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 07:03:24 +0200 Subject: Merging upstream version 4:24.2.3. Signed-off-by: Daniel Baumann --- sw/qa/extras/odfexport/odfexport2.cxx | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 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 4983608290..f654821acf 100644 --- a/sw/qa/extras/odfexport/odfexport2.cxx +++ b/sw/qa/extras/odfexport/odfexport2.cxx @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -1343,6 +1344,35 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf159438) u"bookmark3"_ustr); } +CPPUNIT_TEST_FIXTURE(Test, testTdf160700) +{ + // Given a document with an empty numbered paragraph, and a cross-reference to it + loadAndReload("tdf160700.odt"); + + // Refresh fields and ensure cross-reference to numbered para is okay + auto xTextFieldsSupplier(mxComponent.queryThrow()); + auto xFieldsAccess(xTextFieldsSupplier->getTextFields()); + + xFieldsAccess.queryThrow()->refresh(); + + auto xFields(xFieldsAccess->createEnumeration()); + CPPUNIT_ASSERT(xFields->hasMoreElements()); + auto xTextField(xFields->nextElement().queryThrow()); + // Save must not create markup with text:bookmark-end element before text:bookmark-start + // Withoud the fix, this would fail with + // - Expected: 1 + // - Actual : Error: Reference source not found + // i.e., the bookmark wasn't imported, and the field had no proper source + CPPUNIT_ASSERT_EQUAL(u"1"_ustr, xTextField->getPresentation(false)); + + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); + // Check that we export the bookmark in the empty paragraph as a single text:bookmark + // element. Another walid markup is text:bookmark-start followed by text:bookmark-end + // (in that order). The problem was, that text:bookmark-end was before text:bookmark-start. + assertXPathChildren(pXmlDoc, "//office:text/text:list/text:list-item/text:p"_ostr, 1); + assertXPath(pXmlDoc, "//office:text/text:list/text:list-item/text:p/text:bookmark"_ostr); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3