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