1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: typegroupcontext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/chart/typegroupcontext.hxx"
32 #include "oox/drawingml/chart/seriescontext.hxx"
33 #include "oox/drawingml/chart/typegroupmodel.hxx"
35 using ::oox::core::ContextHandler2Helper
;
36 using ::oox::core::ContextHandlerRef
;
42 // ============================================================================
44 UpDownBarsContext::UpDownBarsContext( ContextHandler2Helper
& rParent
, UpDownBarsModel
& rModel
) :
45 ContextBase
< UpDownBarsModel
>( rParent
, rModel
)
49 UpDownBarsContext::~UpDownBarsContext()
53 ContextHandlerRef
UpDownBarsContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
55 switch( getCurrentElement() )
57 case C_TOKEN( upDownBars
):
60 case C_TOKEN( downBars
):
61 return new ShapePrWrapperContext( *this, mrModel
.mxDownBars
.create() );
62 case C_TOKEN( gapWidth
):
63 mrModel
.mnGapWidth
= rAttribs
.getInteger( XML_val
, 150 );
65 case C_TOKEN( upBars
):
66 return new ShapePrWrapperContext( *this, mrModel
.mxUpBars
.create() );
73 // ============================================================================
75 AreaTypeGroupContext::AreaTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
76 TypeGroupContextBase( rParent
, rModel
)
80 AreaTypeGroupContext::~AreaTypeGroupContext()
84 ContextHandlerRef
AreaTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
86 if( isRootElement() ) switch( nElement
)
89 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
91 case C_TOKEN( dLbls
):
92 return new DataLabelsContext( *this, mrModel
.mxLabels
.create() );
93 case C_TOKEN( dropLines
):
94 return new ShapePrWrapperContext( *this, mrModel
.mxDropLines
.create() );
95 case C_TOKEN( gapDepth
):
96 mrModel
.mnGapDepth
= rAttribs
.getInteger( XML_val
, 150 );
98 case C_TOKEN( grouping
):
99 mrModel
.mnGrouping
= rAttribs
.getToken( XML_val
, XML_standard
);
102 return new AreaSeriesContext( *this, mrModel
.maSeries
.create() );
103 case C_TOKEN( varyColors
):
104 // default is 'false', not 'true' as specified
105 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, false );
111 // ============================================================================
113 BarTypeGroupContext::BarTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
114 TypeGroupContextBase( rParent
, rModel
)
118 BarTypeGroupContext::~BarTypeGroupContext()
122 ContextHandlerRef
BarTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
124 if( isRootElement() ) switch( nElement
)
126 case C_TOKEN( axId
):
127 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
129 case C_TOKEN( barDir
):
130 mrModel
.mnBarDir
= rAttribs
.getToken( XML_val
, XML_col
);
132 case C_TOKEN( dLbls
):
133 return new DataLabelsContext( *this, mrModel
.mxLabels
.create() );
134 case C_TOKEN( gapDepth
):
135 mrModel
.mnGapDepth
= rAttribs
.getInteger( XML_val
, 150 );
137 case C_TOKEN( gapWidth
):
138 mrModel
.mnGapWidth
= rAttribs
.getInteger( XML_val
, 150 );
140 case C_TOKEN( grouping
):
141 // default is 'standard', not 'clustered' as specified
142 mrModel
.mnGrouping
= rAttribs
.getToken( XML_val
, XML_standard
);
144 case C_TOKEN( overlap
):
145 mrModel
.mnOverlap
= rAttribs
.getInteger( XML_val
, 0 );
148 return new BarSeriesContext( *this, mrModel
.maSeries
.create() );
149 case C_TOKEN( serLines
):
150 return new ShapePrWrapperContext( *this, mrModel
.mxSerLines
.create() );
151 case C_TOKEN( shape
):
152 mrModel
.mnShape
= rAttribs
.getToken( XML_val
, XML_box
);
154 case C_TOKEN( varyColors
):
155 // default is 'false', not 'true' as specified
156 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, false );
162 // ============================================================================
164 BubbleTypeGroupContext::BubbleTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
165 TypeGroupContextBase( rParent
, rModel
)
169 BubbleTypeGroupContext::~BubbleTypeGroupContext()
173 ContextHandlerRef
BubbleTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
175 if( isRootElement() ) switch( nElement
)
177 case C_TOKEN( axId
):
178 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
180 case C_TOKEN( bubble3D
):
181 // default is 'false', not 'true' as specified
182 mrModel
.mbBubble3d
= rAttribs
.getBool( XML_val
, false );
184 case C_TOKEN( bubbleScale
):
185 mrModel
.mnBubbleScale
= rAttribs
.getInteger( XML_val
, 100 );
187 case C_TOKEN( dLbls
):
188 return new DataLabelsContext( *this, mrModel
.mxLabels
.create() );
190 return new BubbleSeriesContext( *this, mrModel
.maSeries
.create() );
191 case C_TOKEN( showNegBubbles
):
192 // default is 'false', not 'true' as specified
193 mrModel
.mbShowNegBubbles
= rAttribs
.getBool( XML_val
, false );
195 case C_TOKEN( sizeRepresents
):
196 mrModel
.mnSizeRepresents
= rAttribs
.getToken( XML_val
, XML_area
);
198 case C_TOKEN( varyColors
):
199 // default is 'false', not 'true' as specified
200 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, false );
206 // ============================================================================
208 LineTypeGroupContext::LineTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
209 TypeGroupContextBase( rParent
, rModel
)
213 LineTypeGroupContext::~LineTypeGroupContext()
217 ContextHandlerRef
LineTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
219 if( isRootElement() ) switch( nElement
)
221 case C_TOKEN( axId
):
222 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
224 case C_TOKEN( dLbls
):
225 return new DataLabelsContext( *this, mrModel
.mxLabels
.create() );
226 case C_TOKEN( dropLines
):
227 return new ShapePrWrapperContext( *this, mrModel
.mxDropLines
.create() );
228 case C_TOKEN( gapDepth
):
229 mrModel
.mnGapDepth
= rAttribs
.getInteger( XML_val
, 150 );
231 case C_TOKEN( grouping
):
232 mrModel
.mnGrouping
= rAttribs
.getToken( XML_val
, XML_standard
);
234 case C_TOKEN( hiLowLines
):
235 return new ShapePrWrapperContext( *this, mrModel
.mxHiLowLines
.create() );
236 case C_TOKEN( marker
):
237 // default is 'false', not 'true' as specified
238 mrModel
.mbShowMarker
= rAttribs
.getBool( XML_val
, false );
241 return new LineSeriesContext( *this, mrModel
.maSeries
.create() );
242 case C_TOKEN( smooth
):
243 // default is 'false', not 'true' as specified
244 mrModel
.mbSmooth
= rAttribs
.getBool( XML_val
, false );
246 case C_TOKEN( upDownBars
):
247 return new UpDownBarsContext( *this, mrModel
.mxUpDownBars
.create() );
248 case C_TOKEN( varyColors
):
249 // default is 'false', not 'true' as specified
250 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, false );
256 // ============================================================================
258 PieTypeGroupContext::PieTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
259 TypeGroupContextBase( rParent
, rModel
)
263 PieTypeGroupContext::~PieTypeGroupContext()
267 ContextHandlerRef
PieTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
269 if( isRootElement() ) switch( nElement
)
271 case C_TOKEN( dLbls
):
272 return new DataLabelsContext( *this, mrModel
.mxLabels
.create() );
273 case C_TOKEN( firstSliceAng
):
274 mrModel
.mnFirstAngle
= rAttribs
.getInteger( XML_val
, 0 );
276 case C_TOKEN( gapWidth
):
277 mrModel
.mnGapWidth
= rAttribs
.getInteger( XML_val
, 150 );
279 case C_TOKEN( holeSize
):
280 mrModel
.mnHoleSize
= rAttribs
.getInteger( XML_val
, 10 );
282 case C_TOKEN( ofPieType
):
283 mrModel
.mnOfPieType
= rAttribs
.getToken( XML_val
, XML_pie
);
285 case C_TOKEN( secondPieSize
):
286 mrModel
.mnSecondPieSize
= rAttribs
.getInteger( XML_val
, 75 );
289 return new PieSeriesContext( *this, mrModel
.maSeries
.create() );
290 case C_TOKEN( serLines
):
291 return new ShapePrWrapperContext( *this, mrModel
.mxSerLines
.create() );
292 case C_TOKEN( splitPos
):
293 mrModel
.mfSplitPos
= rAttribs
.getDouble( XML_val
, 0.0 );
295 case C_TOKEN( splitType
):
296 mrModel
.mnSplitType
= rAttribs
.getToken( XML_val
, XML_auto
);
298 case C_TOKEN( varyColors
):
299 // default is 'false', not 'true' as specified
300 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, false );
306 // ============================================================================
308 RadarTypeGroupContext::RadarTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
309 TypeGroupContextBase( rParent
, rModel
)
313 RadarTypeGroupContext::~RadarTypeGroupContext()
317 ContextHandlerRef
RadarTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
319 if( isRootElement() ) switch( nElement
)
321 case C_TOKEN( axId
):
322 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
324 case C_TOKEN( dLbls
):
325 return new DataLabelsContext( *this, mrModel
.mxLabels
.create() );
326 case C_TOKEN( radarStyle
):
327 mrModel
.mnRadarStyle
= rAttribs
.getToken( XML_val
, XML_standard
);
330 return new RadarSeriesContext( *this, mrModel
.maSeries
.create() );
331 case C_TOKEN( varyColors
):
332 // default is 'false', not 'true' as specified
333 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, false );
339 // ============================================================================
341 ScatterTypeGroupContext::ScatterTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
342 TypeGroupContextBase( rParent
, rModel
)
346 ScatterTypeGroupContext::~ScatterTypeGroupContext()
350 ContextHandlerRef
ScatterTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
352 if( isRootElement() ) switch( nElement
)
354 case C_TOKEN( axId
):
355 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
357 case C_TOKEN( dLbls
):
358 return new DataLabelsContext( *this, mrModel
.mxLabels
.create() );
359 case C_TOKEN( scatterStyle
):
360 mrModel
.mnScatterStyle
= rAttribs
.getInteger( XML_val
, XML_marker
);
363 return new ScatterSeriesContext( *this, mrModel
.maSeries
.create() );
364 case C_TOKEN( varyColors
):
365 // default is 'false', not 'true' as specified
366 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, false );
372 // ============================================================================
374 SurfaceTypeGroupContext::SurfaceTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
375 TypeGroupContextBase( rParent
, rModel
)
379 SurfaceTypeGroupContext::~SurfaceTypeGroupContext()
383 ContextHandlerRef
SurfaceTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
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() );
392 case C_TOKEN( wireframe
):
393 // default is 'false', not 'true' as specified
394 mrModel
.mbWireframe
= rAttribs
.getBool( XML_val
, false );
400 // ============================================================================
403 } // namespace drawingml