summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-03-21 11:01:20 +0100
committerAndras Timar <andras.timar@collabora.com>2017-03-29 14:29:52 +0200
commit0a483513f198d2e4bbeb2368d5f0763721f9a062 (patch)
treefe80a07e12e8528e503a67ba23358864aa25d98f /sw
parentadcb19b32076b69e0abfb0b79db6263f59839dac (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> (cherry picked from commit 123bb36e7eafde85732b57e84d0377586a0a66d8)
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/doctxm.cxx42
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();
}