LibreOffice Module oox (master) 1
diagramfragmenthandler.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
23#include "datamodelcontext.hxx"
26#include <oox/token/namespaces.hxx>
27#include <utility>
28
29using namespace ::oox::core;
30using namespace ::com::sun::star::xml::sax;
31using namespace ::com::sun::star::uno;
32
33namespace oox::drawingml {
34
36 const OUString& rFragmentPath,
37 OoxDiagramDataPtr xDataPtr )
38 : FragmentHandler2( rFilter, rFragmentPath )
39 , mpDataPtr(std::move( xDataPtr ))
40{
41}
42
44{
45
46}
47
49{
50
51}
52
55 const AttributeList& )
56{
57 switch( aElement )
58 {
59 case DGM_TOKEN( dataModel ):
60 return new DataModelContext( *this, mpDataPtr );
61 default:
62 break;
63 }
64
65 return this;
66}
67
69 const OUString& rFragmentPath,
70 DiagramLayoutPtr xDataPtr )
71 : FragmentHandler2( rFilter, rFragmentPath )
72 , mpDataPtr(std::move( xDataPtr ))
73{
74}
75
77{
78
79}
80
82{
83
84}
85
88 const AttributeList& rAttribs )
89{
90 switch( aElement )
91 {
92 case DGM_TOKEN( layoutDef ):
93 return new DiagramDefinitionContext( *this, rAttribs, mpDataPtr );
94 default:
95 break;
96 }
97
98 return this;
99}
100
102 const OUString& rFragmentPath,
103 DiagramQStyleMap& rStylesMap ) :
104 FragmentHandler2( rFilter, rFragmentPath ),
105 maStyleEntry(),
106 mrStylesMap( rStylesMap )
107{}
108
110 sal_Int32 nElement,
111 const AttributeList& rAttribs,
112 ShapeStyleRef& o_rStyle )
113{
114 o_rStyle.mnThemedIdx = (nElement == A_TOKEN(fontRef)) ?
115 rAttribs.getToken( XML_idx, XML_none ) : rAttribs.getInteger( XML_idx, 0 );
116 return new ColorContext( *this, o_rStyle.maPhClr );
117}
118
120 const AttributeList& rAttribs )
121{
122 // state-table like way of navigating the color fragment. we
123 // currently ignore everything except styleLbl in the styleDef
124 // element
125 switch( getCurrentElement() )
126 {
127 case XML_ROOT_CONTEXT:
128 return nElement == DGM_TOKEN(styleDef) ? this : nullptr;
129 case DGM_TOKEN(styleDef):
130 return nElement == DGM_TOKEN(styleLbl) ? this : nullptr;
131 case DGM_TOKEN(styleLbl):
132 return nElement == DGM_TOKEN(style) ? this : nullptr;
133 case DGM_TOKEN(style):
134 {
135 switch( nElement )
136 {
137 case A_TOKEN(lnRef): // CT_StyleMatrixReference
138 return createStyleMatrixContext(nElement,rAttribs,
140 case A_TOKEN(fillRef): // CT_StyleMatrixReference
141 return createStyleMatrixContext(nElement,rAttribs,
143 case A_TOKEN(effectRef): // CT_StyleMatrixReference
144 return createStyleMatrixContext(nElement,rAttribs,
146 case A_TOKEN(fontRef): // CT_FontReference
147 return createStyleMatrixContext(nElement,rAttribs,
149 }
150 return nullptr;
151 }
152 }
153
154 return nullptr;
155}
156
158{
159 if( getCurrentElement() == DGM_TOKEN( styleLbl ) )
160 {
161 maStyleName = rAttribs.getStringDefaulted( XML_name);
163 }
164}
165
167{
168 if( getCurrentElement() == DGM_TOKEN(styleLbl) )
170}
171
173 const OUString& rFragmentPath,
174 DiagramColorMap& rColorsMap ) :
175 FragmentHandler2(rFilter,rFragmentPath),
176 maColorEntry(),
177 mrColorsMap(rColorsMap)
178{}
179
181 const AttributeList& /*rAttribs*/ )
182{
183 // state-table like way of navigating the color fragment. we
184 // currently ignore everything except styleLbl in the colorsDef
185 // element
186 switch( getCurrentElement() )
187 {
188 case XML_ROOT_CONTEXT:
189 return nElement == DGM_TOKEN(colorsDef) ? this : nullptr;
190 case DGM_TOKEN(colorsDef):
191 return nElement == DGM_TOKEN(styleLbl) ? this : nullptr;
192 case DGM_TOKEN(styleLbl):
193 {
194 switch( nElement )
195 {
196 // the actual colors - defer to color fragment handlers.
197
198 case DGM_TOKEN(fillClrLst):
199 return new ColorsContext( *this, maColorEntry.maFillColors );
200 case DGM_TOKEN(linClrLst):
201 return new ColorsContext( *this, maColorEntry.maLineColors );
202 case DGM_TOKEN(effectClrLst):
203 return new ColorsContext( *this, maColorEntry.maEffectColors );
204 case DGM_TOKEN(txFillClrLst):
205 return new ColorsContext( *this, maColorEntry.maTextFillColors );
206 case DGM_TOKEN(txLinClrLst):
207 return new ColorsContext( *this, maColorEntry.maTextLineColors );
208 case DGM_TOKEN(txEffectClrLst):
209 return new ColorsContext( *this, maColorEntry.maTextEffectColors );
210 }
211 break;
212 }
213 }
214
215 return nullptr;
216}
217
219{
220 if( getCurrentElement() == DGM_TOKEN(styleLbl) )
221 {
222 maColorName = rAttribs.getStringDefaulted( XML_name);
224 }
225}
226
228{
229 if( getCurrentElement() == DGM_TOKEN(styleLbl) )
231}
232
233}
234
235/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to attribute values of an element.
OUString getStringDefaulted(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute, returns an empty string if attribute not present...
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
Context handler for elements that contain a color value element (a:scrgbClr, a:srgbClr,...
virtual void onStartElement(const AttributeList &rAttribs) override
ColorFragmentHandler(::oox::core::XmlFilterBase &rFilter, const OUString &rFragmentPath, DiagramColorMap &rColorMap)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Same as ColorContext, but handles multiple colors.
DiagramDataFragmentHandler(oox::core::XmlFilterBase &rFilter, const OUString &rFragmentPath, OoxDiagramDataPtr xDataPtr)
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
virtual ~DiagramDataFragmentHandler() noexcept override
virtual void SAL_CALL endDocument() override
virtual ::oox::core::ContextHandlerRef onCreateContext(::sal_Int32 Element, const ::oox::AttributeList &rAttribs) override
DiagramLayoutFragmentHandler(oox::core::XmlFilterBase &rFilter, const OUString &rFragmentPath, DiagramLayoutPtr xDataPtr)
DiagramQStylesFragmentHandler(oox::core::XmlFilterBase &rFilter, const OUString &rFragmentPath, DiagramQStyleMap &rStylesMap)
::oox::core::ContextHandlerRef createStyleMatrixContext(sal_Int32 nElement, const AttributeList &rAttribs, ShapeStyleRef &o_rStyle)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
virtual void onStartElement(const AttributeList &rAttribs) override
const sal_Int32 XML_ROOT_CONTEXT
std::shared_ptr< DiagramData > OoxDiagramDataPtr
Definition: datamodel.hxx:75
std::map< OUString, DiagramColor > DiagramColorMap
std::map< OUString, DiagramStyle > DiagramQStyleMap
std::shared_ptr< DiagramLayout > DiagramLayoutPtr
XML_none
std::vector< oox::drawingml::Color > maTextEffectColors
std::vector< oox::drawingml::Color > maTextFillColors
std::vector< oox::drawingml::Color > maTextLineColors
std::vector< oox::drawingml::Color > maFillColors
std::vector< oox::drawingml::Color > maEffectColors
std::vector< oox::drawingml::Color > maLineColors