summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-09-08 17:26:12 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-09-15 14:38:30 +0200
commite62432c57f21df84885553a79cb765c9fcb35cc9 (patch)
tree08dac04cb3a4dc86221859fc4247b018aa1791b3 /svx
parent2048a2c268125f17a440ec449df4030b91758172 (diff)
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 Change-Id: Iff88fcc4c2e67b543687b1d87d614622cbf2e38a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102709 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/unodraw/unoshape.cxx33
1 files changed, 33 insertions, 0 deletions
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 080f455c4005..e1077663cc68 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -82,6 +82,8 @@
#include <vcl/gdimtf.hxx>
#include <vcl/wmf.hxx>
+#include <svx/sdtfsitm.hxx>
+#include <svx/svdoutl.hxx>
#include <memory>
#include <vector>
@@ -165,6 +167,31 @@ protected:
}
};
+/// 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 )
@@ -2833,6 +2860,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();