1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
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
):
54 case C_TOKEN( builtInUnit
):
55 mrModel
.mnBuiltInUnit
= rAttribs
.getToken( XML_val
, XML_thousands
);
57 case C_TOKEN( custUnit
):
58 mrModel
.mfCustomUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
60 case C_TOKEN( dispUnitsLbl
):
65 case C_TOKEN( dispUnitsLbl
):
68 case C_TOKEN( layout
):
69 return new LayoutContext( *this, mrModel
.mxLayout
.create() );
71 return new ShapePropertiesContext( *this, mrModel
.mxShapeProp
.create() );
73 return new TextContext( *this, mrModel
.mxText
.create() );
75 return new TextBodyContext( *this, mrModel
.mxTextProp
.create() );
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
):
103 case C_TOKEN( axId
):
104 mrModel
.mnAxisId
= rAttribs
.getInteger( XML_val
, -1 );
106 case C_TOKEN( crossAx
):
107 mrModel
.mnCrossAxisId
= rAttribs
.getInteger( XML_val
, -1 );
109 case C_TOKEN( crosses
):
110 mrModel
.mnCrossMode
= rAttribs
.getToken( XML_val
, XML_autoZero
);
112 case C_TOKEN( crossesAt
):
113 mrModel
.mofCrossesAt
= rAttribs
.getDouble( XML_val
, 0.0 );
115 case C_TOKEN( delete ):
116 // default is 'false', not 'true' as specified
117 mrModel
.mbDeleted
= rAttribs
.getBool( XML_val
, false );
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
);
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
);
131 case C_TOKEN( numFmt
):
132 mrModel
.maNumberFormat
.setAttributes( rAttribs
);
134 case C_TOKEN( scaling
):
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
);
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() );
148 case C_TOKEN( scaling
):
151 case C_TOKEN( logBase
):
152 mrModel
.mofLogBase
= rAttribs
.getDouble( XML_val
, 0.0 );
155 mrModel
.mofMax
= rAttribs
.getDouble( XML_val
, 0.0 );
158 mrModel
.mofMin
= rAttribs
.getDouble( XML_val
, 0.0 );
160 case C_TOKEN( orientation
):
161 mrModel
.mnOrientation
= rAttribs
.getToken( XML_val
, XML_minMax
);
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 );
188 case C_TOKEN( axPos
):
189 mrModel
.mnAxisPos
= rAttribs
.getToken( XML_val
, XML_TOKEN_INVALID
);
191 case C_TOKEN( lblAlgn
):
192 mrModel
.mnLabelAlign
= rAttribs
.getToken( XML_val
, XML_ctr
);
194 case C_TOKEN( lblOffset
):
195 mrModel
.mnLabelOffset
= rAttribs
.getInteger( XML_val
, 100 );
197 case C_TOKEN( noMultiLvlLbl
):
198 // default is 'false', not 'true' as specified
199 mrModel
.mbNoMultiLevel
= rAttribs
.getBool( XML_val
, false );
201 case C_TOKEN( tickLblSkip
):
202 mrModel
.mnTickLabelSkip
= rAttribs
.getInteger( XML_val
, 0 );
204 case C_TOKEN( tickMarkSkip
):
205 mrModel
.mnTickMarkSkip
= rAttribs
.getInteger( XML_val
, 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 );
230 case C_TOKEN( baseTimeUnit
):
231 mrModel
.monBaseTimeUnit
= rAttribs
.getToken( XML_val
, XML_days
);
233 case C_TOKEN( lblOffset
):
234 mrModel
.mnLabelOffset
= rAttribs
.getInteger( XML_val
, 100 );
236 case C_TOKEN( majorTimeUnit
):
237 mrModel
.mnMajorTimeUnit
= rAttribs
.getToken( XML_val
, XML_days
);
239 case C_TOKEN( majorUnit
):
240 mrModel
.mofMajorUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
242 case C_TOKEN( minorTimeUnit
):
243 mrModel
.mnMinorTimeUnit
= rAttribs
.getToken( XML_val
, XML_days
);
245 case C_TOKEN( minorUnit
):
246 mrModel
.mofMinorUnit
= rAttribs
.getDouble( XML_val
, 0.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 );
270 case C_TOKEN( tickMarkSkip
):
271 mrModel
.mnTickMarkSkip
= rAttribs
.getInteger( XML_val
, 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
);
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 );
300 case C_TOKEN( minorUnit
):
301 mrModel
.mofMinorUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
304 return AxisContextBase::onCreateContext( nElement
, rAttribs
);
307 // ============================================================================
310 } // namespace drawingml
313 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */