From 5fb8e29926a5c0dd1ae027f05d48826399cc31a1 Mon Sep 17 00:00:00 2001 From: Oliver Specht Date: Mon, 14 Oct 2024 14:50:06 +0200 Subject: tdf#164065 load vml textbox in a group shape Store (vml) textbox elements to determine whether to load shape text or Writer frame. Replay elements in second step and process depending on the outcome. - result flag not yet available while processing - The text shape in docx bugdoc of tdf#152878 can now be loaded as Writer frame but with wrong size/position. - should also be applied to drawing ml shapes currently always loaded as Writer frame Change-Id: I0778057f9985f5523d91a9d757e00f2968aba350 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174902 Tested-by: Jenkins Reviewed-by: Thorsten Behrens Tested-by: Gabor Kelemen --- oox/source/vml/vmlshape.cxx | 8 ++++++++ oox/source/vml/vmlshapecontext.cxx | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'oox') diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 1f5a8f27c59e..7908dd7527c4 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -150,6 +150,7 @@ void ShapeTypeModel::assignUsed( const ShapeTypeModel& rSource ) ShapeType::ShapeType( Drawing& rDrawing ) : mrDrawing( rDrawing ) + , mbTextBox(false) { } @@ -859,6 +860,13 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes PropertySet(xShape).setAnyProperty(PROP_TextLowerDistance, Any(sal_Int32(getTextBox()->borderDistanceBottom))); xShape->setSize(aSize); } + + if (mbTextBox) + { + // similar to drawingml::Shape::createAndInsert(...) + PropertySet(xShape).setAnyProperty(PROP_TextBox, Any(true)); + } + } } diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index daedc527f465..85c70347e0e8 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -548,7 +548,14 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const Attri if (mrShapeModel.mbInGroup) // FIXME: without this a text will be added into the group-shape instead of its // parent shape - dynamic_cast(mrShape).setService(u"com.sun.star.drawing.TextShape"_ustr); + { + if (mrShape.isTextBox()) + dynamic_cast(mrShape).setService( + u"com.sun.star.drawing.CustomShape"_ustr); + else + dynamic_cast(mrShape).setService( + u"com.sun.star.drawing.TextShape"_ustr); + } else // FIXME: without this we does not handle some properties like shadow dynamic_cast(mrShape).setService(u"com.sun.star.text.TextFrame"_ustr); @@ -591,6 +598,10 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const Attri // handle remaining stuff in base class return ShapeTypeContext::onCreateContext( nElement, rAttribs ); } +void ShapeContext::setWriterShape() +{ + mrShape.setTextBox(true); +} void ShapeContext::setPoints(std::u16string_view rPoints) { -- cgit