sc/source/core/data/column2.cxx |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

New commits:
commit 4749d5667add57b8c83919bf3e87c558022e4a13
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Thu May 23 15:09:52 2024 +0200
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Mon Jun 24 10:19:03 2024 +0200

    reduce cost of calc column height calculation
    
    avoid calling GetTextWidth unless we really need to
    
    Change-Id: Ibb0f378e632fa3fce68b4819028630759baf4eb5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167988
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    (cherry picked from commit f91a411340ae204ce1e6997f22e0352a4c6a8355)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167941
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index 0c79029d96c4..f8fc1f5b8527 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -307,9 +307,10 @@ tools::Long ScColumn::GetNeededSize(
         {
             //  SetFont is moved up
 
-            Size aSize( pDev->GetTextWidth( aValStr ), pDev->GetTextHeight() );
+            Size aSize;
             if ( eOrient != SvxCellOrientation::Standard )
             {
+                aSize = Size( pDev->GetTextWidth( aValStr ), 
pDev->GetTextHeight() );
                 tools::Long nTemp = aSize.Width();
                 aSize.setWidth( aSize.Height() );
                 aSize.setHeight( nTemp );
@@ -318,6 +319,7 @@ tools::Long ScColumn::GetNeededSize(
             {
                 //TODO: take different X/Y scaling into consideration
 
+                aSize = Size( pDev->GetTextWidth( aValStr ), 
pDev->GetTextHeight() );
                 double nRealOrient = toRadians(nRotate);
                 double nCosAbs = fabs( cos( nRealOrient ) );
                 double nSinAbs = fabs( sin( nRealOrient ) );
@@ -347,8 +349,13 @@ tools::Long ScColumn::GetNeededSize(
                 }
 
                 aSize = Size( nWidth, nHeight );
+                nValue = bWidth ? aSize.Width() : aSize.Height();
             }
-            nValue = bWidth ? aSize.Width() : aSize.Height();
+            else if (bBreak && !bWidth)
+                aSize = Size( pDev->GetTextWidth( aValStr ), 
pDev->GetTextHeight() );
+            else
+                // in the common case (height), avoid calling the expensive 
GetTextWidth
+                nValue = bWidth ? pDev->GetTextWidth( aValStr ) : 
pDev->GetTextHeight();
 
             if ( bAddMargin )
             {

Reply via email to