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_cNvPr:
73 mpConnectorShapePtr->setId(rAttribs.getStringDefaulted(XML_id));
74 mpConnectorShapePtr->setName(rAttribs.getStringDefaulted(XML_name));
75 break;
76 case XML_stCxn:
77 {
78 ConnectorShapeProperties aConnectorShapeProps;
79 aConnectorShapeProps.mbStartShape = true;
80 aConnectorShapeProps.maDestShapeId = rAttribs.getStringDefaulted(XML_id);
81 aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx, 0);
82 mrConnectorShapePropertiesList.push_back(aConnectorShapeProps);
83 break;
84 }
85 case XML_endCxn:
86 {
87 ConnectorShapeProperties aConnectorShapeProps;
88 aConnectorShapeProps.mbStartShape = false;
89 aConnectorShapeProps.maDestShapeId = rAttribs.getStringDefaulted(XML_id);
90 aConnectorShapeProps.mnDestGlueId = rAttribs.getInteger(XML_idx, 0);
91 mrConnectorShapePropertiesList.push_back(aConnectorShapeProps);
92 break;
93 }
94 default:
95 break;
96 }
97
98 return this;
99}
100
101ConnectorShapeContext::ConnectorShapeContext(
102 ContextHandler2Helper const& rParent, const ShapePtr& pMasterShapePtr,
103 const ShapePtr& pGroupShapePtr,
104 std::vector<ConnectorShapeProperties>& rConnectorShapePropertiesList)
105 : ShapeContext(rParent, pMasterShapePtr, pGroupShapePtr)
106 , mrConnectorShapePropertiesList(rConnectorShapePropertiesList)
107 , mpConnectorShapePtr(pGroupShapePtr)
108{
109}
110
112
114 const AttributeList& rAttribs)
115{
116 switch (getBaseToken(aElementToken))
117 {
118 case XML_nvCxnSpPr:
119 return new ConnectorShapePropertiesContext(*this, mpConnectorShapePtr,
121 }
122
123 return ShapeContext::onCreateContext(aElementToken, rAttribs);
124}
125
126}
127
128/* 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