diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-03-11 13:05:08 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-03-12 20:35:23 +0100 |
commit | 2291cbaeeb87fae2f2d6d75782e06f9296ba9c77 (patch) | |
tree | 343248cb81ac829d3ce55dee48015845742d0ccf /sw | |
parent | 172ba8b3d44c092435d690db7d4ca9090a114127 (diff) |
merge common parts of if/else
Change-Id: I033eb905bcb3102ff1a1aa3beacd8c054e5011a0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131376
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/txtnode/fntcache.cxx | 35 |
1 files changed, 14 insertions, 21 deletions
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<sal_Int32> 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<sal_Int32> 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<sal_uInt16>(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<sal_Int32> 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<sal_uInt16>(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<sal_uInt16>(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()); |