LibreOffice Module oox (master) 1
connectorshapecontext.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 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <com/sun/star/xml/sax/FastToken.hpp>
21#include <com/sun/star/beans/XMultiPropertySet.hpp>
22
27#include <oox/token/namespaces.hxx>
28#include <oox/token/tokens.hxx>
29
30using namespace oox::core;
31using namespace ::com::sun::star;
32using namespace ::com::sun::star::uno;
33using namespace ::com::sun::star::drawing;
34using namespace ::com::sun::star::beans;
35using namespace ::com::sun::star::xml::sax;
36
37namespace oox::drawingml {
38
39namespace
40{
41class ConnectorShapePropertiesContext : public ::oox::core::ContextHandler2
42{
43 std::vector<ConnectorShapeProperties>& mrConnectorShapePropertiesList;
45
46public:
47 ConnectorShapePropertiesContext(
48 ::oox::core::ContextHandler2Helper const& rParent, ShapePtr& pShapePtr,
49 std::vector<ConnectorShapeProperties>& rConnectorShapePropertiesList);
50
51 virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 aElementToken,
52 const AttributeList& rAttribs) override;
53};
54}
55
56ConnectorShapePropertiesContext::ConnectorShapePropertiesContext(
57 ContextHandler2Helper const& rParent, ShapePtr& pShapePtr,
58 std::vector<ConnectorShapeProperties>& rConnectorShapePropertiesList)
59 : ContextHandler2(rParent)
60 , mrConnectorShapePropertiesList(rConnectorShapePropertiesList)
61 , mpConnectorShapePtr(pShapePtr)
62{
63 mpConnectorShapePtr->setConnectorShape(true);
64}
65
67ConnectorShapePropertiesContext::onCreateContext(sal_Int32 aElementToken,
68 const AttributeList& rAttribs)
69{
70 switch (getBaseToken(aElementToken))
71 {
72 case XML_extLst:
73 case XML_ext:
74 break;
75 case XML_decorative:
76 {
77 mpConnectorShapePtr->setDecorative(rAttribs.getBool(XML_val, false));
78 break;
79 }
80 case XML_cNvPr:
81 mpConnectorShapePtr->setId(rAttribs.getStringDefaulted(XML_id));
82 mpConnectorShapePtr->setName(rAttribs.getStringDefaulted(XML_name));
83 break;
84 case XML_stCxn:
85 {
86 ConnectorShapeProperties aConnectorShapeProps;
87 aConnectorShapeProps.mbStartShape = true;
88 aConnectorShapeProps.maDestShapeId = rAttribs.getStringDefaulted(XML_id);
89 aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx, 0);
90 mrConnectorShapePropertiesList.push_back(aConnectorShapeProps);
91 break;
92 }
93 case XML_endCxn:
94 {
95 ConnectorShapeProperties aConnectorShapeProps;
96 aConnectorShapeProps.mbStartShape = false;
97 aConnectorShapeProps.maDestShapeId = rAttribs.getStringDefaulted(XML_id);
98 aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx, 0);
99 mrConnectorShapePropertiesList.push_back(aConnectorShapeProps);
100 break;
101 }
102 default:
103 break;
104 }
105
106 return this;
107}
108
109ConnectorShapeContext::ConnectorShapeContext(
110 ContextHandler2Helper const& rParent, const ShapePtr& pMasterShapePtr,
111 const ShapePtr& pGroupShapePtr,
112 std::vector<ConnectorShapeProperties>& rConnectorShapePropertiesList)
113 : ShapeContext(rParent, pMasterShapePtr, pGroupShapePtr)
114 , mrConnectorShapePropertiesList(rConnectorShapePropertiesList)
115 , mpConnectorShapePtr(pGroupShapePtr)
116{
117}
118
120
122 const AttributeList& rAttribs)
123{
124 switch (getBaseToken(aElementToken))
125 {
126 case XML_nvCxnSpPr:
127 return new ConnectorShapePropertiesContext(*this, mpConnectorShapePtr,
129 }
130
131 return ShapeContext::onCreateContext(aElementToken, rAttribs);
132}
133
134}
135
136/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to attribute values of an element.
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
std::vector< ConnectorShapeProperties > & mrConnectorShapePropertiesList
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
std::vector< ConnectorShapeProperties > & mrConnectorShapePropertiesList
ShapePtr mpConnectorShapePtr
::rtl::Reference< ContextHandler > ContextHandlerRef
std::shared_ptr< Shape > ShapePtr