Kaydet (Commit) 9c497e9e authored tarafından Miklos Vajna's avatar Miklos Vajna

SwDoc::DeleteRangeImplImpl: avoid crash on undoing comment range insert

Change-Id: I1e085448fb8fb1227794a5196e954d97af770218
üst 81d2dd00
......@@ -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
......
......@@ -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);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment