diff options
author | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-05-27 20:00:42 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-05-28 14:09:42 +0200 |
commit | 14c4e6155271d04f0a86029635d0a4c0b460146a (patch) | |
tree | 7a5ff528a8858ba5cdf1fd5c1acb766f691cb0b4 /oox/source/drawingml | |
parent | a2179fb76bb1e1da43e8185130866ea334537b13 (diff) |
SmartArt: adjust text size to fit shapes
up to maximal size of primFontSz constraint.
Do not override text size changed by user.
Change-Id: If7ea6bbb96cb839831d877edc274a1b0eefdaf21
Reviewed-on: https://gerrit.libreoffice.org/73050
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox/source/drawingml')
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index dcd19a61c9e4..a9b2f0c1c5a1 100644 --- a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx +++ b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx @@ -31,6 +31,7 @@ #include <drawingml/textrun.hxx> #include <drawingml/customshapeproperties.hxx> #include <tools/gen.hxx> +#include <com/sun/star/drawing/TextFitToSizeType.hpp> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -1127,6 +1128,7 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, // adjust text alignment // Parse constraints, only self margins as a start. + double fFontSize = 0; for (const auto& rConstr : rConstraints) { if (rConstr.mnRefType == XML_w) @@ -1146,9 +1148,10 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, rShape->getShapeProperties().setProperty(nProperty, nValue); } + if (rConstr.mnType == XML_primFontSz) + fFontSize = rConstr.mfValue; } - // TODO: adjust text size to fit shape TextBodyPtr pTextBody = rShape->getTextBody(); if (!pTextBody || pTextBody->getParagraphs().empty() || @@ -1157,6 +1160,16 @@ void AlgAtom::layoutShape( const ShapePtr& rShape, break; } + // adjust text size to fit shape + if (fFontSize != 0) + { + for (auto& aParagraph : pTextBody->getParagraphs()) + for (auto& aRun : aParagraph->getRuns()) + if (!aRun->getTextCharacterProperties().moHeight.has()) + aRun->getTextCharacterProperties().moHeight = fFontSize * 100; + } + pTextBody->getTextProperties().maPropertyMap.setProperty(PROP_TextFitToSize, drawing::TextFitToSizeType_AUTOFIT); + // ECMA-376-1:2016 21.4.7.5 ST_AutoTextRotation (Auto Text Rotation) const sal_Int32 nautoTxRot = maMap.count(XML_autoTxRot) ? maMap.find(XML_autoTxRot)->second : XML_upr; sal_Int32 nShapeRot = rShape->getRotation(); |