[Libreoffice-commits] .: sw/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Fri Jul 20 08:25:57 PDT 2012


 sw/source/core/doc/docbm.cxx  |    2 +-
 sw/source/core/doc/docedt.cxx |   20 ++++++++------------
 2 files changed, 9 insertions(+), 13 deletions(-)

New commits:
commit 9c497e9ed128f341846072b1c85271d9208290a4
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Fri Jul 20 17:08:20 2012 +0200

    SwDoc::DeleteRangeImplImpl: avoid crash on undoing comment range insert
    
    Change-Id: I1e085448fb8fb1227794a5196e954d97af770218

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index cfc8629..f3befe4 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 3655294..5ae2ab6 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);
             }
         }
     }


More information about the Libreoffice-commits mailing list