diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-05-05 15:34:38 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-05-06 14:38:32 +0200 |
commit | 6c042848b688f64b3c56d65dd9dc5fe85412660a (patch) | |
tree | 280b78e7200d90a3ee60b3c9dce61451b7f62e10 /svx | |
parent | 6868a857fc8a5256b47da239b573b27d40002080 (diff) |
Change text auto-fit alg. to also increase the scaling
When in edit mode, the text can be deleted, so the text box size
can become smaller, but the auto-fit algorithm didn't take into
account.
In this case we already have the font and spacing scaling already
set to a specific value and we need to find a scaling value where
the margin is the smallest.
This change also adds a test for the issue.
Change-Id: I6c52f06dfbf5a1e582f7b31aceabf4736498ee90
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151412
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/svdraw/svdotext.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index f2951787b551..a27e112d85cb 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1303,7 +1303,11 @@ void SdrTextObj::autoFitTextForCompatibility(SdrOutliner& rOutliner, const Size& else fCurrentFitFactor = double(rTextBoxSize.Height()) / aCurrentTextBoxSize.Height(); - if (fCurrentFitFactor >= 1.0) + double fInitialFontScaleY = 0.0; + double fInitialSpacing = 0.0; + rOutliner.getGlobalScale(o3tl::temporary(double()), fInitialFontScaleY, o3tl::temporary(double()), fInitialSpacing); + + if (fCurrentFitFactor >= 1.0 && fInitialFontScaleY >= 100.0 && fInitialSpacing >= 100.0) return; sal_Int32 nFontHeight = GetObjectItemSet().Get(EE_CHAR_FONTHEIGHT).GetHeight(); @@ -1313,9 +1317,21 @@ void SdrTextObj::autoFitTextForCompatibility(SdrOutliner& rOutliner, const Size& double fMaxY = fMaxScale; double fBestFontScale = 0.0; - double fBestSpacing = fMaxScale; + double fBestSpacing = 100.0; double fBestFitFactor = fCurrentFitFactor; + if (fCurrentFitFactor >= 1.0) + { + fMinY = fInitialFontScaleY; + fBestFontScale = fInitialFontScaleY; + fBestSpacing = fInitialSpacing; + fBestFitFactor = fCurrentFitFactor; + } + else + { + fMaxY = std::min(fInitialFontScaleY, fMaxScale); + } + double fInTheMidle = 0.5; int iteration = 0; |