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