sw/qa/extras/layout/data/tdf149709.fodt | 41 +++++++++++++++++++++++ sw/qa/extras/layout/layout2.cxx | 57 ++++++++++++++++++++++++++++++++ sw/source/core/txtnode/ndtxt.cxx | 6 +++ 3 files changed, 104 insertions(+)
New commits: commit db1f4457543918b5e3cd8b4d3a70676855952314 Author: László Németh <nem...@numbertext.org> AuthorDate: Fri Jul 1 11:49:45 2022 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Fri Jul 1 16:48:42 2022 +0200 tdf#149709 sw_redlinenum: fix list levels Levels of ORIGTEXT SwNodeNum weren't updated, resulting bad numbering of multilevel lists during editing and file import. Follow-up to commit d0e49c07203c9ae33c5dfa1855b2b8909c3e16dc "tdf#115524 sw_redlinenum: show original numbering of insertions". Change-Id: I478971643a10b2007f37a4f0074067896d546228 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136734 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/layout/data/tdf149709.fodt b/sw/qa/extras/layout/data/tdf149709.fodt new file mode 100644 index 000000000000..0a33515d1ca9 --- /dev/null +++ b/sw/qa/extras/layout/data/tdf149709.fodt @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oas is:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:officeooo="http://openoffice.org/2009/office" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names: experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard" style:list-style-name="L1"> + <style:text-properties officeooo:rsid="001fa9e2" officeooo:paragraph-rsid="001fa9e2"/> + </style:style> + <text:list-style style:name="L1"> + <text:list-level-style-number text:level="1" text:style-name="Numbering_5f_20_5f_Symbols" loext:num-list-format="%1%." style:num-suffix="." style:num-format="1"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/> + </style:list-level-properties> + </text:list-level-style-number> + <text:list-level-style-number text:level="2" text:style-name="Numbering_20_Symbols" loext:num-list-format="%2%)" style:num-suffix=")" style:num-format="a"> + <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> + <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/> + </style:list-level-properties> + </text:list-level-style-number> + </text:list-style> + </office:automatic-styles> + <office:body> + <office:text> + <text:list xml:id="list2209750722" text:style-name="L1"> + <text:list-item> + <text:p text:style-name="P3">Item</text:p> + <text:list> + <text:list-item> + <text:p text:style-name="P2">Item</text:p> + </text:list-item> + <text:list-item> + <text:p text:style-name="P4">Item</text:p> + </text:list-item> + </text:list> + </text:list-item> + <text:list-item> + <text:p text:style-name="P3">Item</text:p> + </text:list-item> + </text:list> + </office:text> + </office:body> +</office:document> diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx index c9c0a80ca9eb..c755bd62514f 100644 --- a/sw/qa/extras/layout/layout2.cxx +++ b/sw/qa/extras/layout/layout2.cxx @@ -509,6 +509,63 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf149710_RedlineNumberingEditing) assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", "3."); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf149709_RedlineNumberingLevel) +{ + SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf149709.fodt"); + SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + + // Show Changes + SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell(); + SwRootFrame* pLayout(pWrtShell->GetLayout()); + CPPUNIT_ASSERT(!pLayout->IsHideRedlines()); + + // insert a new list item at start of the second list item "a)" + dispatchCommand(mxComponent, ".uno:TrackChanges", {}); + pWrtShell->Down(false, 1); + pWrtShell->SplitNode(false); + + // Dump the rendering of the first page as an XML file. + SwDocShell* pShell = pDoc->GetDocShell(); + std::shared_ptr<GDIMetaFile> xMetaFile = pShell->GetPreviewMetaFile(); + MetafileXmlDump dumper; + + xmlDocUniquePtr pXmlDoc = dumpAndParse(dumper, *xMetaFile); + CPPUNIT_ASSERT(pXmlDoc); + + // Show the correct and the original line numbering instead of counting + // the deleted list items in Show Changes mode, as part of the list + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", "1."); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", "a)"); + // This was "b)[2.]" + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[4]/text", "b)[a)] "); + // This was "c)[3.]" + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[6]/text", "c)[b)] "); + // This was "4.[2.]" (after disabling Show Changes, and enabling again) + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[8]/text", "2."); + + // remove the tracked deletion, and check the layout again + pWrtShell->Undo(); + xMetaFile = pShell->GetPreviewMetaFile(); + pXmlDoc = dumpAndParse(dumper, *xMetaFile); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", "1."); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", "a)"); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", "b)"); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[7]/text", "2."); + + // check Redo + pWrtShell->Redo(); + xMetaFile = pShell->GetPreviewMetaFile(); + pXmlDoc = dumpAndParse(dumper, *xMetaFile); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", "1."); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", "a)"); + // TODO: show as b)[a)] + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[4]/text", "b)"); + // FIXME: This must be "c)[b]" + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[6]/text", "c)[a)] "); + assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[8]/text", "2."); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumberInFootnote) { SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf85610.fodt"); diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index f2eeff874651..62d78bf87526 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -4005,6 +4005,7 @@ void SwTextNode::DoNum(std::function<void (SwNodeNum &)> const& rFunc) // temp. clear because GetActualListLevel() may be called and the assert // there triggered during update, which is unhelpful std::unique_ptr<SwNodeNum> pBackup = std::move(mpNodeNumRLHidden); + std::unique_ptr<SwNodeNum> pBackup2 = std::move(mpNodeNumOrig); assert(mpNodeNum); rFunc(*mpNodeNum); if (pBackup) @@ -4012,6 +4013,11 @@ void SwTextNode::DoNum(std::function<void (SwNodeNum &)> const& rFunc) mpNodeNumRLHidden = std::move(pBackup); rFunc(*mpNodeNumRLHidden); } + if (pBackup2) + { + mpNodeNumOrig = std::move(pBackup2); + rFunc(*mpNodeNumOrig); + } } SwNumberTree::tNumberVector