summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2024-05-23 15:09:52 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-05-23 19:46:32 +0200
commitf91a411340ae204ce1e6997f22e0352a4c6a8355 (patch)
tree856e60c1d7bf972d020c0e2295326722dd84363a /sc/source
parentfc3e2c8bba202a3ea3e92672f566d6ec16f18681 (diff)
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.meeks@collabora.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/column2.cxx11
1 files changed, 9 insertions, 2 deletions
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index c4ac17ffe358..e62ac56a1e14 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 )
{