diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-04-01 20:32:15 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-04-03 04:06:39 +0200 |
commit | db64748f1ee771da9da857f95601b9e08b577166 (patch) | |
tree | 2be5e8a13d75e287da95aa5d1b6891c34812875e /svx/source | |
parent | 6fd33d50603c2d12c0a1d88edb04c0890b6a1ef1 (diff) |
svx: read font and spacing scaling from oox, add bot as UNO prop.
- Read spacing in oox.
- Add spacing scaling as a property.
- Rename property "TextFitToSizeScale" to "TextFitToSizeFontScale"
- Add property "TextFitToSizeSpacingScale"
Change-Id: Icde575e55a3146169d86bb538a57adcf1fa228a7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165633
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'svx/source')
-rw-r--r-- | svx/source/svdraw/svdattr.cxx | 5 | ||||
-rw-r--r-- | svx/source/svdraw/svdotext.cxx | 2 | ||||
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 48 |
3 files changed, 41 insertions, 14 deletions
diff --git a/svx/source/svdraw/svdattr.cxx b/svx/source/svdraw/svdattr.cxx index 19a55c3e810a..914503304bad 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -1134,8 +1134,9 @@ bool SdrTextFitToSizeTypeItem::operator==(const SfxPoolItem& rItem) const { return false; } - - return m_nMaxScale == static_cast<const SdrTextFitToSizeTypeItem&>(rItem).m_nMaxScale; + auto& rTextFitToSizeTypeItem = static_cast<const SdrTextFitToSizeTypeItem&>(rItem); + return mfFontScale == rTextFitToSizeTypeItem.mfFontScale + && mfSpacingScale == rTextFitToSizeTypeItem.mfSpacingScale; } sal_uInt16 SdrTextFitToSizeTypeItem::GetValueCount() const { return 4; } diff --git a/svx/source/svdraw/svdotext.cxx b/svx/source/svdraw/svdotext.cxx index 1a2c28b627f9..8e5e1f835542 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1275,7 +1275,7 @@ void SdrTextObj::autoFitTextForCompatibility(SdrOutliner& rOutliner, const Size& rOutliner.setRoundFontSizeToPt(true); const SdrTextFitToSizeTypeItem& rItem = GetObjectItem(SDRATTR_TEXT_FITTOSIZE); - double fMaxScale = rItem.GetMaxScale(); + double fMaxScale = rItem.getFontScale(); if (fMaxScale > 0.0) { rOutliner.setScalingParameters({ fMaxScale, fMaxScale, 100.0, 100.0 }); diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index 12bd86564261..108ded54426b 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -137,22 +137,22 @@ namespace { /// Calculates what scaling factor will be used for autofit text scaling of this shape. -double GetTextFitToSizeScale(SdrObject* pObject) +SdrTextObj* getTextObjectWithFitToSize(SdrObject* pObject) { SdrTextObj* pTextObj = DynCastSdrTextObj(pObject); if (!pTextObj) { - return 0; + return nullptr; } const SfxItemSet& rTextObjSet = pTextObj->GetMergedItemSet(); if (rTextObjSet.GetItem<SdrTextFitToSizeTypeItem>(SDRATTR_TEXT_FITTOSIZE)->GetValue() != drawing::TextFitToSizeType_AUTOFIT) { - return 0; + return nullptr; } - return pTextObj->GetFontScale(); + return pTextObj; } } @@ -2331,13 +2331,26 @@ bool SvxShape::setPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn break; } - case OWN_ATTR_TEXTFITTOSIZESCALE: + case OWN_ATTR_TEXTFITTOSIZE_FONT_SCALE: { - double nMaxScale = 0.0; - if (rValue >>= nMaxScale) + double fScale = 0.0; + if (rValue >>= fScale) { SdrTextFitToSizeTypeItem aItem(pSdrObject->GetMergedItem(SDRATTR_TEXT_FITTOSIZE)); - aItem.SetMaxScale(nMaxScale); + aItem.setFontScale(fScale); + pSdrObject->SetMergedItem(aItem); + return true; + } + break; + } + + case OWN_ATTR_TEXTFITTOSIZE_SPACING_SCALE: + { + double fScale = 0.0; + if (rValue >>= fScale) + { + SdrTextFitToSizeTypeItem aItem(pSdrObject->GetMergedItem(SDRATTR_TEXT_FITTOSIZE)); + aItem.setSpacingScale(fScale); pSdrObject->SetMergedItem(aItem); return true; } @@ -2858,10 +2871,23 @@ bool SvxShape::getPropertyValueImpl( const OUString&, const SfxItemPropertyMapEn break; } - case OWN_ATTR_TEXTFITTOSIZESCALE: + case OWN_ATTR_TEXTFITTOSIZE_FONT_SCALE: { - double nScale = GetTextFitToSizeScale(GetSdrObject()); - rValue <<= nScale; + auto* pTextObject = getTextObjectWithFitToSize(GetSdrObject()); + if (pTextObject) + { + rValue <<= pTextObject->GetFontScale(); + } + break; + } + + case OWN_ATTR_TEXTFITTOSIZE_SPACING_SCALE: + { + auto* pTextObject = getTextObjectWithFitToSize(GetSdrObject()); + if (pTextObject) + { + rValue <<= pTextObject->GetSpacingScale(); + } break; } |