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 /oox | |
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 'oox')
-rw-r--r-- | oox/inc/drawingml/textbodyproperties.hxx | 1 | ||||
-rw-r--r-- | oox/source/drawingml/diagram/diagram.cxx | 21 | ||||
-rw-r--r-- | oox/source/drawingml/textbodypropertiescontext.cxx | 5 | ||||
-rw-r--r-- | oox/source/token/properties.txt | 2 |
4 files changed, 21 insertions, 8 deletions
diff --git a/oox/inc/drawingml/textbodyproperties.hxx b/oox/inc/drawingml/textbodyproperties.hxx index d935f940638d..46cf99614c56 100644 --- a/oox/inc/drawingml/textbodyproperties.hxx +++ b/oox/inc/drawingml/textbodyproperties.hxx @@ -50,6 +50,7 @@ struct TextBodyProperties OUString msPrst; /// Normal autofit: font scale (default: 100%). sal_Int32 mnFontScale = 100000; + sal_Int32 mnSpacingScale = 100000; OUString msHorzOverflow; std::optional< sal_Int32 > moVertOverflow{}; diff --git a/oox/source/drawingml/diagram/diagram.cxx b/oox/source/drawingml/diagram/diagram.cxx index 029c2c56e962..f63185549c23 100644 --- a/oox/source/drawingml/diagram/diagram.cxx +++ b/oox/source/drawingml/diagram/diagram.cxx @@ -185,30 +185,37 @@ void Diagram::syncDiagramFontHeights() { // Find out the minimum scale within this group. const ShapePairs& rShapePairs = rNameAndPairs.second; - double nMinScale = 100.0; + double fMinFontScale = 100.0; + double fMinSpacingScale = 100.0; for (const auto& rShapePair : rShapePairs) { uno::Reference<beans::XPropertySet> xPropertySet(rShapePair.second, uno::UNO_QUERY); if (xPropertySet.is()) { - double nTextFitToSizeScale = 0.0; - xPropertySet->getPropertyValue("TextFitToSizeScale") >>= nTextFitToSizeScale; - if (nTextFitToSizeScale > 0 && nTextFitToSizeScale < nMinScale) + double fFontScale = 0.0; + double fSpacingScale = 0.0; + xPropertySet->getPropertyValue("TextFitToSizeFontScale") >>= fFontScale; + xPropertySet->getPropertyValue("TextFitToSizeSpacingScale") >>= fSpacingScale; + + if (fFontScale > 0 && fSpacingScale > 0 + && (fFontScale < fMinFontScale || (fFontScale == fMinFontScale && fSpacingScale < fMinSpacingScale))) { - nMinScale = nTextFitToSizeScale; + fMinFontScale = fFontScale; + fMinSpacingScale = fSpacingScale; } } } // Set that minimum scale for all members of the group. - if (nMinScale < 100.0) + if (fMinFontScale < 100.0 || fMinSpacingScale < 100.0) { for (const auto& rShapePair : rShapePairs) { uno::Reference<beans::XPropertySet> xPropertySet(rShapePair.second, uno::UNO_QUERY); if (xPropertySet.is()) { - xPropertySet->setPropertyValue("TextFitToSizeScale", uno::Any(nMinScale)); + xPropertySet->setPropertyValue("TextFitToSizeFontScale", uno::Any(fMinFontScale)); + xPropertySet->setPropertyValue("TextFitToSizeSpacingScale", uno::Any(fMinSpacingScale)); } } } diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx index a08ae8fb9f6d..598bee8daa4e 100644 --- a/oox/source/drawingml/textbodypropertiescontext.cxx +++ b/oox/source/drawingml/textbodypropertiescontext.cxx @@ -237,8 +237,11 @@ ContextHandlerRef TextBodyPropertiesContext::onCreateContext( sal_Int32 aElement case A_TOKEN( normAutofit ): // CT_TextNormalAutofit { mrTextBodyProp.maPropertyMap.setProperty( PROP_TextFitToSize, TextFitToSizeType_AUTOFIT); - mrTextBodyProp.maPropertyMap.setProperty( PROP_TextAutoGrowHeight, false); + mrTextBodyProp.maPropertyMap.setProperty(PROP_TextAutoGrowHeight, false); mrTextBodyProp.mnFontScale = rAttribs.getInteger(XML_fontScale, 100000); + mrTextBodyProp.mnSpacingScale = rAttribs.getInteger(XML_lnSpcReduction, 100000); + mrTextBodyProp.maPropertyMap.setProperty(PROP_TextFitToSizeFontScale, double(mrTextBodyProp.mnFontScale) / 1000.0); + mrTextBodyProp.maPropertyMap.setProperty(PROP_TextFitToSizeSpacingScale, 100.0 - double(mrTextBodyProp.mnSpacingScale) / 1000.0); break; } case A_TOKEN( spAutoFit ): diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 5a0e84708fe3..fd78234fbd0e 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -585,6 +585,8 @@ TextColor TextColumns TextContourFrame TextFitToSize +TextFitToSizeFontScale +TextFitToSizeSpacingScale TextFrames TextHorizontalAdjust TextLeftDistance |