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

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Mon Nov 18 16:37:02 UTC 2019


 sw/source/core/undo/rolbck.cxx |   21 ++++++++++++++++++++-
 sw/source/core/undo/undobj.cxx |   18 +++++++++++-------
 2 files changed, 31 insertions(+), 8 deletions(-)

New commits:
commit 24fd14b387dca458a1b6e9415e936d26562ddb1e
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: Mon Nov 18 17:35:38 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>

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