sw/qa/extras/ooxmlexport/data/tdf153104.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport18.cxx | 22 ++++++++++++++++++++++ sw/source/filter/ww8/docxattributeoutput.cxx | 8 ++++++-- 3 files changed, 28 insertions(+), 2 deletions(-)
New commits: commit a93cb8acdb1b5986c9fffffdb11f4d33c92925bd Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Jan 19 12:16:06 2023 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Jan 19 14:36:10 2023 +0000 tdf#153104: fix the "dummy" levels when overriding lower numbering levels The problem was that Word treats empty w:num/w:lvlOverride elements for higher levels as defining corresponding w:startOverride equal to 0. This only shows when the first list element has a lower level and resets numbering; in this case, implicit higher levels get zero value, and the following higher level items start from 1. This writes the correct w:startOverride values (from the respective rule) to the gap-filling levels. Change-Id: I18db1c6011bf09826ba586aaec16e7939ecb0c6a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145770 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sw/qa/extras/ooxmlexport/data/tdf153104.docx b/sw/qa/extras/ooxmlexport/data/tdf153104.docx new file mode 100644 index 000000000000..d70b09852a83 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf153104.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx index 7b7213e0f019..5328c19081fb 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport18.cxx @@ -272,6 +272,28 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf152425) CPPUNIT_ASSERT_EQUAL(OUString("List 5"), Para5Style); } +CPPUNIT_TEST_FIXTURE(Test, testTdf153104) +{ + loadAndReload("tdf153104.docx"); + + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + OUString numId = getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:numPr/w:numId", "val"); + + xmlDocUniquePtr pXmlNum = parseExport("word/numbering.xml"); + OString numPath = "/w:numbering/w:num[@w:numId='" + + OUStringToOString(numId, RTL_TEXTENCODING_ASCII_US) + "']/"; + + // Check that first level's w:lvlOverride/w:startOverride is written correctly: + // the list defines starting value of 10, which must be kept upon second level + // numbering reset. + // Without the fix, this would fail with + // - Expected: 1 + // - Actual : 0 + // - In <>, XPath '/w:numbering/w:num[@w:numId='3']/w:lvlOverride[@w:ilvl='0']/w:startOverride' number of nodes is incorrect + assertXPath(pXmlNum, numPath + "w:lvlOverride[@w:ilvl='0']/w:startOverride", "val", "10"); + assertXPath(pXmlNum, numPath + "w:lvlOverride[@w:ilvl='1']/w:startOverride", "val", "1"); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 477768e7019a..dfdaa4013bb3 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -8004,10 +8004,14 @@ void DocxAttributeOutput::OverrideNumberingDefinition( if (bListsAreDifferent || levelOverride != rLevelOverrides.end()) { // If there are "gaps" in w:lvlOverride numbers, MS Word can have issues with numbering. - // So we need to emit empty override tokens up to current one. + // So we need to emit default override tokens up to current one. while (nPreviousOverrideLevel < nLevel) { - m_pSerializer->singleElementNS(XML_w, XML_lvlOverride, FSNS(XML_w, XML_ilvl), OString::number(nPreviousOverrideLevel)); + const SwNumFormat& rFormat = rRule.Get(nPreviousOverrideLevel); + m_pSerializer->startElementNS(XML_w, XML_lvlOverride, FSNS(XML_w, XML_ilvl), OString::number(nPreviousOverrideLevel)); + // tdf#153104: absent startOverride is treated by Word as "startOverride value 0". + m_pSerializer->singleElementNS(XML_w, XML_startOverride, FSNS(XML_w, XML_val), OString::number(rFormat.GetStart())); + m_pSerializer->endElementNS(XML_w, XML_lvlOverride); nPreviousOverrideLevel++; }