summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasily Melenchuk <vasily.melenchuk@cib.de>2022-03-09 17:00:02 +0300
committerThorsten Behrens <thorsten.behrens@allotropia.de>2022-03-12 18:21:17 +0100
commit8c94a17e408db8a0d27101ce07345fc640bef64d (patch)
treec95cae4b3629ad2f62110fc3d7ca97967df59e0d
parenteff9dc65b88ca48171e9e6ab51f1e2ec8d0f436d (diff)
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.behrens@allotropia.de>
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx2
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf144563.docxbin0 -> 17488 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport17.cxx29
-rw-r--r--sw/qa/python/check_cross_references.py10
-rw-r--r--sw/source/core/doc/number.cxx6
5 files changed, 41 insertions, 6 deletions
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
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf144563.docx
Binary files 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;
}