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