sw/source/core/txtnode/fntcache.cxx |   35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

New commits:
commit 2291cbaeeb87fae2f2d6d75782e06f9296ba9c77
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Fri Mar 11 13:05:08 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Sat Mar 12 20:35:23 2022 +0100

    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 <caol...@redhat.com>

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());

Reply via email to