Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / drawingml / chart / typegroupcontext.cxx
blob0814dedf93b4c1ad68d5ccdedcfc5f75efc283d0
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 <drawingml/chart/typegroupcontext.hxx>
22 #include <drawingml/chart/seriescontext.hxx>
23 #include <drawingml/chart/typegroupmodel.hxx>
24 #include <oox/core/xmlfilterbase.hxx>
25 #include <oox/helper/attributelist.hxx>
26 #include <oox/token/namespaces.hxx>
27 #include <oox/token/properties.hxx>
28 #include <oox/token/tokens.hxx>
30 namespace oox {
31 namespace drawingml {
32 namespace chart {
34 using ::oox::core::ContextHandler2Helper;
35 using ::oox::core::ContextHandlerRef;
37 UpDownBarsContext::UpDownBarsContext( ContextHandler2Helper& rParent, UpDownBarsModel& rModel ) :
38 ContextBase< UpDownBarsModel >( rParent, rModel )
42 UpDownBarsContext::~UpDownBarsContext()
46 ContextHandlerRef UpDownBarsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
48 switch( getCurrentElement() )
50 case C_TOKEN( upDownBars ):
51 switch( nElement )
53 case C_TOKEN( downBars ):
54 return new ShapePrWrapperContext( *this, mrModel.mxDownBars.create() );
55 case C_TOKEN( gapWidth ):
56 mrModel.mnGapWidth = rAttribs.getInteger( XML_val, 150 );
57 return nullptr;
58 case C_TOKEN( upBars ):
59 return new ShapePrWrapperContext( *this, mrModel.mxUpBars.create() );
61 break;
63 return nullptr;
66 AreaTypeGroupContext::AreaTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
67 TypeGroupContextBase( rParent, rModel )
71 AreaTypeGroupContext::~AreaTypeGroupContext()
75 ContextHandlerRef AreaTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
77 bool bMSO2007Doc = getFilter().isMSO2007Document();
78 if( isRootElement() ) switch( nElement )
80 case C_TOKEN( axId ):
81 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
82 return nullptr;
83 case C_TOKEN( dLbls ):
84 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
85 case C_TOKEN( dropLines ):
86 return new ShapePrWrapperContext( *this, mrModel.mxDropLines.create() );
87 case C_TOKEN( gapDepth ):
88 mrModel.mnGapDepth = rAttribs.getInteger( XML_val, 150 );
89 return nullptr;
90 case C_TOKEN( grouping ):
91 mrModel.mnGrouping = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_standard : XML_clustered );
92 return nullptr;
93 case C_TOKEN( ser ):
94 return new AreaSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
95 case C_TOKEN( varyColors ):
96 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
97 return nullptr;
99 return nullptr;
102 BarTypeGroupContext::BarTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
103 TypeGroupContextBase( rParent, rModel )
107 BarTypeGroupContext::~BarTypeGroupContext()
111 ContextHandlerRef BarTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
113 bool bMSO2007Doc = getFilter().isMSO2007Document();
114 if( isRootElement() ) switch( nElement )
116 case C_TOKEN( axId ):
117 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
118 return nullptr;
119 case C_TOKEN( barDir ):
120 mrModel.mnBarDir = rAttribs.getToken( XML_val, XML_col );
121 return nullptr;
122 case C_TOKEN( dLbls ):
123 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
124 case C_TOKEN( gapDepth ):
125 mrModel.mnGapDepth = rAttribs.getInteger( XML_val, 150 );
126 return nullptr;
127 case C_TOKEN( gapWidth ):
128 mrModel.mnGapWidth = rAttribs.getInteger( XML_val, 150 );
129 return nullptr;
130 case C_TOKEN( grouping ):
131 mrModel.mnGrouping = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_standard : XML_clustered );
132 return nullptr;
133 case C_TOKEN( overlap ):
134 mrModel.mnOverlap = rAttribs.getInteger( XML_val, 0 );
135 return nullptr;
136 case C_TOKEN( ser ):
137 return new BarSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
138 case C_TOKEN( serLines ):
139 return new ShapePrWrapperContext( *this, mrModel.mxSerLines.create() );
140 case C_TOKEN( shape ):
141 mrModel.mnShape = rAttribs.getToken( XML_val, XML_box );
142 return nullptr;
143 case C_TOKEN( varyColors ):
144 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
145 return nullptr;
147 return nullptr;
150 BubbleTypeGroupContext::BubbleTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
151 TypeGroupContextBase( rParent, rModel )
155 BubbleTypeGroupContext::~BubbleTypeGroupContext()
159 ContextHandlerRef BubbleTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
161 bool bMSO2007Doc = getFilter().isMSO2007Document();
162 if( isRootElement() ) switch( nElement )
164 case C_TOKEN( axId ):
165 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
166 return nullptr;
167 case C_TOKEN( bubble3D ):
168 mrModel.mbBubble3d = rAttribs.getBool( XML_val, !bMSO2007Doc );
169 return nullptr;
170 case C_TOKEN( bubbleScale ):
171 mrModel.mnBubbleScale = rAttribs.getInteger( XML_val, 100 );
172 return nullptr;
173 case C_TOKEN( dLbls ):
174 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
175 case C_TOKEN( ser ):
176 return new BubbleSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
177 case C_TOKEN( showNegBubbles ):
178 mrModel.mbShowNegBubbles = rAttribs.getBool( XML_val, !bMSO2007Doc );
179 return nullptr;
180 case C_TOKEN( sizeRepresents ):
181 mrModel.mnSizeRepresents = rAttribs.getToken( XML_val, XML_area );
182 return nullptr;
183 case C_TOKEN( varyColors ):
184 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
185 return nullptr;
187 return nullptr;
190 LineTypeGroupContext::LineTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
191 TypeGroupContextBase( rParent, rModel )
195 LineTypeGroupContext::~LineTypeGroupContext()
199 ContextHandlerRef LineTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
201 bool bMSO2007Doc = getFilter().isMSO2007Document();
202 if( isRootElement() ) switch( nElement )
204 case C_TOKEN( axId ):
205 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
206 return nullptr;
207 case C_TOKEN( dLbls ):
208 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
209 case C_TOKEN( dropLines ):
210 return new ShapePrWrapperContext( *this, mrModel.mxDropLines.create() );
211 case C_TOKEN( gapDepth ):
212 mrModel.mnGapDepth = rAttribs.getInteger( XML_val, 150 );
213 return nullptr;
214 case C_TOKEN( grouping ):
215 mrModel.mnGrouping = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_standard : XML_clustered );
216 return nullptr;
217 case C_TOKEN( hiLowLines ):
218 return new ShapePrWrapperContext( *this, mrModel.mxHiLowLines.create() );
219 case C_TOKEN( marker ):
220 mrModel.mbShowMarker = rAttribs.getBool( XML_val, !bMSO2007Doc );
221 return nullptr;
222 case C_TOKEN( ser ):
223 return new LineSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
224 case C_TOKEN( smooth ):
225 mrModel.mbSmooth = rAttribs.getBool( XML_val, !bMSO2007Doc );
226 return nullptr;
227 case C_TOKEN( upDownBars ):
228 return new UpDownBarsContext( *this, mrModel.mxUpDownBars.create() );
229 case C_TOKEN( varyColors ):
230 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
231 return nullptr;
233 return nullptr;
236 PieTypeGroupContext::PieTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
237 TypeGroupContextBase( rParent, rModel )
241 PieTypeGroupContext::~PieTypeGroupContext()
245 ContextHandlerRef PieTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
247 bool bMSO2007Doc = getFilter().isMSO2007Document();
248 if( isRootElement() ) switch( nElement )
250 case C_TOKEN( dLbls ):
251 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
252 case C_TOKEN( firstSliceAng ):
253 mrModel.mnFirstAngle = rAttribs.getInteger( XML_val, 0 );
254 return nullptr;
255 case C_TOKEN( gapWidth ):
256 mrModel.mnGapWidth = rAttribs.getInteger( XML_val, 150 );
257 return nullptr;
258 case C_TOKEN( holeSize ):
259 mrModel.mnHoleSize = rAttribs.getInteger( XML_val, 10 );
260 return nullptr;
261 case C_TOKEN( ofPieType ):
262 mrModel.mnOfPieType = rAttribs.getToken( XML_val, XML_pie );
263 return nullptr;
264 case C_TOKEN( secondPieSize ):
265 mrModel.mnSecondPieSize = rAttribs.getInteger( XML_val, 75 );
266 return nullptr;
267 case C_TOKEN( ser ):
268 return new PieSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
269 case C_TOKEN( serLines ):
270 return new ShapePrWrapperContext( *this, mrModel.mxSerLines.create() );
271 case C_TOKEN( splitPos ):
272 mrModel.mfSplitPos = rAttribs.getDouble( XML_val, 0.0 );
273 return nullptr;
274 case C_TOKEN( splitType ):
275 mrModel.mnSplitType = rAttribs.getToken( XML_val, XML_auto );
276 return nullptr;
277 case C_TOKEN( varyColors ):
278 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
279 return nullptr;
281 return nullptr;
284 RadarTypeGroupContext::RadarTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
285 TypeGroupContextBase( rParent, rModel )
289 RadarTypeGroupContext::~RadarTypeGroupContext()
293 ContextHandlerRef RadarTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
295 bool bMSO2007Doc = getFilter().isMSO2007Document();
296 if( isRootElement() ) switch( nElement )
298 case C_TOKEN( axId ):
299 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
300 return nullptr;
301 case C_TOKEN( dLbls ):
302 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
303 case C_TOKEN( radarStyle ):
304 mrModel.mnRadarStyle = rAttribs.getToken( XML_val, XML_standard );
305 return nullptr;
306 case C_TOKEN( ser ):
307 return new RadarSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
308 case C_TOKEN( varyColors ):
309 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
310 return nullptr;
312 return nullptr;
315 ScatterTypeGroupContext::ScatterTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
316 TypeGroupContextBase( rParent, rModel )
320 ScatterTypeGroupContext::~ScatterTypeGroupContext()
324 ContextHandlerRef ScatterTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
326 bool bMSO2007Doc = getFilter().isMSO2007Document();
327 if( isRootElement() ) switch( nElement )
329 case C_TOKEN( axId ):
330 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
331 return nullptr;
332 case C_TOKEN( dLbls ):
333 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
334 case C_TOKEN( scatterStyle ):
335 mrModel.mnScatterStyle = rAttribs.getInteger( XML_val, XML_marker );
336 return nullptr;
337 case C_TOKEN( ser ):
338 return new ScatterSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
339 case C_TOKEN( varyColors ):
340 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
341 return nullptr;
343 return nullptr;
346 SurfaceTypeGroupContext::SurfaceTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
347 TypeGroupContextBase( rParent, rModel )
351 SurfaceTypeGroupContext::~SurfaceTypeGroupContext()
355 ContextHandlerRef SurfaceTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
357 bool bMSO2007Doc = getFilter().isMSO2007Document();
358 if( isRootElement() ) switch( nElement )
360 case C_TOKEN( axId ):
361 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
362 return nullptr;
363 case C_TOKEN( ser ):
364 return new SurfaceSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
365 case C_TOKEN( wireframe ):
366 mrModel.mbWireframe = rAttribs.getBool( XML_val, !bMSO2007Doc );
367 return nullptr;
369 return nullptr;
372 } // namespace chart
373 } // namespace drawingml
374 } // namespace oox
376 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */