diff options
author | Regényi Balázs <regenyi.balazs@nisz.hu> | 2020-12-01 12:16:12 +0100 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-12-10 10:27:33 +0100 |
commit | bda05ba17362222b74727872579b65b3fa14e3d8 (patch) | |
tree | 60d9448754f1a992e7e9695c8f458b55cfb62d69 /oox/source/vml/vmlshape.cxx | |
parent | 7720f8cf22718415adb3db2304916581f864f884 (diff) |
tdf#41466 DOCX import: fix VML v:shape/v:textbox
VML v:shape/v:textbox element was imported only as
a text frame, losing (otherwise recognized) preset
shape geometry, i.e. replacing a callout bubble
(wedgeRectCallout) and other special shapes with a
plain rectangle.
Thanks to Attila Bakos for the initial help.
Change-Id: I03a608822ed54a20ed07406a08c3539e72958f5b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105299
Tested-by: Jenkins
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'oox/source/vml/vmlshape.cxx')
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 1e3e1f72e64d..7ee10203341e 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -69,6 +69,7 @@ #include <comphelper/processfactory.hxx> #include <comphelper/propertyvalue.hxx> #include <comphelper/storagehelper.hxx> +#include <comphelper/sequenceashashmap.hxx> using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::uno::Any; @@ -259,6 +260,7 @@ ShapeModel::ShapeModel() : mbIsSignatureLine(false) , mbSignatureLineShowSignDate(true) , mbSignatureLineCanAddComment(false) + , mbInGroup(false) { } @@ -459,6 +461,8 @@ Reference< XShape > ShapeBase::convertAndInsert( const Reference< XShapes >& rxS PropertySet aControlShapeProp( xControlShape->getControl() ); aControlShapeProp.setProperty( PROP_EnableVisible, uno::makeAny( false ) ); } + + xShape = finalImplConvertAndInsert(xShape); /* Notify the drawing that a new shape has been inserted. For convenience, pass the rectangle that contains position and size of the shape. */ @@ -887,6 +891,34 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes return xShape; } +Reference<XShape> SimpleShape::finalImplConvertAndInsert(const css::uno::Reference<css::drawing::XShape>& rxShape) const +{ + // tdf#41466 This setting must be done here, because the position of textbox will be set as an + // effect of the PROP_TextBox property setting, and if we do this setting earlier (setting of + // properties of position and size) then the position of textbox will be set with wrong data. + // TODO: TextShape is set if we have rect shape in group; we should use the shape-with-textbox + // mechanism to handle this situation + if (getTextBox() && maService != "com.sun.star.text.TextFrame" && maService != "com.sun.star.drawing.TextShape" + && !maShapeModel.mbInGroup) + { + const GraphicHelper& rGraphicHelper = mrDrawing.getFilter().getGraphicHelper(); + const auto& nLeft = ConversionHelper::decodeMeasureToHmm( + rGraphicHelper, maTypeModel.maMarginLeft, 0, true, true); + PropertySet aPropertySet(rxShape); + aPropertySet.setProperty(PROP_HoriOrientPosition, nLeft); + const auto& nTop = ConversionHelper::decodeMeasureToHmm( + rGraphicHelper, maTypeModel.maMarginTop, 0, true, true); + aPropertySet.setProperty(PROP_VertOrientPosition, nTop); + aPropertySet.setProperty(PROP_TextBox, true); + + // And these properties must be set after textbox creation (set PROP_Textbox property). + // Note: if you set a new property then you have to handle it in the proper + // SwTextBoxHelper::syncProperty function. + if (maTypeModel.maLayoutFlowAlt == "bottom-to-top") + aPropertySet.setAnyProperty(PROP_TextWritingMode, uno::makeAny(text::WritingMode2::BT_LR)); + } + return ShapeBase::finalImplConvertAndInsert(rxShape); +} Reference< XShape > SimpleShape::createEmbeddedPictureObject( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect, OUString const & rGraphicPath ) const { Reference<XGraphic> xGraphic = mrDrawing.getFilter().getGraphicHelper().importEmbeddedGraphic(rGraphicPath); |