sw/source/core/txtnode/ndtxt.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
New commits: commit 6ffcbd6e8e07989af0dac07e2e43dfd96693dd7a Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> AuthorDate: Fri Sep 28 06:27:09 2018 -0400 Commit: Ashod Nakashian <ashnak...@gmail.com> CommitDate: Thu Dec 26 03:37:40 2019 +0100 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 <ashnak...@gmail.com> (cherry picked from commit 15701ab315a9d4cfc9ab0b05eae11a61b008eddc) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85800 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index 3904e11699e6..619e99efa1b5 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2017,7 +2017,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()) @@ -2108,7 +2108,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 @@ -2256,8 +2255,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); } } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits