1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <drawingml/chart/typegroupcontext.hxx>
22 #include <drawingml/chart/seriescontext.hxx>
23 #include <drawingml/chart/typegroupmodel.hxx>
24 #include <oox/core/xmlfilterbase.hxx>
25 #include <oox/helper/attributelist.hxx>
26 #include <oox/token/namespaces.hxx>
27 #include <oox/token/tokens.hxx>
29 namespace oox::drawingml::chart
{
31 using ::oox::core::ContextHandler2Helper
;
32 using ::oox::core::ContextHandlerRef
;
34 UpDownBarsContext::UpDownBarsContext( ContextHandler2Helper
& rParent
, UpDownBarsModel
& rModel
) :
35 ContextBase
< UpDownBarsModel
>( rParent
, rModel
)
39 UpDownBarsContext::~UpDownBarsContext()
43 ContextHandlerRef
UpDownBarsContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
45 switch( getCurrentElement() )
47 case C_TOKEN( upDownBars
):
50 case C_TOKEN( downBars
):
51 return new ShapePrWrapperContext( *this, mrModel
.mxDownBars
.create() );
52 case C_TOKEN( gapWidth
):
53 mrModel
.mnGapWidth
= rAttribs
.getInteger( XML_val
, 150 );
55 case C_TOKEN( upBars
):
56 return new ShapePrWrapperContext( *this, mrModel
.mxUpBars
.create() );
63 AreaTypeGroupContext::AreaTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
64 TypeGroupContextBase( rParent
, rModel
)
68 AreaTypeGroupContext::~AreaTypeGroupContext()
72 ContextHandlerRef
AreaTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
74 bool bMSO2007Doc
= getFilter().isMSO2007Document();
75 if( isRootElement() ) switch( nElement
)
78 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
80 case C_TOKEN( dLbls
):
81 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
82 case C_TOKEN( dropLines
):
83 return new ShapePrWrapperContext( *this, mrModel
.mxDropLines
.create() );
84 case C_TOKEN( gapDepth
):
85 mrModel
.mnGapDepth
= rAttribs
.getInteger( XML_val
, 150 );
87 case C_TOKEN( grouping
):
88 mrModel
.mnGrouping
= rAttribs
.getToken( XML_val
, bMSO2007Doc
? XML_standard
: XML_clustered
);
91 return new AreaSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
92 case C_TOKEN( varyColors
):
93 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
99 BarTypeGroupContext::BarTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
100 TypeGroupContextBase( rParent
, rModel
)
104 BarTypeGroupContext::~BarTypeGroupContext()
108 ContextHandlerRef
BarTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
110 bool bMSO2007Doc
= getFilter().isMSO2007Document();
111 if( isRootElement() ) switch( nElement
)
113 case C_TOKEN( axId
):
114 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
116 case C_TOKEN( barDir
):
117 mrModel
.mnBarDir
= rAttribs
.getToken( XML_val
, XML_col
);
119 case C_TOKEN( dLbls
):
120 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
121 case C_TOKEN( gapDepth
):
122 mrModel
.mnGapDepth
= rAttribs
.getInteger( XML_val
, 150 );
124 case C_TOKEN( gapWidth
):
125 mrModel
.mnGapWidth
= rAttribs
.getInteger( XML_val
, 150 );
127 case C_TOKEN( grouping
):
128 mrModel
.mnGrouping
= rAttribs
.getToken( XML_val
, bMSO2007Doc
? XML_standard
: XML_clustered
);
130 case C_TOKEN( overlap
):
131 mrModel
.mnOverlap
= rAttribs
.getInteger( XML_val
, 0 );
134 return new BarSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
135 case C_TOKEN( serLines
):
136 return new ShapePrWrapperContext( *this, mrModel
.mxSerLines
.create() );
137 case C_TOKEN( shape
):
138 mrModel
.mnShape
= rAttribs
.getToken( XML_val
, XML_box
);
140 case C_TOKEN( varyColors
):
141 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
147 BubbleTypeGroupContext::BubbleTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
148 TypeGroupContextBase( rParent
, rModel
)
152 BubbleTypeGroupContext::~BubbleTypeGroupContext()
156 ContextHandlerRef
BubbleTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
158 bool bMSO2007Doc
= getFilter().isMSO2007Document();
159 if( isRootElement() ) switch( nElement
)
161 case C_TOKEN( axId
):
162 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
164 case C_TOKEN( bubble3D
):
165 mrModel
.mbBubble3d
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
167 case C_TOKEN( bubbleScale
):
168 mrModel
.mnBubbleScale
= rAttribs
.getInteger( XML_val
, 100 );
170 case C_TOKEN( dLbls
):
171 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
173 return new BubbleSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
174 case C_TOKEN( showNegBubbles
):
175 mrModel
.mbShowNegBubbles
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
177 case C_TOKEN( sizeRepresents
):
178 mrModel
.mnSizeRepresents
= rAttribs
.getToken( XML_val
, XML_area
);
180 case C_TOKEN( varyColors
):
181 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
187 LineTypeGroupContext::LineTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
188 TypeGroupContextBase( rParent
, rModel
)
192 LineTypeGroupContext::~LineTypeGroupContext()
196 ContextHandlerRef
LineTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
198 bool bMSO2007Doc
= getFilter().isMSO2007Document();
199 if( isRootElement() ) switch( nElement
)
201 case C_TOKEN( axId
):
202 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
204 case C_TOKEN( dLbls
):
205 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
206 case C_TOKEN( dropLines
):
207 return new ShapePrWrapperContext( *this, mrModel
.mxDropLines
.create() );
208 case C_TOKEN( gapDepth
):
209 mrModel
.mnGapDepth
= rAttribs
.getInteger( XML_val
, 150 );
211 case C_TOKEN( grouping
):
212 mrModel
.mnGrouping
= rAttribs
.getToken( XML_val
, bMSO2007Doc
? XML_standard
: XML_clustered
);
214 case C_TOKEN( hiLowLines
):
215 return new ShapePrWrapperContext( *this, mrModel
.mxHiLowLines
.create() );
216 case C_TOKEN( marker
):
217 mrModel
.mbShowMarker
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
220 return new LineSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
221 case C_TOKEN( smooth
):
222 mrModel
.mbSmooth
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
224 case C_TOKEN( upDownBars
):
225 return new UpDownBarsContext( *this, mrModel
.mxUpDownBars
.create() );
226 case C_TOKEN( varyColors
):
227 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
233 PieTypeGroupContext::PieTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
234 TypeGroupContextBase( rParent
, rModel
)
238 PieTypeGroupContext::~PieTypeGroupContext()
242 ContextHandlerRef
PieTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
244 bool bMSO2007Doc
= getFilter().isMSO2007Document();
245 if( isRootElement() ) switch( nElement
)
247 case C_TOKEN( dLbls
):
248 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
249 case C_TOKEN( firstSliceAng
):
250 mrModel
.mnFirstAngle
= rAttribs
.getInteger( XML_val
, 0 );
252 case C_TOKEN( gapWidth
):
253 mrModel
.mnGapWidth
= rAttribs
.getInteger( XML_val
, 150 );
255 case C_TOKEN( holeSize
):
256 mrModel
.mnHoleSize
= rAttribs
.getInteger( XML_val
, 10 );
259 return new PieSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
260 case C_TOKEN( serLines
):
261 return new ShapePrWrapperContext( *this, mrModel
.mxSerLines
.create() );
262 case C_TOKEN( varyColors
):
263 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
269 OfPieTypeGroupContext::OfPieTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
270 TypeGroupContextBase( rParent
, rModel
)
274 OfPieTypeGroupContext::~OfPieTypeGroupContext()
278 ContextHandlerRef
OfPieTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
280 bool bMSO2007Doc
= getFilter().isMSO2007Document();
281 if( isRootElement() ) switch( nElement
)
283 case C_TOKEN( dLbls
):
284 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
285 case C_TOKEN( gapWidth
):
286 mrModel
.mnGapWidth
= rAttribs
.getInteger( XML_val
, 150 );
288 case C_TOKEN( ofPieType
):
289 mrModel
.mnOfPieType
= rAttribs
.getToken( XML_val
, XML_pie
);
291 case C_TOKEN( secondPieSize
):
292 mrModel
.mnSecondPieSize
= rAttribs
.getInteger( XML_val
, 75 );
295 return new PieSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
296 case C_TOKEN( serLines
):
297 return new ShapePrWrapperContext( *this, mrModel
.mxSerLines
.create() );
298 case C_TOKEN( splitPos
):
299 mrModel
.mfSplitPos
= rAttribs
.getDouble( XML_val
, 2.0 );
301 case C_TOKEN( splitType
):
302 mrModel
.mnSplitType
= rAttribs
.getToken( XML_val
, XML_auto
);
304 case C_TOKEN( varyColors
):
305 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
311 RadarTypeGroupContext::RadarTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
312 TypeGroupContextBase( rParent
, rModel
)
316 RadarTypeGroupContext::~RadarTypeGroupContext()
320 ContextHandlerRef
RadarTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
322 bool bMSO2007Doc
= getFilter().isMSO2007Document();
323 if( isRootElement() ) switch( nElement
)
325 case C_TOKEN( axId
):
326 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
328 case C_TOKEN( dLbls
):
329 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
330 case C_TOKEN( radarStyle
):
331 mrModel
.mnRadarStyle
= rAttribs
.getToken( XML_val
, XML_standard
);
334 return new RadarSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
335 case C_TOKEN( varyColors
):
336 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
342 ScatterTypeGroupContext::ScatterTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
343 TypeGroupContextBase( rParent
, rModel
)
347 ScatterTypeGroupContext::~ScatterTypeGroupContext()
351 ContextHandlerRef
ScatterTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
353 bool bMSO2007Doc
= getFilter().isMSO2007Document();
354 if( isRootElement() ) switch( nElement
)
356 case C_TOKEN( axId
):
357 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
359 case C_TOKEN( dLbls
):
360 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
361 case C_TOKEN( scatterStyle
):
362 mrModel
.mnScatterStyle
= rAttribs
.getInteger( XML_val
, XML_marker
);
365 return new ScatterSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
366 case C_TOKEN( varyColors
):
367 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
373 SurfaceTypeGroupContext::SurfaceTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
374 TypeGroupContextBase( rParent
, rModel
)
378 SurfaceTypeGroupContext::~SurfaceTypeGroupContext()
382 ContextHandlerRef
SurfaceTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
384 bool bMSO2007Doc
= getFilter().isMSO2007Document();
385 if( isRootElement() ) switch( nElement
)
387 case C_TOKEN( axId
):
388 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
391 return new SurfaceSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
392 case C_TOKEN( wireframe
):
393 mrModel
.mbWireframe
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
399 } // namespace oox::drawingml::chart
401 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */