summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-07-16 16:09:52 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-07-17 09:55:16 +0200
commit2f52f37f8363cb696bb3ead7249a87a826409908 (patch)
treec0d0732df8146952b041f52784051768da9ba7ca
parente2a443f520782d5960188e7755230571811f65d7 (diff)
SwDoc::DeleteRangeImplImpl: handle fieldmarks before postits
These were not deleted earlier, leaving a gray field after comment deletion. Change-Id: I66d5e04f075a54eb0638a63b8cd7bd8c1920603e
-rw-r--r--sw/source/core/doc/docedt.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index fd7540337a0d..365529457e12 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -74,6 +74,8 @@
#include <vcl/msgbox.hxx>
#include "comcore.hrc"
#include "editsh.hxx"
+#include <fldbas.hxx>
+#include <fmtfld.hxx>
#include <unoflatpara.hxx>
#include <SwGrammarMarkUp.hxx>
@@ -1639,6 +1641,30 @@ bool SwDoc::DeleteRangeImplImpl(SwPaM & rPam)
}
}
+ // Delete fieldmarks before postits.
+ if (pStt->nNode == pEnd->nNode && (pEnd->nContent.GetIndex() - pStt->nContent.GetIndex()) == 1)
+ {
+ SwTxtNode* pTxtNd = rPam.Start()->nNode.GetNode().GetTxtNode();
+ xub_StrLen nIndex = rPam.Start()->nContent.GetIndex();
+ // If there are at least two chars before the postit, we may have a fieldmark there.
+ if (pTxtNd->GetTxt().GetChar(nIndex) == CH_TXTATR_INWORD && nIndex > 1)
+ {
+ SwTxtAttr* pTxtAttr = pTxtNd->GetTxtAttrForCharAt(nIndex, RES_TXTATR_FIELD);
+ if (pTxtAttr && pTxtAttr->GetFld().GetFld()->Which() == RES_POSTITFLD && pTxtNd->GetTxt().GetChar(nIndex - 1) == CH_TXT_ATR_FIELDEND)
+ {
+ xub_StrLen nStart = pTxtNd->GetTxt().SearchBackward(CH_TXT_ATR_FIELDSTART, nIndex - 2);
+ if (nStart != STRING_NOTFOUND)
+ {
+ SwIndex aStart(pStt->nContent);
+ aStart = nStart;
+ SwIndex aEnd(pEnd->nContent);
+ aEnd = nIndex - 1;
+ _DelBookmarks(pStt->nNode, pEnd->nNode, NULL, &aStart, &aEnd);
+ }
+ }
+ }
+ }
+
{
// Send DataChanged before deletion, so that we still know
// which objects are in the range.