sw/qa/core/unocore/unocore.cxx | 40 ++++++++++++++++++++++++++++++++ sw/source/core/unocore/unoparagraph.cxx | 14 +++-------- 2 files changed, 44 insertions(+), 10 deletions(-)
New commits: commit 5938687e5764ee50759374b54d2bb1cf0e0d59d3 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Jun 27 10:18:32 2022 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jun 27 12:37:34 2022 +0200 tdf#149668 sw: fix DOCX->ODT: Multilevel lists causing list numbering reset The bug document had an outer (ordered) numbering and an inner one, finally the outer numbering was continued. This was fine after DOCX import, but once we saved to ODT and re-opened, the second outer numbering was restarted, not continued the first outer one. This happened because on one hand, lcl_SwXParagraph_getPropertyState() says that the state of the ListId property is "default" if the paragraph's item set doesn't have a RES_PARATR_LIST_ID, but on the other hand xmloff/ will only write the xml:id="..." attribute on a list if the ListId state is not default. This is a problem, because it can happen that xmloff/ refers to a list later by its id, even if the list doesn't have a RES_PARATR_LIST_ID set. Fix the problem by relaxing the condition where lcl_SwXParagraph_getPropertyState() reports FN_UNO_LIST_ID as non-default: just require that that the text node has a numbering rule + the numbering rule has at least one continue list. This fixes the reported DOCX -> ODT case with named list styles and keeps the original ODT import and HTML import use-cases working to not write un-referenced xml:id="..." attributes on export. This was a regression from commit 8f48f91009caa86d896f247059874242ed18bf39 (ODT export: omit unreferenced <text:list xml:id="...">, 2022-03-10). Change-Id: I300ebe7aa7da71a336c03abe7530074b696417f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136477 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins diff --git a/sw/qa/core/unocore/unocore.cxx b/sw/qa/core/unocore/unocore.cxx index 56b9ed4c74de..bd2385d1eb54 100644 --- a/sw/qa/core/unocore/unocore.cxx +++ b/sw/qa/core/unocore/unocore.cxx @@ -639,6 +639,46 @@ CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testContentControlDate) CPPUNIT_ASSERT_EQUAL(OUString("008000"), pContentControl->GetColor()); } +CPPUNIT_TEST_FIXTURE(SwCoreUnocoreTest, testListIdState) +{ + // Given a document with 3 paragraphs: an outer numbering on para 1 & 3, an inner numbering on + // para 2: + SwDoc* pDoc = createSwDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + { + SfxItemSetFixed<RES_PARATR_NUMRULE, RES_PARATR_NUMRULE> aSet(pWrtShell->GetAttrPool()); + SwNumRuleItem aItem("Numbering ABC"); + aSet.Put(aItem); + pWrtShell->SetAttrSet(aSet); + } + pWrtShell->SplitNode(); + { + SfxItemSetFixed<RES_PARATR_NUMRULE, RES_PARATR_NUMRULE> aSet(pWrtShell->GetAttrPool()); + SwNumRuleItem aItem("Numbering 123"); + aSet.Put(aItem); + pWrtShell->SetAttrSet(aSet); + } + pWrtShell->SplitNode(); + { + SfxItemSetFixed<RES_PARATR_NUMRULE, RES_PARATR_NUMRULE> aSet(pWrtShell->GetAttrPool()); + SwNumRuleItem aItem("Numbering ABC"); + aSet.Put(aItem); + pWrtShell->SetAttrSet(aSet); + } + + // When checking if xml:id="..." needs writing for the first paragraph during ODT export: + uno::Reference<beans::XPropertyState> xPara(getParagraph(1), uno::UNO_QUERY); + beans::PropertyState eState = xPara->getPropertyState("ListId"); + + // Then make sure that xml:id="..." gets written for para 1, as it'll be continued in para 3. + // Without the accompanying fix in place, this test would have failed with: + // - Expected: 0 (DIRECT_VALUE) + // - Actual : 1 (DEFAULT_VALUE) + // i.e. para 1 didn't write an xml:id="..." but para 3 referred to it using continue-list="...", + // which is inconsistent. + CPPUNIT_ASSERT_EQUAL(beans::PropertyState_DIRECT_VALUE, eState); +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/unocore/unoparagraph.cxx b/sw/source/core/unocore/unoparagraph.cxx index d13bd6c65945..7485b98b1580 100644 --- a/sw/source/core/unocore/unoparagraph.cxx +++ b/sw/source/core/unocore/unoparagraph.cxx @@ -922,18 +922,12 @@ static beans::PropertyState lcl_SwXParagraph_getPropertyState( } case FN_UNO_LIST_ID: { - if (*ppSet) + SwNumRule* pNumRule = rTextNode.GetNumRule(); + if (pNumRule && pNumRule->HasContinueList()) { - if ((*ppSet)->GetItemState(RES_PARATR_LIST_ID, false) == SfxItemState::SET) - { - SwNumRule* pNumRule = rTextNode.GetNumRule(); - if (!pNumRule || pNumRule->HasContinueList()) - { - eRet = beans::PropertyState_DIRECT_VALUE; - } - } - bDone = true; + eRet = beans::PropertyState_DIRECT_VALUE; } + bDone = true; break; } case FN_UNO_ANCHOR_TYPES: