bump product version to 4.1.6.2
[LibreOffice.git] / oox / source / drawingml / chart / axiscontext.cxx
blobcf023f203c25b94479fb7f79414e6a6c17fff1fb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "oox/drawingml/chart/axiscontext.hxx"
22 #include "oox/drawingml/shapepropertiescontext.hxx"
23 #include "oox/drawingml/textbodycontext.hxx"
24 #include "oox/drawingml/chart/axismodel.hxx"
25 #include "oox/drawingml/chart/titlecontext.hxx"
27 namespace oox {
28 namespace drawingml {
29 namespace chart {
31 // ============================================================================
33 using ::oox::core::ContextHandlerRef;
34 using ::oox::core::ContextHandler2Helper;
36 // ============================================================================
38 AxisDispUnitsContext::AxisDispUnitsContext( ContextHandler2Helper& rParent, AxisDispUnitsModel& rModel ) :
39 ContextBase< AxisDispUnitsModel >( rParent, rModel )
43 AxisDispUnitsContext::~AxisDispUnitsContext()
47 ContextHandlerRef AxisDispUnitsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
49 switch( getCurrentElement() )
51 case C_TOKEN( dispUnits ):
52 switch( nElement )
54 case C_TOKEN( builtInUnit ):
55 mrModel.mnBuiltInUnit = rAttribs.getToken( XML_val, XML_thousands );
56 return 0;
57 case C_TOKEN( custUnit ):
58 mrModel.mfCustomUnit = rAttribs.getDouble( XML_val, 0.0 );
59 return 0;
60 case C_TOKEN( dispUnitsLbl ):
61 return this;
63 break;
65 case C_TOKEN( dispUnitsLbl ):
66 switch( nElement )
68 case C_TOKEN( layout ):
69 return new LayoutContext( *this, mrModel.mxLayout.create() );
70 case C_TOKEN( spPr ):
71 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
72 case C_TOKEN( tx ):
73 return new TextContext( *this, mrModel.mxText.create() );
74 case C_TOKEN( txPr ):
75 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
77 break;
79 return 0;
82 // ============================================================================
84 AxisContextBase::AxisContextBase( ContextHandler2Helper& rParent, AxisModel& rModel ) :
85 ContextBase< AxisModel >( rParent, rModel )
89 AxisContextBase::~AxisContextBase()
93 ContextHandlerRef AxisContextBase::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
95 switch( getCurrentElement() )
97 case C_TOKEN( catAx ):
98 case C_TOKEN( dateAx ):
99 case C_TOKEN( serAx ):
100 case C_TOKEN( valAx ):
101 switch( nElement )
103 case C_TOKEN( axId ):
104 mrModel.mnAxisId = rAttribs.getInteger( XML_val, -1 );
105 return 0;
106 case C_TOKEN( crossAx ):
107 mrModel.mnCrossAxisId = rAttribs.getInteger( XML_val, -1 );
108 return 0;
109 case C_TOKEN( crosses ):
110 mrModel.mnCrossMode = rAttribs.getToken( XML_val, XML_autoZero );
111 return 0;
112 case C_TOKEN( crossesAt ):
113 mrModel.mofCrossesAt = rAttribs.getDouble( XML_val, 0.0 );
114 return 0;
115 case C_TOKEN( delete ):
116 // default is 'false', not 'true' as specified
117 mrModel.mbDeleted = rAttribs.getBool( XML_val, false );
118 return 0;
119 case C_TOKEN( majorGridlines ):
120 return new ShapePrWrapperContext( *this, mrModel.mxMajorGridLines.create() );
121 case C_TOKEN( majorTickMark ):
122 // default is 'out', not 'cross' as specified
123 mrModel.mnMajorTickMark = rAttribs.getToken( XML_val, XML_out );
124 return 0;
125 case C_TOKEN( minorGridlines ):
126 return new ShapePrWrapperContext( *this, mrModel.mxMinorGridLines.create() );
127 case C_TOKEN( minorTickMark ):
128 // default is 'none', not 'cross' as specified
129 mrModel.mnMinorTickMark = rAttribs.getToken( XML_val, XML_none );
130 return 0;
131 case C_TOKEN( numFmt ):
132 mrModel.maNumberFormat.setAttributes( rAttribs );
133 return 0;
134 case C_TOKEN( scaling ):
135 return this;
136 case C_TOKEN( spPr ):
137 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
138 case C_TOKEN( tickLblPos ):
139 mrModel.mnTickLabelPos = rAttribs.getToken( XML_val, XML_nextTo );
140 return 0;
141 case C_TOKEN( title ):
142 return new TitleContext( *this, mrModel.mxTitle.create() );
143 case C_TOKEN( txPr ):
144 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
146 break;
148 case C_TOKEN( scaling ):
149 switch( nElement )
151 case C_TOKEN( logBase ):
152 mrModel.mofLogBase = rAttribs.getDouble( XML_val, 0.0 );
153 return 0;
154 case C_TOKEN( max ):
155 mrModel.mofMax = rAttribs.getDouble( XML_val, 0.0 );
156 return 0;
157 case C_TOKEN( min ):
158 mrModel.mofMin = rAttribs.getDouble( XML_val, 0.0 );
159 return 0;
160 case C_TOKEN( orientation ):
161 mrModel.mnOrientation = rAttribs.getToken( XML_val, XML_minMax );
162 return 0;
164 break;
166 return 0;
169 // ============================================================================
171 CatAxisContext::CatAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
172 AxisContextBase( rParent, rModel )
176 CatAxisContext::~CatAxisContext()
180 ContextHandlerRef CatAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
182 if( isRootElement() ) switch( nElement )
184 case C_TOKEN( auto ):
185 // default is 'false', not 'true' as specified
186 mrModel.mbAuto = rAttribs.getBool( XML_val, false );
187 return 0;
188 case C_TOKEN( axPos ):
189 mrModel.mnAxisPos = rAttribs.getToken( XML_val, XML_TOKEN_INVALID );
190 return 0;
191 case C_TOKEN( lblAlgn ):
192 mrModel.mnLabelAlign = rAttribs.getToken( XML_val, XML_ctr );
193 return 0;
194 case C_TOKEN( lblOffset ):
195 mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
196 return 0;
197 case C_TOKEN( noMultiLvlLbl ):
198 // default is 'false', not 'true' as specified
199 mrModel.mbNoMultiLevel = rAttribs.getBool( XML_val, false );
200 return 0;
201 case C_TOKEN( tickLblSkip ):
202 mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
203 return 0;
204 case C_TOKEN( tickMarkSkip ):
205 mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
206 return 0;
208 return AxisContextBase::onCreateContext( nElement, rAttribs );
211 // ============================================================================
213 DateAxisContext::DateAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
214 AxisContextBase( rParent, rModel )
218 DateAxisContext::~DateAxisContext()
222 ContextHandlerRef DateAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
224 if( isRootElement() ) switch( nElement )
226 case C_TOKEN( auto ):
227 // default is 'false', not 'true' as specified
228 mrModel.mbAuto = rAttribs.getBool( XML_val, false );
229 return 0;
230 case C_TOKEN( baseTimeUnit ):
231 mrModel.monBaseTimeUnit = rAttribs.getToken( XML_val, XML_days );
232 return 0;
233 case C_TOKEN( lblOffset ):
234 mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
235 return 0;
236 case C_TOKEN( majorTimeUnit ):
237 mrModel.mnMajorTimeUnit = rAttribs.getToken( XML_val, XML_days );
238 return 0;
239 case C_TOKEN( majorUnit ):
240 mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
241 return 0;
242 case C_TOKEN( minorTimeUnit ):
243 mrModel.mnMinorTimeUnit = rAttribs.getToken( XML_val, XML_days );
244 return 0;
245 case C_TOKEN( minorUnit ):
246 mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
247 return 0;
249 return AxisContextBase::onCreateContext( nElement, rAttribs );
252 // ============================================================================
254 SerAxisContext::SerAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
255 AxisContextBase( rParent, rModel )
259 SerAxisContext::~SerAxisContext()
263 ContextHandlerRef SerAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
265 if( isRootElement() ) switch( nElement )
267 case C_TOKEN( tickLblSkip ):
268 mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
269 return 0;
270 case C_TOKEN( tickMarkSkip ):
271 mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
272 return 0;
274 return AxisContextBase::onCreateContext( nElement, rAttribs );
277 // ============================================================================
279 ValAxisContext::ValAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
280 AxisContextBase( rParent, rModel )
284 ValAxisContext::~ValAxisContext()
288 ContextHandlerRef ValAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
290 if( isRootElement() ) switch( nElement )
292 case C_TOKEN( crossBetween ):
293 mrModel.mnCrossBetween = rAttribs.getToken( XML_val, XML_between );
294 return 0;
295 case C_TOKEN( dispUnits ):
296 return new AxisDispUnitsContext( *this, mrModel.mxDispUnits.create() );
297 case C_TOKEN( majorUnit ):
298 mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
299 return 0;
300 case C_TOKEN( minorUnit ):
301 mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
302 return 0;
304 return AxisContextBase::onCreateContext( nElement, rAttribs );
307 // ============================================================================
309 } // namespace chart
310 } // namespace drawingml
311 } // namespace oox
313 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */