/src/libreoffice/oox/source/shape/LockedCanvasContext.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | */ |
9 | | |
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> |
21 | | |
22 | | using namespace com::sun::star; |
23 | | |
24 | | namespace oox::shape |
25 | | { |
26 | | LockedCanvasContext::LockedCanvasContext(FragmentHandler2 const& rParent) |
27 | 40 | : FragmentHandler2(rParent) |
28 | 40 | { |
29 | 40 | mpShapePtr = std::make_shared<oox::drawingml::Shape>(u"com.sun.star.drawing.GroupShape"_ustr); |
30 | 40 | mpShapePtr->setLockedCanvas(true); // will be "LockedCanvas" in InteropGrabBag |
31 | 40 | } |
32 | | |
33 | 40 | LockedCanvasContext::~LockedCanvasContext() = default; |
34 | | |
35 | | ::oox::core::ContextHandlerRef |
36 | | LockedCanvasContext::onCreateContext(sal_Int32 nElementToken, const ::oox::AttributeList& rAttribs) |
37 | 240 | { |
38 | 240 | switch (getBaseToken(nElementToken)) |
39 | 240 | { |
40 | 40 | case XML_nvGrpSpPr: // CT_GvmlGroupShapeNonVisual, child see at end |
41 | 40 | return this; |
42 | 40 | case XML_grpSpPr: // CT_GroupShapeProperties |
43 | 40 | return new oox::drawingml::ShapePropertiesContext(*this, *mpShapePtr); |
44 | 0 | case XML_txSp: // CT_GvmlTextShape |
45 | 0 | break; |
46 | 0 | case XML_sp: // CT_GvmlShape |
47 | 0 | { |
48 | 0 | return new oox::drawingml::ShapeContext( |
49 | 0 | *this, mpShapePtr, |
50 | 0 | std::make_shared<oox::drawingml::Shape>(u"com.sun.star.drawing.CustomShape"_ustr, |
51 | 0 | true)); |
52 | 0 | } |
53 | 0 | case XML_cxnSp: // CT_GvmlConnector |
54 | 0 | { |
55 | 0 | oox::drawingml::ShapePtr pShape = std::make_shared<oox::drawingml::Shape>( |
56 | 0 | u"com.sun.star.drawing.ConnectorShape"_ustr); |
57 | 0 | return new oox::drawingml::ConnectorShapeContext(*this, mpShapePtr, pShape, |
58 | 0 | pShape->getConnectorShapeProperties()); |
59 | 0 | } |
60 | 0 | case XML_pic: // CT_GvmlPicture |
61 | 0 | { |
62 | 0 | return new oox::drawingml::GraphicShapeContext( |
63 | 0 | *this, mpShapePtr, |
64 | 0 | std::make_shared<oox::drawingml::Shape>( |
65 | 0 | u"com.sun.star.drawing.GraphicObjectShape"_ustr)); |
66 | 0 | } |
67 | 0 | case XML_graphicFrame: // CT_GvmlGraphicObjectFrame |
68 | 0 | { |
69 | 0 | return new oox::drawingml::GraphicalObjectFrameContext( |
70 | 0 | *this, mpShapePtr, |
71 | 0 | std::make_shared<oox::drawingml::Shape>( |
72 | 0 | u"com.sun.star.drawing.GraphicObjectShape"_ustr), |
73 | 0 | true); |
74 | 0 | } |
75 | 40 | case XML_grpSp: // CT_GvmlGroupShape |
76 | 40 | { |
77 | 40 | return new oox::drawingml::ShapeGroupContext( |
78 | 40 | *this, mpShapePtr, |
79 | 40 | std::make_shared<oox::drawingml::Shape>(u"com.sun.star.drawing.GroupShape"_ustr)); |
80 | 0 | } |
81 | | // mandatory child elements of CT_GvmlGroupShapeNonVisual |
82 | 40 | case XML_cNvPr: // CT_NonVisualDrawingProps |
83 | 40 | { |
84 | 40 | mpShapePtr->setHidden(rAttribs.getBool(XML_hidden, false)); |
85 | 40 | mpShapePtr->setId(rAttribs.getStringDefaulted(XML_id)); |
86 | 40 | mpShapePtr->setName(rAttribs.getStringDefaulted(XML_name)); |
87 | 40 | break; |
88 | 0 | } |
89 | 40 | case XML_cNvGrpSpPr: // CT_NonVisualGroupDrawingShapeProps |
90 | 40 | break; |
91 | 40 | default: |
92 | 40 | SAL_WARN("oox", "LockedCanvasContext::createFastChildContext: unhandled element:" |
93 | 40 | << getBaseToken(nElementToken)); |
94 | 40 | break; |
95 | 240 | } |
96 | 120 | return nullptr; |
97 | 240 | } |
98 | | } |
99 | | |
100 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |