diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-04-01 20:32:15 +0900 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2024-04-15 14:54:26 +0200 |
commit | 134bbf9ad54ad351b859e31bd4f7aecae17e595c (patch) | |
tree | 738b0ce2b53c46c81fd45aa509c672de1858bde6 /svx | |
parent | 2bae6eaf65d7ffb17f8a14e80268eb0eaf313669 (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>
(cherry picked from commit db64748f1ee771da9da857f95601b9e08b577166)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165709
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'svx')
-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 c518900e6f03..14d5acb356ea 100644 --- a/svx/source/svdraw/svdattr.cxx +++ b/svx/source/svdraw/svdattr.cxx @@ -1021,8 +1021,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 2193369fac82..0f25ce9095a1 100644 --- a/svx/source/svdraw/svdotext.cxx +++ b/svx/source/svdraw/svdotext.cxx @@ -1276,7 +1276,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 b6ef17b86616..6ed78fd17fe5 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -139,22 +139,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; } } @@ -2332,13 +2332,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; } @@ -2859,10 +2872,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; } |