diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-03-21 11:01:20 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-03-29 12:28:39 +0000 |
commit | 123bb36e7eafde85732b57e84d0377586a0a66d8 (patch) | |
tree | 3c4f32c235d272d9e56109db80d6b3d38b9909cf | |
parent | 1c5d8ea51f9da89d76b2b2d3bb896225a6ac9dca (diff) |
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@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/source/core/doc/doctxm.cxx | 42 |
1 files changed, 27 insertions, 15 deletions
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(); } |