summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2023-04-25 11:04:05 +0200
committerLászló Németh <nemeth@numbertext.org>2023-04-25 14:27:57 +0200
commitdd5e5f3fab4b8f736baeda0f706c77a4ea9b6804 (patch)
tree12e3ce9006148406744aa249021e399fe735d63b
parentoox: add support for theme import and export of blip effects (diff)
downloadcore-dd5e5f3fab4b8f736baeda0f706c77a4ea9b6804.tar.gz
core-dd5e5f3fab4b8f736baeda0f706c77a4ea9b6804.zip
tdf#150824 sw DOCX: fix export of new tracked tables
New tracked tables handled by a single redline, which lost during the export: only the tracked text changes of the cells were exported, but not the table changes. This resulted also problems in MSO, e.g. rejecting text changes removed only single cells of the tables, modifying the table structure. To fix this, add missing tracking to the table rows, if needed. Follow-up to commit 896c2199d9f0a28bd405dd2d1068f5e2973cdf06 "tdf#79069 DOCX: support tracked table (row) deletion". Change-Id: Ic900cafa7bea3c934d8d1bd585b3e95f56746db2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150967 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/inc/swtable.hxx3
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf150824.fodt48
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport12.cxx13
-rw-r--r--sw/source/core/table/swtable.cxx14
-rw-r--r--sw/source/filter/ww8/docxtableexport.cxx4
5 files changed, 82 insertions, 0 deletions
diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 272ba18393f1..bd674486278f 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -426,6 +426,9 @@ public:
// Cache also the type of the redline associated to the changed table row.
SwRedlineTable::size_type UpdateTextChangesOnly(
SwRedlineTable::size_type& rRedlinePos, bool bUpdateProperty = true) const;
+ // tracked text changes, i.e. a single redline can contain tables
+ // get that redline for the table row, if it exists
+ SwRedlineTable::size_type GetTableRedline() const;
// is it a tracked row
bool IsTracked(SwRedlineTable::size_type& rRedlinePos, bool bOnlyDeleted = false) const;
// is it a tracked deleted row
diff --git a/sw/qa/extras/ooxmlexport/data/tdf150824.fodt b/sw/qa/extras/ooxmlexport/data/tdf150824.fodt
new file mode 100644
index 000000000000..c1e437a12198
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf150824.fodt
@@ -0,0 +1,48 @@
+<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext: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:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form: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:officeooo="http://openoffice.org/2009/office" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext: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="ct94228217946240" text:id="ct94228217946240">
+ <text:insertion>
+ <office:change-info>
+ <dc:creator>Unknown Author</dc:creator>
+ <dc:date>2022-09-06T14:47:25</dc:date>
+ </office:change-info>
+ </text:insertion>
+ </text:changed-region>
+ </text:tracked-changes>
+ <text:change-start text:change-id="ct94228217946240"/>
+ <table:table table:name="Table1" table:style-name="Table1">
+ <table:table-column table:style-name="Table1.A"/>
+ <table:table-column table:style-name="Table1.B"/>
+ <table:table-row>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents"/>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.B1" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents"/>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table1.A2" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents"/>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.B2" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents"/>
+ </table:table-cell>
+ </table:table-row>
+ <table:table-row>
+ <table:table-cell table:style-name="Table1.A2" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents"/>
+ </table:table-cell>
+ <table:table-cell table:style-name="Table1.B2" office:value-type="string">
+ <text:p text:style-name="Table_20_Contents"/>
+ </table:table-cell>
+ </table:table-row>
+ </table:table>
+ <text:p text:style-name="Standard"><text:change-end text:change-id="ct94228217946240"/></text:p>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
index c97a60677b3c..661d2415e6cb 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport12.cxx
@@ -1310,6 +1310,19 @@ DECLARE_OOXMLEXPORT_TEST(testTdf143510_within_table2, "TC-table-rowDND-front.doc
}
}
+DECLARE_OOXMLEXPORT_TEST(testTdf150824, "tdf150824.fodt")
+{
+ // check tracked table row insertion (stored in a single redline)
+ if (isExported())
+ {
+ xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml");
+ // This was 0 (missing tracked table row deletion/insertion)
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:trPr/w:ins", 1);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[2]/w:trPr/w:ins", 1);
+ assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[3]/w:trPr/w:ins", 1);
+ }
+}
+
DECLARE_OOXMLEXPORT_TEST(testTdf113608_runAwayNumbering, "tdf113608_runAwayNumbering.docx")
{
// check that an incorrect numbering style is not applied
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 523f14e0c46f..5fda482c35e0 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -1892,6 +1892,20 @@ SwRedlineTable::size_type SwTableLine::UpdateTextChangesOnly(
return nRet;
}
+SwRedlineTable::size_type SwTableLine::GetTableRedline() const
+{
+ const SwRedlineTable& aRedlineTable = GetFrameFormat()->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable();
+ const SwPosition aLineStart(*GetTabBoxes().front()->GetSttNd());
+ const SwPosition aLineEnd(*GetTabBoxes().back()->GetSttNd());
+ SwRedlineTable::size_type n = 0;
+
+ const SwRangeRedline* pFnd = aRedlineTable.FindAtPosition( aLineStart, n, /*next=*/false );
+ if( pFnd && *pFnd->Start() < aLineStart && *pFnd->End() > aLineEnd )
+ return n;
+
+ return SwRedlineTable::npos;
+}
+
bool SwTableLine::IsTracked(SwRedlineTable::size_type& rRedlinePos, bool bOnlyDeleted) const
{
SwRedlineTable::size_type nPos = UpdateTextChangesOnly(rRedlinePos);
diff --git a/sw/source/filter/ww8/docxtableexport.cxx b/sw/source/filter/ww8/docxtableexport.cxx
index 5915caa2a9ab..aa8697c2f150 100644
--- a/sw/source/filter/ww8/docxtableexport.cxx
+++ b/sw/source/filter/ww8/docxtableexport.cxx
@@ -625,6 +625,10 @@ void DocxAttributeOutput::TableRowRedline(
// check table row property "HasTextChangesOnly"
SwRedlineTable::size_type nPos(0);
SwRedlineTable::size_type nChange = pTabLine->UpdateTextChangesOnly(nPos);
+ // tdf#150824 if no tracked table row, is the table in a single redline?
+ // if yes, convert the row to a tracked table row instead of losing its tracking
+ if (nChange == SwRedlineTable::npos)
+ nChange = pTabLine->GetTableRedline();
if (nChange != SwRedlineTable::npos)
{
const SwRedlineTable& aRedlineTable