sw/qa/extras/layout/data/tdf115524.fodt |   44 ++++++++++++++++++++++++++++++++
 sw/qa/extras/layout/layout2.cxx         |   21 +++++++++++++++
 sw/source/core/txtnode/ndtxt.cxx        |    7 +++++
 3 files changed, 72 insertions(+)

New commits:
commit 508ed558948353a3eb8be9adf3588368e440f4cf
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Tue Jun 28 11:20:45 2022 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Wed Jun 29 14:32:12 2022 +0200

    tdf#115524 sw_redlinenum: show original numbering of insertions
    
    in Show Changes mode, according to the name "Show Changes" and
    according to the interoperability requirements.
    
    Follow-up to commit 2413f213625253a9c2b1787b3b9fe859d724a9bd
    "tdf#115523 sw_redlinenum: show correct, also original numbering"
    and commit d3b0fb222f96964d7bd2b82fe20e1547f731b7a6
    "tdf#149710 sw_redlinenum: update numbering at deletion".
    
    Change-Id: I32476baa3daa73b48f9398282cbe7837d95b0a04
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136562
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit 05312bbcaf7c0a8b58b1e8b9f107261933e9a31b)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136536

diff --git a/sw/qa/extras/layout/data/tdf115524.fodt 
b/sw/qa/extras/layout/data/tdf115524.fodt
new file mode 100644
index 000000000000..4e589ad9a1a4
--- /dev/null
+++ b/sw/qa/extras/layout/data/tdf115524.fodt
@@ -0,0 +1,44 @@
+<?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_20_Symbols" 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-style>
+ </office:automatic-styles>
+ <office:body>
+  <office:text>
+   <text:tracked-changes text:track-changes="false">
+    <text:changed-region xml:id="ct94824274497104" text:id="ct94824274497104">
+     <text:insertion>
+      <office:change-info>
+       <dc:creator>Unknown Author</dc:creator>
+       <dc:date>2022-06-27T14:35:42</dc:date>
+      </office:change-info>
+     </text:insertion>
+    </text:changed-region>
+   </text:tracked-changes>
+   <text:list text:style-name="L1">
+    <text:list-item>
+     <text:p text:style-name="P1">Item</text:p>
+    </text:list-item>
+    <text:list-item>
+     <text:p text:style-name="P2">Item<text:change-start 
text:change-id="ct94824274497104"/></text:p>
+    </text:list-item>
+    <text:list-item>
+     <text:p text:style-name="P3">New item<text:change-end 
text:change-id="ct94824274497104"/></text:p>
+    </text:list-item>
+    <text:list-item>
+     <text:p text:style-name="P1">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 66941abc4269..08160784a4d0 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -332,6 +332,27 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumbering)
     assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", 
"2.[3.] ");
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testRedlineNumbering2)
+{
+    SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf115524.fodt");
+    SwDocShell* pShell = pDoc->GetDocShell();
+
+    // Dump the rendering of the first page as an XML file.
+    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 in Show Changes mode
+    assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[1]/text", 
"1.");
+    assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[3]/text", 
"2.");
+    // FIXME: show as 3.[2.]
+    assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[5]/text", 
"3.");
+    // This was "4." (not shown the original number)
+    assertXPathContent(pXmlDoc, "/metafile/push/push/push/textarray[7]/text", 
"4.[3.] ");
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf149710_RedlineNumberingEditing)
 {
     SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf149710.fodt");
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 72cd894e045e..f2eeff874651 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -4324,6 +4324,9 @@ void SwTextNode::AddToList()
     pList->InsertListItem(*mpNodeNum, SwListRedlineType::SHOW, 
GetAttrListLevel(), GetDoc());
 
     // set redline lists
+    // "default" list: visible items in Show Changes mode (tracked insertions 
and deletions)
+    // "hidden" list: visible items in Hide Changes mode (tracked insertions, 
but not deletions)
+    // "orig" list: visible items rejecting all changes (no tracked insertions 
and deletions)
     bool bRecordChanges = GetDoc().GetDocShell() && 
GetDoc().GetDocShell()->IsChangeRecording();
     if (!bRecordChanges || GetDoc().IsInXMLImport() || 
GetDoc().IsInWriterfilterImport() )
     {
@@ -4334,10 +4337,14 @@ void SwTextNode::AddToList()
         {
             AddToListOrig();
 
+            // if the paragraph is not deleted, add to the "hidden" list, too
             SwRedlineTable::size_type nRedlPosDel = 
GetDoc().getIDocumentRedlineAccess().GetRedlinePos(*this, RedlineType::Delete);
             if ( SwRedlineTable::npos == nRedlPosDel )
                 AddToListRLHidden();
         }
+        // inserted paragraph, e.g. during file load, add to the "hidden" list
+        else if ( SwRedlineTable::npos != nRedlPos )
+            AddToListRLHidden();
     }
     else if ( bRecordChanges )
         AddToListRLHidden();

Reply via email to