diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-03-23 11:24:30 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-04-07 12:35:28 +0200 |
commit | 81ff712657dba53376c94c9bb266e7c838ef40e2 (patch) | |
tree | 4398a1cbb46fd321353c4d520a14cf7d4c1cc94d /include | |
parent | baf9a9b40d6fbe62fbe1c024c5d808631432da84 (diff) |
tdf#90407 Change the auto-fit alg. to match better with OOXML
The auto-fit algorithm has been tweaked to be more in-line with
the expectations of OOXML. This means a couple of changes to what
properties are scaled by the algorithm have been made:
- most properties that influence the X axis position or size (for
example indent) are not scaled down or changed by scaling.
- properties that influence y axis position and size are scaled
by a separate parameter (like in the OOXML). This is used in the
auto-fit algorithm in a different way.
- if line spacing is proportional, it is now scaled with the
spacing parameter. Fixed line spacing doesn't get scaled.
- the main scaling X,Y parameter only scales the fonts.
- trying hard to scale the fonts to the nearest pt (point) value
With this change the scaling is much more stable than it was
before - for example it doesn't matter what the unscaled font
size is, when it is scaled down to the text box size, it (should)
always look the same (for example scaling from 32pt -> 10pt or
64pt -> 10pt or even 999pt -> 10pt).
The algorithm is also rewritten to be better at finding a fit and
is also better at find a good fit, but it can take more iterations
by doing so (there are ways to improve it however). Previous
algorithm used a linear search to converge to the best fit in less
iterations, but the issue with that was that it could in some cases
miss a solution (especially since change to floating point scaling
parameter). The new algorithm now uses a binary search - always
trying the middle of the search space.
OOXML export and import was also changed to take advantage of the
font scaling and spacing scaling parameters. The additional
scaling at export that was needed to have consistent OOXML support
was removed.
Change-Id: I8f3bb8d43a01931f18bd7ffdf8e0ba40caa73d8b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149207
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149934
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/editeng/editeng.hxx | 8 | ||||
-rw-r--r-- | include/editeng/outliner.hxx | 6 | ||||
-rw-r--r-- | include/svx/sdtfsitm.hxx | 20 | ||||
-rw-r--r-- | include/svx/svdotext.hxx | 5 | ||||
-rw-r--r-- | include/svx/unoshprp.hxx | 2 |
5 files changed, 27 insertions, 14 deletions
diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index 29e33da53d71..6ac71935d54f 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -414,8 +414,12 @@ public: void QuickDelete( const ESelection& rSel ); void QuickMarkToBeRepainted( sal_Int32 nPara ); - void SetGlobalCharStretching(double nX, double nY); - void GetGlobalCharStretching(double& rX, double& rY) const; + void setGlobalScale(double fFontScaleX, double fFontScaleY, double fSpacingScaleX, double fSpacingScaleY); + + void getGlobalSpacingScale(double& rX, double& rY) const; + void getGlobalFontScale(double& rX, double& rY) const; + + void setRoundFontSizeToPt(bool bRound) const; void SetEditTextObjectPool( SfxItemPool* pPool ); SfxItemPool* GetEditTextObjectPool() const; diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index 1d560b3643bc..be51c08d7fbf 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -925,8 +925,10 @@ public: bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder ); bool IsTextPos( const Point& rPaperPos, sal_uInt16 nBorder, bool* pbBulletPos ); - void SetGlobalCharStretching(double nX = 100.0, double nY = 100.0); - void GetGlobalCharStretching(double& rX, double& rY) const; + void setGlobalScale(double rFontX = 100.0, double rFontY = 100.0, double rSpacingX = 100.0, double rSpacingY = 100.0); + void getGlobalScale(double& rFontX, double& rFontY, double& rSpacingX, double& rSpacingY) const; + void setRoundFontSizeToPt(bool bRound) const; + void EraseVirtualDevice(); bool ShouldCreateBigTextObject() const; diff --git a/include/svx/sdtfsitm.hxx b/include/svx/sdtfsitm.hxx index d98e431dab68..ccdcb7c4dbe9 100644 --- a/include/svx/sdtfsitm.hxx +++ b/include/svx/sdtfsitm.hxx @@ -35,14 +35,17 @@ class SVXCORE_DLLPUBLIC SdrTextFitToSizeTypeItem final { public: static SfxPoolItem* CreateDefault(); - SdrTextFitToSizeTypeItem( - css::drawing::TextFitToSizeType const eFit = css::drawing::TextFitToSizeType_NONE) - : SfxEnumItem(SDRATTR_TEXT_FITTOSIZE, eFit) {} + SdrTextFitToSizeTypeItem(css::drawing::TextFitToSizeType const eFit = css::drawing::TextFitToSizeType_NONE) + : SfxEnumItem(SDRATTR_TEXT_FITTOSIZE, eFit) + { + } + SdrTextFitToSizeTypeItem(const SdrTextFitToSizeTypeItem& rItem) - : SfxEnumItem(rItem), - m_nMaxScale(rItem.GetMaxScale()) + : SfxEnumItem(rItem) + , m_nMaxScale(rItem.GetMaxScale()) { } + virtual SdrTextFitToSizeTypeItem* Clone(SfxItemPool* pPool=nullptr) const override; bool operator==(const SfxPoolItem& rItem) const override; virtual sal_uInt16 GetValueCount() const override; @@ -55,10 +58,11 @@ public: virtual bool HasBoolValue() const override; virtual bool GetBoolValue() const override; virtual void SetBoolValue(bool bVal) override; - void SetMaxScale(sal_Int16 nMaxScale) { m_nMaxScale = nMaxScale; } - sal_Int16 GetMaxScale() const { return m_nMaxScale; } + + void SetMaxScale(double nMaxScale) { m_nMaxScale = nMaxScale; } + double GetMaxScale() const { return m_nMaxScale; } private: - sal_Int16 m_nMaxScale = 0; + double m_nMaxScale = 0.0; }; #endif diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index d192552d16ad..4c086dc67497 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -253,6 +253,7 @@ private: void ImpAutoFitText( SdrOutliner& rOutliner ) const; void ImpAutoFitText( SdrOutliner& rOutliner, const Size& rShapeSize, bool bIsVerticalWriting ) const; SVX_DLLPRIVATE SdrObjectUniquePtr ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const; + void autoFitTextForCompatibility(SdrOutliner& rOutliner, const Size& rShapeSize) const; SVX_DLLPRIVATE void ImpRegisterLink(); SVX_DLLPRIVATE void ImpDeregisterLink(); SVX_DLLPRIVATE ImpSdrObjTextLinkUserData* GetLinkUserData() const; @@ -380,7 +381,9 @@ public: // FitToSize and Fontwork are not taken into account in GetTextSize()! virtual const Size& GetTextSize() const; void FitFrameToTextSize(); - sal_uInt16 GetFontScaleY() const; + + double GetFontScale() const; + double GetSpacingScale() const; // Simultaneously sets the text into the Outliner (possibly // the one of the EditOutliner) and sets the PaperSize. diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx index 357655c5e71a..4deec20d7783 100644 --- a/include/svx/unoshprp.hxx +++ b/include/svx/unoshprp.hxx @@ -361,7 +361,7 @@ { u"" UNO_NAME_MISC_OBJ_SIZEPROTECT, SDRATTR_OBJSIZEPROTECT , cppu::UnoType<bool>::get(), 0, 0},\ { u"UINameSingular", OWN_ATTR_UINAME_SINGULAR , ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY, 0}, \ { u"UINamePlural", OWN_ATTR_UINAME_PLURAL , ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY, 0}, \ - { u"TextFitToSizeScale", OWN_ATTR_TEXTFITTOSIZESCALE, ::cppu::UnoType<sal_Int16>::get(), 0, 0}, \ + { u"TextFitToSizeScale", OWN_ATTR_TEXTFITTOSIZESCALE, ::cppu::UnoType<double>::get(), 0, 0}, \ /* #i68101# */ \ { u"" UNO_NAME_MISC_OBJ_TITLE, OWN_ATTR_MISC_OBJ_TITLE , ::cppu::UnoType<OUString>::get(), 0, 0}, \ { u"" UNO_NAME_MISC_OBJ_DESCRIPTION, OWN_ATTR_MISC_OBJ_DESCRIPTION , ::cppu::UnoType<OUString>::get(), 0, 0}, \ |