diff options
author | Attila Szűcs <attila.szucs@collabora.com> | 2024-02-26 10:04:23 +0100 |
---|---|---|
committer | Attila Szűcs <attila.szucs@collabora.com> | 2024-02-27 09:51:43 +0100 |
commit | 0079f0e77e74a355d57b24d3a6b6d1a29f45eb79 (patch) | |
tree | 040478f61d9c09fe31a67b4de7b7cfa01a29eb38 | |
parent | a73b3994fb6a2cc10b2d65cbaad201762610cecc (diff) |
tdf#67347 pptx import: stacked + horz/vert aligment
In case of Stacked, PP calculates in the vertical direction
with the horizontal alignment.
We simulate it by setting TextVerticalAdjust at import time
(from PPTX) based on the ParagraphAdjust of the 1. paragraph
It is not perfect, because we have 1 TextVerticalAdjust / 1 shape,
and it does not support justified,
while we can have many ParagraphAdjust / 1 shape
(if the shape have more paragraphs)
For a better solution we should re-implement the entire stacked
thing, but that is a much bigger task.
Change-Id: I4011be0f118b870ab7f9e2ddc15c6dc5a21f8a89
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163934
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
Reviewed-by: Attila Szűcs <attila.szucs@collabora.com>
-rw-r--r-- | oox/source/drawingml/shape.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx index 8f3aedf3488a..d9a3f8b8db59 100644 --- a/oox/source/drawingml/shape.cxx +++ b/oox/source/drawingml/shape.cxx @@ -90,6 +90,7 @@ #include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/i18n/ScriptType.hpp> +#include <com/sun/star/text/WritingMode2.hpp> #include <basegfx/point/b2dpoint.hxx> #include <basegfx/polygon/b2dpolygon.hxx> @@ -1354,6 +1355,46 @@ Reference< XShape > const & Shape::createAndInsert( // add properties from textbody to shape properties if( mpTextBody ) { + // tdf#67347: In case of Stacked, PP calculates in the vertical direction with the + // horizontal alignment. + // In LO, we simulate it by setting TextVerticalAdjust based on the ParagraphAdjust + // of the 1. paragraph + // It is not perfect, because we have 1 TextVerticalAdjust / 1 shape, and it + // does not support justified, while we can have many ParagraphAdjust / 1 shape + // (if the shape have more paragraphs) + if (mpTextBody->getTextProperties().maPropertyMap.hasProperty(PROP_WritingMode) + && mpTextBody->getTextProperties().maPropertyMap.getProperty(PROP_WritingMode) + == uno::Any(text::WritingMode2::STACKED) + && mpTextBody->getParagraphs().size() > 0 + && aServiceName != "com.sun.star.drawing.GroupShape") + { + std::optional<css::style::ParagraphAdjust>& oParaAdjust + = mpTextBody->getParagraphs()[0]->getProperties().getParaAdjust(); + + if (oParaAdjust) + { + switch (*oParaAdjust) + { + case ParagraphAdjust::ParagraphAdjust_LEFT: + mpTextBody->getTextProperties().meVA + = TextVerticalAdjust::TextVerticalAdjust_TOP; + break; + case ParagraphAdjust::ParagraphAdjust_CENTER: + mpTextBody->getTextProperties().meVA + = TextVerticalAdjust::TextVerticalAdjust_CENTER; + break; + case ParagraphAdjust::ParagraphAdjust_RIGHT: + mpTextBody->getTextProperties().meVA + = TextVerticalAdjust::TextVerticalAdjust_BOTTOM; + break; + default: + break; + } + mpTextBody->getTextProperties().maPropertyMap.setProperty( + PROP_TextVerticalAdjust, mpTextBody->getTextProperties().meVA); + } + } + 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 |