summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-11-10 08:58:29 -0500
committerAshod Nakashian <ashnakash@gmail.com>2017-11-10 22:20:13 +0100
commit3b2ae25594774e23ab513ea6f99a0552c7ac5caf (patch)
tree5a1c1d7b9cec50f7974ebd803864c1272c473909 /sw
parent8e84dfd7c678e2774522a8d23fa4f6313ed6281a (diff)
TSCP: strip metadata fields when copying
Since the RDF entries are not copied (due to limitations in the clipboard doc), metadata fields become inconsistent upon copying. This is especially problematic for signatures and classification as they are no longer maintainable or verifyable (which is a particularly critical issue for crypto signatures of paragraphs). Change-Id: I5468a961ed43befdc48fcea8be00734453917c1f Reviewed-on: https://gerrit.libreoffice.org/43631 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/txtnode/ndtxt.cxx26
1 files changed, 24 insertions, 2 deletions
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index 2fc443a2d4ba..2596f115e9e5 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -1795,14 +1795,16 @@ void SwTextNode::CopyText( SwTextNode *const pDest,
// Del-Array for all RefMarks without extent
SwpHts aRefMrkArr;
+ std::vector<std::pair<sal_Int32, sal_Int32>> metaFieldRanges;
sal_Int32 nDeletedDummyChars(0);
for (size_t n = 0; n < nSize; ++n)
{
- const sal_Int32 nAttrStartIdx = m_pSwpHints->Get(n)->GetStart();
+ SwTextAttr * const pHt = m_pSwpHints->Get(n);
+
+ const sal_Int32 nAttrStartIdx = pHt->GetStart();
if (!( nAttrStartIdx < nEnd))
break;
- SwTextAttr * const pHt = m_pSwpHints->Get(n);
const sal_Int32 * const pEndIdx = pHt->GetEnd();
const sal_uInt16 nWhich = pHt->Which();
@@ -1838,6 +1840,13 @@ void SwTextNode::CopyText( SwTextNode *const pDest,
}
}
+ if (nWhich == RES_TXTATR_METAFIELD)
+ {
+ // Skip metadata fields. Also remember the range to strip the text later.
+ metaFieldRanges.emplace_back(nAttrStartIdx, pEndIdx ? *pEndIdx : nEnd);
+ continue;
+ }
+
sal_Int32 nAttrStt = 0;
sal_Int32 nAttrEnd = 0;
@@ -1911,6 +1920,19 @@ void SwTextNode::CopyText( SwTextNode *const pDest,
}
}
+ // Strip the metadata fields, since we don't copy the RDF entries
+ // yet and so they are inconsistent upon copy/pasting.
+ if (!metaFieldRanges.empty())
+ {
+ // Reverse to remove without messing the offsets.
+ std::reverse(metaFieldRanges.begin(), metaFieldRanges.end());
+ for (const auto& pair : metaFieldRanges)
+ {
+ const SwIndex aIdx(pDest, pair.first);
+ pDest->EraseText(aIdx, pair.second - pair.first);
+ }
+ }
+
// this can only happen when copying into self
for (SwTextAttr* i : aArr)
{