LibreOffice Module oox (master)  1
LockedCanvasContext.cxx
Go to the documentation of this file.
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>
15 #include <oox/drawingml/shape.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  : FragmentHandler2(rParent)
28 {
29  mpShapePtr = std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape");
30  mpShapePtr->setLockedCanvas(true); // will be "LockedCanvas" in InteropGrabBag
31 }
32 
34 
36 LockedCanvasContext::onCreateContext(sal_Int32 nElementToken, const ::oox::AttributeList& rAttribs)
37 {
38  switch (getBaseToken(nElementToken))
39  {
40  case XML_nvGrpSpPr: // CT_GvmlGroupShapeNonVisual, child see at end
41  return this;
42  case XML_grpSpPr: // CT_GroupShapeProperties
44  case XML_txSp: // CT_GvmlTextShape
45  break;
46  case XML_sp: // CT_GvmlShape
47  {
49  *this, mpShapePtr,
50  std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.CustomShape", true));
51  }
52  case XML_cxnSp: // CT_GvmlConnector
53  {
55  *this, mpShapePtr,
56  std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.ConnectorShape"));
57  }
58  case XML_pic: // CT_GvmlPicture
59  {
61  *this, mpShapePtr,
62  std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GraphicObjectShape"));
63  }
64  case XML_graphicFrame: // CT_GvmlGraphicObjectFrame
65  {
67  *this, mpShapePtr,
68  std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GraphicObjectShape"),
69  true);
70  }
71  case XML_grpSp: // CT_GvmlGroupShape
72  {
74  *this, mpShapePtr,
75  std::make_shared<oox::drawingml::Shape>("com.sun.star.drawing.GroupShape"));
76  }
77  // mandatory child elements of CT_GvmlGroupShapeNonVisual
78  case XML_cNvPr: // CT_NonVisualDrawingProps
79  {
80  mpShapePtr->setHidden(rAttribs.getBool(XML_hidden, false));
81  mpShapePtr->setId(rAttribs.getString(XML_id).get());
82  mpShapePtr->setName(rAttribs.getString(XML_name).get());
83  break;
84  }
85  case XML_cNvGrpSpPr: // CT_NonVisualGroupDrawingShapeProps
86  break;
87  default:
88  SAL_WARN("oox", "LockedCanvasContext::createFastChildContext: unhandled element:"
89  << getBaseToken(nElementToken));
90  break;
91  }
92  return nullptr;
93 }
94 }
95 
96 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElementToken, const ::oox::AttributeList &rAttribs) override
oox::drawingml::ShapePtr mpShapePtr
#define SAL_WARN(area, stream)