diff options
author | Balazs Varga <balazs.varga.extern@allotropia.de> | 2024-10-13 20:58:17 +0200 |
---|---|---|
committer | Gabor Kelemen <gabor.kelemen.extern@allotropia.de> | 2024-10-16 20:19:58 +0200 |
commit | 1d9ce0a67a71e51569cd33c26270eeece587a354 (patch) | |
tree | 5eff2680a14dc056d8a827c3d7c774b054baef99 /oox | |
parent | 3233383b2631788e7cfb0dd0b92d879322561616 (diff) |
tdf#162571 - sd: Text box expands or shrinks on left or right or
both sides, depending on the text alignment. Set the text anchor
position based on the first paragraph alignment.
WIP: testing...
Change-Id: Ie1588c3eab5dd24eddb20baf342aca57c0dd39fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174885
Reviewed-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Tested-by: Jenkins
Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/drawingml/shape.cxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 56e04caadbf1..f01c4b90a7a6 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -75,6 +75,7 @@ #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/drawing/HomogenMatrix3.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> +#include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/drawing/GraphicExportFilter.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/drawing/EnhancedCustomShapeAdjustmentValue.hpp> @@ -616,6 +617,16 @@ static SdrTextHorzAdjust lcl_convertAdjust( ParagraphAdjust eAdjust ) return SDRTEXTHORZADJUST_LEFT; } +static TextHorizontalAdjust lcl_convertTextAdjust(ParagraphAdjust eAdjust) +{ + if (eAdjust == ParagraphAdjust_LEFT) + return drawing::TextHorizontalAdjust_LEFT; + else if (eAdjust == ParagraphAdjust_RIGHT) + return drawing::TextHorizontalAdjust_RIGHT; + else + return drawing::TextHorizontalAdjust_BLOCK; +} + // LO does not interpret properties in styles belonging to the text content of a FontWork shape, // but only those in the shape style. This method copies properties from the text content styles to // the shape style. @@ -1508,6 +1519,35 @@ Reference< XShape > const & Shape::createAndInsert( } } + // tdf#162571: In case of shapes with TextAutoGrowHeight, PP calculates/grow the + // shapes size in edit mode (typing) based on the text horizontal alignment. + // In LO, we simulate it by setting TextHorizontalAdjust based on the ParagraphAdjust + // of the 1. paragraph + // It is not perfect, because we have 1 TextHorizontalAdjust / 1 shape, + // while we can have many ParagraphAdjust / 1 shape + if (!mpTextBody->getTextProperties().maPropertyMap.hasProperty(PROP_WritingMode) + && mpTextBody->getParagraphs().size() > 0) + { + std::optional<css::style::ParagraphAdjust>& oParaAdjust + = mpTextBody->getParagraphs()[0]->getProperties().getParaAdjust(); + + bool bAutoHeight = false; + Reference< XPropertySetInfo > xSetInfo(xSet->getPropertySetInfo()); + const OUString& rPropName = PropertyMap::getPropertyName(PROP_TextAutoGrowHeight); + if (xSetInfo.is() && xSetInfo->hasPropertyByName(rPropName)) + { + uno::Any aTextAutoGrowHeight = xSet->getPropertyValue(u"TextAutoGrowHeight"_ustr); + aTextAutoGrowHeight >>= bAutoHeight; + } + + if (bAutoHeight && nShapeRotateInclCamera == 0) + { + mpTextBody->getTextProperties().maPropertyMap.setProperty( + PROP_TextHorizontalAdjust, lcl_convertTextAdjust( + oParaAdjust ? *oParaAdjust : ParagraphAdjust_LEFT)); + } + } + mpTextBody->getTextProperties().pushTextDistances(Size(aShapeRectHmm.Width, aShapeRectHmm.Height)); aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap ); // Push char properties as well - specifically useful when this is a placeholder |