cid#1640468 Dereference after null check
[LibreOffice.git] / oox / source / drawingml / connectorshapecontext.cxx
blob62c7a245e87bbbb10f1b3d460b9bf1fee77e8aee
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <com/sun/star/xml/sax/FastToken.hpp>
21 #include <com/sun/star/beans/XMultiPropertySet.hpp>
23 #include <oox/drawingml/connectorshapecontext.hxx>
24 #include <oox/drawingml/drawingmltypes.hxx>
25 #include <oox/drawingml/shape.hxx>
26 #include <oox/helper/attributelist.hxx>
27 #include <oox/token/namespaces.hxx>
28 #include <oox/token/tokens.hxx>
30 using namespace oox::core;
31 using namespace ::com::sun::star;
33 namespace oox::drawingml {
35 ConnectorShapePropertiesContext::ConnectorShapePropertiesContext(
36 ContextHandler2Helper const& rParent, ShapePtr& pShapePtr,
37 std::vector<ConnectorShapeProperties>& rConnectorShapePropertiesList)
38 : ContextHandler2(rParent)
39 , mrConnectorShapePropertiesList(rConnectorShapePropertiesList)
40 , mpConnectorShapePtr(pShapePtr)
42 mpConnectorShapePtr->setConnectorShape(true);
45 ::oox::core::ContextHandlerRef
46 ConnectorShapePropertiesContext::onCreateContext(sal_Int32 aElementToken,
47 const AttributeList& rAttribs)
49 switch (getBaseToken(aElementToken))
51 case XML_extLst:
52 case XML_ext:
53 break;
54 case XML_decorative:
56 mpConnectorShapePtr->setDecorative(rAttribs.getBool(XML_val, false));
57 break;
59 case XML_cNvPr:
60 mpConnectorShapePtr->setId(rAttribs.getStringDefaulted(XML_id));
61 mpConnectorShapePtr->setName(rAttribs.getStringDefaulted(XML_name));
62 break;
63 case XML_stCxn:
65 ConnectorShapeProperties aConnectorShapeProps;
66 aConnectorShapeProps.mbStartShape = true;
67 aConnectorShapeProps.maDestShapeId = rAttribs.getStringDefaulted(XML_id);
68 aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx, 0);
69 mrConnectorShapePropertiesList.push_back(aConnectorShapeProps);
70 break;
72 case XML_endCxn:
74 ConnectorShapeProperties aConnectorShapeProps;
75 aConnectorShapeProps.mbStartShape = false;
76 aConnectorShapeProps.maDestShapeId = rAttribs.getStringDefaulted(XML_id);
77 aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx, 0);
78 mrConnectorShapePropertiesList.push_back(aConnectorShapeProps);
79 break;
81 default:
82 break;
85 return this;
88 ConnectorShapeContext::ConnectorShapeContext(
89 ContextHandler2Helper const& rParent, const ShapePtr& pMasterShapePtr,
90 const ShapePtr& pGroupShapePtr,
91 std::vector<ConnectorShapeProperties>& rConnectorShapePropertiesList)
92 : ShapeContext(rParent, pMasterShapePtr, pGroupShapePtr)
93 , mrConnectorShapePropertiesList(rConnectorShapePropertiesList)
94 , mpConnectorShapePtr(pGroupShapePtr)
98 ConnectorShapeContext::~ConnectorShapeContext() {}
100 ContextHandlerRef ConnectorShapeContext::onCreateContext(sal_Int32 aElementToken,
101 const AttributeList& rAttribs)
103 switch (getBaseToken(aElementToken))
105 case XML_nvCxnSpPr:
106 return new ConnectorShapePropertiesContext(*this, mpConnectorShapePtr,
107 mrConnectorShapePropertiesList);
110 return ShapeContext::onCreateContext(aElementToken, rAttribs);
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */