diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-09-28 06:27:09 -0400 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2018-12-03 08:10:45 +0100 |
commit | b402d0112a0bb53221b847fa372bfa3f6390a0e2 (patch) | |
tree | 770cf33fa2b14159ca62a469b6bf75110d435182 /sw | |
parent | 349748e63c698076bb44f75da9eaa104489e959c (diff) |
sw: paragraph-sign: erase metafields from copied text correctly
This is relevant for paragraph signatures where the
metadata is not yet copied and so we exclude it.
The issue was that in some cases we didn't use
the proper range of text and an assertion was
triggered in debug builds.
Otherwise there should be no change of behavior
in release builds with this patch.
Change-Id: I90bc2ca56d586b96d39f34c68de53d3dac6099d7
Reviewed-on: https://gerrit.libreoffice.org/63000
Tested-by: Jenkins
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/txtnode/ndtxt.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index a979650504e1..ce948ec68c3c 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2018,7 +2018,7 @@ void SwTextNode::CopyText( SwTextNode *const pDest, { CHECK_SWPHINTS_IF_FRM(this); CHECK_SWPHINTS(pDest); - sal_Int32 nTextStartIdx = rStart.GetIndex(); + const sal_Int32 nTextStartIdx = rStart.GetIndex(); sal_Int32 nDestStart = rDestStart.GetIndex(); // remember old Pos if (pDest->GetDoc()->IsClipBoard() && GetNum()) @@ -2109,7 +2109,6 @@ void SwTextNode::CopyText( SwTextNode *const pDest, // Fetch end only now, because copying into self updates the start index // and all attributes - nTextStartIdx = rStart.GetIndex(); const sal_Int32 nEnd = nTextStartIdx + nLen; // 2. copy attributes @@ -2257,8 +2256,10 @@ void SwTextNode::CopyText( SwTextNode *const pDest, std::reverse(metaFieldRanges.begin(), metaFieldRanges.end()); for (const auto& pair : metaFieldRanges) { - const SwIndex aIdx(pDest, pair.first); - pDest->EraseText(aIdx, pair.second - pair.first); + const SwIndex aIdx(pDest, std::max<sal_Int32>(pair.first - nTextStartIdx, 0)); + const sal_Int32 nCount = pair.second - pair.first; + if (nCount > 0) + pDest->EraseText(aIdx, nCount); } } |