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/properties.hxx>
28 #include <oox/token/tokens.hxx>
34 using ::oox::core::ContextHandler2Helper
;
35 using ::oox::core::ContextHandlerRef
;
37 UpDownBarsContext::UpDownBarsContext( ContextHandler2Helper
& rParent
, UpDownBarsModel
& rModel
) :
38 ContextBase
< UpDownBarsModel
>( rParent
, rModel
)
42 UpDownBarsContext::~UpDownBarsContext()
46 ContextHandlerRef
UpDownBarsContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
48 switch( getCurrentElement() )
50 case C_TOKEN( upDownBars
):
53 case C_TOKEN( downBars
):
54 return new ShapePrWrapperContext( *this, mrModel
.mxDownBars
.create() );
55 case C_TOKEN( gapWidth
):
56 mrModel
.mnGapWidth
= rAttribs
.getInteger( XML_val
, 150 );
58 case C_TOKEN( upBars
):
59 return new ShapePrWrapperContext( *this, mrModel
.mxUpBars
.create() );
66 AreaTypeGroupContext::AreaTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
67 TypeGroupContextBase( rParent
, rModel
)
71 AreaTypeGroupContext::~AreaTypeGroupContext()
75 ContextHandlerRef
AreaTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
77 bool bMSO2007Doc
= getFilter().isMSO2007Document();
78 if( isRootElement() ) switch( nElement
)
81 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
83 case C_TOKEN( dLbls
):
84 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
85 case C_TOKEN( dropLines
):
86 return new ShapePrWrapperContext( *this, mrModel
.mxDropLines
.create() );
87 case C_TOKEN( gapDepth
):
88 mrModel
.mnGapDepth
= rAttribs
.getInteger( XML_val
, 150 );
90 case C_TOKEN( grouping
):
91 mrModel
.mnGrouping
= rAttribs
.getToken( XML_val
, bMSO2007Doc
? XML_standard
: XML_clustered
);
94 return new AreaSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
95 case C_TOKEN( varyColors
):
96 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
102 BarTypeGroupContext::BarTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
103 TypeGroupContextBase( rParent
, rModel
)
107 BarTypeGroupContext::~BarTypeGroupContext()
111 ContextHandlerRef
BarTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
113 bool bMSO2007Doc
= getFilter().isMSO2007Document();
114 if( isRootElement() ) switch( nElement
)
116 case C_TOKEN( axId
):
117 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
119 case C_TOKEN( barDir
):
120 mrModel
.mnBarDir
= rAttribs
.getToken( XML_val
, XML_col
);
122 case C_TOKEN( dLbls
):
123 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
124 case C_TOKEN( gapDepth
):
125 mrModel
.mnGapDepth
= rAttribs
.getInteger( XML_val
, 150 );
127 case C_TOKEN( gapWidth
):
128 mrModel
.mnGapWidth
= rAttribs
.getInteger( XML_val
, 150 );
130 case C_TOKEN( grouping
):
131 mrModel
.mnGrouping
= rAttribs
.getToken( XML_val
, bMSO2007Doc
? XML_standard
: XML_clustered
);
133 case C_TOKEN( overlap
):
134 mrModel
.mnOverlap
= rAttribs
.getInteger( XML_val
, 0 );
137 return new BarSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
138 case C_TOKEN( serLines
):
139 return new ShapePrWrapperContext( *this, mrModel
.mxSerLines
.create() );
140 case C_TOKEN( shape
):
141 mrModel
.mnShape
= rAttribs
.getToken( XML_val
, XML_box
);
143 case C_TOKEN( varyColors
):
144 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
150 BubbleTypeGroupContext::BubbleTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
151 TypeGroupContextBase( rParent
, rModel
)
155 BubbleTypeGroupContext::~BubbleTypeGroupContext()
159 ContextHandlerRef
BubbleTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
161 bool bMSO2007Doc
= getFilter().isMSO2007Document();
162 if( isRootElement() ) switch( nElement
)
164 case C_TOKEN( axId
):
165 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
167 case C_TOKEN( bubble3D
):
168 mrModel
.mbBubble3d
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
170 case C_TOKEN( bubbleScale
):
171 mrModel
.mnBubbleScale
= rAttribs
.getInteger( XML_val
, 100 );
173 case C_TOKEN( dLbls
):
174 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
176 return new BubbleSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
177 case C_TOKEN( showNegBubbles
):
178 mrModel
.mbShowNegBubbles
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
180 case C_TOKEN( sizeRepresents
):
181 mrModel
.mnSizeRepresents
= rAttribs
.getToken( XML_val
, XML_area
);
183 case C_TOKEN( varyColors
):
184 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
190 LineTypeGroupContext::LineTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
191 TypeGroupContextBase( rParent
, rModel
)
195 LineTypeGroupContext::~LineTypeGroupContext()
199 ContextHandlerRef
LineTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
201 bool bMSO2007Doc
= getFilter().isMSO2007Document();
202 if( isRootElement() ) switch( nElement
)
204 case C_TOKEN( axId
):
205 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
207 case C_TOKEN( dLbls
):
208 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
209 case C_TOKEN( dropLines
):
210 return new ShapePrWrapperContext( *this, mrModel
.mxDropLines
.create() );
211 case C_TOKEN( gapDepth
):
212 mrModel
.mnGapDepth
= rAttribs
.getInteger( XML_val
, 150 );
214 case C_TOKEN( grouping
):
215 mrModel
.mnGrouping
= rAttribs
.getToken( XML_val
, bMSO2007Doc
? XML_standard
: XML_clustered
);
217 case C_TOKEN( hiLowLines
):
218 return new ShapePrWrapperContext( *this, mrModel
.mxHiLowLines
.create() );
219 case C_TOKEN( marker
):
220 mrModel
.mbShowMarker
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
223 return new LineSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
224 case C_TOKEN( smooth
):
225 mrModel
.mbSmooth
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
227 case C_TOKEN( upDownBars
):
228 return new UpDownBarsContext( *this, mrModel
.mxUpDownBars
.create() );
229 case C_TOKEN( varyColors
):
230 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
236 PieTypeGroupContext::PieTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
237 TypeGroupContextBase( rParent
, rModel
)
241 PieTypeGroupContext::~PieTypeGroupContext()
245 ContextHandlerRef
PieTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
247 bool bMSO2007Doc
= getFilter().isMSO2007Document();
248 if( isRootElement() ) switch( nElement
)
250 case C_TOKEN( dLbls
):
251 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
252 case C_TOKEN( firstSliceAng
):
253 mrModel
.mnFirstAngle
= rAttribs
.getInteger( XML_val
, 0 );
255 case C_TOKEN( gapWidth
):
256 mrModel
.mnGapWidth
= rAttribs
.getInteger( XML_val
, 150 );
258 case C_TOKEN( holeSize
):
259 mrModel
.mnHoleSize
= rAttribs
.getInteger( XML_val
, 10 );
261 case C_TOKEN( ofPieType
):
262 mrModel
.mnOfPieType
= rAttribs
.getToken( XML_val
, XML_pie
);
264 case C_TOKEN( secondPieSize
):
265 mrModel
.mnSecondPieSize
= rAttribs
.getInteger( XML_val
, 75 );
268 return new PieSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
269 case C_TOKEN( serLines
):
270 return new ShapePrWrapperContext( *this, mrModel
.mxSerLines
.create() );
271 case C_TOKEN( splitPos
):
272 mrModel
.mfSplitPos
= rAttribs
.getDouble( XML_val
, 0.0 );
274 case C_TOKEN( splitType
):
275 mrModel
.mnSplitType
= rAttribs
.getToken( XML_val
, XML_auto
);
277 case C_TOKEN( varyColors
):
278 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
284 RadarTypeGroupContext::RadarTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
285 TypeGroupContextBase( rParent
, rModel
)
289 RadarTypeGroupContext::~RadarTypeGroupContext()
293 ContextHandlerRef
RadarTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
295 bool bMSO2007Doc
= getFilter().isMSO2007Document();
296 if( isRootElement() ) switch( nElement
)
298 case C_TOKEN( axId
):
299 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
301 case C_TOKEN( dLbls
):
302 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
303 case C_TOKEN( radarStyle
):
304 mrModel
.mnRadarStyle
= rAttribs
.getToken( XML_val
, XML_standard
);
307 return new RadarSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
308 case C_TOKEN( varyColors
):
309 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
315 ScatterTypeGroupContext::ScatterTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
316 TypeGroupContextBase( rParent
, rModel
)
320 ScatterTypeGroupContext::~ScatterTypeGroupContext()
324 ContextHandlerRef
ScatterTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
326 bool bMSO2007Doc
= getFilter().isMSO2007Document();
327 if( isRootElement() ) switch( nElement
)
329 case C_TOKEN( axId
):
330 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
332 case C_TOKEN( dLbls
):
333 return new DataLabelsContext( *this, mrModel
.mxLabels
.create(bMSO2007Doc
) );
334 case C_TOKEN( scatterStyle
):
335 mrModel
.mnScatterStyle
= rAttribs
.getInteger( XML_val
, XML_marker
);
338 return new ScatterSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
339 case C_TOKEN( varyColors
):
340 mrModel
.mbVaryColors
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
346 SurfaceTypeGroupContext::SurfaceTypeGroupContext( ContextHandler2Helper
& rParent
, TypeGroupModel
& rModel
) :
347 TypeGroupContextBase( rParent
, rModel
)
351 SurfaceTypeGroupContext::~SurfaceTypeGroupContext()
355 ContextHandlerRef
SurfaceTypeGroupContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
357 bool bMSO2007Doc
= getFilter().isMSO2007Document();
358 if( isRootElement() ) switch( nElement
)
360 case C_TOKEN( axId
):
361 mrModel
.maAxisIds
.push_back( rAttribs
.getInteger( XML_val
, -1 ) );
364 return new SurfaceSeriesContext( *this, mrModel
.maSeries
.create(bMSO2007Doc
) );
365 case C_TOKEN( wireframe
):
366 mrModel
.mbWireframe
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
373 } // namespace drawingml
376 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */