fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / chart / axiscontext.cxx
blobe735ac82fd45b2fefcbbf3dabceb353543c78203
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 "drawingml/chart/axiscontext.hxx"
22 #include "drawingml/shapepropertiescontext.hxx"
23 #include "drawingml/textbodycontext.hxx"
24 #include "drawingml/chart/axismodel.hxx"
25 #include "drawingml/chart/titlecontext.hxx"
27 namespace oox {
28 namespace drawingml {
29 namespace chart {
31 using ::oox::core::ContextHandlerRef;
32 using ::oox::core::ContextHandler2Helper;
34 AxisDispUnitsContext::AxisDispUnitsContext( ContextHandler2Helper& rParent, AxisDispUnitsModel& rModel ) :
35 ContextBase< AxisDispUnitsModel >( rParent, rModel )
39 AxisDispUnitsContext::~AxisDispUnitsContext()
43 ContextHandlerRef AxisDispUnitsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
45 switch( getCurrentElement() )
47 case C_TOKEN( dispUnits ):
48 switch( nElement )
50 case C_TOKEN( builtInUnit ):
51 mrModel.mnBuiltInUnit = rAttribs.getString( XML_val, "thousands" );
52 return 0;
53 case C_TOKEN( custUnit ):
54 mrModel.mfCustomUnit = rAttribs.getDouble( XML_val, 0.0 );
55 return 0;
56 case C_TOKEN( dispUnitsLbl ):
57 return this;
59 break;
61 case C_TOKEN( dispUnitsLbl ):
62 switch( nElement )
64 case C_TOKEN( layout ):
65 return new LayoutContext( *this, mrModel.mxLayout.create() );
66 case C_TOKEN( spPr ):
67 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
68 case C_TOKEN( tx ):
69 return new TextContext( *this, mrModel.mxText.create() );
70 case C_TOKEN( txPr ):
71 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
73 break;
75 return 0;
78 AxisContextBase::AxisContextBase( ContextHandler2Helper& rParent, AxisModel& rModel ) :
79 ContextBase< AxisModel >( rParent, rModel )
83 AxisContextBase::~AxisContextBase()
87 ContextHandlerRef AxisContextBase::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
89 bool bMSO2007Doc = getFilter().isMSO2007Document();
90 switch( getCurrentElement() )
92 case C_TOKEN( catAx ):
93 case C_TOKEN( dateAx ):
94 case C_TOKEN( serAx ):
95 case C_TOKEN( valAx ):
96 switch( nElement )
98 case C_TOKEN( axId ):
99 mrModel.mnAxisId = rAttribs.getInteger( XML_val, -1 );
100 return 0;
101 case C_TOKEN( crossAx ):
102 mrModel.mnCrossAxisId = rAttribs.getInteger( XML_val, -1 );
103 return 0;
104 case C_TOKEN( crosses ):
105 mrModel.mnCrossMode = rAttribs.getToken( XML_val, XML_autoZero );
106 return 0;
107 case C_TOKEN( crossesAt ):
108 mrModel.mofCrossesAt = rAttribs.getDouble( XML_val, 0.0 );
109 return 0;
110 case C_TOKEN( delete ):
111 mrModel.mbDeleted = rAttribs.getBool( XML_val, !bMSO2007Doc );
112 return 0;
113 case C_TOKEN( majorGridlines ):
114 return new ShapePrWrapperContext( *this, mrModel.mxMajorGridLines.create() );
115 case C_TOKEN( majorTickMark ):
116 mrModel.mnMajorTickMark = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_out : XML_cross );
117 return 0;
118 case C_TOKEN(axPos):
119 mrModel.mnAxisPos = rAttribs.getToken( XML_val, XML_TOKEN_INVALID );
120 return 0;
121 case C_TOKEN( minorGridlines ):
122 return new ShapePrWrapperContext( *this, mrModel.mxMinorGridLines.create() );
123 case C_TOKEN( minorTickMark ):
124 mrModel.mnMinorTickMark = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_none : XML_cross );
125 return 0;
126 case C_TOKEN( numFmt ):
127 mrModel.maNumberFormat.setAttributes( rAttribs );
128 return 0;
129 case C_TOKEN( scaling ):
130 return this;
131 case C_TOKEN( spPr ):
132 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
133 case C_TOKEN( tickLblPos ):
134 mrModel.mnTickLabelPos = rAttribs.getToken( XML_val, XML_nextTo );
135 return 0;
136 case C_TOKEN( title ):
138 bool bVerticalDefault = mrModel.mnAxisPos == XML_l || mrModel.mnAxisPos == XML_r;
139 sal_Int32 nDefaultRotation = bVerticalDefault ? -5400000 : 0;
140 return new TitleContext( *this, mrModel.mxTitle.create(nDefaultRotation) );
142 case C_TOKEN( txPr ):
143 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
145 break;
147 case C_TOKEN( scaling ):
148 switch( nElement )
150 case C_TOKEN( logBase ):
151 mrModel.mofLogBase = rAttribs.getDouble( XML_val, 0.0 );
152 return 0;
153 case C_TOKEN( max ):
154 mrModel.mofMax = rAttribs.getDouble( XML_val, 0.0 );
155 return 0;
156 case C_TOKEN( min ):
157 mrModel.mofMin = rAttribs.getDouble( XML_val, 0.0 );
158 return 0;
159 case C_TOKEN( orientation ):
160 mrModel.mnOrientation = rAttribs.getToken( XML_val, XML_minMax );
161 return 0;
163 break;
165 return 0;
168 CatAxisContext::CatAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
169 AxisContextBase( rParent, rModel )
173 CatAxisContext::~CatAxisContext()
177 ContextHandlerRef CatAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
179 bool bMSO2007Doc = getFilter().isMSO2007Document();
180 if( isRootElement() ) switch( nElement )
182 case C_TOKEN( auto ):
183 mrModel.mbAuto = rAttribs.getBool( XML_val, !bMSO2007Doc );
184 return 0;
185 case C_TOKEN( lblAlgn ):
186 mrModel.mnLabelAlign = rAttribs.getToken( XML_val, XML_ctr );
187 return 0;
188 case C_TOKEN( lblOffset ):
189 mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
190 return 0;
191 case C_TOKEN( noMultiLvlLbl ):
192 mrModel.mbNoMultiLevel = rAttribs.getBool( XML_val, !bMSO2007Doc );
193 return 0;
194 case C_TOKEN( tickLblSkip ):
195 mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
196 return 0;
197 case C_TOKEN( tickMarkSkip ):
198 mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
199 return 0;
201 return AxisContextBase::onCreateContext( nElement, rAttribs );
204 DateAxisContext::DateAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
205 AxisContextBase( rParent, rModel )
209 DateAxisContext::~DateAxisContext()
213 ContextHandlerRef DateAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
215 bool bMSO2007Doc = getFilter().isMSO2007Document();
216 if( isRootElement() ) switch( nElement )
218 case C_TOKEN( auto ):
219 mrModel.mbAuto = rAttribs.getBool( XML_val, !bMSO2007Doc );
220 return 0;
221 case C_TOKEN( baseTimeUnit ):
222 mrModel.monBaseTimeUnit = rAttribs.getToken( XML_val, XML_days );
223 return 0;
224 case C_TOKEN( lblOffset ):
225 mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
226 return 0;
227 case C_TOKEN( majorTimeUnit ):
228 mrModel.mnMajorTimeUnit = rAttribs.getToken( XML_val, XML_days );
229 return 0;
230 case C_TOKEN( majorUnit ):
231 mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
232 return 0;
233 case C_TOKEN( minorTimeUnit ):
234 mrModel.mnMinorTimeUnit = rAttribs.getToken( XML_val, XML_days );
235 return 0;
236 case C_TOKEN( minorUnit ):
237 mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
238 return 0;
240 return AxisContextBase::onCreateContext( nElement, rAttribs );
243 SerAxisContext::SerAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
244 AxisContextBase( rParent, rModel )
248 SerAxisContext::~SerAxisContext()
252 ContextHandlerRef SerAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
254 if( isRootElement() ) switch( nElement )
256 case C_TOKEN( tickLblSkip ):
257 mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
258 return 0;
259 case C_TOKEN( tickMarkSkip ):
260 mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
261 return 0;
263 return AxisContextBase::onCreateContext( nElement, rAttribs );
266 ValAxisContext::ValAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
267 AxisContextBase( rParent, rModel )
271 ValAxisContext::~ValAxisContext()
275 ContextHandlerRef ValAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
277 if( isRootElement() ) switch( nElement )
279 case C_TOKEN( crossBetween ):
280 mrModel.mnCrossBetween = rAttribs.getToken( XML_val, XML_between );
281 return 0;
282 case C_TOKEN( dispUnits ):
283 return new AxisDispUnitsContext( *this, mrModel.mxDispUnits.create() );
284 case C_TOKEN( majorUnit ):
285 mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
286 return 0;
287 case C_TOKEN( minorUnit ):
288 mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
289 return 0;
291 return AxisContextBase::onCreateContext( nElement, rAttribs );
294 } // namespace chart
295 } // namespace drawingml
296 } // namespace oox
298 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */