tdf#131098 docx export: write fill property of graphic
[LibreOffice.git] / oox / source / shape / LockedCanvasContext.cxx
blob31f04a991a8340564f1dbdf6965a92a74c809990
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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;
24 namespace oox::shape
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
41 return this;
42 case XML_grpSpPr: // CT_GroupShapeProperties
43 return new oox::drawingml::ShapePropertiesContext(*this, *mpShapePtr);
44 case XML_txSp: // CT_GvmlTextShape
45 break;
46 case XML_sp: // CT_GvmlShape
48 return new oox::drawingml::ShapeContext(
49 *this, mpShapePtr,
50 std::make_shared<oox::drawingml::Shape>(u"com.sun.star.drawing.CustomShape"_ustr,
51 true));
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(
63 *this, mpShapePtr,
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(
70 *this, mpShapePtr,
71 std::make_shared<oox::drawingml::Shape>(
72 u"com.sun.star.drawing.GraphicObjectShape"_ustr),
73 true);
75 case XML_grpSp: // CT_GvmlGroupShape
77 return new oox::drawingml::ShapeGroupContext(
78 *this, mpShapePtr,
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));
87 break;
89 case XML_cNvGrpSpPr: // CT_NonVisualGroupDrawingShapeProps
90 break;
91 default:
92 SAL_WARN("oox", "LockedCanvasContext::createFastChildContext: unhandled element:"
93 << getBaseToken(nElementToken));
94 break;
96 return nullptr;
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */