diff options
author | Michael Stahl <mstahl@redhat.com> | 2017-03-21 11:01:20 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-03-21 11:31:12 +0100 |
commit | 63f7da77985674ddf59bb566bdada9c41893e822 (patch) | |
tree | 0945ba44349131f42a7cd06731f4cc8cd8cbf090 /sw | |
parent | 155b1bc18a180dc036d61eb98184737058b84b8a (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
Diffstat (limited to 'sw')
-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 48ff5a95f0fa..460a647749f4 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(); } |