[Libreoffice-commits] core.git: Branch 'libreoffice-6-4' - 2 commits - sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Tue Nov 19 15:08:47 UTC 2019


 sw/source/core/undo/rolbck.cxx |   21 ++++++++++++++++++++-
 sw/source/core/undo/undel.cxx  |    6 +++---
 sw/source/core/undo/undobj.cxx |   18 +++++++++++-------
 sw/source/core/undo/untblk.cxx |    4 +++-
 4 files changed, 37 insertions(+), 12 deletions(-)

New commits:
commit cddd1cae07ade16d1700c48d42e36c938cc01823
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Mon Nov 18 13:16:54 2019 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Nov 19 16:08:08 2019 +0100

    tdf#128739 sw: don't delete bookmarks prematurely in SwUndoDelete
    
    ::RedoImpl() and SwUndoInserts::UndoImpl().
    
    The bookmarks will be deleted again by DelContentIndex(), which also
    adds them to m_pHistory, but RemoveIdxFromRange() deletes them without
    adding them to m_pHistory so they won't be restored.
    
    There is some funny commit c50f2e0a69204b8760c2e06313a18b6194f2d109
    which is a mystery: if the rPam has to be saved across the
    RemoveIdxFromRange() call, then either the rPam that's passed to
    RemoveIdxFromRange() is wrong, or the rPam that is restored after the
    call is wrong... just revert it and set the same values to rPam.
    
    Change-Id: I9e93ef75bcd2931594aeae07e761c48752d31d9b
    Reviewed-on: https://gerrit.libreoffice.org/83084
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 83edee3009240a3c26271b8de2450eed3e5acf97)
    Reviewed-on: https://gerrit.libreoffice.org/83110

diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index ebdf25a63978..ab32dff0901c 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -1153,9 +1153,9 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext)
 
     if( !m_bDelFullPara )
     {
-        SwUndRng aTmpRng( rPam );
-        RemoveIdxFromRange( rPam, false );
-        aTmpRng.SetPaM( rPam );
+        // tdf#128739 correct cursors but do not delete bookmarks yet
+        ::PaMCorrAbs(rPam, *rPam.End());
+        SetPaM(rPam);
 
         if( !m_bJoinNext )           // then restore selection from bottom to top
             rPam.Exchange();
diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index 75d509d43004..0ca015873f88 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -27,6 +27,7 @@
 #include <docary.hxx>
 #include <swundo.hxx>
 #include <pam.hxx>
+#include <mvsave.hxx>
 #include <ndtxt.hxx>
 #include <UndoCore.hxx>
 #include <rolbck.hxx>
@@ -238,7 +239,8 @@ void SwUndoInserts::UndoImpl(::sw::UndoRedoContext & rContext)
                 m_pLastNodeColl = pTextNd->GetTextColl();
         }
 
-        RemoveIdxFromRange(rPam, false);
+        // tdf#128739 correct cursors but do not delete bookmarks yet
+        ::PaMCorrAbs(rPam, *rPam.End());
 
         SetPaM(rPam);
     }
commit 1140dae89387b2012bfba6e97c6475cf39cf101b
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Fri Nov 15 16:44:23 2019 +0100
Commit:     Michael Stahl <michael.stahl at cib.de>
CommitDate: Tue Nov 19 16:07:58 2019 +0100

    tdf#128739 sw: delete fieldmarks if exactly selected ...
    
    ... in SwUndoSaveContent::DelContentIndex().
    
    The problem is that the fieldmark survives but its dummy characters are
    all deleted; this will eventually lead to unhappiness in Undo.
    
    Another issue is that SwHistoryBookmark doesn't know about dummy
    characters, so use the SwHistory*Fieldmark instead.
    
    This still doesn't work completely because SwUndoDelete::RedoImpl() is
    quite borked.
    
    (regression from 4dc1615c80e8e66d339dc86fa95bbc76e884d988..d9030ad6298e2f49ee63489d6158ea6ad23c0111)
    
    Change-Id: Ia98d143fa46e79348fde200be5462cc461455b58
    Reviewed-on: https://gerrit.libreoffice.org/82815
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.stahl at cib.de>
    (cherry picked from commit 24fd14b387dca458a1b6e9415e936d26562ddb1e)
    Reviewed-on: https://gerrit.libreoffice.org/83109

diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 8a2c027b93f5..353ce708fe8a 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -1070,7 +1070,26 @@ void SwHistory::Add(const ::sw::mark::IMark& rBkmk, bool bSavePos, bool bSaveOth
 {
     OSL_ENSURE( !m_nEndDiff, "History was not deleted after REDO" );
 
-    std::unique_ptr<SwHistoryHint> pHt(new SwHistoryBookmark(rBkmk, bSavePos, bSaveOtherPos));
+    std::unique_ptr<SwHistoryHint> pHt;
+
+    switch (IDocumentMarkAccess::GetType(rBkmk))
+    {
+        case IDocumentMarkAccess::MarkType::TEXT_FIELDMARK:
+        case IDocumentMarkAccess::MarkType::DATE_FIELDMARK:
+            assert(bSavePos && bSaveOtherPos); // must be deleted completely!
+            pHt.reset(new SwHistoryTextFieldmark(dynamic_cast<sw::mark::IFieldmark const&>(rBkmk)));
+            break;
+        case IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK:
+        case IDocumentMarkAccess::MarkType::DROPDOWN_FIELDMARK:
+            assert(bSavePos && bSaveOtherPos); // must be deleted completely!
+            pHt.reset(new SwHistoryNoTextFieldmark(dynamic_cast<sw::mark::IFieldmark const&>(rBkmk)));
+            break;
+        default:
+            pHt.reset(new SwHistoryBookmark(rBkmk, bSavePos, bSaveOtherPos));
+            break;
+    }
+
+    assert(pHt);
     m_SwpHstry.push_back( std::move(pHt) );
 }
 
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 5a3dd9a3e66c..bb5683853a51 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -1063,13 +1063,13 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
         IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
         if( pMarkAccess->getAllMarksCount() )
         {
-
             for( sal_Int32 n = 0; n < pMarkAccess->getAllMarksCount(); ++n )
             {
                 // #i81002#
                 bool bSavePos = false;
                 bool bSaveOtherPos = false;
-                const ::sw::mark::IMark* pBkmk = pMarkAccess->getAllMarksBegin()[n];
+                const ::sw::mark::IMark *const pBkmk = pMarkAccess->getAllMarksBegin()[n];
+                auto const type(IDocumentMarkAccess::GetType(*pBkmk));
 
                 if( DelContentType::CheckNoCntnt & nDelContentType )
                 {
@@ -1090,8 +1090,8 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
                     // #i92125#
                     // keep cross-reference bookmarks, if content inside one paragraph is deleted.
                     if ( rMark.nNode == rPoint.nNode
-                         && ( IDocumentMarkAccess::GetType(*pBkmk) == IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK
-                              || IDocumentMarkAccess::GetType(*pBkmk) == IDocumentMarkAccess::MarkType::CROSSREF_NUMITEM_BOOKMARK ) )
+                        && (   type == IDocumentMarkAccess::MarkType::CROSSREF_HEADING_BOOKMARK
+                            || type == IDocumentMarkAccess::MarkType::CROSSREF_NUMITEM_BOOKMARK))
                     {
                         continue;
                     }
@@ -1109,7 +1109,11 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
                         *pStt <= pBkmk->GetOtherMarkPos() && pBkmk->GetOtherMarkPos() <= *pEnd )
                     {
                         if ( bSavePos || bSaveOtherPos
-                             || ( pBkmk->GetOtherMarkPos() < *pEnd && pBkmk->GetOtherMarkPos() > *pStt ) )
+                            || (*pStt < pBkmk->GetOtherMarkPos() && pBkmk->GetOtherMarkPos() < *pEnd)
+                            || type == IDocumentMarkAccess::MarkType::TEXT_FIELDMARK
+                            || type == IDocumentMarkAccess::MarkType::CHECKBOX_FIELDMARK
+                            || type == IDocumentMarkAccess::MarkType::DROPDOWN_FIELDMARK
+                            || type == IDocumentMarkAccess::MarkType::DATE_FIELDMARK)
                         {
                             if( bMaybe )
                                 bSavePos = true;
@@ -1145,7 +1149,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
                             }
                         }
                     }
-                    else if ( IDocumentMarkAccess::GetType(*pBkmk) == IDocumentMarkAccess::MarkType::ANNOTATIONMARK )
+                    else if (type == IDocumentMarkAccess::MarkType::ANNOTATIONMARK)
                     {
                         // delete annotation marks, if its end position is covered by the deletion
                         const SwPosition& rAnnotationEndPos = pBkmk->GetMarkEnd();
@@ -1159,7 +1163,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
 
                 if ( bSavePos || bSaveOtherPos )
                 {
-                    if( IDocumentMarkAccess::GetType(*pBkmk) != IDocumentMarkAccess::MarkType::UNO_BOOKMARK )
+                    if (type != IDocumentMarkAccess::MarkType::UNO_BOOKMARK)
                     {
                         if( !m_pHistory )
                             m_pHistory.reset( new SwHistory );


More information about the Libreoffice-commits mailing list