summaryrefslogtreecommitdiff
path: root/xmloff/qa/unit
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-02-24 16:43:19 +0100
committerMiklos Vajna <vmiklos@collabora.com>2022-02-25 09:09:01 +0100
commitd5a67b97b47bcb57467cf0ddc5855c0b29a82122 (patch)
tree8f13f91f0363dd7d832087dc5da0015536827d0b /xmloff/qa/unit
parenta45f880cc11a7287a1c8ff3c4ffebaa20e41653b (diff)
ODT import: fix MSO-style <text:list text:continue-numbering="true">
The ODF spec says that text:continue-numbering="true" should only continue the numbering in case the styles of the previous and the current list match. In contrast, Word continues the numbering even in case there is e.g. numbering, then bullets, then numbering again, in case the list styles of the two numberings are the same. Work this around at import time when the generator confirms that the document is coming from Word. At least Office 2019 and the latest renderer at office.com is affected. (I've mailed dochelp@microsoft, no answer yet.) (cherry picked from commit 1127c63470096f62394f133c61cee2e6fb7fd0c7) Change-Id: Ib63e14322e5501a6220f798abd9365d7913dab4c
Diffstat (limited to 'xmloff/qa/unit')
-rw-r--r--xmloff/qa/unit/data/continue-numbering-word.odtbin0 -> 6151 bytes
-rw-r--r--xmloff/qa/unit/text.cxx25
2 files changed, 25 insertions, 0 deletions
diff --git a/xmloff/qa/unit/data/continue-numbering-word.odt b/xmloff/qa/unit/data/continue-numbering-word.odt
new file mode 100644
index 000000000000..278a1fa65684
--- /dev/null
+++ b/xmloff/qa/unit/data/continue-numbering-word.odt
Binary files differ
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index 9ac9ac93dbc4..1d239e2e0c09 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -220,6 +220,31 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testParaStyleListLevel)
"list-level", "2");
}
+CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testContinueNumberingWord)
+{
+ // Given a document, which is produced by Word and contains text:continue-numbering="true":
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "continue-numbering-word.odt";
+
+ // When loading that document:
+ getComponent() = loadFromDesktop(aURL);
+
+ // Then make sure that the numbering from the 1st para is continued on the 3rd para:
+ uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<text::XText> xText = xTextDocument->getText();
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
+ uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+ xParaEnum->nextElement();
+ xParaEnum->nextElement();
+ uno::Reference<beans::XPropertySet> xPara(xParaEnum->nextElement(), uno::UNO_QUERY);
+ auto aActual = xPara->getPropertyValue("ListLabelString").get<OUString>();
+ // Without the accompanying fix in place, this failed with:
+ // - Expected: 2.
+ // - Actual : 1.
+ // i.e. the numbering was not continued, like in Word.
+ CPPUNIT_ASSERT_EQUAL(OUString("2."), aActual);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */