diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2021-07-29 22:02:25 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-08-04 14:39:34 +0200 |
commit | 4fb5817ecb614bd0c83afb3627d7caadbfe8c082 (patch) | |
tree | 7efd5c1f1124916cd80ab94696084ed7e0362430 /oox | |
parent | 71b3d7392bd3d0871c7383748d49ae5d46c80e51 (diff) |
tdf#143476 improve import of lockedCanvas
A lockedCanvas is used in Word 2007 to include dml-shapes. It is
treated similar to a group, only that its content is not editable.
This patch changes the implementation so, that the lockedCanvas is
imported as group. Prior only content was imported in the case the
content was a single custom-shape or a single group.
That has resulted in these errors:
Image or line in a lockedCanvas were not imported at all.
Only one of several shapes in a lockedCanvas was imported.
I have changed mpShape to mpShapePtr to reflect the data type and be
consistent with ShapeContext.
The patch changes GraphicImport so, that lockedCanvas as special
version of a group is detected and handled. That solves regression
from commit 3262fc5ef3bde5b158909d11ccb008161ea95519
Change-Id: I57005e64ff073bca6ebb46a404486203fb6802ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119684
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/shape/LockedCanvasContext.cxx | 64 | ||||
-rw-r--r-- | oox/source/shape/LockedCanvasContext.hxx | 4 |
2 files changed, 51 insertions, 17 deletions
diff --git a/oox/source/shape/LockedCanvasContext.cxx b/oox/source/shape/LockedCanvasContext.cxx index 0a56a42eda46..88a3de0040e7 100644 --- a/oox/source/shape/LockedCanvasContext.cxx +++ b/oox/source/shape/LockedCanvasContext.cxx @@ -9,9 +9,13 @@ #include "LockedCanvasContext.hxx" #include <sal/log.hxx> +#include <drawingml/shapepropertiescontext.hxx> +#include <oox/drawingml/connectorshapecontext.hxx> +#include <oox/drawingml/graphicshapecontext.hxx> #include <oox/drawingml/shape.hxx> #include <oox/drawingml/shapecontext.hxx> #include <oox/drawingml/shapegroupcontext.hxx> +#include <oox/helper/attributelist.hxx> #include <oox/token/namespaces.hxx> #include <oox/token/tokens.hxx> @@ -22,34 +26,64 @@ namespace oox::shape LockedCanvasContext::LockedCanvasContext(FragmentHandler2 const& rParent) : FragmentHandler2(rParent) { + mpShapePtr = std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape"); + mpShapePtr->setLockedCanvas(true); // will be "LockedCanvas" in InteropGrabBag } LockedCanvasContext::~LockedCanvasContext() = default; ::oox::core::ContextHandlerRef -LockedCanvasContext::onCreateContext(sal_Int32 nElementToken, - const ::oox::AttributeList& /*rAttribs*/) +LockedCanvasContext::onCreateContext(sal_Int32 nElementToken, const ::oox::AttributeList& rAttribs) { switch (getBaseToken(nElementToken)) { - case XML_lockedCanvas: - case XML_nvGrpSpPr: - case XML_grpSpPr: + case XML_nvGrpSpPr: // CT_GvmlGroupShapeNonVisual, child see at end + return this; + case XML_grpSpPr: // CT_GroupShapeProporties + return new oox::drawingml::ShapePropertiesContext(*this, *mpShapePtr); + case XML_txSp: // CT_GvmlTextShape break; - case XML_sp: + case XML_sp: // CT_GvmlShape { - oox::drawingml::ShapePtr pMasterShape; - mpShape = std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.CustomShape"); - mpShape->setLockedCanvas(true); - return new oox::drawingml::ShapeContext(*this, pMasterShape, mpShape); + return new oox::drawingml::ShapeContext( + *this, mpShapePtr, + std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.CustomShape", true)); } - case XML_grpSp: + case XML_cxnSp: // CT_GvmlConnector { - oox::drawingml::ShapePtr pMasterShape; - mpShape = std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape"); - mpShape->setLockedCanvas(true); - return new oox::drawingml::ShapeGroupContext(*this, pMasterShape, mpShape); + return new oox::drawingml::ConnectorShapeContext( + *this, mpShapePtr, + std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.ConnectorShape")); } + case XML_pic: // CT_GvmlPicture + { + return new oox::drawingml::GraphicShapeContext( + *this, mpShapePtr, + std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GraphicObjectShape")); + } + case XML_graphicFrame: // CT_GvmlGraphicObjectFrame + { + return new oox::drawingml::GraphicalObjectFrameContext( + *this, mpShapePtr, + std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GraphicObjectShape"), + true); + } + case XML_grpSp: // CT_GvmlGroupShape + { + return new oox::drawingml::ShapeGroupContext( + *this, mpShapePtr, + std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape")); + } + // mandatory child elements of CT_GvmlGroupShapeNonVisual + case XML_cNvPr: // CT_NonVisualDrawingProps + { + mpShapePtr->setHidden(rAttribs.getBool(XML_hidden, false)); + mpShapePtr->setId(rAttribs.getString(XML_id).get()); + mpShapePtr->setName(rAttribs.getString(XML_name).get()); + break; + } + case XML_cNvGrpSpPr: // CT_NonVisualGroupDrawingShapeProps + break; default: SAL_WARN("oox", "LockedCanvasContext::createFastChildContext: unhandled element:" << getBaseToken(nElementToken)); diff --git a/oox/source/shape/LockedCanvasContext.hxx b/oox/source/shape/LockedCanvasContext.hxx index bf6766f36b79..076931d092c0 100644 --- a/oox/source/shape/LockedCanvasContext.hxx +++ b/oox/source/shape/LockedCanvasContext.hxx @@ -25,10 +25,10 @@ public: oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElementToken, const ::oox::AttributeList& rAttribs) override; - const oox::drawingml::ShapePtr& getShape() const { return mpShape; } + const oox::drawingml::ShapePtr& getShape() const { return mpShapePtr; } private: - oox::drawingml::ShapePtr mpShape; + oox::drawingml::ShapePtr mpShapePtr; }; } |