1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "oox/drawingml/chart/typegroupcontext.hxx"
25 
26 #include "oox/drawingml/chart/seriescontext.hxx"
27 #include "oox/drawingml/chart/typegroupmodel.hxx"
28 
29 namespace oox {
30 namespace drawingml {
31 namespace chart {
32 
33 // ============================================================================
34 
35 using ::oox::core::ContextHandler2Helper;
36 using ::oox::core::ContextHandlerRef;
37 
38 // ============================================================================
39 
UpDownBarsContext(ContextHandler2Helper & rParent,UpDownBarsModel & rModel)40 UpDownBarsContext::UpDownBarsContext( ContextHandler2Helper& rParent, UpDownBarsModel& rModel ) :
41     ContextBase< UpDownBarsModel >( rParent, rModel )
42 {
43 }
44 
~UpDownBarsContext()45 UpDownBarsContext::~UpDownBarsContext()
46 {
47 }
48 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)49 ContextHandlerRef UpDownBarsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
50 {
51     switch( getCurrentElement() )
52     {
53         case C_TOKEN( upDownBars ):
54             switch( nElement )
55             {
56                 case C_TOKEN( downBars ):
57                     return new ShapePrWrapperContext( *this, mrModel.mxDownBars.create() );
58                 case C_TOKEN( gapWidth ):
59                     mrModel.mnGapWidth = rAttribs.getInteger( XML_val, 150 );
60                     return 0;
61                 case C_TOKEN( upBars ):
62                     return new ShapePrWrapperContext( *this, mrModel.mxUpBars.create() );
63             }
64         break;
65     }
66     return 0;
67 }
68 
69 // ============================================================================
70 
AreaTypeGroupContext(ContextHandler2Helper & rParent,TypeGroupModel & rModel)71 AreaTypeGroupContext::AreaTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
72     TypeGroupContextBase( rParent, rModel )
73 {
74 }
75 
~AreaTypeGroupContext()76 AreaTypeGroupContext::~AreaTypeGroupContext()
77 {
78 }
79 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)80 ContextHandlerRef AreaTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
81 {
82     if( isRootElement() ) switch( nElement )
83     {
84         case C_TOKEN( axId ):
85             mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
86             return 0;
87         case C_TOKEN( dLbls ):
88             return new DataLabelsContext( *this, mrModel.mxLabels.create() );
89         case C_TOKEN( dropLines ):
90             return new ShapePrWrapperContext( *this, mrModel.mxDropLines.create() );
91         case C_TOKEN( gapDepth ):
92             mrModel.mnGapDepth = rAttribs.getInteger( XML_val, 150 );
93             return 0;
94         case C_TOKEN( grouping ):
95             mrModel.mnGrouping = rAttribs.getToken( XML_val, XML_standard );
96             return 0;
97         case C_TOKEN( ser ):
98             return new AreaSeriesContext( *this, mrModel.maSeries.create() );
99         case C_TOKEN( varyColors ):
100             // default is 'false', not 'true' as specified
101             mrModel.mbVaryColors = rAttribs.getBool( XML_val, false );
102             return 0;
103     }
104     return 0;
105 }
106 
107 // ============================================================================
108 
BarTypeGroupContext(ContextHandler2Helper & rParent,TypeGroupModel & rModel)109 BarTypeGroupContext::BarTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
110     TypeGroupContextBase( rParent, rModel )
111 {
112 }
113 
~BarTypeGroupContext()114 BarTypeGroupContext::~BarTypeGroupContext()
115 {
116 }
117 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)118 ContextHandlerRef BarTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
119 {
120     if( isRootElement() ) switch( nElement )
121     {
122         case C_TOKEN( axId ):
123             mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
124             return 0;
125         case C_TOKEN( barDir ):
126             mrModel.mnBarDir = rAttribs.getToken( XML_val, XML_col );
127             return 0;
128         case C_TOKEN( dLbls ):
129             return new DataLabelsContext( *this, mrModel.mxLabels.create() );
130         case C_TOKEN( gapDepth ):
131             mrModel.mnGapDepth = rAttribs.getInteger( XML_val, 150 );
132             return 0;
133         case C_TOKEN( gapWidth ):
134             mrModel.mnGapWidth = rAttribs.getInteger( XML_val, 150 );
135             return 0;
136         case C_TOKEN( grouping ):
137             // default is 'standard', not 'clustered' as specified
138             mrModel.mnGrouping = rAttribs.getToken( XML_val, XML_standard );
139             return 0;
140         case C_TOKEN( overlap ):
141             mrModel.mnOverlap = rAttribs.getInteger( XML_val, 0 );
142             return 0;
143         case C_TOKEN( ser ):
144             return new BarSeriesContext( *this, mrModel.maSeries.create() );
145         case C_TOKEN( serLines ):
146             return new ShapePrWrapperContext( *this, mrModel.mxSerLines.create() );
147         case C_TOKEN( shape ):
148             mrModel.mnShape = rAttribs.getToken( XML_val, XML_box );
149             return 0;
150         case C_TOKEN( varyColors ):
151             // default is 'false', not 'true' as specified
152             mrModel.mbVaryColors = rAttribs.getBool( XML_val, false );
153             return 0;
154     }
155     return 0;
156 }
157 
158 // ============================================================================
159 
BubbleTypeGroupContext(ContextHandler2Helper & rParent,TypeGroupModel & rModel)160 BubbleTypeGroupContext::BubbleTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
161     TypeGroupContextBase( rParent, rModel )
162 {
163 }
164 
~BubbleTypeGroupContext()165 BubbleTypeGroupContext::~BubbleTypeGroupContext()
166 {
167 }
168 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)169 ContextHandlerRef BubbleTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
170 {
171     if( isRootElement() ) switch( nElement )
172     {
173         case C_TOKEN( axId ):
174             mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
175             return 0;
176         case C_TOKEN( bubble3D ):
177             // default is 'false', not 'true' as specified
178             mrModel.mbBubble3d = rAttribs.getBool( XML_val, false );
179             return 0;
180         case C_TOKEN( bubbleScale ):
181             mrModel.mnBubbleScale = rAttribs.getInteger( XML_val, 100 );
182             return 0;
183         case C_TOKEN( dLbls ):
184             return new DataLabelsContext( *this, mrModel.mxLabels.create() );
185         case C_TOKEN( ser ):
186             return new BubbleSeriesContext( *this, mrModel.maSeries.create() );
187         case C_TOKEN( showNegBubbles ):
188             // default is 'false', not 'true' as specified
189             mrModel.mbShowNegBubbles = rAttribs.getBool( XML_val, false );
190             return 0;
191         case C_TOKEN( sizeRepresents ):
192             mrModel.mnSizeRepresents = rAttribs.getToken( XML_val, XML_area );
193             return 0;
194         case C_TOKEN( varyColors ):
195             // default is 'false', not 'true' as specified
196             mrModel.mbVaryColors = rAttribs.getBool( XML_val, false );
197             return 0;
198     }
199     return 0;
200 }
201 
202 // ============================================================================
203 
LineTypeGroupContext(ContextHandler2Helper & rParent,TypeGroupModel & rModel)204 LineTypeGroupContext::LineTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
205     TypeGroupContextBase( rParent, rModel )
206 {
207 }
208 
~LineTypeGroupContext()209 LineTypeGroupContext::~LineTypeGroupContext()
210 {
211 }
212 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)213 ContextHandlerRef LineTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
214 {
215     if( isRootElement() ) switch( nElement )
216     {
217         case C_TOKEN( axId ):
218             mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
219             return 0;
220         case C_TOKEN( dLbls ):
221             return new DataLabelsContext( *this, mrModel.mxLabels.create() );
222         case C_TOKEN( dropLines ):
223             return new ShapePrWrapperContext( *this, mrModel.mxDropLines.create() );
224         case C_TOKEN( gapDepth ):
225             mrModel.mnGapDepth = rAttribs.getInteger( XML_val, 150 );
226             return 0;
227         case C_TOKEN( grouping ):
228             mrModel.mnGrouping = rAttribs.getToken( XML_val, XML_standard );
229             return 0;
230         case C_TOKEN( hiLowLines ):
231             return new ShapePrWrapperContext( *this, mrModel.mxHiLowLines.create() );
232         case C_TOKEN( marker ):
233             // default is 'false', not 'true' as specified
234             mrModel.mbShowMarker = rAttribs.getBool( XML_val, false );
235             return 0;
236         case C_TOKEN( ser ):
237             return new LineSeriesContext( *this, mrModel.maSeries.create() );
238         case C_TOKEN( smooth ):
239             // default is 'false', not 'true' as specified
240             mrModel.mbSmooth = rAttribs.getBool( XML_val, false );
241             return 0;
242         case C_TOKEN( upDownBars ):
243             return new UpDownBarsContext( *this, mrModel.mxUpDownBars.create() );
244         case C_TOKEN( varyColors ):
245             // default is 'false', not 'true' as specified
246             mrModel.mbVaryColors = rAttribs.getBool( XML_val, false );
247             return 0;
248     }
249     return 0;
250 }
251 
252 // ============================================================================
253 
PieTypeGroupContext(ContextHandler2Helper & rParent,TypeGroupModel & rModel)254 PieTypeGroupContext::PieTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
255     TypeGroupContextBase( rParent, rModel )
256 {
257 }
258 
~PieTypeGroupContext()259 PieTypeGroupContext::~PieTypeGroupContext()
260 {
261 }
262 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)263 ContextHandlerRef PieTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
264 {
265     if( isRootElement() ) switch( nElement )
266     {
267         case C_TOKEN( dLbls ):
268             return new DataLabelsContext( *this, mrModel.mxLabels.create() );
269         case C_TOKEN( firstSliceAng ):
270             mrModel.mnFirstAngle = rAttribs.getInteger( XML_val, 0 );
271             return 0;
272         case C_TOKEN( gapWidth ):
273             mrModel.mnGapWidth = rAttribs.getInteger( XML_val, 150 );
274             return 0;
275         case C_TOKEN( holeSize ):
276             mrModel.mnHoleSize = rAttribs.getInteger( XML_val, 10 );
277             return 0;
278         case C_TOKEN( ofPieType ):
279             mrModel.mnOfPieType = rAttribs.getToken( XML_val, XML_pie );
280             return 0;
281         case C_TOKEN( secondPieSize ):
282             mrModel.mnSecondPieSize = rAttribs.getInteger( XML_val, 75 );
283             return 0;
284         case C_TOKEN( ser ):
285             return new PieSeriesContext( *this, mrModel.maSeries.create() );
286         case C_TOKEN( serLines ):
287             return new ShapePrWrapperContext( *this, mrModel.mxSerLines.create() );
288         case C_TOKEN( splitPos ):
289             mrModel.mfSplitPos = rAttribs.getDouble( XML_val, 0.0 );
290             return 0;
291         case C_TOKEN( splitType ):
292             mrModel.mnSplitType = rAttribs.getToken( XML_val, XML_auto );
293             return 0;
294         case C_TOKEN( varyColors ):
295             // default is 'false', not 'true' as specified
296             mrModel.mbVaryColors = rAttribs.getBool( XML_val, false );
297             return 0;
298     }
299     return 0;
300 }
301 
302 // ============================================================================
303 
RadarTypeGroupContext(ContextHandler2Helper & rParent,TypeGroupModel & rModel)304 RadarTypeGroupContext::RadarTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
305     TypeGroupContextBase( rParent, rModel )
306 {
307 }
308 
~RadarTypeGroupContext()309 RadarTypeGroupContext::~RadarTypeGroupContext()
310 {
311 }
312 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)313 ContextHandlerRef RadarTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
314 {
315     if( isRootElement() ) switch( nElement )
316     {
317         case C_TOKEN( axId ):
318             mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
319             return 0;
320         case C_TOKEN( dLbls ):
321             return new DataLabelsContext( *this, mrModel.mxLabels.create() );
322         case C_TOKEN( radarStyle ):
323             mrModel.mnRadarStyle = rAttribs.getToken( XML_val, XML_standard );
324             return 0;
325         case C_TOKEN( ser ):
326             return new RadarSeriesContext( *this, mrModel.maSeries.create() );
327         case C_TOKEN( varyColors ):
328             // default is 'false', not 'true' as specified
329             mrModel.mbVaryColors = rAttribs.getBool( XML_val, false );
330             return 0;
331     }
332     return 0;
333 }
334 
335 // ============================================================================
336 
ScatterTypeGroupContext(ContextHandler2Helper & rParent,TypeGroupModel & rModel)337 ScatterTypeGroupContext::ScatterTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
338     TypeGroupContextBase( rParent, rModel )
339 {
340 }
341 
~ScatterTypeGroupContext()342 ScatterTypeGroupContext::~ScatterTypeGroupContext()
343 {
344 }
345 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)346 ContextHandlerRef ScatterTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
347 {
348     if( isRootElement() ) switch( nElement )
349     {
350         case C_TOKEN( axId ):
351             mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
352             return 0;
353         case C_TOKEN( dLbls ):
354             return new DataLabelsContext( *this, mrModel.mxLabels.create() );
355         case C_TOKEN( scatterStyle ):
356             mrModel.mnScatterStyle = rAttribs.getInteger( XML_val, XML_marker );
357             return 0;
358         case C_TOKEN( ser ):
359             return new ScatterSeriesContext( *this, mrModel.maSeries.create() );
360         case C_TOKEN( varyColors ):
361             // default is 'false', not 'true' as specified
362             mrModel.mbVaryColors = rAttribs.getBool( XML_val, false );
363             return 0;
364     }
365     return 0;
366 }
367 
368 // ============================================================================
369 
SurfaceTypeGroupContext(ContextHandler2Helper & rParent,TypeGroupModel & rModel)370 SurfaceTypeGroupContext::SurfaceTypeGroupContext( ContextHandler2Helper& rParent, TypeGroupModel& rModel ) :
371     TypeGroupContextBase( rParent, rModel )
372 {
373 }
374 
~SurfaceTypeGroupContext()375 SurfaceTypeGroupContext::~SurfaceTypeGroupContext()
376 {
377 }
378 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)379 ContextHandlerRef SurfaceTypeGroupContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
380 {
381     if( isRootElement() ) switch( nElement )
382     {
383         case C_TOKEN( axId ):
384             mrModel.maAxisIds.push_back( rAttribs.getInteger( XML_val, -1 ) );
385             return 0;
386         case C_TOKEN( ser ):
387             return new SurfaceSeriesContext( *this, mrModel.maSeries.create() );
388         case C_TOKEN( wireframe ):
389             // default is 'false', not 'true' as specified
390             mrModel.mbWireframe = rAttribs.getBool( XML_val, false );
391             return 0;
392     }
393     return 0;
394 }
395 
396 // ============================================================================
397 
398 } // namespace chart
399 } // namespace drawingml
400 } // namespace oox
401