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
>(u
"com.sun.star.drawing.GroupShape"_ustr
);
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
>(u
"com.sun.star.drawing.CustomShape"_ustr
,
53 case XML_cxnSp
: // CT_GvmlConnector
55 oox::drawingml::ShapePtr pShape
= std::make_shared
<oox::drawingml::Shape
>(
56 u
"com.sun.star.drawing.ConnectorShape"_ustr
);
57 return new oox::drawingml::ConnectorShapeContext(*this, mpShapePtr
, pShape
,
58 pShape
->getConnectorShapeProperties());
60 case XML_pic
: // CT_GvmlPicture
62 return new oox::drawingml::GraphicShapeContext(
64 std::make_shared
<oox::drawingml::Shape
>(
65 u
"com.sun.star.drawing.GraphicObjectShape"_ustr
));
67 case XML_graphicFrame
: // CT_GvmlGraphicObjectFrame
69 return new oox::drawingml::GraphicalObjectFrameContext(
71 std::make_shared
<oox::drawingml::Shape
>(
72 u
"com.sun.star.drawing.GraphicObjectShape"_ustr
),
75 case XML_grpSp
: // CT_GvmlGroupShape
77 return new oox::drawingml::ShapeGroupContext(
79 std::make_shared
<oox::drawingml::Shape
>(u
"com.sun.star.drawing.GroupShape"_ustr
));
81 // mandatory child elements of CT_GvmlGroupShapeNonVisual
82 case XML_cNvPr
: // CT_NonVisualDrawingProps
84 mpShapePtr
->setHidden(rAttribs
.getBool(XML_hidden
, false));
85 mpShapePtr
->setId(rAttribs
.getStringDefaulted(XML_id
));
86 mpShapePtr
->setName(rAttribs
.getStringDefaulted(XML_name
));
89 case XML_cNvGrpSpPr
: // CT_NonVisualGroupDrawingShapeProps
92 SAL_WARN("oox", "LockedCanvasContext::createFastChildContext: unhandled element:"
93 << getBaseToken(nElementToken
));
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */