[Libreoffice-commits] core.git: Branch 'libreoffice-5-3' - sw/source

Michael Stahl mstahl at redhat.com
Wed Mar 29 12:29:01 UTC 2017


 sw/source/core/doc/doctxm.cxx |   42 +++++++++++++++++++++++++++---------------
 1 file changed, 27 insertions(+), 15 deletions(-)

New commits:
commit 123bb36e7eafde85732b57e84d0377586a0a66d8
Author: Michael Stahl <mstahl at redhat.com>
Date:   Tue Mar 21 11:01:20 2017 +0100

    tdf#106377 sw: fix Undo of delete of ToXMark from dialog
    
    The problem is that SwUndoResetAttr and the SwHistorySetTOXMark by
    design only insert the SwTextAttr, they don't insert the dummy char of
    a SwTextAttr that needs one, like the ToXMark does if it marks a point.
    
    So just change SwDoc::DeleteTOXMark to create SwUndoDelete instead.
    
    Change-Id: Ic1eebac4cf859771a6032bffb2fd8e198aa08084
    (cherry picked from commit 63f7da77985674ddf59bb566bdada9c41893e822)
    Reviewed-on: https://gerrit.libreoffice.org/35501
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index b3462b761a41..46496a78d662 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -154,26 +154,38 @@ void SwDoc::DeleteTOXMark( const SwTOXMark* pTOXMark )
     SwTextNode& rTextNd = const_cast<SwTextNode&>(pTextTOXMark->GetTextNode());
     OSL_ENSURE( rTextNd.GetpSwpHints(), "cannot be deleted" );
 
-    std::unique_ptr<SwRegHistory> aRHst;
-    if (GetIDocumentUndoRedo().DoesUndo())
+    if (pTextTOXMark->HasDummyChar())
     {
-        // save attributes for Undo
-        SwUndoResetAttr* pUndo = new SwUndoResetAttr(
-            SwPosition( rTextNd, SwIndex( &rTextNd, pTextTOXMark->GetStart() ) ),
-            RES_TXTATR_TOXMARK );
-        GetIDocumentUndoRedo().AppendUndo( pUndo );
-
-        aRHst.reset(new SwRegHistory(rTextNd, &pUndo->GetHistory()));
-        rTextNd.GetpSwpHints()->Register(aRHst.get());
+        // tdf#106377 don't use SwUndoResetAttr, it uses NOTXTATRCHR
+        SwPaM tmp(rTextNd, pTextTOXMark->GetStart(),
+                  rTextNd, pTextTOXMark->GetStart()+1);
+        assert(rTextNd.GetText()[pTextTOXMark->GetStart()] == CH_TXTATR_INWORD);
+        getIDocumentContentOperations().DeleteRange(tmp);
     }
+    else
+    {
+        std::unique_ptr<SwRegHistory> aRHst;
+        if (GetIDocumentUndoRedo().DoesUndo())
+        {
+            // save attributes for Undo
+            SwUndoResetAttr* pUndo = new SwUndoResetAttr(
+                SwPosition( rTextNd, SwIndex( &rTextNd, pTextTOXMark->GetStart() ) ),
+                RES_TXTATR_TOXMARK );
+            GetIDocumentUndoRedo().AppendUndo( pUndo );
+
+            aRHst.reset(new SwRegHistory(rTextNd, &pUndo->GetHistory()));
+            rTextNd.GetpSwpHints()->Register(aRHst.get());
+        }
 
-    rTextNd.DeleteAttribute( const_cast<SwTextTOXMark*>(pTextTOXMark) );
+        rTextNd.DeleteAttribute( const_cast<SwTextTOXMark*>(pTextTOXMark) );
 
-    if (GetIDocumentUndoRedo().DoesUndo())
-    {
-        if( rTextNd.GetpSwpHints() )
-            rTextNd.GetpSwpHints()->DeRegister();
+        if (GetIDocumentUndoRedo().DoesUndo())
+        {
+            if( rTextNd.GetpSwpHints() )
+                rTextNd.GetpSwpHints()->DeRegister();
+        }
     }
+
     getIDocumentState().SetModified();
 }
 


More information about the Libreoffice-commits mailing list