[Libreoffice-commits] core.git: include/svx svx/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 9 16:33:42 UTC 2020


 include/svx/sdtfsitm.hxx        |   10 ++++++++++
 include/svx/svdotext.hxx        |    2 +-
 include/svx/unoshprp.hxx        |    2 +-
 svx/source/svdraw/svdattr.cxx   |   10 ++++++++++
 svx/source/svdraw/svdotext.cxx  |   10 +++++++++-
 svx/source/unodraw/unoshape.cxx |   13 +++++++++++++
 6 files changed, 44 insertions(+), 3 deletions(-)

New commits:
commit 81345de4858d6e72ecb8fc6621396570f4a4ee93
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Sep 9 15:49:16 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Sep 9 18:32:52 2020 +0200

    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.
    
    Change-Id: I31a5e097c62e6e65b32956a4a32137bc3339c64c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102324
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

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 41e9baa3faa9..1de1b3edd89c 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 c73d0c8a5e72..04a9213dc2a9 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -351,7 +351,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(), css::beans::PropertyAttribute::READONLY, 0}, \
+    { u"TextFitToSizeScale", OWN_ATTR_TEXTFITTOSIZESCALE, ::cppu::UnoType<sal_Int16>::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},
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx
index 8ba7b86c57bc..005676d47e83 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -940,6 +940,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 1d4ae9094aa5..dfba1f6cf464 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 c78f5f65a71e..860e6a24895b 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:
     {


More information about the Libreoffice-commits mailing list