diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-09-09 15:49:16 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-09-15 14:38:47 +0200 |
commit | 618b12b768eaffd40fcd98eb0ed55d0e7850b64c (patch) | |
tree | 4d94f5d4ccf973e556fe142d0194c04b45b9035a | |
parent | e62432c57f21df84885553a79cb765c9fcb35cc9 (diff) |
svx UNO API for shapes: allow setting a max factor for autofit text scale
This allows getting the scale factor from multiple shapes (that have
text), seeing what factors they use and then setting the factor to the
minimum of the values.
Towards allowing both "autofit" and "same font size for these shapes" at
the same time for SmartArt purposes.
(cherry picked from commit 81345de4858d6e72ecb8fc6621396570f4a4ee93)
Conflicts:
include/svx/unoshprp.hxx
Change-Id: I31a5e097c62e6e65b32956a4a32137bc3339c64c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102710
Tested-by: Jenkins
Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
-rw-r--r-- | include/svx/sdtfsitm.hxx | 10 | ||||
-rw-r--r-- | include/svx/svdotext.hxx | 2 | ||||
-rw-r--r-- | include/svx/unoshprp.hxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdattr.cxx | 10 | ||||
-rw-r--r-- | svx/source/svdraw/svdotext.cxx | 10 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 13 |
6 files changed, 44 insertions, 3 deletions
diff --git a/include/svx/sdtfsitm.hxx b/include/svx/sdtfsitm.hxx index 597da1ad591c..c446bc1fbca6 100644 --- a/include/svx/sdtfsitm.hxx +++ b/include/svx/sdtfsitm.hxx @@ -38,7 +38,13 @@ public: 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()) + { + } virtual SdrTextFitToSizeTypeItem* Clone(SfxItemPool* pPool=nullptr) const override; + bool operator==(const SfxPoolItem& rItem) const override; virtual sal_uInt16 GetValueCount() const override; virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; @@ -49,6 +55,10 @@ 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; } +private: + sal_Int16 m_nMaxScale = 0; }; #endif diff --git a/include/svx/svdotext.hxx b/include/svx/svdotext.hxx index 6f1804bb1757..5ee175520251 100644 --- a/include/svx/svdotext.hxx +++ b/include/svx/svdotext.hxx @@ -263,7 +263,7 @@ private: tools::Rectangle& rPaintRect, Fraction& aFitXCorrection ) const; void ImpAutoFitText( SdrOutliner& rOutliner ) const; - static void ImpAutoFitText( SdrOutliner& rOutliner, const Size& rShapeSize, bool bIsVerticalWriting ); + void ImpAutoFitText( SdrOutliner& rOutliner, const Size& rShapeSize, bool bIsVerticalWriting ) const; SVX_DLLPRIVATE SdrObjectUniquePtr ImpConvertContainedTextToSdrPathObjs(bool bToPoly) const; SVX_DLLPRIVATE void ImpRegisterLink(); SVX_DLLPRIVATE void ImpDeregisterLink(); diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx index 8051634c3e42..cf7452e8303a 100644 --- a/include/svx/unoshprp.hxx +++ b/include/svx/unoshprp.hxx @@ -349,7 +349,7 @@ { OUString(UNO_NAME_MISC_OBJ_SIZEPROTECT), SDRATTR_OBJSIZEPROTECT , cppu::UnoType<bool>::get(), 0, 0},\ { OUString("UINameSingular"), OWN_ATTR_UINAME_SINGULAR , ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY, 0}, \ { OUString("UINamePlural"), OWN_ATTR_UINAME_PLURAL , ::cppu::UnoType<OUString>::get(), css::beans::PropertyAttribute::READONLY, 0}, \ - { OUString("TextFitToSizeScale"), OWN_ATTR_TEXTFITTOSIZESCALE, ::cppu::UnoType<sal_Int16>::get(), css::beans::PropertyAttribute::READONLY, 0}, \ + { OUString("TextFitToSizeScale"), OWN_ATTR_TEXTFITTOSIZESCALE, ::cppu::UnoType<sal_Int16>::get(), 0, 0}, \ /* #i68101# */ \ { OUString(UNO_NAME_MISC_OBJ_TITLE), OWN_ATTR_MISC_OBJ_TITLE , ::cppu::UnoType<OUString>::get(), 0, 0}, \ { OUString(UNO_NAME_MISC_OBJ_DESCRIPTION), OWN_ATTR_MISC_OBJ_DESCRIPTION , ::cppu::UnoType<OUString>::get(), 0, 0}, diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index f57b523db96e..05992d9dc86d 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -937,6 +937,16 @@ SfxPoolItem* SdrTextFitToSizeTypeItem::CreateDefault() { return new SdrTextFitTo SdrTextFitToSizeTypeItem* SdrTextFitToSizeTypeItem::Clone(SfxItemPool* /*pPool*/) const { return new SdrTextFitToSizeTypeItem(*this); } +bool SdrTextFitToSizeTypeItem::operator==(const SfxPoolItem& rItem) const +{ + if (!SfxEnumItem<css::drawing::TextFitToSizeType>::operator==(rItem)) + { + return false; + } + + return m_nMaxScale == static_cast<const SdrTextFitToSizeTypeItem&>(rItem).m_nMaxScale; +} + sal_uInt16 SdrTextFitToSizeTypeItem::GetValueCount() const { return 4; } OUString SdrTextFitToSizeTypeItem::GetValueTextByPos(sal_uInt16 nPos) diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index e43fdedae0cf..3c2923c9cd25 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1260,7 +1260,8 @@ void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner ) const IsVerticalWriting() ); } -void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner, const Size& rTextSize, bool bIsVerticalWriting ) +void SdrTextObj::ImpAutoFitText(SdrOutliner& rOutliner, const Size& rTextSize, + bool bIsVerticalWriting) const { // EditEngine formatting is unstable enough for // line-breaking text that we need some more samples @@ -1316,6 +1317,13 @@ void SdrTextObj::ImpAutoFitText( SdrOutliner& rOutliner, const Size& rTextSize, } } + const SdrTextFitToSizeTypeItem& rItem = GetObjectItem(SDRATTR_TEXT_FITTOSIZE); + if (rItem.GetMaxScale() > 0) + { + nMinStretchX = std::min<sal_uInt16>(rItem.GetMaxScale(), nMinStretchX); + nMinStretchY = std::min<sal_uInt16>(rItem.GetMaxScale(), nMinStretchY); + } + SAL_INFO("svx", "final zoom is " << nMinStretchX); rOutliner.SetGlobalCharStretching(std::min(sal_uInt16(100),nMinStretchX), std::min(sal_uInt16(100),nMinStretchY)); diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index e1077663cc68..f5be3192d8c0 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -2411,6 +2411,19 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertySimpl break; } + case OWN_ATTR_TEXTFITTOSIZESCALE: + { + sal_Int16 nMaxScale = 0; + if (rValue >>= nMaxScale) + { + SdrTextFitToSizeTypeItem aItem(GetSdrObject()->GetMergedItem(SDRATTR_TEXT_FITTOSIZE)); + aItem.SetMaxScale(nMaxScale); + GetSdrObject()->SetMergedItem(aItem); + return true; + } + break; + } + // #i68101# case OWN_ATTR_MISC_OBJ_TITLE: { |