diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-12-27 21:44:12 +0600 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-12-28 10:21:22 +0100 |
commit | 56fa314c518fa094411f553e1b97dcd9e8860c73 (patch) | |
tree | 488330e61f604cc28c53202f4186179a552aa11c /sw | |
parent | feb035b265210379ed81511d1694466b28695ff3 (diff) |
Simplify a bit
Change-Id: I4a78ef11e7ed87e231548773669a3e057d09364f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161375
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/text/itrform2.cxx | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/sw/source/core/text/itrform2.cxx b/sw/source/core/text/itrform2.cxx index 7d122dda2497..55fa779a86aa 100644 --- a/sw/source/core/text/itrform2.cxx +++ b/sw/source/core/text/itrform2.cxx @@ -1327,25 +1327,20 @@ SwTextPortion *SwTextFormatter::NewTextPortion( SwTextFormatInfo &rInf ) Seek( rInf.GetIdx() ); SwTextPortion *pPor = WhichTextPor( rInf ); + TextFrameIndex nNextChg(rInf.GetText().getLength()); + // until next attribute change: const TextFrameIndex nNextAttr = GetNextAttr(); - TextFrameIndex nNextChg = std::min(nNextAttr, TextFrameIndex(rInf.GetText().getLength())); - // end of script type: const TextFrameIndex nNextScript = m_pScriptInfo->NextScriptChg(rInf.GetIdx()); - nNextChg = std::min( nNextChg, nNextScript ); - // end of direction: const TextFrameIndex nNextDir = m_pScriptInfo->NextDirChg(rInf.GetIdx()); - nNextChg = std::min( nNextChg, nNextDir ); - // hidden change (potentially via bookmark): const TextFrameIndex nNextHidden = m_pScriptInfo->NextHiddenChg(rInf.GetIdx()); - nNextChg = std::min( nNextChg, nNextHidden ); - // bookmarks const TextFrameIndex nNextBookmark = m_pScriptInfo->NextBookmark(rInf.GetIdx()); - nNextChg = std::min(nNextChg, nNextBookmark); + + nNextChg = std::min({ nNextChg, nNextAttr, nNextScript, nNextDir, nNextHidden, nNextBookmark }); // Turbo boost: // We assume that font characters are not larger than twice @@ -1364,13 +1359,12 @@ SwTextPortion *SwTextFormatter::NewTextPortion( SwTextFormatInfo &rInf ) CalcAscent( rInf, pPor ); const SwFont* pTmpFnt = rInf.GetFont(); - sal_Int32 nExpect = std::min( sal_Int32( pTmpFnt->GetHeight() ), - sal_Int32( pPor->GetAscent() ) ) / 8; - if ( !nExpect ) - nExpect = 1; - nExpect = sal_Int32(rInf.GetIdx()) + (rInf.GetLineWidth() / nExpect); - if (TextFrameIndex(nExpect) > rInf.GetIdx() && nNextChg > TextFrameIndex(nExpect)) - nNextChg = TextFrameIndex(std::min(nExpect, rInf.GetText().getLength())); + auto nCharWidthGuess = std::min(pTmpFnt->GetHeight(), pPor->GetAscent()) / 8; + if (!nCharWidthGuess) + nCharWidthGuess = 1; + auto nExpect = rInf.GetIdx() + TextFrameIndex(rInf.GetLineWidth() / nCharWidthGuess); + if (nExpect > rInf.GetIdx() && nNextChg > nExpect) + nNextChg = nExpect; // we keep an invariant during method calls: // there are no portion ending characters like hard spaces |