diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-01-11 17:32:18 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-01-11 17:46:51 +0100 |
commit | f132eaa5a6ec6fd3051442bda9caf94a3341c680 (patch) | |
tree | a331f4fde48fecb51852c45f950517c4ae869cbc | |
parent | 1874df3041789729478ef99ff156ccee489c6a7a (diff) |
fdo#53487 SwUndoInsert: take care of fieldmarks when deleting field chars
The problem was that while SwUndoInsert removed the field characters, it
didn't remove the fieldmark, so after unding a comment insert, it wasn't
possible to re-insert a comment.
-rw-r--r-- | sw/source/core/undo/unins.cxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index 0dbb1bed7b56..473a9154253d 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -25,6 +25,7 @@ #include <sot/storage.hxx> #include <editeng/keepitem.hxx> #include <svx/svdobj.hxx> +#include <xmloff/odffields.hxx> #include <docsh.hxx> #include <fmtcntnt.hxx> @@ -242,6 +243,26 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) RemoveIdxFromRange( aPaM, sal_False ); pTxt = new String( pTxtNode->GetTxt().Copy(nCntnt-nLen, nLen) ); pTxtNode->EraseText( aPaM.GetPoint()->nContent, nLen ); + + // Undo deletes fieldmarks in two step: first the end then the start position. + // Once the start position is deleted, make sure the fieldmark itself is deleted as well. + if (nLen == 1) + { + IDocumentMarkAccess* const pMarkAccess = pTmpDoc->getIDocumentMarkAccess(); + for ( IDocumentMarkAccess::const_iterator_t i = pMarkAccess->getMarksBegin(); i != pMarkAccess->getMarksEnd(); ++i) + { + sw::mark::IMark* pMark = i->get(); + if (pMark->GetMarkStart() == *aPaM.GetPoint() && pMark->GetMarkStart().nContent == aPaM.GetPoint()->nContent) + { + sw::mark::IFieldmark* pFieldmark = dynamic_cast<sw::mark::IFieldmark*>(pMark); + if (pFieldmark && pFieldmark->GetFieldname() == ODF_COMMENTRANGE) + { + pTmpDoc->getIDocumentMarkAccess()->deleteMark(pMark); + break; + } + } + } + } } else // otherwise Graphics/OLE/Text/... { |