Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include "oox/drawingml/chart/axiscontext.hxx"
21 :
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"
26 :
27 : namespace oox {
28 : namespace drawingml {
29 : namespace chart {
30 :
31 :
32 :
33 : using ::oox::core::ContextHandlerRef;
34 : using ::oox::core::ContextHandler2Helper;
35 :
36 :
37 :
38 0 : AxisDispUnitsContext::AxisDispUnitsContext( ContextHandler2Helper& rParent, AxisDispUnitsModel& rModel ) :
39 0 : ContextBase< AxisDispUnitsModel >( rParent, rModel )
40 : {
41 0 : }
42 :
43 0 : AxisDispUnitsContext::~AxisDispUnitsContext()
44 : {
45 0 : }
46 :
47 0 : ContextHandlerRef AxisDispUnitsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
48 : {
49 0 : switch( getCurrentElement() )
50 : {
51 : case C_TOKEN( dispUnits ):
52 0 : switch( nElement )
53 : {
54 : case C_TOKEN( builtInUnit ):
55 0 : mrModel.mnBuiltInUnit = rAttribs.getString( XML_val, "thousands" );
56 0 : return 0;
57 : case C_TOKEN( custUnit ):
58 0 : mrModel.mfCustomUnit = rAttribs.getDouble( XML_val, 0.0 );
59 0 : return 0;
60 : case C_TOKEN( dispUnitsLbl ):
61 0 : return this;
62 : }
63 0 : break;
64 :
65 : case C_TOKEN( dispUnitsLbl ):
66 0 : switch( nElement )
67 : {
68 : case C_TOKEN( layout ):
69 0 : return new LayoutContext( *this, mrModel.mxLayout.create() );
70 : case C_TOKEN( spPr ):
71 0 : return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
72 : case C_TOKEN( tx ):
73 0 : return new TextContext( *this, mrModel.mxText.create() );
74 : case C_TOKEN( txPr ):
75 0 : return new TextBodyContext( *this, mrModel.mxTextProp.create() );
76 : }
77 0 : break;
78 : }
79 0 : return 0;
80 : }
81 :
82 :
83 :
84 0 : AxisContextBase::AxisContextBase( ContextHandler2Helper& rParent, AxisModel& rModel ) :
85 0 : ContextBase< AxisModel >( rParent, rModel )
86 : {
87 0 : }
88 :
89 0 : AxisContextBase::~AxisContextBase()
90 : {
91 0 : }
92 :
93 0 : ContextHandlerRef AxisContextBase::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
94 : {
95 0 : switch( getCurrentElement() )
96 : {
97 : case C_TOKEN( catAx ):
98 : case C_TOKEN( dateAx ):
99 : case C_TOKEN( serAx ):
100 : case C_TOKEN( valAx ):
101 0 : switch( nElement )
102 : {
103 : case C_TOKEN( axId ):
104 0 : mrModel.mnAxisId = rAttribs.getInteger( XML_val, -1 );
105 0 : return 0;
106 : case C_TOKEN( crossAx ):
107 0 : mrModel.mnCrossAxisId = rAttribs.getInteger( XML_val, -1 );
108 0 : return 0;
109 : case C_TOKEN( crosses ):
110 0 : mrModel.mnCrossMode = rAttribs.getToken( XML_val, XML_autoZero );
111 0 : return 0;
112 : case C_TOKEN( crossesAt ):
113 0 : mrModel.mofCrossesAt = rAttribs.getDouble( XML_val, 0.0 );
114 0 : return 0;
115 : case C_TOKEN( delete ):
116 : // default is 'false', not 'true' as specified
117 0 : mrModel.mbDeleted = rAttribs.getBool( XML_val, false );
118 0 : return 0;
119 : case C_TOKEN( majorGridlines ):
120 0 : return new ShapePrWrapperContext( *this, mrModel.mxMajorGridLines.create() );
121 : case C_TOKEN( majorTickMark ):
122 : // default is 'out', not 'cross' as specified
123 0 : mrModel.mnMajorTickMark = rAttribs.getToken( XML_val, XML_out );
124 0 : return 0;
125 : case C_TOKEN( minorGridlines ):
126 0 : return new ShapePrWrapperContext( *this, mrModel.mxMinorGridLines.create() );
127 : case C_TOKEN( minorTickMark ):
128 : // default is 'none', not 'cross' as specified
129 0 : mrModel.mnMinorTickMark = rAttribs.getToken( XML_val, XML_none );
130 0 : return 0;
131 : case C_TOKEN( numFmt ):
132 0 : mrModel.maNumberFormat.setAttributes( rAttribs );
133 0 : return 0;
134 : case C_TOKEN( scaling ):
135 0 : return this;
136 : case C_TOKEN( spPr ):
137 0 : return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
138 : case C_TOKEN( tickLblPos ):
139 0 : mrModel.mnTickLabelPos = rAttribs.getToken( XML_val, XML_nextTo );
140 0 : return 0;
141 : case C_TOKEN( title ):
142 0 : return new TitleContext( *this, mrModel.mxTitle.create() );
143 : case C_TOKEN( txPr ):
144 0 : return new TextBodyContext( *this, mrModel.mxTextProp.create() );
145 : }
146 0 : break;
147 :
148 : case C_TOKEN( scaling ):
149 0 : switch( nElement )
150 : {
151 : case C_TOKEN( logBase ):
152 0 : mrModel.mofLogBase = rAttribs.getDouble( XML_val, 0.0 );
153 0 : return 0;
154 : case C_TOKEN( max ):
155 0 : mrModel.mofMax = rAttribs.getDouble( XML_val, 0.0 );
156 0 : return 0;
157 : case C_TOKEN( min ):
158 0 : mrModel.mofMin = rAttribs.getDouble( XML_val, 0.0 );
159 0 : return 0;
160 : case C_TOKEN( orientation ):
161 0 : mrModel.mnOrientation = rAttribs.getToken( XML_val, XML_minMax );
162 0 : return 0;
163 : }
164 0 : break;
165 : }
166 0 : return 0;
167 : }
168 :
169 :
170 :
171 0 : CatAxisContext::CatAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
172 0 : AxisContextBase( rParent, rModel )
173 : {
174 0 : }
175 :
176 0 : CatAxisContext::~CatAxisContext()
177 : {
178 0 : }
179 :
180 0 : ContextHandlerRef CatAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
181 : {
182 0 : if( isRootElement() ) switch( nElement )
183 : {
184 : case C_TOKEN( auto ):
185 : // default is 'false', not 'true' as specified
186 0 : mrModel.mbAuto = rAttribs.getBool( XML_val, false );
187 0 : return 0;
188 : case C_TOKEN( axPos ):
189 0 : mrModel.mnAxisPos = rAttribs.getToken( XML_val, XML_TOKEN_INVALID );
190 0 : return 0;
191 : case C_TOKEN( lblAlgn ):
192 0 : mrModel.mnLabelAlign = rAttribs.getToken( XML_val, XML_ctr );
193 0 : return 0;
194 : case C_TOKEN( lblOffset ):
195 0 : mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
196 0 : return 0;
197 : case C_TOKEN( noMultiLvlLbl ):
198 : // default is 'false', not 'true' as specified
199 0 : mrModel.mbNoMultiLevel = rAttribs.getBool( XML_val, false );
200 0 : return 0;
201 : case C_TOKEN( tickLblSkip ):
202 0 : mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
203 0 : return 0;
204 : case C_TOKEN( tickMarkSkip ):
205 0 : mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
206 0 : return 0;
207 : }
208 0 : return AxisContextBase::onCreateContext( nElement, rAttribs );
209 : }
210 :
211 :
212 :
213 0 : DateAxisContext::DateAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
214 0 : AxisContextBase( rParent, rModel )
215 : {
216 0 : }
217 :
218 0 : DateAxisContext::~DateAxisContext()
219 : {
220 0 : }
221 :
222 0 : ContextHandlerRef DateAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
223 : {
224 0 : if( isRootElement() ) switch( nElement )
225 : {
226 : case C_TOKEN( auto ):
227 : // default is 'false', not 'true' as specified
228 0 : mrModel.mbAuto = rAttribs.getBool( XML_val, false );
229 0 : return 0;
230 : case C_TOKEN( baseTimeUnit ):
231 0 : mrModel.monBaseTimeUnit = rAttribs.getToken( XML_val, XML_days );
232 0 : return 0;
233 : case C_TOKEN( lblOffset ):
234 0 : mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
235 0 : return 0;
236 : case C_TOKEN( majorTimeUnit ):
237 0 : mrModel.mnMajorTimeUnit = rAttribs.getToken( XML_val, XML_days );
238 0 : return 0;
239 : case C_TOKEN( majorUnit ):
240 0 : mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
241 0 : return 0;
242 : case C_TOKEN( minorTimeUnit ):
243 0 : mrModel.mnMinorTimeUnit = rAttribs.getToken( XML_val, XML_days );
244 0 : return 0;
245 : case C_TOKEN( minorUnit ):
246 0 : mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
247 0 : return 0;
248 : }
249 0 : return AxisContextBase::onCreateContext( nElement, rAttribs );
250 : }
251 :
252 :
253 :
254 0 : SerAxisContext::SerAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
255 0 : AxisContextBase( rParent, rModel )
256 : {
257 0 : }
258 :
259 0 : SerAxisContext::~SerAxisContext()
260 : {
261 0 : }
262 :
263 0 : ContextHandlerRef SerAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
264 : {
265 0 : if( isRootElement() ) switch( nElement )
266 : {
267 : case C_TOKEN( tickLblSkip ):
268 0 : mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
269 0 : return 0;
270 : case C_TOKEN( tickMarkSkip ):
271 0 : mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
272 0 : return 0;
273 : }
274 0 : return AxisContextBase::onCreateContext( nElement, rAttribs );
275 : }
276 :
277 :
278 :
279 0 : ValAxisContext::ValAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
280 0 : AxisContextBase( rParent, rModel )
281 : {
282 0 : }
283 :
284 0 : ValAxisContext::~ValAxisContext()
285 : {
286 0 : }
287 :
288 0 : ContextHandlerRef ValAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
289 : {
290 0 : if( isRootElement() ) switch( nElement )
291 : {
292 : case C_TOKEN( crossBetween ):
293 0 : mrModel.mnCrossBetween = rAttribs.getToken( XML_val, XML_between );
294 0 : return 0;
295 : case C_TOKEN( dispUnits ):
296 0 : return new AxisDispUnitsContext( *this, mrModel.mxDispUnits.create() );
297 : case C_TOKEN( majorUnit ):
298 0 : mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
299 0 : return 0;
300 : case C_TOKEN( minorUnit ):
301 0 : mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
302 0 : return 0;
303 : }
304 0 : return AxisContextBase::onCreateContext( nElement, rAttribs );
305 : }
306 :
307 :
308 :
309 : } // namespace chart
310 : } // namespace drawingml
311 0 : } // namespace oox
312 :
313 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|