summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2018-09-14 17:14:43 +0200
committerLászló Németh <nemeth@numbertext.org>2018-09-15 11:57:44 +0200
commit2cdc870a7ee82d0faf35cdb5b2bf4e687cfd2b8d (patch)
treed6e6a8fc64cd4309319c5f26366b66b493aa7a31
parent6fc90bcb8593b21d99027f45e8a54ff0042d1224 (diff)
tdf#115521 DOCX export: keep empty paragraphs in tracked deletion
of a paragraph sequence by inspecting every paragraph in a "redline" range. Before this fix, all empty paragraphs of a multiparagraph deletion reappeared as normal text in the DOCX export. Change-Id: I928504bdbd8c04673698e8f34c0b608eb3ecc5fc Reviewed-on: https://gerrit.libreoffice.org/60503 Tested-by: Jenkins Reviewed-by: László Németh <nemeth@numbertext.org>
-rw-r--r--sw/qa/extras/ooxmlexport/data/testTrackChangesEmptyParagraphsInADeletion.docxbin0 -> 13952 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport11.cxx10
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx30
3 files changed, 31 insertions, 9 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/testTrackChangesEmptyParagraphsInADeletion.docx b/sw/qa/extras/ooxmlexport/data/testTrackChangesEmptyParagraphsInADeletion.docx
new file mode 100644
index 000000000000..fcd78e9cd105
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/testTrackChangesEmptyParagraphsInADeletion.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
index e92bb8178b4b..9d0c9fa829ee 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport11.cxx
@@ -721,6 +721,16 @@ DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedEmptyParagraph, "testTrackChange
assertXPath(pXmlDoc, "/w:document/w:body/w:p[3]/w:pPr/w:rPr/w:del");
}
+DECLARE_OOXMLEXPORT_TEST(testTrackChangesEmptyParagraphsInADeletion, "testTrackChangesEmptyParagraphsInADeletion.docx")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+
+ for (int i = 1; i < 12; ++i)
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[" + OString::number(i) + "]/w:pPr/w:rPr/w:del");
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index a86094fda676..8cabd8d90f34 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -5480,21 +5480,33 @@ const SwRedlineData* AttributeOutputBase::GetParagraphMarkerRedline( const SwTex
const SwPosition* pCheckedStt = pRedl->Start();
const SwPosition* pCheckedEnd = pRedl->End();
+ sal_uLong uStartNodeIndex = pCheckedStt->nNode.GetIndex();
+ sal_uLong uStartCharIndex = pCheckedStt->nContent.GetIndex();
+ sal_uLong uEndNodeIndex = pCheckedEnd->nNode.GetIndex();
+ sal_uLong uEndCharIndex = pCheckedEnd->nContent.GetIndex();
+ sal_uLong uNodeIndex = rNode.GetIndex();
- if( pCheckedStt->nNode == rNode )
+ if( uStartNodeIndex <= uNodeIndex && uNodeIndex < uEndNodeIndex )
{
if ( !pCheckedEnd )
continue;
- sal_uLong uStartNodeIndex = pCheckedStt->nNode.GetIndex();
- sal_uLong uStartCharIndex = pCheckedStt->nContent.GetIndex();
- sal_uLong uEndNodeIndex = pCheckedEnd->nNode.GetIndex();
- sal_uLong uEndCharIndex = pCheckedEnd->nContent.GetIndex();
-
// Maybe add here a check that also the start & end of the redline is the entire paragraph
- if ( ( uStartNodeIndex == uEndNodeIndex - 1 ) &&
- ( uStartCharIndex == static_cast<sal_uLong>(rNode.Len()) ) &&
- ( uEndCharIndex == 0)
+ if ( ( uStartNodeIndex < uEndNodeIndex ) &&
+ // check start:
+ // 1. start in the same node
+ (( uStartNodeIndex == uNodeIndex &&
+ uStartCharIndex == static_cast<sal_uLong>(rNode.Len()) ) ||
+ // 2. or in a previous node
+ uStartNodeIndex < uNodeIndex
+ ) &&
+ // check end:
+ // 1. end in the same node
+ (( uEndNodeIndex == (uNodeIndex + 1) &&
+ uEndCharIndex == 0) ||
+ // 2. or end in after that
+ uEndNodeIndex > (uNodeIndex + 1)
+ )
)
{
return &( pRedl->GetRedlineData() );