sw/inc/IDocumentRedlineAccess.hxx                       |    2 
 sw/qa/extras/uiwriter/data2/tdf119019.docx              |binary
 sw/qa/extras/uiwriter/uiwriter2.cxx                     |   35 ++++++++++++++++
 sw/source/core/doc/DocumentContentOperationsManager.cxx |   13 +++++
 sw/source/core/doc/DocumentRedlineManager.cxx           |   25 +++++++++++
 sw/source/core/inc/DocumentRedlineManager.hxx           |    2 
 6 files changed, 77 insertions(+)

New commits:
commit 694a6389e84d5b416cde6dde2d5eaa589a0a6493
Author:     László Németh <nem...@numbertext.org>
AuthorDate: Thu Sep 6 17:21:05 2018 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Fri Sep 7 20:55:03 2018 +0200

    tdf#119019 DOCX track changes: fix invisible delete and insert
    
    during editing in a paragraph with tracked paragraph formatting,
    by accepting the old formatting change automatically in the
    actual paragraph before text deletion/insertion.
    
    Note: it's not possible to reject paragraph formatting
    changes in LO, but showing them is a minimal requirement.
    Now they are still visible in change tracking dialog and
    by the vertical line before the related paragraphs until
    there are no new text deletions and insertions in those
    paragraphs.
    
    Change-Id: I526daad8dd96212ac73a10627128553452e4d31c
    Reviewed-on: https://gerrit.libreoffice.org/60101
    Tested-by: Jenkins
    Reviewed-by: László Németh <nem...@numbertext.org>

diff --git a/sw/inc/IDocumentRedlineAccess.hxx 
b/sw/inc/IDocumentRedlineAccess.hxx
index a68af07fb707..f8b1ee6b1a81 100644
--- a/sw/inc/IDocumentRedlineAccess.hxx
+++ b/sw/inc/IDocumentRedlineAccess.hxx
@@ -205,6 +205,8 @@ public:
 
     virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool 
bCallDelete) = 0;
 
+    virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM& rPam ) 
= 0;
+
     virtual bool RejectRedline(/*[in]*/SwRedlineTable::size_type nPos, 
/*[in]*/bool bCallDelete) = 0;
 
     virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool 
bCallDelete) = 0;
diff --git a/sw/qa/extras/uiwriter/data2/tdf119019.docx 
b/sw/qa/extras/uiwriter/data2/tdf119019.docx
new file mode 100644
index 000000000000..d38c9e4ae146
Binary files /dev/null and b/sw/qa/extras/uiwriter/data2/tdf119019.docx differ
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx 
b/sw/qa/extras/uiwriter/uiwriter2.cxx
index 77398885940c..c2545de641a7 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -25,11 +25,13 @@ public:
     void testTdf101534();
     void testTdf54819();
     void testTdf119571();
+    void testTdf119019();
 
     CPPUNIT_TEST_SUITE(SwUiWriterTest2);
     CPPUNIT_TEST(testTdf101534);
     CPPUNIT_TEST(testTdf54819);
     CPPUNIT_TEST(testTdf119571);
+    CPPUNIT_TEST(testTdf119019);
     CPPUNIT_TEST_SUITE_END();
 };
 
@@ -130,6 +132,39 @@ void SwUiWriterTest2::testTdf119571()
                          getProperty<OUString>(getParagraph(2), 
"ParaStyleName"));
 }
 
+void SwUiWriterTest2::testTdf119019()
+{
+    load(DATA_DIRECTORY, "tdf119019.docx");
+
+    SwXTextDocument* pTextDoc = 
dynamic_cast<SwXTextDocument*>(mxComponent.get());
+    CPPUNIT_ASSERT(pTextDoc);
+
+    CPPUNIT_ASSERT_EQUAL(OUString("Nunc viverra imperdiet enim. Fusce est. 
Vivamus a tellus."),
+                         getParagraph(2)->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(2), 
1)->getString());
+    // second paragraph has got a tracked paragraph formatting yet
+    CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 1), "RedlineType"));
+
+    // delete last word of the second paragraph to remove tracked paragraph 
formatting
+    // of this paragraph to track and show word deletion correctly.
+    SwWrtShell* pWrtShell = pTextDoc->GetDocShell()->GetWrtShell();
+    pWrtShell->Down(/*bSelect=*/false);
+    pWrtShell->Down(/*bSelect=*/false);
+    pWrtShell->Down(/*bSelect=*/false);
+    pWrtShell->EndPara(/*bSelect=*/false);
+    pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 7, 
/*bBasicCall=*/false);
+    rtl::Reference<SwTransferable> pTransfer = new SwTransferable(*pWrtShell);
+    pTransfer->Cut();
+
+    // check tracked text deletion
+    CPPUNIT_ASSERT_EQUAL(OUString("tellus."), getRun(getParagraph(2), 
3)->getString());
+    CPPUNIT_ASSERT_EQUAL(OUString(""), getRun(getParagraph(2), 
2)->getString());
+    CPPUNIT_ASSERT(hasProperty(getRun(getParagraph(2), 2), "RedlineType"));
+
+    // check removing of tracked paragraph formatting
+    CPPUNIT_ASSERT(!hasProperty(getRun(getParagraph(2), 1), "RedlineType"));
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest2);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx 
b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 788cb61dd7df..52e67c6d0146 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2449,6 +2449,15 @@ bool DocumentContentOperationsManager::Overwrite( const 
SwPaM &rRg, const OUStri
 bool DocumentContentOperationsManager::InsertString( const SwPaM &rRg, const 
OUString &rStr,
         const SwInsertFlags nInsertMode )
 {
+    // tdf#119019 accept tracked paragraph formatting to do not hide new 
insertions
+    if( m_rDoc.getIDocumentRedlineAccess().IsRedlineOn() )
+    {
+        RedlineFlags eOld = 
m_rDoc.getIDocumentRedlineAccess().GetRedlineFlags();
+        m_rDoc.getIDocumentRedlineAccess().AcceptRedlineParagraphFormatting( 
rRg );
+        if (eOld != m_rDoc.getIDocumentRedlineAccess().GetRedlineFlags())
+            m_rDoc.getIDocumentRedlineAccess().SetRedlineFlags( eOld );
+    }
+
     // fetching DoesUndo is surprisingly expensive
     bool bDoesUndo = m_rDoc.GetIDocumentUndoRedo().DoesUndo();
     if (bDoesUndo)
@@ -3578,6 +3587,10 @@ bool 
DocumentContentOperationsManager::DeleteAndJoinWithRedlineImpl( SwPaM & rPa
             }
         }
 
+        // tdf#119019 accept tracked paragraph formatting to do not hide new 
deletions
+        if ( *rPam.GetPoint() != *rPam.GetMark() )
+            
m_rDoc.getIDocumentRedlineAccess().AcceptRedlineParagraphFormatting( rPam );
+
         if (m_rDoc.GetIDocumentUndoRedo().DoesUndo())
         {
 
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index c5b259f6aef6..d489d6065d49 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -2262,6 +2262,31 @@ bool DocumentRedlineManager::AcceptRedline( const SwPaM& 
rPam, bool bCallDelete
     // #TODO - add 'SwExtraRedlineTable' also ?
 }
 
+void DocumentRedlineManager::AcceptRedlineParagraphFormatting( const SwPaM 
&rPam )
+{
+    const SwPosition* pStt = rPam.Start(),
+                    * pEnd = pStt == rPam.GetPoint() ? rPam.GetMark()
+                                                     : rPam.GetPoint();
+
+    const sal_uLong nSttIdx = pStt->nNode.GetIndex();
+    const sal_uLong nEndIdx = pEnd->nNode.GetIndex();
+
+    for( SwRedlineTable::size_type n = 0; n < mpRedlineTable->size() ; ++n )
+    {
+        const SwRangeRedline* pTmp = (*mpRedlineTable)[ n ];
+        sal_uLong nPt = pTmp->GetPoint()->nNode.GetIndex(),
+              nMk = pTmp->GetMark()->nNode.GetIndex();
+        if( nPt < nMk ) { long nTmp = nMk; nMk = nPt; nPt = nTmp; }
+
+        if( nsRedlineType_t::REDLINE_PARAGRAPH_FORMAT == pTmp->GetType() &&
+            ( (nSttIdx <= nMk && nMk <= nEndIdx) || (nSttIdx <= nPt && nPt <= 
nEndIdx) ) )
+                AcceptRedline( n, false );
+
+        if( nMk > nEndIdx )
+            break;
+    }
+}
+
 bool DocumentRedlineManager::RejectRedline( SwRedlineTable::size_type nPos, 
bool bCallDelete )
 {
     bool bRet = false;
diff --git a/sw/source/core/inc/DocumentRedlineManager.hxx 
b/sw/source/core/inc/DocumentRedlineManager.hxx
index 1a410a15b6ba..9a3bd2cbd6ab 100644
--- a/sw/source/core/inc/DocumentRedlineManager.hxx
+++ b/sw/source/core/inc/DocumentRedlineManager.hxx
@@ -86,6 +86,8 @@ public:
 
     virtual bool AcceptRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool 
bCallDelete) override;
 
+    virtual void AcceptRedlineParagraphFormatting(/*[in]*/const SwPaM& rPam) 
override;
+
     virtual bool RejectRedline(/*[in]*/SwRedlineTable::size_type nPos, 
/*[in]*/bool bCallDelete) override;
 
     virtual bool RejectRedline(/*[in]*/const SwPaM& rPam, /*[in]*/bool 
bCallDelete) override;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to