[Libreoffice-commits] core.git: sw/qa sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Sep 5 05:49:21 UTC 2018


 sw/qa/extras/uiwriter/uiwriter2.cxx           |   39 ++++++++++++++++++++++++++
 sw/source/core/doc/DocumentRedlineManager.cxx |   22 ++++++++++++++
 2 files changed, 61 insertions(+)

New commits:
commit 1bbbe57dfc0b43d6b5444798d77dcdf5e4e76e49
Author:     László Németh <nemeth at numbertext.org>
AuthorDate: Tue Aug 28 21:13:09 2018 +0200
Commit:     László Németh <nemeth at numbertext.org>
CommitDate: Wed Sep 5 07:48:59 2018 +0200

    tdf#119571 change tracking: show layout changes at paragraph join
    
    in Show changes mode, too. Delayed update of the paragraph
    layout at file saving etc. resulted invisible style changes.
    
    All removed paragraphs get the style of the first (partially
    deleted) paragraph to avoid text insertion with bad style in
    the deleted area later, as in MSO (except the incomplete undo
    of paragraph styles here and at other paragraph
    formattings during change tracking).
    
    Note: see also tdf#105413 for the remaining problem: style
    changes after deleted paragraphs are losing in Show changes mode.
    
    Change-Id: Ic6c6055c2e4da61755b09a1d78b4aa8826212047
    Reviewed-on: https://gerrit.libreoffice.org/59821
    Tested-by: Jenkins
    Reviewed-by: László Németh <nemeth at numbertext.org>

diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 0a789a73b87d..77398885940c 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -24,10 +24,12 @@ class SwUiWriterTest2 : public SwModelTestBase
 public:
     void testTdf101534();
     void testTdf54819();
+    void testTdf119571();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest2);
     CPPUNIT_TEST(testTdf101534);
     CPPUNIT_TEST(testTdf54819);
+    CPPUNIT_TEST(testTdf119571);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -91,6 +93,43 @@ void SwUiWriterTest2::testTdf54819()
                          getProperty<OUString>(getParagraph(1), "ParaStyleName"));
 }
 
+void SwUiWriterTest2::testTdf119571()
+{
+    load(DATA_DIRECTORY, "tdf54819.fodt");
+
+    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("Standard"),
+                         getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+
+    //turn on red-lining and show changes
+    SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+    pDoc->getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowDelete
+                                                      | RedlineFlags::ShowInsert);
+    CPPUNIT_ASSERT_MESSAGE("redlining should be on",
+                           pDoc->getIDocumentRedlineAccess().IsRedlineOn());
+    CPPUNIT_ASSERT_MESSAGE(
+        "redlines should be visible",
+        IDocumentRedlineAccess::IsShowChanges(pDoc->getIDocumentRedlineAccess().GetRedlineFlags()));
+
+    // join paragraphs by removing the end of the first one with paragraph break
+    SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+    pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+    pWrtShell->EndPara(/*bSelect=*/true);
+    pWrtShell->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
+    rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
+    pTransfer->Cut();
+
+    // second paragraph changes its style in "Show changes" mode
+    CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+                         getProperty<OUString>(getParagraph(1), "ParaStyleName"));
+    CPPUNIT_ASSERT_EQUAL(OUString("Heading 1"),
+                         getProperty<OUString>(getParagraph(2), "ParaStyleName"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx
index 6838e7fc8dcd..c5b259f6aef6 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -1692,6 +1692,28 @@ DocumentRedlineManager::AppendRedline(SwRangeRedline* pNewRedl, bool const bCall
                     if (pDelNode != nullptr && pTextNode != nullptr && pDelNode != pTextNode)
                         pTextNode->CopyCollFormat( *pDelNode );
                 }
+                else
+                {
+                    // tdf#119571 update the style of the joined paragraph
+                    // after a partially deleted paragraph to show its correct style
+                    // in "Show changes" mode, too. All removed paragraphs
+                    // get the style of the first (partially deleted) paragraph
+                    // to avoid text insertion with bad style in the deleted
+                    // area later.
+                    SwContentNode* pDelNd = pStt->nNode.GetNode().GetContentNode();
+                    SwContentNode* pTextNd = pEnd->nNode.GetNode().GetContentNode();
+                    SwTextNode* pDelNode = pStt->nNode.GetNode().GetTextNode();
+                    SwTextNode* pTextNode;
+                    SwNodeIndex aIdx( pEnd->nNode.GetNode() );
+
+                    while (pDelNode != nullptr && pTextNd != nullptr && pDelNd->GetIndex() < pTextNd->GetIndex())
+                    {
+                        pTextNode = pTextNd->GetTextNode();
+                        if (pTextNode && pDelNode != pTextNode )
+                            pDelNode->CopyCollFormat( *pTextNode );
+                        pTextNd = SwNodes::GoPrevious( &aIdx );
+                    }
+                }
                 mpRedlineTable->Insert( pNewRedl );
             }
         }


More information about the Libreoffice-commits mailing list