sw/source/core/text/itrform2.cxx | 26 ++++++++------------- sw/source/core/text/pormulti.cxx | 48 ++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 41 deletions(-)
New commits: commit 4904da4ba40c0ca1a77ef0e6f0df6ce68a147029 Author: Mike Kaganski <[email protected]> AuthorDate: Thu Dec 28 06:27:01 2023 +0100 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Dec 28 10:21:30 2023 +0100 Flatten a bit: !pNode was excluded above Change-Id: If109ff4b5cfbb45ae7844765a4f615b6b77c6c03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161324 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx index 7771ab9b5e8f..7d79b990b2f9 100644 --- a/sw/source/core/text/pormulti.cxx +++ b/sw/source/core/text/pormulti.cxx @@ -1032,35 +1032,33 @@ std::optional<SwMultiCreator> SwTextSizeInfo::GetMultiCreator(TextFrameIndex &rP } } } - else if (pNode) // !pAttr && pNode means the node changed + // !pAttr && pNode means the node changed + if (startPos.first->GetIndex() < pNode->GetIndex()) { - if (startPos.first->GetIndex() < pNode->GetIndex()) + break; // only one node initially + } + if (startPos.first->GetIndex() == pNode->GetIndex()) + { + iterAtStartOfNode.Assign(iter); + if (SfxItemState::SET == pNode->GetSwAttrSet().GetItemState( + RES_CHRATR_ROTATE, true, &pNodeRotateItem) && + pNodeRotateItem->GetValue()) { - break; // only one node initially + pActiveRotateItem = pNodeRotateItem; } - if (startPos.first->GetIndex() == pNode->GetIndex()) + else { - iterAtStartOfNode.Assign(iter); - if (SfxItemState::SET == pNode->GetSwAttrSet().GetItemState( - RES_CHRATR_ROTATE, true, &pNodeRotateItem) && - pNodeRotateItem->GetValue()) - { - pActiveRotateItem = pNodeRotateItem; - } - else - { - pNodeRotateItem = nullptr; - } - if (SfxItemState::SET == startPos.first->GetSwAttrSet().GetItemState( - RES_CHRATR_TWO_LINES, true, &pNodeTwoLinesItem) && - pNodeTwoLinesItem->GetValue()) - { - pActiveTwoLinesItem = pNodeTwoLinesItem; - } - else - { - pNodeTwoLinesItem = nullptr; - } + pNodeRotateItem = nullptr; + } + if (SfxItemState::SET == startPos.first->GetSwAttrSet().GetItemState( + RES_CHRATR_TWO_LINES, true, &pNodeTwoLinesItem) && + pNodeTwoLinesItem->GetValue()) + { + pActiveTwoLinesItem = pNodeTwoLinesItem; + } + else + { + pNodeTwoLinesItem = nullptr; } } } commit 56fa314c518fa094411f553e1b97dcd9e8860c73 Author: Mike Kaganski <[email protected]> AuthorDate: Wed Dec 27 21:44:12 2023 +0600 Commit: Mike Kaganski <[email protected]> CommitDate: Thu Dec 28 10:21:22 2023 +0100 Simplify a bit Change-Id: I4a78ef11e7ed87e231548773669a3e057d09364f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161375 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> 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
