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

Michael Stahl mstahl at redhat.com
Tue Mar 7 22:41:48 UTC 2017


 sw/source/core/doc/doccomp.cxx  |   22 ++++++++++++++++++++++
 sw/source/core/undo/unredln.cxx |   12 ++++++++----
 2 files changed, 30 insertions(+), 4 deletions(-)

New commits:
commit cdfe5c28a31ee94a6b00fefd1b4a31aaf6333cf9
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Mar 7 23:13:51 2017 +0100

    sw: SwUndoCompDoc: fix assertion about invalid node indexes
    
    Try the steps from i#101009, then Undo and Redo:
    Assertion `idx < m_nSize' failed
    
    The problem is that the indexes stored in SwUndoCompDoc are for the
    document *post* insertion of the content of the other document,
    so delay the creation of rPam in SwUndoCompDoc::RedoImpl() until
    the content is inserted.
    
    Change-Id: I0d9c8dc90ea88c87bc56329b42a0ec22bbc6b248

diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index 5e6a7c3..690b424 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -462,10 +462,10 @@ void SwUndoCompDoc::UndoImpl(::sw::UndoRedoContext & rContext)
 void SwUndoCompDoc::RedoImpl(::sw::UndoRedoContext & rContext)
 {
     SwDoc& rDoc = rContext.GetDoc();
-    SwPaM& rPam(AddUndoRedoPaM(rContext));
 
     if( bInsert )
     {
+        SwPaM& rPam(AddUndoRedoPaM(rContext));
         if( pRedlData && IDocumentRedlineAccess::IsRedlineOn( GetRedlineFlags() ))
         {
             SwRangeRedline* pTmp = new SwRangeRedline(*pRedlData, rPam);
@@ -474,7 +474,10 @@ void SwUndoCompDoc::RedoImpl(::sw::UndoRedoContext & rContext)
         }
         else if( !( RedlineFlags::Ignore & GetRedlineFlags() ) &&
                 !rDoc.getIDocumentRedlineAccess().GetRedlineTable().empty() )
+        {
             rDoc.getIDocumentRedlineAccess().SplitRedline(rPam);
+        }
+        SetPaM(rPam, true);
     }
     else
     {
@@ -488,14 +491,15 @@ void SwUndoCompDoc::RedoImpl(::sw::UndoRedoContext & rContext)
         delete pUnDel;
         pUnDel = nullptr;
 
-        SetPaM(rPam);
+        // note: don't call SetPaM before executing Undo of members
+        SwPaM& rPam(AddUndoRedoPaM(rContext));
 
         SwRangeRedline* pTmp = new SwRangeRedline(*pRedlData, rPam);
         static_cast<SwRedlineTable&>(rDoc.getIDocumentRedlineAccess().GetRedlineTable()).Insert( pTmp );
         pTmp->InvalidateRange();
-    }
 
-    SetPaM(rPam, true);
+        SetPaM(rPam, true);
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 9b3fa51e7ba4e2bfe9806295c3cbc8db347480d8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Mar 7 23:12:44 2017 +0100

    tdf#106218 sw: compare document: tweak special handling of EndOfContent
    
    In case the last paragraph in the document is inserted or deleted, the
    redline must not be positioned on the EndOfContent node (i#101009).
    
    But then rejecting the redline will have an additional paragraph as
    compared to the original document.  Try to avoid that by tweaking the
    start position of the redline to the end of the previous paragraph.
    
    (regression from f4609c4c294a62023b6cd6baeb6a73d44992dec3)
    
    Change-Id: Iae75042a3124d0f3bca955fb856c94a6f478b986

diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 74d4452..09bd3d0 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -1680,6 +1680,17 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo )
                 SwContentNode *const pContentNode( pTmp->GetContentNode() );
                 pTmp->GetPoint()->nContent.Assign( pContentNode,
                         (pContentNode) ? pContentNode->Len() : 0 );
+                // tdf#106218 try to avoid losing a paragraph break here:
+                if (pTmp->GetMark()->nContent == 0)
+                {
+                    SwNodeIndex const prev(pTmp->GetMark()->nNode, -1);
+                    if (prev.GetNode().IsTextNode())
+                    {
+                        *pTmp->GetMark() = SwPosition(
+                            *prev.GetNode().GetTextNode(),
+                            prev.GetNode().GetTextNode()->Len());
+                    }
+                }
             }
 
             rDoc.getIDocumentRedlineAccess().DeleteRedline( *pTmp, false, USHRT_MAX );
@@ -1712,6 +1723,17 @@ void CompareData::SetRedlinesToDoc( bool bUseDocInfo )
                 SwContentNode *const pContentNode( pTmp->GetContentNode() );
                 pTmp->GetPoint()->nContent.Assign( pContentNode,
                         (pContentNode) ? pContentNode->Len() : 0 );
+                // tdf#106218 try to avoid losing a paragraph break here:
+                if (pTmp->GetMark()->nContent == 0)
+                {
+                    SwNodeIndex const prev(pTmp->GetMark()->nNode, -1);
+                    if (prev.GetNode().IsTextNode())
+                    {
+                        *pTmp->GetMark() = SwPosition(
+                            *prev.GetNode().GetTextNode(),
+                            prev.GetNode().GetTextNode()->Len());
+                    }
+                }
             }
         } while( pInsRing != ( pTmp = pTmp->GetNext()) );
         SwRedlineData aRedlnData( nsRedlineType_t::REDLINE_INSERT, nAuthor, aTimeStamp,


More information about the Libreoffice-commits mailing list