sw/qa/extras/layout/data/table_in_text_change.fodt |   66 +++++++++++++++++++++
 sw/qa/extras/layout/layout2.cxx                    |   18 +++++
 sw/source/core/table/swtable.cxx                   |    5 +
 3 files changed, 89 insertions(+)

New commits:
commit 49c4eec4f7974b21cd3c802892ff00b9e834cdd1
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Tue Jun 13 13:04:28 2023 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Wed Jun 14 14:22:36 2023 +0200

    tdf#155187 sw track changes: color tables in single changes
    
    In Show Changes mode, whole tables within a single redline,
    i.e. in a single text change get similar coloring, as in
    separately tracked table rows or columns.
    
    Follow-up to commit 48898a72066ff9982feafebb26708c4e779fd460
    "tdf#60382 sw xmloff: import/export tracked table/row deletion"
    and commit f348440e17debacbcba9153e238e010e8c020bdc
    "tdf#146120 sw: show tracked table changes with different color".
    
    Change-Id: I0154a20146cd6689750fa33edfe960eb22d7610a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152959
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit 1f558103ce7730319a1804b9ca66132e8f48101e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152987

diff --git a/sw/qa/extras/layout/data/table_in_text_change.fodt 
b/sw/qa/extras/layout/data/table_in_text_change.fodt
new file mode 100644
index 000000000000..6d1ccaf2c2cd
--- /dev/null
+++ b/sw/qa/extras/layout/data/table_in_text_change.fodt
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:css3t="http://www.w3.org/TR/css3-text/"; 
xmlns:grddl="http://www.w3.org/2003/g/data-view#"; 
xmlns:xhtml="http://www.w3.org/1999/xhtml"; 
xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:dom="http://www.w3.org/2001/xml-events"; 
xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" 
xmlns:xforms="http://www.w3.org/2002/xforms"; 
xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" 
xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0"
 xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" 
xmlns:drawooo="http://openoffice.org/2010/draw"; 
xmlns:math="http://www.w3.org/1998/Math/MathML"; 
xmlns:tableooo="http://openoffice.org/2009/table"; 
xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" 
xmlns:oooc="http://openoffice.org/2004/calc"; 
xmlns:ooow="http://openoffice.org/200
 4/writer" 
xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0"
 xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" 
xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" 
xmlns:xlink="http://www.w3.org/1999/xlink"; 
xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" 
xmlns:dc="http://purl.org/dc/elements/1.1/"; 
xmlns:ooo="http://openoffice.org/2004/office"; 
xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" 
xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta: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:rpt="http://openoffice.org/2005/report"; 
xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" 
xmlns:officeooo="http://openoffice.org/2009/office"; 
xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" 
xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" 
xmlns:table="urn:oasis:names:tc:open
 document:xmlns:table:1.0" 
xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" 
office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+  <office:text>
+   <text:tracked-changes text:track-changes="false">
+    <text:changed-region xml:id="ct94093202651936" text:id="ct94093202651936">
+     <text:deletion>
+      <office:change-info>
+       <dc:creator>x</dc:creator>
+       <dc:date>2023-06-13T12:47:02</dc:date>
+      </office:change-info>
+     </text:deletion>
+    </text:changed-region>
+    <text:changed-region xml:id="ct94093229462240" text:id="ct94093229462240">
+     <text:insertion>
+      <office:change-info>
+       <dc:creator>x</dc:creator>
+       <dc:date>2023-06-13T12:43:39</dc:date>
+      </office:change-info>
+     </text:insertion>
+    </text:changed-region>
+   </text:tracked-changes>
+   <text:h text:outline-level="1"><text:change-start 
text:change-id="ct94093202651936"/>Whole tables in tracked text 
deletion</text:h>
+   <table:table table:name="Table1">
+    <table:table-column table:number-columns-repeated="2"/>
+    <table:table-row>
+     <table:table-cell office:value-type="string">
+      <text:p>1</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string">
+      <text:p>2</text:p>
+     </table:table-cell>
+    </table:table-row>
+    <table:table-row>
+     <table:table-cell office:value-type="string">
+      <text:p>3</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string">
+      <text:p>4</text:p>
+     </table:table-cell>
+    </table:table-row>
+   </table:table>
+   <text:h text:outline-level="1">Whole <text:change-end 
text:change-id="ct94093202651936"/>tables in tracked text 
insertion<text:change-start text:change-id="ct94093229462240"/></text:h>
+   <table:table table:name="Table2">
+    <table:table-column table:number-columns-repeated="2"/>
+    <table:table-row>
+     <table:table-cell office:value-type="string">
+      <text:p>I</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string">
+      <text:p>II</text:p>
+     </table:table-cell>
+    </table:table-row>
+    <table:table-row>
+     <table:table-cell office:value-type="string">
+      <text:p>III</text:p>
+     </table:table-cell>
+     <table:table-cell office:value-type="string">
+      <text:p>IV</text:p>
+     </table:table-cell>
+    </table:table-row>
+   </table:table>
+   <text:p><text:change-end text:change-id="ct94093229462240"/></text:p>
+  </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/layout/layout2.cxx b/sw/qa/extras/layout/layout2.cxx
index 9daa260c21c4..e9654dc7c9b6 100644
--- a/sw/qa/extras/layout/layout2.cxx
+++ b/sw/qa/extras/layout/layout2.cxx
@@ -973,6 +973,24 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testChangedTableRows)
     assertXPath(pXmlDoc, 
"/metafile/push/push/push/push/push/fillcolor[@color='#3faf46']", 1);
 }
 
+CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, testTdf155187_TableInTextChange)
+{
+    createSwDoc("table_in_text_change.fodt");
+    SwDoc* pDoc = getSwDoc();
+    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);
+
+    // This was 0 (other color, not COL_AUTHOR_TABLE_DEL, color of the tracked 
row deletion)
+    assertXPath(pXmlDoc, 
"/metafile/push/push/push/push/push/fillcolor[@color='#fce6f4']", 2);
+    // This was 0 (other color, not COL_AUTHOR_TABLE_INS, color of the tracked 
row insertion)
+    assertXPath(pXmlDoc, 
"/metafile/push/push/push/push/push/fillcolor[@color='#e1f2fa']", 2);
+}
+
 CPPUNIT_TEST_FIXTURE(SwLayoutWriter2, 
testTdf145225_RedlineMovingWithBadInsertion)
 {
     createSwDoc("tdf42748.fodt");
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index ee4753b96d67..04d58363b97d 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1975,6 +1975,11 @@ RedlineType SwTableLine::GetRedlineType() const
         // empty the cache
         const_cast<SwTableLine*>(this)->SetRedlineType( RedlineType::None );
 
+    // is the whole table part of a changed text
+    SwRedlineTable::size_type nTableRedline = GetTableRedline();
+    if ( nTableRedline != SwRedlineTable::npos )
+        return aRedlineTable[nTableRedline]->GetType();
+
     return RedlineType::None;
 }
 

Reply via email to