diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-09-09 15:49:16 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-09-09 18:32:52 +0200 |
commit | 81345de4858d6e72ecb8fc6621396570f4a4ee93 (patch) | |
tree | 06325b18bd85ddd7bff06d8ed16fd4dce47e35e8 /svx | |
parent | ad6ef813e9d745d44719dae381d64cdcc2f82719 (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.
Change-Id: I31a5e097c62e6e65b32956a4a32137bc3339c64c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102324
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'svx')
-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 |
3 files changed, 32 insertions, 1 deletions
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: { |