sw/qa/extras/ooxmlimport/ooxmlimport.cxx           |   22 +++++++++------
 sw/qa/extras/uiwriter/data2/redline-para-join.docx |binary
 sw/qa/extras/uiwriter/uiwriter2.cxx                |   29 ++++++++++++++++++++-
 writerfilter/source/dmapper/DomainMapper_Impl.cxx  |    6 ++--
 4 files changed, 44 insertions(+), 13 deletions(-)

New commits:
commit 5ab9cbe7f8d0c0bfd6a2fe1de2e14dfe201d008b
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Tue Jul 23 11:51:58 2019 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Jul 23 17:57:10 2019 +0200

    tdf#126516 DOCX change tracking: fix paragraph style rejection
    
    by keeping paragraph-level ParagraphFormat redlines.
    
    (regression from commit a5abe0fc4d435d3a7a7de8bf55ec74087fdd299a
    "tdf#125546 DOCX import: fix overgrowth of change tracking entries")
    
    Change-Id: I1357a9e082f990c8a7d1d1aa6f93a06c3dfee5a8
    Reviewed-on: https://gerrit.libreoffice.org/76154
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx 
b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 4799a44db8c4..f90d894b0f1e 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -960,11 +960,13 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, "bnc821804.docx")
     CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(4), 1), "RedlineType"));
     
CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(4),
 1), "RedlineType"));
     CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(4), 1), 
"IsStart"));
-    CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(4), 2), "RedlineType"));
-    CPPUNIT_ASSERT_EQUAL(OUString("Inserted and formatted"), 
getRun(getParagraph(4),2)->getString());
-    CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(4), 3), "RedlineType"));
-    
CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(4),
 3), "RedlineType"));
-    CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(4), 3), 
"IsStart"));
+    CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(4), 2), "RedlineType"));
+    
CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(4),
 2), "RedlineType"));
+    CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(4), 2), 
"IsStart"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Inserted and formatted"), 
getRun(getParagraph(4),3)->getString());
+    CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(4), 4), "RedlineType"));
+    
CPPUNIT_ASSERT_EQUAL(OUString("Insert"),getProperty<OUString>(getRun(getParagraph(4),
 4), "RedlineType"));
+    CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(4), 4), 
"IsStart"));
     CPPUNIT_ASSERT_EQUAL(OUString(" and this is only formatted"), 
getRun(getParagraph(4),5)->getString());
     CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(4), 6), "RedlineType"));
     
CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(4),
 6), "RedlineType"));
@@ -1024,11 +1026,13 @@ DECLARE_OOXMLIMPORT_TEST(testBnc821804, 
"bnc821804.docx")
     CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(8), 1), "RedlineType"));
     
CPPUNIT_ASSERT_EQUAL(OUString("Delete"),getProperty<OUString>(getRun(getParagraph(8),
 1), "RedlineType"));
     CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(8), 1), 
"IsStart"));
-    CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(8), 2), "RedlineType"));
-    CPPUNIT_ASSERT_EQUAL(OUString("Deleted and formatted"), 
getRun(getParagraph(8),2)->getString());
+    CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(8), 2), "RedlineType"));
+    
CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(8),
 2), "RedlineType"));
+    CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(8), 1), 
"IsStart"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Deleted and formatted"), 
getRun(getParagraph(8),3)->getString());
     CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(8), 4), "RedlineType"));
-    
CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(8),
 4), "RedlineType"));
-    CPPUNIT_ASSERT_EQUAL(true,getProperty<bool>(getRun(getParagraph(8), 4), 
"IsStart"));
+    
CPPUNIT_ASSERT_EQUAL(OUString("Delete"),getProperty<OUString>(getRun(getParagraph(8),
 4), "RedlineType"));
+    CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(8), 4), 
"IsStart"));
     CPPUNIT_ASSERT_EQUAL(OUString(" and this is only formatted"), 
getRun(getParagraph(8),5)->getString());
     
CPPUNIT_ASSERT_EQUAL(OUString("ParagraphFormat"),getProperty<OUString>(getRun(getParagraph(8),
 6), "RedlineType"));
     CPPUNIT_ASSERT_EQUAL(false,getProperty<bool>(getRun(getParagraph(8), 6), 
"IsStart"));
diff --git a/sw/qa/extras/uiwriter/data2/redline-para-join.docx 
b/sw/qa/extras/uiwriter/data2/redline-para-join.docx
new file mode 100644
index 000000000000..c1ed90f801fb
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/redline-para-join.docx 
differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 7c10db4e7730..868cc0882db4 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -711,7 +711,9 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf119824)
 
     // and a tracked text deletion at the beginning of the paragraph
     CPPUNIT_ASSERT_EQUAL(OUString("Pellentesque habitant morbi tristique 
senectus "),
-                         getRun(getParagraph(3), 2)->getString());
+                         getRun(getParagraph(3), 3)->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(3), 
2)->getString());
+    CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(3), 2), "RedlineType"));
 
     // delete last word of the third paragraph to remove tracked paragraph 
formatting
     // of this paragraph to track and show word deletion correctly.
@@ -1773,6 +1775,31 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf120338)
                          getProperty<OUString>(getParagraph(11), 
"ParaStyleName"));
 }
 
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testTdf120338_multiple_paragraph_join)
+{
+    load(DATA_DIRECTORY, "redline-para-join.docx");
+
+    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+                         getProperty<OUString>(getParagraph(1), 
"ParaStyleName"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+                         getProperty<OUString>(getParagraph(2), 
"ParaStyleName"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+                         getProperty<OUString>(getParagraph(3), 
"ParaStyleName"));
+
+    // reject tracked paragraph styles
+    lcl_dispatchCommand(mxComponent, ".uno:RejectAllTrackedChanges", {});
+
+    CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+                         getProperty<OUString>(getParagraph(1), 
"ParaStyleName"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Heading 2"),
+                         getProperty<OUString>(getParagraph(2), 
"ParaStyleName"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Heading 3"),
+                         getProperty<OUString>(getParagraph(3), 
"ParaStyleName"));
+}
+
 CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testShapePageMove)
 {
     // Load a document with 2 pages, shape on the first page.
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx 
b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index f566f6d4aa4a..632eb860e146 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -2148,13 +2148,13 @@ void DomainMapper_Impl::CheckRedline( uno::Reference< 
text::XTextRange > const&
     bool bUsedRange = m_aRedlines.top().size() > 0 || 
(GetTopContextOfType(CONTEXT_CHARACTER) &&
         GetTopContextOfType(CONTEXT_CHARACTER)->Redlines().size() > 0);
 
-    // only export ParagraphFormat, when there is no other redline in the same 
text portion to avoid missing redline compression
-    if( !bUsedRange && GetTopContextOfType(CONTEXT_PARAGRAPH) )
+    // only export ParagraphFormat, when there is no other redline in the same 
text portion to avoid missing redline compression,
+    // but always export the first ParagraphFormat redline in a paragraph to 
keep the paragraph style change data for rejection
+    if( (!bUsedRange || !m_bParaChanged) && 
GetTopContextOfType(CONTEXT_PARAGRAPH) )
     {
         std::vector<RedlineParamsPtr>& avRedLines = 
GetTopContextOfType(CONTEXT_PARAGRAPH)->Redlines();
         for( const auto& rRedline : avRedLines )
             CreateRedline( xRange, rRedline );
-        return;
     }
     if( GetTopContextOfType(CONTEXT_CHARACTER) )
     {
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to