[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/svx svx/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 15 11:53:35 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 3e8cce134c92690da1955953da118d45f1c5ddde
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Sep 9 15:49:16 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Sep 15 13:52:57 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.
    
    (cherry picked from commit 81345de4858d6e72ecb8fc6621396570f4a4ee93)
    
    Conflicts:
            include/svx/sdtfsitm.hxx
            include/svx/unoshprp.hxx
    
    Change-Id: I31a5e097c62e6e65b32956a4a32137bc3339c64c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102725
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/include/svx/sdtfsitm.hxx b/include/svx/sdtfsitm.hxx
index ac5b71cec722..d884dc7a5995 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 SfxPoolItem*     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 78e09d508199..020bcb6cdd22 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 873cd9a4676a..cf263ea8cadd 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -341,7 +341,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 31cf34a76c73..1eb98121a203 100644
--- a/svx/source/svdraw/svdattr.cxx
+++ b/svx/source/svdraw/svdattr.cxx
@@ -939,6 +939,16 @@ SfxPoolItem* SdrTextFitToSizeTypeItem::CreateDefault() { return new SdrTextFitTo
 
 SfxPoolItem* 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 4ce65ca33f61..3df06ba3bfb2 100644
--- a/svx/source/svdraw/svdotext.cxx
+++ b/svx/source/svdraw/svdotext.cxx
@@ -1277,7 +1277,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
@@ -1333,6 +1334,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 cd71640027d2..9ab31b26dfa0 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -2420,6 +2420,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