summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-07-20 17:08:20 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-07-20 17:25:15 +0200
commit9c497e9ed128f341846072b1c85271d9208290a4 (patch)
tree250547b005b02bca67e85b11ab3db18497a95ca9 /sw
parent81d2dd00391dbc8a040e5c1f3059121863269d2c (diff)
SwDoc::DeleteRangeImplImpl: avoid crash on undoing comment range insert
Change-Id: I1e085448fb8fb1227794a5196e954d97af770218
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/docbm.cxx2
-rw-r--r--sw/source/core/doc/docedt.cxx20
2 files changed, 9 insertions, 13 deletions
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index cfc8629fc280..f3befe4f1ecd 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -593,7 +593,7 @@ namespace sw { namespace mark
isPosInRange = true, isOtherPosInRange = true;
}
- if(isPosInRange && (isOtherPosInRange || !pMark->IsExpanded() || IDocumentMarkAccess::GetType(*pMark) == TEXT_FIELDMARK))
+ if(isPosInRange && (isOtherPosInRange || !pMark->IsExpanded()))
{
// completely in range
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 365529457e12..5ae2ab6f5d16 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -76,6 +76,7 @@
#include "editsh.hxx"
#include <fldbas.hxx>
#include <fmtfld.hxx>
+#include <docufld.hxx>
#include <unoflatpara.hxx>
#include <SwGrammarMarkUp.hxx>
@@ -1646,21 +1647,16 @@ bool SwDoc::DeleteRangeImplImpl(SwPaM & rPam)
{
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)
+ // We may have a postit here.
+ if (pTxtNd->GetTxt().GetChar(nIndex) == CH_TXTATR_INWORD)
{
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)
+ if (pTxtAttr && pTxtAttr->GetFld().GetFld()->Which() == RES_POSTITFLD)
{
- 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);
- }
+ const SwPostItField* pField = dynamic_cast<const SwPostItField*>(pTxtAttr->GetFld().GetFld());
+ IDocumentMarkAccess::const_iterator_t ppMark = getIDocumentMarkAccess()->findMark(pField->GetName());
+ if (ppMark != getIDocumentMarkAccess()->getMarksEnd())
+ getIDocumentMarkAccess()->deleteMark(ppMark);
}
}
}