sw/qa/extras/odfexport/odfexport.cxx | 2 - sw/qa/extras/ooxmlexport/data/tdf144563.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 29 +++++++++++++++++++++++++++ sw/qa/python/check_cross_references.py | 10 ++++----- sw/source/core/doc/number.cxx | 6 +++++ 5 files changed, 41 insertions(+), 6 deletions(-)
New commits: commit 8c94a17e408db8a0d27101ce07345fc640bef64d Author: Vasily Melenchuk <vasily.melenc...@cib.de> AuthorDate: Wed Mar 9 17:00:02 2022 +0300 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Sat Mar 12 18:21:17 2022 +0100 tdf#144563: remove final dot in cross-references to paragraph It looks like in cross-references ending with dot (".") one last dot is removed in case of MS Word. This is not a true for any other suffixes after numeration. Change-Id: I554e62cf45e643bf27823df5344e1689b5b6ae54 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131254 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index d7aef384764e..33c6a2deb4a5 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -2797,7 +2797,7 @@ DECLARE_ODFEXPORT_TEST(testReferenceLanguage, "referencelanguage.odt") OUString const aFieldTexts[] = { "A 2", "Az Isten", "Az 50-esek", "A 2018-asok", "Az egyebek", "A fejezetek", u"Az „Őseinket...”", "a 2", - "Az v.", "az 1", "Az e)", "az 1", + "Az v", "az 1", "Az e)", "az 1", "Az (5)", "az 1", "A 2", "az 1" }; uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); // update "A (4)" to "Az (5)" diff --git a/sw/qa/extras/ooxmlexport/data/tdf144563.docx b/sw/qa/extras/ooxmlexport/data/tdf144563.docx new file mode 100644 index 000000000000..59d64d2d1bf3 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf144563.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 7905091de82f..8b70d879f4b4 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -8,7 +8,10 @@ */ #include <com/sun/star/text/XBookmarksSupplier.hpp> +#include <com/sun/star/text/XTextFieldsSupplier.hpp> +#include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/util/XRefreshable.hpp> #include <comphelper/scopeguard.hxx> #include <officecfg/Office/Common.hxx> @@ -289,6 +292,32 @@ DECLARE_OOXMLEXPORT_TEST(testTdf81507, "tdf81507.docx") xmlXPathFreeObject(pXmlObj); } +DECLARE_OOXMLEXPORT_TEST(testTdf144563, "tdf144563.docx") +{ + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); + + // Refresh all cross-reference fields + uno::Reference<util::XRefreshable>(xFieldsAccess, uno::UNO_QUERY_THROW)->refresh(); + + // Verify values + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + + std::vector<OUString> aExpectedValues = { + // These field values are NOT in order in document: getTextFields did provide + // fields in a strange but fixed order + "1", "1", "1", "1", "1/", "1/", "1/", "1)", "1)", "1)", "1.)", + "1.)", "1.)", "1..", "1..", "1..", "1.", "1.", "1.", "1", "1" + }; + + sal_uInt16 nIndex = 0; + while (xFields->hasMoreElements()) + { + uno::Reference<text::XTextField> xTextField(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(aExpectedValues[nIndex++], xTextField->getPresentation(false)); + } +} + DECLARE_OOXMLEXPORT_TEST(testTdf144668, "tdf144668.odt") { uno::Reference<beans::XPropertySet> xPara1(getParagraph(1, u"level1"), uno::UNO_QUERY); diff --git a/sw/qa/python/check_cross_references.py b/sw/qa/python/check_cross_references.py index 3c9319200ea7..7778ff5f2100 100644 --- a/sw/qa/python/check_cross_references.py +++ b/sw/qa/python/check_cross_references.py @@ -89,16 +89,16 @@ class CheckCrossReferences(unittest.TestCase): FieldResult1 = "*i*" FieldResult2 = "+b+*i*" FieldResult3 = "-1-+b+*i*" - FieldResult4 = "1." - FieldResult5 = "1." - FieldResult6 = "A.1." + FieldResult4 = "1" + FieldResult5 = "1" + FieldResult6 = "A.1" FieldResult7 = " 2.(a)" FieldResult8 = " 2.(b)" - FieldResult9 = " 2." + FieldResult9 = " 2" FieldResult10 = " 1.(a)" FieldResult11 = "(b)" FieldResult12 = "(a)" - FieldResult13 = " 1." + FieldResult13 = " 1" # variables for current field xField = self.getNextField() diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 40fec8c7d8d1..2589084f807d 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -882,6 +882,12 @@ OUString SwNumRule::MakeRefNumString( const SwNodeNum& rNodeNum, pWorkingNodeNum->GetLevelInListTree() >= nRestrictInclToThisLevel ); } + if (aRefNumStr.endsWith(".")) + { + // tdf#144563: looks like a special case for refs by MS Word: if numbering is ending with dot, this dot is removed + aRefNumStr = aRefNumStr.copy(0, aRefNumStr.getLength() - 1); + } + return aRefNumStr; }