summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-06-18 21:25:27 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-06-19 13:29:12 +0200
commitf9ceb96c11dcb262f030966cf44b2dc5ed657144 (patch)
treef3a2687d14804a3cf3de9dac87b16dde3773c4ea
parent03b5c306044c8a41e58b99ef7f648f81ee4a9533 (diff)
ofz#48122 Timeout
Change-Id: Ia00a8ced550a5d4c84899e6cfb293779216898e8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136093 Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeFontWork.cxx34
1 files changed, 27 insertions, 7 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
index a08e03f146eb..de621c1367e7 100644
--- a/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeFontWork.cxx
@@ -243,16 +243,36 @@ static void CalculateHorizontalScalingFactor(
if (fScalingFactor < 1.0)
{
- // if we have a very large font that will require scaling down to a very small value then
- // skip directly to a small font size
+ // we have a very large font that will require scaling down to a very small value.
if (nFontSize > 128)
{
- double nEstimatedFinalFontSize = nFontSize * fScalingFactor;
- double nOnePercentFontSize = nFontSize / 100.0;
- if (nEstimatedFinalFontSize < nOnePercentFontSize)
+ // see if it will even be possible at the min size
+ sal_Int32 nOrigFontSize = nFontSize;
+ double fOrigScalingFactor = fScalingFactor;
+
+ nFontSize = 2;
+ pVirDev->Push(vcl::PushFlags::FONT);
+ aFont.SetFontHeight(nFontSize);
+ pVirDev->SetFont(aFont);
+ UpdateScalingMode(rFWData, rOutline2d, bSingleLineMode, pVirDev, fScalingFactor);
+ pVirDev->Pop();
+
+ const bool bHopeLess = fScalingFactor < 1.0;
+ // if its hopeless then just continue on with this FontSize of 2, otherwise
+ // continue to try smaller sizes
+ if (!bHopeLess)
{
- nFontSize = std::max<int>(16, std::ceil(5 * nEstimatedFinalFontSize));
- SAL_WARN("svx", "CalculateHorizontalScalingFactor skipping direct to: " << nFontSize << " from " << rFontHeight.GetHeight());
+ nFontSize = nOrigFontSize;
+ fScalingFactor = fOrigScalingFactor;
+
+ // skip directly to a small font size
+ double nEstimatedFinalFontSize = nFontSize * fScalingFactor;
+ double nOnePercentFontSize = nFontSize / 100.0;
+ if (nEstimatedFinalFontSize < nOnePercentFontSize)
+ {
+ nFontSize = std::max<int>(16, std::ceil(5 * nEstimatedFinalFontSize));
+ SAL_WARN("svx", "CalculateHorizontalScalingFactor skipping direct to: " << nFontSize << " from " << rFontHeight.GetHeight());
+ }
}
}
nFontSize--;