summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2024-06-12 17:16:01 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2024-06-14 13:48:02 +0200
commit8e1ab38cfef6d64e11fc9e6bf63317ad83514318 (patch)
tree9fd1b4efa18addcfc506198a9cbed7b877c58af5
parent2b3e57c7d5726bf49dba224a337650bbc4395eaa (diff)
sw: fix SwTextFrameInfo::GetSpaces() for line containing only spaces
This would assert: frminf.cxx:139: void AddRange(): Assertion `rRanges.empty() || rRanges.back().second <= nPos' failed. Change-Id: Ib41f4c6c971fee9307140c108e74d5df7d94c973 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168824 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> (cherry picked from commit f97008c50ff88a7cf0a80a583a743ee1fb041327) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168807
-rw-r--r--sw/source/core/text/frminf.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/sw/source/core/text/frminf.cxx b/sw/source/core/text/frminf.cxx
index a123691db703..386f40942f5f 100644
--- a/sw/source/core/text/frminf.cxx
+++ b/sw/source/core/text/frminf.cxx
@@ -172,14 +172,15 @@ void SwTextFrameInfo::GetSpaces(
// in the selection
if( aLine.GetNext() )
{
- nPos = aLine.GetTextEnd();
+ TextFrameIndex const nEndPos{aLine.GetTextEnd()};
- if( nPos < aLine.GetEnd() )
+ // if only whitespace in line, nEndPos < nPos !
+ if (nPos < nEndPos && nEndPos < aLine.GetEnd())
{
TextFrameIndex const nOff( !bWithLineBreak && CH_BREAK ==
aLine.GetInfo().GetChar(aLine.GetEnd() - TextFrameIndex(1))
? 1 : 0 );
- AddRange( rRanges, nPos, aLine.GetEnd() - nPos - nOff );
+ AddRange(rRanges, nEndPos, aLine.GetEnd() - nEndPos - nOff);
}
}
}