Update ooo320-m1
[ooovba.git] / oox / source / drawingml / chart / axiscontext.cxx
blob00ca3d740bb733a5b5ae6d9d235994a2022de3eb
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: axiscontext.cxx,v $
10 * $Revision: 1.6 $
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/axiscontext.hxx"
32 #include "oox/drawingml/shapepropertiescontext.hxx"
33 #include "oox/drawingml/textbodycontext.hxx"
34 #include "oox/drawingml/chart/axismodel.hxx"
35 #include "oox/drawingml/chart/titlecontext.hxx"
37 using ::rtl::OUString;
38 using ::oox::core::ContextHandlerRef;
39 using ::oox::core::ContextHandler2Helper;
41 namespace oox {
42 namespace drawingml {
43 namespace chart {
45 // ============================================================================
47 AxisDispUnitsContext::AxisDispUnitsContext( ContextHandler2Helper& rParent, AxisDispUnitsModel& rModel ) :
48 ContextBase< AxisDispUnitsModel >( rParent, rModel )
52 AxisDispUnitsContext::~AxisDispUnitsContext()
56 ContextHandlerRef AxisDispUnitsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
58 switch( getCurrentElement() )
60 case C_TOKEN( dispUnits ):
61 switch( nElement )
63 case C_TOKEN( builtInUnit ):
64 mrModel.mnBuiltInUnit = rAttribs.getToken( XML_val, XML_thousands );
65 return 0;
66 case C_TOKEN( custUnit ):
67 mrModel.mfCustomUnit = rAttribs.getDouble( XML_val, 0.0 );
68 return 0;
69 case C_TOKEN( dispUnitsLbl ):
70 return this;
72 break;
74 case C_TOKEN( dispUnitsLbl ):
75 switch( nElement )
77 case C_TOKEN( layout ):
78 return new LayoutContext( *this, mrModel.mxLayout.create() );
79 case C_TOKEN( spPr ):
80 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
81 case C_TOKEN( tx ):
82 return new TextContext( *this, mrModel.mxText.create() );
83 case C_TOKEN( txPr ):
84 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
86 break;
88 return 0;
91 // ============================================================================
93 AxisContextBase::AxisContextBase( ContextHandler2Helper& rParent, AxisModel& rModel ) :
94 ContextBase< AxisModel >( rParent, rModel )
98 AxisContextBase::~AxisContextBase()
102 ContextHandlerRef AxisContextBase::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
104 switch( getCurrentElement() )
106 case C_TOKEN( catAx ):
107 case C_TOKEN( dateAx ):
108 case C_TOKEN( serAx ):
109 case C_TOKEN( valAx ):
110 switch( nElement )
112 case C_TOKEN( axId ):
113 mrModel.mnAxisId = rAttribs.getInteger( XML_val, -1 );
114 return 0;
115 case C_TOKEN( crossAx ):
116 mrModel.mnCrossAxisId = rAttribs.getInteger( XML_val, -1 );
117 return 0;
118 case C_TOKEN( crosses ):
119 mrModel.mnCrossMode = rAttribs.getToken( XML_val, XML_autoZero );
120 return 0;
121 case C_TOKEN( crossesAt ):
122 mrModel.mofCrossesAt = rAttribs.getDouble( XML_val, 0.0 );
123 return 0;
124 case C_TOKEN( delete ):
125 // default is 'false', not 'true' as specified
126 mrModel.mbDeleted = rAttribs.getBool( XML_val, false );
127 return 0;
128 case C_TOKEN( majorGridlines ):
129 return new ShapePrWrapperContext( *this, mrModel.mxMajorGridLines.create() );
130 case C_TOKEN( majorTickMark ):
131 // default is 'out', not 'cross' as specified
132 mrModel.mnMajorTickMark = rAttribs.getToken( XML_val, XML_out );
133 return 0;
134 case C_TOKEN( minorGridlines ):
135 return new ShapePrWrapperContext( *this, mrModel.mxMinorGridLines.create() );
136 case C_TOKEN( minorTickMark ):
137 // default is 'none', not 'cross' as specified
138 mrModel.mnMinorTickMark = rAttribs.getToken( XML_val, XML_none );
139 return 0;
140 case C_TOKEN( numFmt ):
141 mrModel.maNumberFormat.setAttributes( rAttribs );
142 return 0;
143 case C_TOKEN( scaling ):
144 return this;
145 case C_TOKEN( spPr ):
146 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
147 case C_TOKEN( tickLblPos ):
148 mrModel.mnTickLabelPos = rAttribs.getToken( XML_val, XML_nextTo );
149 return 0;
150 case C_TOKEN( title ):
151 return new TitleContext( *this, mrModel.mxTitle.create() );
152 case C_TOKEN( txPr ):
153 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
155 break;
157 case C_TOKEN( scaling ):
158 switch( nElement )
160 case C_TOKEN( logBase ):
161 mrModel.mofLogBase = rAttribs.getDouble( XML_val, 0.0 );
162 return 0;
163 case C_TOKEN( max ):
164 mrModel.mofMax = rAttribs.getDouble( XML_val, 0.0 );
165 return 0;
166 case C_TOKEN( min ):
167 mrModel.mofMin = rAttribs.getDouble( XML_val, 0.0 );
168 return 0;
169 case C_TOKEN( orientation ):
170 mrModel.mnOrientation = rAttribs.getToken( XML_val, XML_minMax );
171 return 0;
173 break;
175 return 0;
178 // ============================================================================
180 CatAxisContext::CatAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
181 AxisContextBase( rParent, rModel )
185 CatAxisContext::~CatAxisContext()
189 ContextHandlerRef CatAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
191 if( isRootElement() ) switch( nElement )
193 case C_TOKEN( auto ):
194 // default is 'false', not 'true' as specified
195 mrModel.mbAuto = rAttribs.getBool( XML_val, false );
196 return 0;
197 case C_TOKEN( axPos ):
198 mrModel.mnAxisPos = rAttribs.getToken( XML_val, XML_TOKEN_INVALID );
199 return 0;
200 case C_TOKEN( lblAlgn ):
201 mrModel.mnLabelAlign = rAttribs.getToken( XML_val, XML_ctr );
202 return 0;
203 case C_TOKEN( lblOffset ):
204 mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
205 return 0;
206 case C_TOKEN( noMultiLvlLbl ):
207 // default is 'false', not 'true' as specified
208 mrModel.mbNoMultiLevel = rAttribs.getBool( XML_val, false );
209 return 0;
210 case C_TOKEN( tickLblSkip ):
211 mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
212 return 0;
213 case C_TOKEN( tickMarkSkip ):
214 mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
215 return 0;
217 return AxisContextBase::onCreateContext( nElement, rAttribs );
220 // ============================================================================
222 DateAxisContext::DateAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
223 AxisContextBase( rParent, rModel )
227 DateAxisContext::~DateAxisContext()
231 ContextHandlerRef DateAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
233 if( isRootElement() ) switch( nElement )
235 case C_TOKEN( auto ):
236 // default is 'false', not 'true' as specified
237 mrModel.mbAuto = rAttribs.getBool( XML_val, false );
238 return 0;
239 case C_TOKEN( baseTimeUnit ):
240 mrModel.mnBaseTimeUnit = rAttribs.getToken( XML_val, XML_days );
241 return 0;
242 case C_TOKEN( lblOffset ):
243 mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
244 return 0;
245 case C_TOKEN( majorTimeUnit ):
246 mrModel.mnMajorTimeUnit = rAttribs.getToken( XML_val, XML_days );
247 return 0;
248 case C_TOKEN( majorUnit ):
249 mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
250 return 0;
251 case C_TOKEN( minorTimeUnit ):
252 mrModel.mnMinorTimeUnit = rAttribs.getToken( XML_val, XML_days );
253 return 0;
254 case C_TOKEN( minorUnit ):
255 mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
256 return 0;
258 return AxisContextBase::onCreateContext( nElement, rAttribs );
261 // ============================================================================
263 SerAxisContext::SerAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
264 AxisContextBase( rParent, rModel )
268 SerAxisContext::~SerAxisContext()
272 ContextHandlerRef SerAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
274 if( isRootElement() ) switch( nElement )
276 case C_TOKEN( tickLblSkip ):
277 mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
278 return 0;
279 case C_TOKEN( tickMarkSkip ):
280 mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
281 return 0;
283 return AxisContextBase::onCreateContext( nElement, rAttribs );
286 // ============================================================================
288 ValAxisContext::ValAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
289 AxisContextBase( rParent, rModel )
293 ValAxisContext::~ValAxisContext()
297 ContextHandlerRef ValAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
299 if( isRootElement() ) switch( nElement )
301 case C_TOKEN( crossBetween ):
302 mrModel.mnCrossBetween = rAttribs.getToken( XML_val, XML_between );
303 return 0;
304 case C_TOKEN( dispUnits ):
305 return new AxisDispUnitsContext( *this, mrModel.mxDispUnits.create() );
306 case C_TOKEN( majorUnit ):
307 mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
308 return 0;
309 case C_TOKEN( minorUnit ):
310 mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
311 return 0;
313 return AxisContextBase::onCreateContext( nElement, rAttribs );
316 // ============================================================================
318 } // namespace chart
319 } // namespace drawingml
320 } // namespace oox