diff options
author | Vasily Melenchuk <vasily.melenchuk@cib.de> | 2022-05-16 21:21:51 +0300 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2022-05-18 14:59:58 +0200 |
commit | 198381eb32edcc3e82d0f23df65f0804a08b44e6 (patch) | |
tree | 905f7f41efdca419772615e77f33f9bcb83cf33a /sw | |
parent | 75918e709a6d0e2b94b5e4fd9c2eb248ef912e00 (diff) |
tdf#148455 docx import/export: improvements to lvlOverride
On save LO was just emitting w:lvlOverride to actual level
where override does happen. But MS Word won't accept override
for next level if there are no overrides for previous ones.
For example, if we are overriding level 3 we should also emit
empty lvlOverride for levels 0-2.
Provided fix did cause some problems on DOCX import: overrides
were applied to current level, but in this context current !=
actual level where override did happen.
Change-Id: Ia00dd9a5990f7f122027e8126f411642c32da189
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134411
Tested-by: Jenkins
Tested-by: Gabor Kelemen <kelemeng@ubuntu.com>
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf148455_1.docx | bin | 0 -> 3038 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf148455_2.docx | bin | 0 -> 3022 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport17.cxx | 24 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 9 |
4 files changed, 33 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf148455_1.docx b/sw/qa/extras/ooxmlexport/data/tdf148455_1.docx Binary files differnew file mode 100644 index 000000000000..295d3ee744c7 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf148455_1.docx diff --git a/sw/qa/extras/ooxmlexport/data/tdf148455_2.docx b/sw/qa/extras/ooxmlexport/data/tdf148455_2.docx Binary files differnew file mode 100644 index 000000000000..3cde58ce5a77 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf148455_2.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx index 5c911887c29d..c02926ac60af 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport17.cxx @@ -725,6 +725,30 @@ DECLARE_OOXMLEXPORT_TEST(testTdf144668, "tdf144668.odt") CPPUNIT_ASSERT_EQUAL(OUString("[001]"), getProperty<OUString>(xPara2, "ListLabelString")); } +DECLARE_OOXMLEXPORT_TEST(testTdf148455_1, "tdf148455_1.docx") +{ + uno::Reference<beans::XPropertySet> xPara2(getParagraph(3, u"1.1.1"), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("1.1.1."), getProperty<OUString>(xPara2, "ListLabelString")); +} + +DECLARE_OOXMLEXPORT_TEST(testTdf148455_2, "tdf148455_2.docx") +{ + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + if (!pXmlDoc) + return; // initial import, no further checks + + // Find list id for restarted list + sal_Int32 nListId = getXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:numPr/w:numId", "val").toInt32(); + + xmlDocUniquePtr pNumberingDoc = parseExport("word/numbering.xml"); + + // Ensure we have empty lvlOverride for levels 0 - 1 + getXPath(pNumberingDoc, "/w:numbering/w:num[@w:numId='" + OString::number(nListId) +"']/w:lvlOverride[@w:ilvl='0']", ""); + getXPath(pNumberingDoc, "/w:numbering/w:num[@w:numId='" + OString::number(nListId) +"']/w:lvlOverride[@w:ilvl='1']", ""); + // And normal overrride for level 2 + getXPath(pNumberingDoc, "/w:numbering/w:num[@w:numId='" + OString::number(nListId) +"']/w:lvlOverride[@w:ilvl='2']/w:startOverride", "val"); +} + CPPUNIT_TEST_FIXTURE(Test, testTdf147978enhancedPathABVW) { load(DATA_DIRECTORY, "tdf147978_enhancedPath_commandABVW.odt"); diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 6f111b645c2d..4e46b456c602 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -7738,6 +7738,7 @@ void DocxAttributeOutput::OverrideNumberingDefinition( SwNumRule const& rAbstractRule = *(*m_rExport.m_pUsedNumTable)[nAbstractNum - 1]; sal_uInt8 const nLevels = static_cast<sal_uInt8>(rRule.IsContinusNum() ? WW8ListManager::nMinLevel : WW8ListManager::nMaxLevel); + sal_uInt8 nPreviousOverrideLevel = 0; for (sal_uInt8 nLevel = 0; nLevel < nLevels; ++nLevel) { const auto levelOverride = rLevelOverrides.find(nLevel); @@ -7747,6 +7748,14 @@ void DocxAttributeOutput::OverrideNumberingDefinition( // or we have a level numbering override 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. + while (nPreviousOverrideLevel < nLevel) + { + m_pSerializer->singleElementNS(XML_w, XML_lvlOverride, FSNS(XML_w, XML_ilvl), OString::number(nPreviousOverrideLevel)); + nPreviousOverrideLevel++; + } + m_pSerializer->startElementNS(XML_w, XML_lvlOverride, FSNS(XML_w, XML_ilvl), OString::number(nLevel)); if (bListsAreDifferent) |