1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include "LockedCanvasContext.hxx"
11 #include <sal/log.hxx>
12 #include <drawingml/shapepropertiescontext.hxx>
13 #include <oox/drawingml/connectorshapecontext.hxx>
14 #include <oox/drawingml/graphicshapecontext.hxx>
15 #include <oox/drawingml/shape.hxx>
16 #include <oox/drawingml/shapecontext.hxx>
17 #include <oox/drawingml/shapegroupcontext.hxx>
18 #include <oox/helper/attributelist.hxx>
19 #include <oox/token/namespaces.hxx>
20 #include <oox/token/tokens.hxx>
22 using namespace com::sun::star
;
26 LockedCanvasContext::LockedCanvasContext(FragmentHandler2
const& rParent
)
27 : FragmentHandler2(rParent
)
29 mpShapePtr
= std::make_shared
<oox::drawingml::Shape
>("com.sun.star.drawing.GroupShape");
30 mpShapePtr
->setLockedCanvas(true); // will be "LockedCanvas" in InteropGrabBag
33 LockedCanvasContext::~LockedCanvasContext() = default;
35 ::oox::core::ContextHandlerRef
36 LockedCanvasContext::onCreateContext(sal_Int32 nElementToken
, const ::oox::AttributeList
& rAttribs
)
38 switch (getBaseToken(nElementToken
))
40 case XML_nvGrpSpPr
: // CT_GvmlGroupShapeNonVisual, child see at end
42 case XML_grpSpPr
: // CT_GroupShapeProperties
43 return new oox::drawingml::ShapePropertiesContext(*this, *mpShapePtr
);
44 case XML_txSp
: // CT_GvmlTextShape
46 case XML_sp
: // CT_GvmlShape
48 return new oox::drawingml::ShapeContext(
50 std::make_shared
<oox::drawingml::Shape
>("com.sun.star.drawing.CustomShape", true));
52 case XML_cxnSp
: // CT_GvmlConnector
54 oox::drawingml::ShapePtr pShape
55 = std::make_shared
<oox::drawingml::Shape
>("com.sun.star.drawing.ConnectorShape");
56 return new oox::drawingml::ConnectorShapeContext(*this, mpShapePtr
, pShape
,
57 pShape
->getConnectorShapeProperties());
59 case XML_pic
: // CT_GvmlPicture
61 return new oox::drawingml::GraphicShapeContext(
63 std::make_shared
<oox::drawingml::Shape
>("com.sun.star.drawing.GraphicObjectShape"));
65 case XML_graphicFrame
: // CT_GvmlGraphicObjectFrame
67 return new oox::drawingml::GraphicalObjectFrameContext(
69 std::make_shared
<oox::drawingml::Shape
>("com.sun.star.drawing.GraphicObjectShape"),
72 case XML_grpSp
: // CT_GvmlGroupShape
74 return new oox::drawingml::ShapeGroupContext(
76 std::make_shared
<oox::drawingml::Shape
>("com.sun.star.drawing.GroupShape"));
78 // mandatory child elements of CT_GvmlGroupShapeNonVisual
79 case XML_cNvPr
: // CT_NonVisualDrawingProps
81 mpShapePtr
->setHidden(rAttribs
.getBool(XML_hidden
, false));
82 mpShapePtr
->setId(rAttribs
.getStringDefaulted(XML_id
));
83 mpShapePtr
->setName(rAttribs
.getStringDefaulted(XML_name
));
86 case XML_cNvGrpSpPr
: // CT_NonVisualGroupDrawingShapeProps
89 SAL_WARN("oox", "LockedCanvasContext::createFastChildContext: unhandled element:"
90 << getBaseToken(nElementToken
));
97 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */