From 516dc02998fd59035fb54f2c78b7891ac7c7578a Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Fri, 3 Jul 2020 10:49:26 +0200 Subject: avoid some sorting Change-Id: I02aacffcac30d48f79fd8d2640392aa3f1214b41 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97826 Tested-by: Jenkins Reviewed-by: Noel Grandin --- editeng/source/editeng/editdoc.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'editeng') diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index fbcb4c51ed41..0d5213355c5c 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -2420,6 +2420,7 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn rpStarting = nullptr; bool bChanged = false; + bool bNeedsSorting = false; DBG_ASSERT( nStart <= nEnd, "Small miscalculations in InsertAttribInSelection" ); @@ -2443,6 +2444,7 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn bChanged = true; if ( pAttr->GetEnd() > nEnd ) { + bNeedsSorting = true; pAttr->GetStart() = nEnd; // then it starts after this rpStarting = pAttr; if ( nWhich ) @@ -2476,6 +2478,7 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn bChanged = true; if ( pAttr->GetStart() == nStart ) { + bNeedsSorting = true; pAttr->GetStart() = nEnd; rpStarting = pAttr; if ( nWhich ) @@ -2490,6 +2493,7 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn } else // Attribute must be split ... { + bNeedsSorting = true; sal_Int32 nOldEnd = pAttr->GetEnd(); pAttr->GetEnd() = nStart; rpEnding = pAttr; @@ -2514,7 +2518,8 @@ bool EditDoc::RemoveAttribs( ContentNode* pNode, sal_Int32 nStart, sal_Int32 nEn if ( bChanged ) { // char attributes need to be sorted by start again - pNode->GetCharAttribs().ResortAttribs(); + if (bNeedsSorting) + pNode->GetCharAttribs().ResortAttribs(); SetModified(true); } -- cgit