diff options
author | Grzegorz Araminowicz <grzegorz.araminowicz@collabora.com> | 2019-05-27 20:00:42 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-06-03 09:48:01 +0200 |
commit | 9b4cb15e41618fb1943c6c2cb150582dccc5c96c (patch) | |
tree | 820ff26052bf25117e2bd697f38df2d982ee1692 /oox | |
parent | a36236e82c99839d327094b182a167ac53c4ea66 (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>
Reviewed-on: https://gerrit.libreoffice.org/73251
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/diagram/diagramlayoutatoms.cxx | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/oox/source/drawingml/diagram/diagramlayoutatoms.cxx b/oox/source/drawingml/diagram/diagramlayoutatoms.cxx index bc30ec38e219..808960093f29 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; @@ -1105,6 +1106,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) @@ -1124,9 +1126,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() || @@ -1135,6 +1138,17 @@ 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; switch(nautoTxRot) |