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/seriescontext.hxx"
25
26 #include "oox/drawingml/shapepropertiescontext.hxx"
27 #include "oox/drawingml/textbodycontext.hxx"
28 #include "oox/drawingml/chart/datasourcecontext.hxx"
29 #include "oox/drawingml/chart/seriesmodel.hxx"
30 #include "oox/drawingml/chart/titlecontext.hxx"
31
32 namespace oox {
33 namespace drawingml {
34 namespace chart {
35
36 // ============================================================================
37
38 using ::oox::core::ContextHandler2;
39 using ::oox::core::ContextHandler2Helper;
40 using ::oox::core::ContextHandlerRef;
41 using ::rtl::OUString;
42
43 // ============================================================================
44
45 namespace {
46
lclDataLabelSharedCreateContext(ContextHandler2 & rContext,sal_Int32 nElement,const AttributeList & rAttribs,DataLabelModelBase & orModel)47 ContextHandlerRef lclDataLabelSharedCreateContext( ContextHandler2& rContext,
48 sal_Int32 nElement, const AttributeList& rAttribs, DataLabelModelBase& orModel )
49 {
50 if( rContext.isRootElement() ) switch( nElement )
51 {
52 case C_TOKEN( delete ):
53 // default is 'false', not 'true' as specified
54 orModel.mbDeleted = rAttribs.getBool( XML_val, false );
55 return 0;
56 case C_TOKEN( dLblPos ):
57 orModel.monLabelPos = rAttribs.getToken( XML_val, XML_TOKEN_INVALID );
58 return 0;
59 case C_TOKEN( numFmt ):
60 orModel.maNumberFormat.setAttributes( rAttribs );
61 return 0;
62 case C_TOKEN( showBubbleSize ):
63 orModel.mobShowBubbleSize = rAttribs.getBool( XML_val );
64 return 0;
65 case C_TOKEN( showCatName ):
66 orModel.mobShowCatName = rAttribs.getBool( XML_val );
67 return 0;
68 case C_TOKEN( showLegendKey ):
69 orModel.mobShowLegendKey = rAttribs.getBool( XML_val );
70 return 0;
71 case C_TOKEN( showPercent ):
72 orModel.mobShowPercent = rAttribs.getBool( XML_val );
73 return 0;
74 case C_TOKEN( showSerName ):
75 orModel.mobShowSerName = rAttribs.getBool( XML_val );
76 return 0;
77 case C_TOKEN( showVal ):
78 orModel.mobShowVal = rAttribs.getBool( XML_val );
79 return 0;
80 case C_TOKEN( separator ):
81 // collect separator text in onCharacters()
82 return &rContext;
83 case C_TOKEN( spPr ):
84 return new ShapePropertiesContext( rContext, orModel.mxShapeProp.create() );
85 case C_TOKEN( txPr ):
86 return new TextBodyContext( rContext, orModel.mxTextProp.create() );
87 }
88 return 0;
89 }
90
lclDataLabelSharedCharacters(ContextHandler2 & rContext,const OUString & rChars,DataLabelModelBase & orModel)91 void lclDataLabelSharedCharacters( ContextHandler2& rContext, const OUString& rChars, DataLabelModelBase& orModel )
92 {
93 if( rContext.isCurrentElement( C_TOKEN( separator ) ) )
94 orModel.moaSeparator = rChars;
95 }
96
97 } // namespace
98
99 // ============================================================================
100
DataLabelContext(ContextHandler2Helper & rParent,DataLabelModel & rModel)101 DataLabelContext::DataLabelContext( ContextHandler2Helper& rParent, DataLabelModel& rModel ) :
102 ContextBase< DataLabelModel >( rParent, rModel )
103 {
104 }
105
~DataLabelContext()106 DataLabelContext::~DataLabelContext()
107 {
108 }
109
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)110 ContextHandlerRef DataLabelContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
111 {
112 if( isRootElement() ) switch( nElement )
113 {
114 case C_TOKEN( idx ):
115 mrModel.mnIndex = rAttribs.getInteger( XML_val, -1 );
116 return 0;
117 case C_TOKEN( layout ):
118 return new LayoutContext( *this, mrModel.mxLayout.create() );
119 case C_TOKEN( tx ):
120 return new TextContext( *this, mrModel.mxText.create() );
121 }
122 return lclDataLabelSharedCreateContext( *this, nElement, rAttribs, mrModel );
123 }
124
onCharacters(const OUString & rChars)125 void DataLabelContext::onCharacters( const OUString& rChars )
126 {
127 lclDataLabelSharedCharacters( *this, rChars, mrModel );
128 }
129
130 // ============================================================================
131
DataLabelsContext(ContextHandler2Helper & rParent,DataLabelsModel & rModel)132 DataLabelsContext::DataLabelsContext( ContextHandler2Helper& rParent, DataLabelsModel& rModel ) :
133 ContextBase< DataLabelsModel >( rParent, rModel )
134 {
135 }
136
~DataLabelsContext()137 DataLabelsContext::~DataLabelsContext()
138 {
139 }
140
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)141 ContextHandlerRef DataLabelsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
142 {
143 if( isRootElement() ) switch( nElement )
144 {
145 case C_TOKEN( dLbl ):
146 return new DataLabelContext( *this, mrModel.maPointLabels.create() );
147 case C_TOKEN( leaderLines ):
148 return new ShapePrWrapperContext( *this, mrModel.mxLeaderLines.create() );
149 case C_TOKEN( showLeaderLines ):
150 // default is 'false', not 'true' as specified
151 mrModel.mbShowLeaderLines = rAttribs.getBool( XML_val, false );
152 return 0;
153 }
154 return lclDataLabelSharedCreateContext( *this, nElement, rAttribs, mrModel );
155 }
156
onCharacters(const OUString & rChars)157 void DataLabelsContext::onCharacters( const OUString& rChars )
158 {
159 lclDataLabelSharedCharacters( *this, rChars, mrModel );
160 }
161
162 // ============================================================================
163
PictureOptionsContext(ContextHandler2Helper & rParent,PictureOptionsModel & rModel)164 PictureOptionsContext::PictureOptionsContext( ContextHandler2Helper& rParent, PictureOptionsModel& rModel ) :
165 ContextBase< PictureOptionsModel >( rParent, rModel )
166 {
167 }
168
~PictureOptionsContext()169 PictureOptionsContext::~PictureOptionsContext()
170 {
171 }
172
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)173 ContextHandlerRef PictureOptionsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
174 {
175 if( isRootElement() ) switch( nElement )
176 {
177 case C_TOKEN( applyToEnd ):
178 // default is 'false', not 'true' as specified
179 mrModel.mbApplyToEnd = rAttribs.getBool( XML_val, false );
180 return 0;
181 case C_TOKEN( applyToFront ):
182 // default is 'false', not 'true' as specified
183 mrModel.mbApplyToFront = rAttribs.getBool( XML_val, false );
184 return 0;
185 case C_TOKEN( applyToSides ):
186 // default is 'false', not 'true' as specified
187 mrModel.mbApplyToSides = rAttribs.getBool( XML_val, false );
188 return 0;
189 case C_TOKEN( pictureFormat ):
190 mrModel.mnPictureFormat = rAttribs.getToken( XML_val, XML_stretch );
191 return 0;
192 case C_TOKEN( pictureStackUnit ):
193 mrModel.mfStackUnit = rAttribs.getDouble( XML_val, 1.0 );
194 return 0;
195 }
196 return 0;
197 }
198
199 // ============================================================================
200
ErrorBarContext(ContextHandler2Helper & rParent,ErrorBarModel & rModel)201 ErrorBarContext::ErrorBarContext( ContextHandler2Helper& rParent, ErrorBarModel& rModel ) :
202 ContextBase< ErrorBarModel >( rParent, rModel )
203 {
204 }
205
~ErrorBarContext()206 ErrorBarContext::~ErrorBarContext()
207 {
208 }
209
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)210 ContextHandlerRef ErrorBarContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
211 {
212 if( isRootElement() ) switch( nElement )
213 {
214 case C_TOKEN( errBarType ):
215 mrModel.mnTypeId = rAttribs.getToken( XML_val, XML_both );
216 return 0;
217 case C_TOKEN( errDir ):
218 mrModel.mnDirection = rAttribs.getToken( XML_val, XML_TOKEN_INVALID );
219 return 0;
220 case C_TOKEN( errValType ):
221 mrModel.mnValueType = rAttribs.getToken( XML_val, XML_fixedVal );
222 return 0;
223 case C_TOKEN( minus ):
224 return new DataSourceContext( *this, mrModel.maSources.create( ErrorBarModel::MINUS ) );
225 case C_TOKEN( noEndCap ):
226 // default is 'false', not 'true' as specified
227 mrModel.mbNoEndCap = rAttribs.getBool( XML_val, false );
228 return 0;
229 case C_TOKEN( plus ):
230 return new DataSourceContext( *this, mrModel.maSources.create( ErrorBarModel::PLUS ) );
231 case C_TOKEN( spPr ):
232 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
233 case C_TOKEN( val ):
234 mrModel.mfValue = rAttribs.getDouble( XML_val, 0.0 );
235 return 0;
236 }
237 return 0;
238 }
239
240 // ============================================================================
241
TrendlineLabelContext(ContextHandler2Helper & rParent,TrendlineLabelModel & rModel)242 TrendlineLabelContext::TrendlineLabelContext( ContextHandler2Helper& rParent, TrendlineLabelModel& rModel ) :
243 ContextBase< TrendlineLabelModel >( rParent, rModel )
244 {
245 }
246
~TrendlineLabelContext()247 TrendlineLabelContext::~TrendlineLabelContext()
248 {
249 }
250
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)251 ContextHandlerRef TrendlineLabelContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
252 {
253 if( isRootElement() ) switch( nElement )
254 {
255 case C_TOKEN( layout ):
256 return new LayoutContext( *this, mrModel.mxLayout.create() );
257 case C_TOKEN( numFmt ):
258 mrModel.maNumberFormat.setAttributes( rAttribs );
259 return 0;
260 case C_TOKEN( spPr ):
261 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
262 case C_TOKEN( tx ):
263 return new TextContext( *this, mrModel.mxText.create() );
264 case C_TOKEN( txPr ):
265 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
266 }
267 return 0;
268 }
269
270 // ============================================================================
271
TrendlineContext(ContextHandler2Helper & rParent,TrendlineModel & rModel)272 TrendlineContext::TrendlineContext( ContextHandler2Helper& rParent, TrendlineModel& rModel ) :
273 ContextBase< TrendlineModel >( rParent, rModel )
274 {
275 }
276
~TrendlineContext()277 TrendlineContext::~TrendlineContext()
278 {
279 }
280
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)281 ContextHandlerRef TrendlineContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
282 {
283 if( isRootElement() ) switch( nElement )
284 {
285 case C_TOKEN( backward ):
286 mrModel.mfBackward = rAttribs.getDouble( XML_val, 0.0 );
287 return 0;
288 case C_TOKEN( dispEq ):
289 // default is 'false', not 'true' as specified
290 mrModel.mbDispEquation = rAttribs.getBool( XML_val, false );
291 return 0;
292 case C_TOKEN( dispRSqr ):
293 // default is 'false', not 'true' as specified
294 mrModel.mbDispRSquared = rAttribs.getBool( XML_val, false );
295 return 0;
296 case C_TOKEN( forward ):
297 mrModel.mfForward = rAttribs.getDouble( XML_val, 0.0 );
298 return 0;
299 case C_TOKEN( intercept ):
300 mrModel.mfIntercept = rAttribs.getDouble( XML_val, 0.0 );
301 return 0;
302 case C_TOKEN( name ):
303 return this; // collect name in onCharacters()
304 case C_TOKEN( order ):
305 mrModel.mnOrder = rAttribs.getInteger( XML_val, 2 );
306 return 0;
307 case C_TOKEN( period ):
308 mrModel.mnPeriod = rAttribs.getInteger( XML_val, 2 );
309 return 0;
310 case C_TOKEN( spPr ):
311 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
312 case C_TOKEN( trendlineLbl ):
313 return new TrendlineLabelContext( *this, mrModel.mxLabel.create() );
314 case C_TOKEN( trendlineType ):
315 mrModel.mnTypeId = rAttribs.getToken( XML_val, XML_linear );
316 return 0;
317 }
318 return 0;
319 }
320
onCharacters(const OUString & rChars)321 void TrendlineContext::onCharacters( const OUString& rChars )
322 {
323 if( isCurrentElement( C_TOKEN( name ) ) )
324 mrModel.maName = rChars;
325 }
326
327 // ============================================================================
328
DataPointContext(ContextHandler2Helper & rParent,DataPointModel & rModel)329 DataPointContext::DataPointContext( ContextHandler2Helper& rParent, DataPointModel& rModel ) :
330 ContextBase< DataPointModel >( rParent, rModel )
331 {
332 }
333
~DataPointContext()334 DataPointContext::~DataPointContext()
335 {
336 }
337
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)338 ContextHandlerRef DataPointContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
339 {
340 switch( getCurrentElement() )
341 {
342 case C_TOKEN( dPt ):
343 switch( nElement )
344 {
345 case C_TOKEN( bubble3D ):
346 mrModel.mobBubble3d = rAttribs.getBool( XML_val );
347 return 0;
348 case C_TOKEN( explosion ):
349 // if the 'val' attribute is missing, series explosion remains unchanged
350 mrModel.monExplosion = rAttribs.getInteger( XML_val );
351 return 0;
352 case C_TOKEN( idx ):
353 mrModel.mnIndex = rAttribs.getInteger( XML_val, -1 );
354 return 0;
355 case C_TOKEN( invertIfNegative ):
356 // default is 'false', not 'true' as specified (value not derived from series!)
357 mrModel.mbInvertNeg = rAttribs.getBool( XML_val, false );
358 return 0;
359 case C_TOKEN( marker ):
360 return this;
361 case C_TOKEN( pictureOptions ):
362 return new PictureOptionsContext( *this, mrModel.mxPicOptions.create() );
363 case C_TOKEN( spPr ):
364 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
365 }
366 break;
367
368 case C_TOKEN( marker ):
369 switch( nElement )
370 {
371 case C_TOKEN( size ):
372 mrModel.monMarkerSize = rAttribs.getInteger( XML_val, 5 );
373 return 0;
374 case C_TOKEN( spPr ):
375 return new ShapePropertiesContext( *this, mrModel.mxMarkerProp.create() );
376 case C_TOKEN( symbol ):
377 mrModel.monMarkerSymbol = rAttribs.getToken( XML_val, XML_none );
378 return 0;
379 }
380 break;
381 }
382 return 0;
383 }
384
385 // ============================================================================
386
SeriesContextBase(ContextHandler2Helper & rParent,SeriesModel & rModel)387 SeriesContextBase::SeriesContextBase( ContextHandler2Helper& rParent, SeriesModel& rModel ) :
388 ContextBase< SeriesModel >( rParent, rModel )
389 {
390 }
391
~SeriesContextBase()392 SeriesContextBase::~SeriesContextBase()
393 {
394 }
395
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)396 ContextHandlerRef SeriesContextBase::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
397 {
398 switch( getCurrentElement() )
399 {
400 case C_TOKEN( ser ):
401 switch( nElement )
402 {
403 case C_TOKEN( idx ):
404 mrModel.mnIndex = rAttribs.getInteger( XML_val, -1 );
405 return 0;
406 case C_TOKEN( order ):
407 mrModel.mnOrder = rAttribs.getInteger( XML_val, -1 );
408 return 0;
409 case C_TOKEN( spPr ):
410 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
411 case C_TOKEN( tx ):
412 return new TextContext( *this, mrModel.mxText.create() );
413 }
414 break;
415
416 case C_TOKEN( marker ):
417 switch( nElement )
418 {
419 case C_TOKEN( size ):
420 mrModel.mnMarkerSize = rAttribs.getInteger( XML_val, 5 );
421 return 0;
422 case C_TOKEN( spPr ):
423 return new ShapePropertiesContext( *this, mrModel.mxMarkerProp.create() );
424 case C_TOKEN( symbol ):
425 mrModel.mnMarkerSymbol = rAttribs.getToken( XML_val, XML_none );
426 return 0;
427 }
428 break;
429 }
430 return 0;
431 }
432
433 // ============================================================================
434
AreaSeriesContext(ContextHandler2Helper & rParent,SeriesModel & rModel)435 AreaSeriesContext::AreaSeriesContext( ContextHandler2Helper& rParent, SeriesModel& rModel ) :
436 SeriesContextBase( rParent, rModel )
437 {
438 }
439
~AreaSeriesContext()440 AreaSeriesContext::~AreaSeriesContext()
441 {
442 }
443
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)444 ContextHandlerRef AreaSeriesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
445 {
446 switch( getCurrentElement() )
447 {
448 case C_TOKEN( ser ):
449 switch( nElement )
450 {
451 case C_TOKEN( cat ):
452 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::CATEGORIES ) );
453 case C_TOKEN( errBars ):
454 return new ErrorBarContext( *this, mrModel.maErrorBars.create() );
455 case C_TOKEN( dLbls ):
456 return new DataLabelsContext( *this, mrModel.mxLabels.create() );
457 case C_TOKEN( dPt ):
458 return new DataPointContext( *this, mrModel.maPoints.create() );
459 case C_TOKEN( trendline ):
460 return new TrendlineContext( *this, mrModel.maTrendlines.create() );
461 case C_TOKEN( val ):
462 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::VALUES ) );
463 }
464 break;
465 }
466 return SeriesContextBase::onCreateContext( nElement, rAttribs );
467 }
468
469 // ============================================================================
470
BarSeriesContext(ContextHandler2Helper & rParent,SeriesModel & rModel)471 BarSeriesContext::BarSeriesContext( ContextHandler2Helper& rParent, SeriesModel& rModel ) :
472 SeriesContextBase( rParent, rModel )
473 {
474 }
475
~BarSeriesContext()476 BarSeriesContext::~BarSeriesContext()
477 {
478 }
479
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)480 ContextHandlerRef BarSeriesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
481 {
482 switch( getCurrentElement() )
483 {
484 case C_TOKEN( ser ):
485 switch( nElement )
486 {
487 case C_TOKEN( cat ):
488 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::CATEGORIES ) );
489 case C_TOKEN( dLbls ):
490 return new DataLabelsContext( *this, mrModel.mxLabels.create() );
491 case C_TOKEN( dPt ):
492 return new DataPointContext( *this, mrModel.maPoints.create() );
493 case C_TOKEN( errBars ):
494 return new ErrorBarContext( *this, mrModel.maErrorBars.create() );
495 case C_TOKEN( invertIfNegative ):
496 // default is 'false', not 'true' as specified
497 mrModel.mbInvertNeg = rAttribs.getBool( XML_val, false );
498 return 0;
499 case C_TOKEN( pictureOptions ):
500 return new PictureOptionsContext( *this, mrModel.mxPicOptions.create() );
501 case C_TOKEN( shape ):
502 // missing attribute does not change shape type to 'box' as specified
503 mrModel.monShape = rAttribs.getToken( XML_val );
504 return 0;
505 case C_TOKEN( trendline ):
506 return new TrendlineContext( *this, mrModel.maTrendlines.create() );
507 case C_TOKEN( val ):
508 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::VALUES ) );
509 }
510 break;
511 }
512 return SeriesContextBase::onCreateContext( nElement, rAttribs );
513 }
514
515 // ============================================================================
516
BubbleSeriesContext(ContextHandler2Helper & rParent,SeriesModel & rModel)517 BubbleSeriesContext::BubbleSeriesContext( ContextHandler2Helper& rParent, SeriesModel& rModel ) :
518 SeriesContextBase( rParent, rModel )
519 {
520 }
521
~BubbleSeriesContext()522 BubbleSeriesContext::~BubbleSeriesContext()
523 {
524 }
525
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)526 ContextHandlerRef BubbleSeriesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
527 {
528 switch( getCurrentElement() )
529 {
530 case C_TOKEN( ser ):
531 switch( nElement )
532 {
533 case C_TOKEN( bubble3D ):
534 // default is 'false', not 'true' as specified
535 mrModel.mbBubble3d = rAttribs.getBool( XML_val, false );
536 return 0;
537 case C_TOKEN( bubbleSize ):
538 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::POINTS ) );
539 case C_TOKEN( dLbls ):
540 return new DataLabelsContext( *this, mrModel.mxLabels.create() );
541 case C_TOKEN( dPt ):
542 return new DataPointContext( *this, mrModel.maPoints.create() );
543 case C_TOKEN( errBars ):
544 return new ErrorBarContext( *this, mrModel.maErrorBars.create() );
545 case C_TOKEN( invertIfNegative ):
546 // default is 'false', not 'true' as specified
547 mrModel.mbInvertNeg = rAttribs.getBool( XML_val, false );
548 return 0;
549 case C_TOKEN( trendline ):
550 return new TrendlineContext( *this, mrModel.maTrendlines.create() );
551 case C_TOKEN( xVal ):
552 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::CATEGORIES ) );
553 case C_TOKEN( yVal ):
554 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::VALUES ) );
555 }
556 break;
557 }
558 return SeriesContextBase::onCreateContext( nElement, rAttribs );
559 }
560
561 // ============================================================================
562
LineSeriesContext(ContextHandler2Helper & rParent,SeriesModel & rModel)563 LineSeriesContext::LineSeriesContext( ContextHandler2Helper& rParent, SeriesModel& rModel ) :
564 SeriesContextBase( rParent, rModel )
565 {
566 }
567
~LineSeriesContext()568 LineSeriesContext::~LineSeriesContext()
569 {
570 }
571
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)572 ContextHandlerRef LineSeriesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
573 {
574 switch( getCurrentElement() )
575 {
576 case C_TOKEN( ser ):
577 switch( nElement )
578 {
579 case C_TOKEN( cat ):
580 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::CATEGORIES ) );
581 case C_TOKEN( dLbls ):
582 return new DataLabelsContext( *this, mrModel.mxLabels.create() );
583 case C_TOKEN( dPt ):
584 return new DataPointContext( *this, mrModel.maPoints.create() );
585 case C_TOKEN( errBars ):
586 return new ErrorBarContext( *this, mrModel.maErrorBars.create() );
587 case C_TOKEN( marker ):
588 return this;
589 case C_TOKEN( smooth ):
590 // default is 'false', not 'true' as specified
591 mrModel.mbSmooth = rAttribs.getBool( XML_val, false );
592 return 0;
593 case C_TOKEN( trendline ):
594 return new TrendlineContext( *this, mrModel.maTrendlines.create() );
595 case C_TOKEN( val ):
596 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::VALUES ) );
597 }
598 break;
599 }
600 return SeriesContextBase::onCreateContext( nElement, rAttribs );
601 }
602
603 // ============================================================================
604
PieSeriesContext(ContextHandler2Helper & rParent,SeriesModel & rModel)605 PieSeriesContext::PieSeriesContext( ContextHandler2Helper& rParent, SeriesModel& rModel ) :
606 SeriesContextBase( rParent, rModel )
607 {
608 }
609
~PieSeriesContext()610 PieSeriesContext::~PieSeriesContext()
611 {
612 }
613
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)614 ContextHandlerRef PieSeriesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
615 {
616 switch( getCurrentElement() )
617 {
618 case C_TOKEN( ser ):
619 switch( nElement )
620 {
621 case C_TOKEN( cat ):
622 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::CATEGORIES ) );
623 case C_TOKEN( dLbls ):
624 return new DataLabelsContext( *this, mrModel.mxLabels.create() );
625 case C_TOKEN( dPt ):
626 return new DataPointContext( *this, mrModel.maPoints.create() );
627 case C_TOKEN( explosion ):
628 mrModel.mnExplosion = rAttribs.getInteger( XML_val, 0 );
629 return 0;
630 case C_TOKEN( val ):
631 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::VALUES ) );
632 }
633 break;
634 }
635 return SeriesContextBase::onCreateContext( nElement, rAttribs );
636 }
637
638 // ============================================================================
639
RadarSeriesContext(ContextHandler2Helper & rParent,SeriesModel & rModel)640 RadarSeriesContext::RadarSeriesContext( ContextHandler2Helper& rParent, SeriesModel& rModel ) :
641 SeriesContextBase( rParent, rModel )
642 {
643 }
644
~RadarSeriesContext()645 RadarSeriesContext::~RadarSeriesContext()
646 {
647 }
648
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)649 ContextHandlerRef RadarSeriesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
650 {
651 switch( getCurrentElement() )
652 {
653 case C_TOKEN( ser ):
654 switch( nElement )
655 {
656 case C_TOKEN( cat ):
657 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::CATEGORIES ) );
658 case C_TOKEN( dLbls ):
659 return new DataLabelsContext( *this, mrModel.mxLabels.create() );
660 case C_TOKEN( dPt ):
661 return new DataPointContext( *this, mrModel.maPoints.create() );
662 case C_TOKEN( marker ):
663 return this;
664 case C_TOKEN( smooth ):
665 // default is 'false', not 'true' as specified
666 mrModel.mbSmooth = rAttribs.getBool( XML_val, false );
667 return 0;
668 case C_TOKEN( val ):
669 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::VALUES ) );
670 }
671 break;
672 }
673 return SeriesContextBase::onCreateContext( nElement, rAttribs );
674 }
675
676 // ============================================================================
677
ScatterSeriesContext(ContextHandler2Helper & rParent,SeriesModel & rModel)678 ScatterSeriesContext::ScatterSeriesContext( ContextHandler2Helper& rParent, SeriesModel& rModel ) :
679 SeriesContextBase( rParent, rModel )
680 {
681 }
682
~ScatterSeriesContext()683 ScatterSeriesContext::~ScatterSeriesContext()
684 {
685 }
686
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)687 ContextHandlerRef ScatterSeriesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
688 {
689 switch( getCurrentElement() )
690 {
691 case C_TOKEN( ser ):
692 switch( nElement )
693 {
694 case C_TOKEN( dLbls ):
695 return new DataLabelsContext( *this, mrModel.mxLabels.create() );
696 case C_TOKEN( dPt ):
697 return new DataPointContext( *this, mrModel.maPoints.create() );
698 case C_TOKEN( errBars ):
699 return new ErrorBarContext( *this, mrModel.maErrorBars.create() );
700 case C_TOKEN( marker ):
701 return this;
702 case C_TOKEN( smooth ):
703 // default is 'false', not 'true' as specified
704 mrModel.mbSmooth = rAttribs.getBool( XML_val, false );
705 return 0;
706 case C_TOKEN( trendline ):
707 return new TrendlineContext( *this, mrModel.maTrendlines.create() );
708 case C_TOKEN( xVal ):
709 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::CATEGORIES ) );
710 case C_TOKEN( yVal ):
711 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::VALUES ) );
712 }
713 break;
714 }
715 return SeriesContextBase::onCreateContext( nElement, rAttribs );
716 }
717
718 // ============================================================================
719
SurfaceSeriesContext(ContextHandler2Helper & rParent,SeriesModel & rModel)720 SurfaceSeriesContext::SurfaceSeriesContext( ContextHandler2Helper& rParent, SeriesModel& rModel ) :
721 SeriesContextBase( rParent, rModel )
722 {
723 }
724
~SurfaceSeriesContext()725 SurfaceSeriesContext::~SurfaceSeriesContext()
726 {
727 }
728
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)729 ContextHandlerRef SurfaceSeriesContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
730 {
731 switch( getCurrentElement() )
732 {
733 case C_TOKEN( ser ):
734 switch( nElement )
735 {
736 case C_TOKEN( cat ):
737 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::CATEGORIES ) );
738 case C_TOKEN( val ):
739 return new DataSourceContext( *this, mrModel.maSources.create( SeriesModel::VALUES ) );
740 }
741 break;
742 }
743 return SeriesContextBase::onCreateContext( nElement, rAttribs );
744 }
745
746 // ============================================================================
747
748 } // namespace chart
749 } // namespace drawingml
750 } // namespace oox
751