From 2291cbaeeb87fae2f2d6d75782e06f9296ba9c77 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 11 Mar 2022 13:05:08 +0000 Subject: merge common parts of if/else MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I033eb905bcb3102ff1a1aa3beacd8c054e5011a0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131376 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sw/source/core/txtnode/fntcache.cxx | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'sw') diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index 2bdd00124dd4..0e19dc23a064 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -1954,47 +1954,40 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf ) // This is the part used e.g., for cursor travelling // See condition for DrawText or DrawTextArray (bDirectPrint) + std::vector aKernArray; if ( m_pPrinter && m_pPrinter.get() != rInf.GetpOut() ) { if( !m_pPrtFont->IsSameInstance( m_pPrinter->GetFont() ) ) m_pPrinter->SetFont(*m_pPrtFont); aTextSize.setHeight( m_pPrinter->GetTextHeight() ); - std::vector aKernArray; + CreateScrFont( *rInf.GetShell(), rInf.GetOut() ); if( !GetScrFont()->IsSameInstance( rInf.GetOut().GetFont() ) ) rInf.GetOut().SetFont( *m_pScrFont ); GetTextArray(*m_pPrinter, rInf.GetText(), aKernArray, - sal_Int32(rInf.GetIdx()), sal_Int32(nLn), false); - if( bCompress ) - rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( aKernArray.data(), - rInf.GetIdx(), nLn, rInf.GetKanaComp(), - o3tl::narrowing(m_aFont.GetFontSize().Height()) ,lcl_IsFullstopCentered( rInf.GetOut() ) ) ); - else - rInf.SetKanaDiff( 0 ); - - aTextSize.setWidth(aKernArray[sal_Int32(nLn) - 1]); + sal_Int32(rInf.GetIdx()), sal_Int32(nLn), false); } else { if( !m_pPrtFont->IsSameInstance( rInf.GetOut().GetFont() ) ) rInf.GetOut().SetFont( *m_pPrtFont ); - - std::vector aKernArray; + aTextSize.setHeight( rInf.GetOut().GetTextHeight() ); GetTextArray(rInf.GetOut(), rInf.GetText(), aKernArray, sal_Int32(rInf.GetIdx()), sal_Int32(nLn), true); - if( bCompress ) - rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( aKernArray.data(), - rInf.GetIdx(), nLn, rInf.GetKanaComp(), - o3tl::narrowing(m_aFont.GetFontSize().Height()) ,lcl_IsFullstopCentered( rInf.GetOut() ) ) ); - else - rInf.SetKanaDiff( 0 ); - - aTextSize.setWidth( aKernArray[sal_Int32(nLn) - 1] ); + } - aTextSize.setHeight( rInf.GetOut().GetTextHeight() ); + if (bCompress) + { + rInf.SetKanaDiff(rInf.GetScriptInfo()->Compress(aKernArray.data(), rInf.GetIdx(), nLn, rInf.GetKanaComp(), + o3tl::narrowing(m_aFont.GetFontSize().Height()), lcl_IsFullstopCentered(rInf.GetOut()))); } + else + rInf.SetKanaDiff( 0 ); + + aTextSize.setWidth(aKernArray[sal_Int32(nLn) - 1]); + if ( rInf.GetKern() && nLn ) aTextSize.AdjustWidth((sal_Int32(nLn) - 1) * rInf.GetKern()); -- cgit v1.2.3