1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
;
32 using namespace ::com::sun::star::uno
;
33 using namespace ::com::sun::star::drawing
;
34 using namespace ::com::sun::star::beans
;
35 using namespace ::com::sun::star::xml::sax
;
37 namespace oox::drawingml
{
41 class ConnectorShapePropertiesContext
: public ::oox::core::ContextHandler2
43 std::vector
<ConnectorShapeProperties
>& mrConnectorShapePropertiesList
;
44 ShapePtr mpConnectorShapePtr
;
47 ConnectorShapePropertiesContext(
48 ::oox::core::ContextHandler2Helper
const& rParent
, ShapePtr
& pShapePtr
,
49 std::vector
<ConnectorShapeProperties
>& rConnectorShapePropertiesList
);
51 virtual ::oox::core::ContextHandlerRef
onCreateContext(sal_Int32 aElementToken
,
52 const AttributeList
& rAttribs
) override
;
56 ConnectorShapePropertiesContext::ConnectorShapePropertiesContext(
57 ContextHandler2Helper
const& rParent
, ShapePtr
& pShapePtr
,
58 std::vector
<ConnectorShapeProperties
>& rConnectorShapePropertiesList
)
59 : ContextHandler2(rParent
)
60 , mrConnectorShapePropertiesList(rConnectorShapePropertiesList
)
61 , mpConnectorShapePtr(pShapePtr
)
63 mpConnectorShapePtr
->setConnectorShape(true);
66 ::oox::core::ContextHandlerRef
67 ConnectorShapePropertiesContext::onCreateContext(sal_Int32 aElementToken
,
68 const AttributeList
& rAttribs
)
70 switch (getBaseToken(aElementToken
))
77 mpConnectorShapePtr
->setDecorative(rAttribs
.getBool(XML_val
, false));
81 mpConnectorShapePtr
->setId(rAttribs
.getStringDefaulted(XML_id
));
82 mpConnectorShapePtr
->setName(rAttribs
.getStringDefaulted(XML_name
));
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
);
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
);
109 ConnectorShapeContext::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
)
119 ConnectorShapeContext::~ConnectorShapeContext() {}
121 ContextHandlerRef
ConnectorShapeContext::onCreateContext(sal_Int32 aElementToken
,
122 const AttributeList
& rAttribs
)
124 switch (getBaseToken(aElementToken
))
127 return new ConnectorShapePropertiesContext(*this, mpConnectorShapePtr
,
128 mrConnectorShapePropertiesList
);
131 return ShapeContext::onCreateContext(aElementToken
, rAttribs
);
136 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */