summaryrefslogtreecommitdiff
path: root/sw/source/core/doc
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-04-01 17:16:20 +0200
committerCaolán McNamara <caolanm@redhat.com>2022-04-03 18:12:39 +0200
commit542673c0d4c6a992113999101f2c1bf21e0c5c22 (patch)
treee56a7fffc4ed291fbe5e3c26bdf4b31f3ba9b6ff /sw/source/core/doc
parent87c1615c1f6525c3f0e0d16dd98269744d21d183 (diff)
forcepoint#96 sw: delete fieldmarks in DelFullPara()
The problem is that CorrAbs() will move any position of a fieldmark that's in the deleted SwTextNodes to a different node that doesn't have the CH_TXT_ATR_FIELD*. Then it will inevitably crash later when it can't find its chars. The other problem is that if there's only a CH_TXT_ATR_FIELDSEP in the deleted nodes, that fieldmark would then be missing it. Just delete fieldmarks with positions in deleted nodes, that should work fine for the usual cases where DelFullPara() is called. Change-Id: I8dfac9a315d74025dbe1ed5ccb95b7c9121fb569 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132379 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw/source/core/doc')
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index c9f15ad54226..11f91cfe38b5 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -2255,6 +2255,37 @@ bool DocumentContentOperationsManager::DelFullPara( SwPaM& rPam )
return false;
}
}
+
+ // must delete all fieldmarks before CorrAbs(), or they'll remain
+ // moved to wrong node without their CH_TXT_ATR_FIELD*
+ // (note: deleteMarks() doesn't help here, in case of partially
+ // selected fieldmarks; let's delete these as re-inserting their chars
+ // elsewhere looks difficult)
+ ::std::set<::sw::mark::IFieldmark*> fieldmarks;
+ for (SwNodeIndex i = aRg.aStart; i <= aRg.aEnd; ++i)
+ {
+ if (SwTextNode *const pTextNode = i.GetNode().GetTextNode())
+ {
+ for (sal_Int32 j = 0; j < pTextNode->GetText().getLength(); ++j)
+ {
+ switch (pTextNode->GetText()[j])
+ {
+ case CH_TXT_ATR_FIELDSTART:
+ case CH_TXT_ATR_FIELDEND:
+ fieldmarks.insert(m_rDoc.getIDocumentMarkAccess()->getFieldmarkAt(SwPosition(*pTextNode, j)));
+ break;
+ case CH_TXT_ATR_FIELDSEP:
+ fieldmarks.insert(m_rDoc.getIDocumentMarkAccess()->getFieldmarkFor(SwPosition(*pTextNode, j)));
+ break;
+ }
+ }
+ }
+ }
+ for (auto const pFieldMark : fieldmarks)
+ {
+ m_rDoc.getIDocumentMarkAccess()->deleteMark(pFieldMark);
+ }
+
// move bookmarks, redlines etc.
if (aRg.aStart == aRg.aEnd) // only first CorrAbs variant handles this
{