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 1a85d29bbc467354a5bc2d02e672fcdbffe5586d Author: Vasily Melenchuk <vasily.melenc...@cib.de> AuthorDate: Wed Mar 9 17:00:02 2022 +0300 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Mar 15 11:36:38 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> Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131542 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index f06778fc25b4..87e2aead4997 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -2794,7 +2794,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 ec07a5a946f0..52465ed66d90 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -12,6 +12,9 @@ #include <string_view> #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/util/XRefreshable.hpp> #include <comphelper/configuration.hxx> #include <comphelper/scopeguard.hxx> @@ -170,6 +173,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 93a5c149f15c..8a5b9c5d7c60 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; }