Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / oox / source / drawingml / chart / typegroupcontext.cxx
blob96c4d6fc2bfcd1df38a984d5976c84ed12f47fa6
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/tokens.hxx>
29 namespace oox::drawingml::chart {
31 using ::oox::core::ContextHandler2Helper;
32 using ::oox::core::ContextHandlerRef;
34 UpDownBarsContext::UpDownBarsContext( ContextHandler2Helper& rParent, UpDownBarsModel& rModel ) :
35 ContextBase< UpDownBarsModel >( rParent, rModel )
39 UpDownBarsContext::~UpDownBarsContext()
43 ContextHandlerRef UpDownBarsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
45 switch( getCurrentElement() )
47 case C_TOKEN( upDownBars ):
48 switch( nElement )
50 case C_TOKEN( downBars ):
51 return new ShapePrWrapperContext( *this, mrModel.mxDownBars.create() );
52 case C_TOKEN( gapWidth ):
53 mrModel.mnGapWidth = rAttribs.getInteger( XML_val, 150 );
54 return nullptr;
55 case C_TOKEN( upBars ):
56 return new ShapePrWrapperContext( *this, mrModel.mxUpBars.create() );
58 break;
60 return nullptr;
63 AreaTypeGroupContext::AreaTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
64 TypeGroupContextBase( rParent, rModel )
68 AreaTypeGroupContext::~AreaTypeGroupContext()
72 ContextHandlerRef AreaTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
74 bool bMSO2007Doc = getFilter().isMSO2007Document();
75 if( isRootElement() ) switch( nElement )
77 case C_TOKEN( axId ):
78 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
79 return nullptr;
80 case C_TOKEN( dLbls ):
81 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
82 case C_TOKEN( dropLines ):
83 return new ShapePrWrapperContext( *this, mrModel.mxDropLines.create() );
84 case C_TOKEN( gapDepth ):
85 mrModel.mnGapDepth = rAttribs.getInteger( XML_val, 150 );
86 return nullptr;
87 case C_TOKEN( grouping ):
88 mrModel.mnGrouping = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_standard : XML_clustered );
89 return nullptr;
90 case C_TOKEN( ser ):
91 return new AreaSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
92 case C_TOKEN( varyColors ):
93 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
94 return nullptr;
96 return nullptr;
99 BarTypeGroupContext::BarTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
100 TypeGroupContextBase( rParent, rModel )
104 BarTypeGroupContext::~BarTypeGroupContext()
108 ContextHandlerRef BarTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
110 bool bMSO2007Doc = getFilter().isMSO2007Document();
111 if( isRootElement() ) switch( nElement )
113 case C_TOKEN( axId ):
114 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
115 return nullptr;
116 case C_TOKEN( barDir ):
117 mrModel.mnBarDir = rAttribs.getToken( XML_val, XML_col );
118 return nullptr;
119 case C_TOKEN( dLbls ):
120 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
121 case C_TOKEN( gapDepth ):
122 mrModel.mnGapDepth = rAttribs.getInteger( XML_val, 150 );
123 return nullptr;
124 case C_TOKEN( gapWidth ):
125 mrModel.mnGapWidth = rAttribs.getInteger( XML_val, 150 );
126 return nullptr;
127 case C_TOKEN( grouping ):
128 mrModel.mnGrouping = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_standard : XML_clustered );
129 return nullptr;
130 case C_TOKEN( overlap ):
131 mrModel.mnOverlap = rAttribs.getInteger( XML_val, 0 );
132 return nullptr;
133 case C_TOKEN( ser ):
134 return new BarSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
135 case C_TOKEN( serLines ):
136 return new ShapePrWrapperContext( *this, mrModel.mxSerLines.create() );
137 case C_TOKEN( shape ):
138 mrModel.mnShape = rAttribs.getToken( XML_val, XML_box );
139 return nullptr;
140 case C_TOKEN( varyColors ):
141 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
142 return nullptr;
144 return nullptr;
147 BubbleTypeGroupContext::BubbleTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
148 TypeGroupContextBase( rParent, rModel )
152 BubbleTypeGroupContext::~BubbleTypeGroupContext()
156 ContextHandlerRef BubbleTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
158 bool bMSO2007Doc = getFilter().isMSO2007Document();
159 if( isRootElement() ) switch( nElement )
161 case C_TOKEN( axId ):
162 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
163 return nullptr;
164 case C_TOKEN( bubble3D ):
165 mrModel.mbBubble3d = rAttribs.getBool( XML_val, !bMSO2007Doc );
166 return nullptr;
167 case C_TOKEN( bubbleScale ):
168 mrModel.mnBubbleScale = rAttribs.getInteger( XML_val, 100 );
169 return nullptr;
170 case C_TOKEN( dLbls ):
171 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
172 case C_TOKEN( ser ):
173 return new BubbleSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
174 case C_TOKEN( showNegBubbles ):
175 mrModel.mbShowNegBubbles = rAttribs.getBool( XML_val, !bMSO2007Doc );
176 return nullptr;
177 case C_TOKEN( sizeRepresents ):
178 mrModel.mnSizeRepresents = rAttribs.getToken( XML_val, XML_area );
179 return nullptr;
180 case C_TOKEN( varyColors ):
181 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
182 return nullptr;
184 return nullptr;
187 LineTypeGroupContext::LineTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
188 TypeGroupContextBase( rParent, rModel )
192 LineTypeGroupContext::~LineTypeGroupContext()
196 ContextHandlerRef LineTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
198 bool bMSO2007Doc = getFilter().isMSO2007Document();
199 if( isRootElement() ) switch( nElement )
201 case C_TOKEN( axId ):
202 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
203 return nullptr;
204 case C_TOKEN( dLbls ):
205 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
206 case C_TOKEN( dropLines ):
207 return new ShapePrWrapperContext( *this, mrModel.mxDropLines.create() );
208 case C_TOKEN( gapDepth ):
209 mrModel.mnGapDepth = rAttribs.getInteger( XML_val, 150 );
210 return nullptr;
211 case C_TOKEN( grouping ):
212 mrModel.mnGrouping = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_standard : XML_clustered );
213 return nullptr;
214 case C_TOKEN( hiLowLines ):
215 return new ShapePrWrapperContext( *this, mrModel.mxHiLowLines.create() );
216 case C_TOKEN( marker ):
217 mrModel.mbShowMarker = rAttribs.getBool( XML_val, !bMSO2007Doc );
218 return nullptr;
219 case C_TOKEN( ser ):
220 return new LineSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
221 case C_TOKEN( smooth ):
222 mrModel.mbSmooth = rAttribs.getBool( XML_val, !bMSO2007Doc );
223 return nullptr;
224 case C_TOKEN( upDownBars ):
225 return new UpDownBarsContext( *this, mrModel.mxUpDownBars.create() );
226 case C_TOKEN( varyColors ):
227 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
228 return nullptr;
230 return nullptr;
233 PieTypeGroupContext::PieTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
234 TypeGroupContextBase( rParent, rModel )
238 PieTypeGroupContext::~PieTypeGroupContext()
242 ContextHandlerRef PieTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
244 bool bMSO2007Doc = getFilter().isMSO2007Document();
245 if( isRootElement() ) switch( nElement )
247 case C_TOKEN( dLbls ):
248 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
249 case C_TOKEN( firstSliceAng ):
250 mrModel.mnFirstAngle = rAttribs.getInteger( XML_val, 0 );
251 return nullptr;
252 case C_TOKEN( gapWidth ):
253 mrModel.mnGapWidth = rAttribs.getInteger( XML_val, 150 );
254 return nullptr;
255 case C_TOKEN( holeSize ):
256 mrModel.mnHoleSize = rAttribs.getInteger( XML_val, 10 );
257 return nullptr;
258 case C_TOKEN( ofPieType ):
259 mrModel.mnOfPieType = rAttribs.getToken( XML_val, XML_pie );
260 return nullptr;
261 case C_TOKEN( secondPieSize ):
262 mrModel.mnSecondPieSize = rAttribs.getInteger( XML_val, 75 );
263 return nullptr;
264 case C_TOKEN( ser ):
265 return new PieSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
266 case C_TOKEN( serLines ):
267 return new ShapePrWrapperContext( *this, mrModel.mxSerLines.create() );
268 case C_TOKEN( splitPos ):
269 mrModel.mfSplitPos = rAttribs.getDouble( XML_val, 0.0 );
270 return nullptr;
271 case C_TOKEN( splitType ):
272 mrModel.mnSplitType = rAttribs.getToken( XML_val, XML_auto );
273 return nullptr;
274 case C_TOKEN( varyColors ):
275 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
276 return nullptr;
278 return nullptr;
281 RadarTypeGroupContext::RadarTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
282 TypeGroupContextBase( rParent, rModel )
286 RadarTypeGroupContext::~RadarTypeGroupContext()
290 ContextHandlerRef RadarTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
292 bool bMSO2007Doc = getFilter().isMSO2007Document();
293 if( isRootElement() ) switch( nElement )
295 case C_TOKEN( axId ):
296 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
297 return nullptr;
298 case C_TOKEN( dLbls ):
299 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
300 case C_TOKEN( radarStyle ):
301 mrModel.mnRadarStyle = rAttribs.getToken( XML_val, XML_standard );
302 return nullptr;
303 case C_TOKEN( ser ):
304 return new RadarSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
305 case C_TOKEN( varyColors ):
306 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
307 return nullptr;
309 return nullptr;
312 ScatterTypeGroupContext::ScatterTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
313 TypeGroupContextBase( rParent, rModel )
317 ScatterTypeGroupContext::~ScatterTypeGroupContext()
321 ContextHandlerRef ScatterTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
323 bool bMSO2007Doc = getFilter().isMSO2007Document();
324 if( isRootElement() ) switch( nElement )
326 case C_TOKEN( axId ):
327 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
328 return nullptr;
329 case C_TOKEN( dLbls ):
330 return new DataLabelsContext( *this, mrModel.mxLabels.create(bMSO2007Doc) );
331 case C_TOKEN( scatterStyle ):
332 mrModel.mnScatterStyle = rAttribs.getInteger( XML_val, XML_marker );
333 return nullptr;
334 case C_TOKEN( ser ):
335 return new ScatterSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
336 case C_TOKEN( varyColors ):
337 mrModel.mbVaryColors = rAttribs.getBool( XML_val, !bMSO2007Doc );
338 return nullptr;
340 return nullptr;
343 SurfaceTypeGroupContext::SurfaceTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
344 TypeGroupContextBase( rParent, rModel )
348 SurfaceTypeGroupContext::~SurfaceTypeGroupContext()
352 ContextHandlerRef SurfaceTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
354 bool bMSO2007Doc = getFilter().isMSO2007Document();
355 if( isRootElement() ) switch( nElement )
357 case C_TOKEN( axId ):
358 mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
359 return nullptr;
360 case C_TOKEN( ser ):
361 return new SurfaceSeriesContext( *this, mrModel.maSeries.create(bMSO2007Doc) );
362 case C_TOKEN( wireframe ):
363 mrModel.mbWireframe = rAttribs.getBool( XML_val, !bMSO2007Doc );
364 return nullptr;
366 return nullptr;
369 } // namespace oox::drawingml::chart
371 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */