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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 15 11:35:15 UTC 2020


 include/svl/solar.hrc           |    2 +-
 include/svx/unoshprp.hxx        |    4 +++-
 svx/source/unodraw/unoshape.cxx |   37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 2 deletions(-)

New commits:
commit 564550b8049e478ce4012a099d445f64d803336a
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Sep 8 17:26:12 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Sep 15 13:34:41 2020 +0200

    svx UNO API for shapes: expose what scaling factor is used for autofit scaling
    
    TextFitToSizeScale is 0 when the shape has no text or autofit is not
    enabled, 100 when there is autofit (but no scale-down), a value between
    the two otherwise.
    
    Towards allowing both "autofit" and "same font size for these shapes" at
    the same time for SmartArt purposes.
    
    (cherry picked from commit cd268f0047443ddbb22361cdc15093e881f83588)
    
    Conflicts:
            include/svx/unoshprp.hxx
            svx/source/unodraw/unoshape.cxx
    
    Change-Id: Iff88fcc4c2e67b543687b1d87d614622cbf2e38a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102724
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/include/svl/solar.hrc b/include/svl/solar.hrc
index 6b4cb07bbc33..317d45a84bc1 100644
--- a/include/svl/solar.hrc
+++ b/include/svl/solar.hrc
@@ -23,7 +23,7 @@
 // defines ------------------------------------------------------------------
 
 #define OWN_ATTR_VALUE_START                    3900
-#define OWN_ATTR_VALUE_END                      4004
+#define OWN_ATTR_VALUE_END                      4005
 
 #define RID_LIB_START               10000
 #define RID_LIB_END                 19999
diff --git a/include/svx/unoshprp.hxx b/include/svx/unoshprp.hxx
index 54b8db4b2715..873cd9a4676a 100644
--- a/include/svx/unoshprp.hxx
+++ b/include/svx/unoshprp.hxx
@@ -192,7 +192,8 @@
 #define OWN_ATTR_SIGNATURELINE_UNSIGNED_IMAGE   (OWN_ATTR_VALUE_START+102)
 #define OWN_ATTR_SIGNATURELINE_IS_SIGNED        (OWN_ATTR_VALUE_START+103)
 #define OWN_ATTR_QRCODE                         (OWN_ATTR_VALUE_START+104)
-// ATTENTION: maximum is OWN_ATTR_VALUE_START+104 svx, see include/svl/solar.hrc
+#define OWN_ATTR_TEXTFITTOSIZESCALE             (OWN_ATTR_VALUE_START+105)
+// ATTENTION: maximum is OWN_ATTR_VALUE_START+105 svx, see include/svl/solar.hrc
 
 // #FontWork#
 #define FONTWORK_PROPERTIES \
@@ -340,6 +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}, \
     /* #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/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 3f07f5ab9a82..cd71640027d2 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -93,6 +93,8 @@
 #include <drawinglayer/primitive2d/transformprimitive2d.hxx>
 
 #include <vcl/wmf.hxx>
+#include <svx/sdtfsitm.hxx>
+#include <svx/svdoutl.hxx>
 
 #include <memory>
 #include <vector>
@@ -174,6 +176,35 @@ protected:
     }
 };
 
+namespace
+{
+/// Calculates what scaling factor will be used for autofit text scaling of this shape.
+sal_Int16 GetTextFitToSizeScale(SdrObject* pObject)
+{
+    SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>(pObject);
+    if (!pTextObj)
+    {
+        return 0;
+    }
+
+    const SfxItemSet& rTextObjSet = pTextObj->GetMergedItemSet();
+    if (rTextObjSet.GetItem<SdrTextFitToSizeTypeItem>(SDRATTR_TEXT_FITTOSIZE)->GetValue()
+        != drawing::TextFitToSizeType_AUTOFIT)
+    {
+        return 0;
+    }
+
+    std::unique_ptr<SdrOutliner> pOutliner
+        = pTextObj->getSdrModelFromSdrObject().createOutliner(OutlinerMode::TextObject);
+    tools::Rectangle aBoundRect(pTextObj->GetCurrentBoundRect());
+    pTextObj->SetupOutlinerFormatting(*pOutliner, aBoundRect);
+    sal_uInt16 nX = 0;
+    sal_uInt16 nY = 0;
+    pOutliner->GetGlobalCharStretching(nX, nY);
+    return nY;
+}
+}
+
 SvxShape::SvxShape( SdrObject* pObject )
 :   maSize(100,100)
 ,   mpImpl( new SvxShapeImpl( *this, maMutex ) )
@@ -2838,6 +2869,12 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertySimpl
         break;
     }
 
+    case OWN_ATTR_TEXTFITTOSIZESCALE:
+    {
+        rValue <<= GetTextFitToSizeScale(GetSdrObject());
+        break;
+    }
+
     case OWN_ATTR_UINAME_PLURAL:
     {
         rValue <<= GetSdrObject()->TakeObjNamePlural();


More information about the Libreoffice-commits mailing list