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