LibreOffice Module oox (master) 1
axiscontext.cxx
Go to the documentation of this file.
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
21
28#include <oox/token/namespaces.hxx>
29#include <oox/token/tokens.hxx>
30
31namespace oox::drawingml::chart {
32
34using ::oox::core::ContextHandler2Helper;
35
36AxisDispUnitsContext::AxisDispUnitsContext( ContextHandler2Helper& rParent, AxisDispUnitsModel& rModel ) :
37 ContextBase< AxisDispUnitsModel >( rParent, rModel )
38{
39}
40
42{
43}
44
46{
47 switch( getCurrentElement() )
48 {
49 case C_TOKEN( dispUnits ):
50 switch( nElement )
51 {
52 case C_TOKEN( builtInUnit ):
53 mrModel.mnBuiltInUnit = rAttribs.getString( XML_val, "thousands" );
54 return nullptr;
55 case C_TOKEN( custUnit ):
56 mrModel.mfCustomUnit = rAttribs.getDouble( XML_val, 0.0 );
57 return nullptr;
58 case C_TOKEN( dispUnitsLbl ):
59 return this;
60 }
61 break;
62
63 case C_TOKEN( dispUnitsLbl ):
64 switch( nElement )
65 {
66 case C_TOKEN( layout ):
67 return new LayoutContext( *this, mrModel.mxLayout.create() );
68 case C_TOKEN( spPr ):
69 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
70 case C_TOKEN( tx ):
71 return new TextContext( *this, mrModel.mxText.create() );
72 case C_TOKEN( txPr ):
73 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
74 }
75 break;
76 }
77 return nullptr;
78}
79
80AxisContextBase::AxisContextBase( ContextHandler2Helper& rParent, AxisModel& rModel ) :
81 ContextBase< AxisModel >( rParent, rModel )
82{
83}
84
86{
87}
88
90{
91 bool bMSO2007Doc = getFilter().isMSO2007Document();
92 switch( getCurrentElement() )
93 {
94 case C_TOKEN( catAx ):
95 case C_TOKEN( dateAx ):
96 case C_TOKEN( serAx ):
97 case C_TOKEN( valAx ):
98 switch( nElement )
99 {
100 case C_TOKEN( axId ):
101 mrModel.mnAxisId = rAttribs.getInteger( XML_val, -1 );
102 return nullptr;
103 case C_TOKEN( crossAx ):
104 mrModel.mnCrossAxisId = rAttribs.getInteger( XML_val, -1 );
105 return nullptr;
106 case C_TOKEN( crosses ):
107 mrModel.mnCrossMode = rAttribs.getToken( XML_val, XML_autoZero );
108 return nullptr;
109 case C_TOKEN( crossesAt ):
110 mrModel.mofCrossesAt = rAttribs.getDouble( XML_val, 0.0 );
111 return nullptr;
112 case C_TOKEN( delete ):
113 mrModel.mbDeleted = rAttribs.getBool( XML_val, !bMSO2007Doc );
114 return nullptr;
115 case C_TOKEN( majorGridlines ):
117 case C_TOKEN( majorTickMark ):
118 mrModel.mnMajorTickMark = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_out : XML_cross );
119 return nullptr;
120 case C_TOKEN(axPos):
121 mrModel.mnAxisPos = rAttribs.getToken( XML_val, XML_TOKEN_INVALID );
122 return nullptr;
123 case C_TOKEN( minorGridlines ):
125 case C_TOKEN( minorTickMark ):
126 mrModel.mnMinorTickMark = rAttribs.getToken( XML_val, bMSO2007Doc ? XML_none : XML_cross );
127 return nullptr;
128 case C_TOKEN( numFmt ):
130 return nullptr;
131 case C_TOKEN( scaling ):
132 return this;
133 case C_TOKEN( spPr ):
134 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
135 case C_TOKEN( tickLblPos ):
136 mrModel.mnTickLabelPos = rAttribs.getToken( XML_val, XML_nextTo );
137 return nullptr;
138 case C_TOKEN( title ):
139 {
140 bool bVerticalDefault = mrModel.mnAxisPos == XML_l || mrModel.mnAxisPos == XML_r;
141 sal_Int32 nDefaultRotation = bVerticalDefault ? -5400000 : 0;
142 return new TitleContext( *this, mrModel.mxTitle.create(nDefaultRotation) );
143 }
144 case C_TOKEN( txPr ):
145 return new TextBodyContext( *this, mrModel.mxTextProp.create() );
146 }
147 break;
148
149 case C_TOKEN( scaling ):
150 switch( nElement )
151 {
152 case C_TOKEN( logBase ):
153 mrModel.mofLogBase = rAttribs.getDouble( XML_val, 0.0 );
154 return nullptr;
155 case C_TOKEN( max ):
156 mrModel.mofMax = rAttribs.getDouble( XML_val, 0.0 );
157 return nullptr;
158 case C_TOKEN( min ):
159 mrModel.mofMin = rAttribs.getDouble( XML_val, 0.0 );
160 return nullptr;
161 case C_TOKEN( orientation ):
162 mrModel.mnOrientation = rAttribs.getToken( XML_val, XML_minMax );
163 return nullptr;
164 }
165 break;
166 }
167 return nullptr;
168}
169
170CatAxisContext::CatAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
171 AxisContextBase( rParent, rModel )
172{
173}
174
176{
177}
178
180{
181 bool bMSO2007Doc = getFilter().isMSO2007Document();
182 if( isRootElement() ) switch( nElement )
183 {
184 case C_TOKEN( auto ):
185 mrModel.mbAuto = rAttribs.getBool( XML_val, !bMSO2007Doc );
186 return nullptr;
187 case C_TOKEN( lblAlgn ):
188 mrModel.mnLabelAlign = rAttribs.getToken( XML_val, XML_ctr );
189 return nullptr;
190 case C_TOKEN( lblOffset ):
191 mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
192 return nullptr;
193 case C_TOKEN( noMultiLvlLbl ):
194 mrModel.mbNoMultiLevel = rAttribs.getBool( XML_val, !bMSO2007Doc );
195 return nullptr;
196 case C_TOKEN( tickLblSkip ):
197 mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
198 return nullptr;
199 case C_TOKEN( tickMarkSkip ):
200 mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
201 return nullptr;
202 }
203 return AxisContextBase::onCreateContext( nElement, rAttribs );
204}
205
206DateAxisContext::DateAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
207 AxisContextBase( rParent, rModel )
208{
209}
210
212{
213}
214
216{
217 bool bMSO2007Doc = getFilter().isMSO2007Document();
218 if( isRootElement() ) switch( nElement )
219 {
220 case C_TOKEN( auto ):
221 mrModel.mbAuto = rAttribs.getBool( XML_val, !bMSO2007Doc );
222 return nullptr;
223 case C_TOKEN( baseTimeUnit ):
224 mrModel.monBaseTimeUnit = rAttribs.getToken( XML_val, XML_days );
225 return nullptr;
226 case C_TOKEN( lblOffset ):
227 mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
228 return nullptr;
229 case C_TOKEN( majorTimeUnit ):
230 mrModel.mnMajorTimeUnit = rAttribs.getToken( XML_val, XML_days );
231 return nullptr;
232 case C_TOKEN( majorUnit ):
233 mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
234 return nullptr;
235 case C_TOKEN( minorTimeUnit ):
236 mrModel.mnMinorTimeUnit = rAttribs.getToken( XML_val, XML_days );
237 return nullptr;
238 case C_TOKEN( minorUnit ):
239 mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
240 return nullptr;
241 }
242 return AxisContextBase::onCreateContext( nElement, rAttribs );
243}
244
245SerAxisContext::SerAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
246 AxisContextBase( rParent, rModel )
247{
248}
249
251{
252}
253
255{
256 if( isRootElement() ) switch( nElement )
257 {
258 case C_TOKEN( tickLblSkip ):
259 mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
260 return nullptr;
261 case C_TOKEN( tickMarkSkip ):
262 mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
263 return nullptr;
264 }
265 return AxisContextBase::onCreateContext( nElement, rAttribs );
266}
267
268ValAxisContext::ValAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
269 AxisContextBase( rParent, rModel )
270{
271}
272
274{
275}
276
278{
279 if( isRootElement() ) switch( nElement )
280 {
281 case C_TOKEN( crossBetween ):
282 mrModel.mnCrossBetween = rAttribs.getToken( XML_val, -1 );
283 return nullptr;
284 case C_TOKEN( dispUnits ):
285 return new AxisDispUnitsContext( *this, mrModel.mxDispUnits.create() );
286 case C_TOKEN( majorUnit ):
287 mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
288 return nullptr;
289 case C_TOKEN( minorUnit ):
290 mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
291 return nullptr;
292 }
293 return AxisContextBase::onCreateContext( nElement, rAttribs );
294}
295
296} // namespace oox::drawingml::chart
297
298/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides access to attribute values of an element.
std::optional< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Returns the 32-bit signed integer value of the specified attribute (decimal).
std::optional< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
std::optional< bool > getBool(sal_Int32 nAttrToken) const
Returns the boolean value of the specified attribute.
std::optional< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
std::optional< double > getDouble(sal_Int32 nAttrToken) const
Returns the double value of the specified attribute.
XmlFilterBase & getFilter() const
Returns the filter instance.
Base class for axis context handlers (c:catAx, c:dateAx, c:serAx, c:valAx elements).
Definition: axiscontext.hxx:48
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Definition: axiscontext.cxx:89
AxisContextBase(::oox::core::ContextHandler2Helper &rParent, AxisModel &rModel)
Definition: axiscontext.cxx:80
Handler for a value axis display units context (c:dispUnits element).
Definition: axiscontext.hxx:33
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Definition: axiscontext.cxx:45
AxisDispUnitsContext(::oox::core::ContextHandler2Helper &rParent, AxisDispUnitsModel &rModel)
Definition: axiscontext.cxx:36
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
CatAxisContext(::oox::core::ContextHandler2Helper &rParent, AxisModel &rModel)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
DateAxisContext(::oox::core::ContextHandler2Helper &rParent, AxisModel &rModel)
Handler for a chart layout context (c:layout element).
SerAxisContext(::oox::core::ContextHandler2Helper &rParent, AxisModel &rModel)
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Help class for all contexts that have only the c:spPr child element.
Handler for a chart text context (c:tx element).
Handler for a chart title context (c:title element).
virtual ::oox::core::ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
ValAxisContext(::oox::core::ContextHandler2Helper &rParent, AxisModel &rModel)
#define max(a, b)
::rtl::Reference< ContextHandler > ContextHandlerRef
orientation
XML_none
XML_TOKEN_INVALID
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
TextRef mxText
Layout/position of the axis units label.
Definition: axismodel.hxx:38
double mfCustomUnit
Text source of the axis units label.
Definition: axismodel.hxx:39
LayoutRef mxLayout
Label text formatting.
Definition: axismodel.hxx:37
OUString mnBuiltInUnit
Custom unit size on value axis.
Definition: axismodel.hxx:40
TextBodyRef mxTextProp
Label frame formatting.
Definition: axismodel.hxx:36
sal_Int32 mnTickLabelSkip
Position of tick mark labels relative to the axis.
Definition: axismodel.hxx:80
AxisDispUnitsRef mxDispUnits
Axis title.
Definition: axismodel.hxx:56
NumberFormat maNumberFormat
Minor grid lines formatting.
Definition: axismodel.hxx:59
sal_Int32 mnAxisPos
Unique axis identifier.
Definition: axismodel.hxx:68
sal_Int32 mnTickMarkSkip
Number of tick mark labels to skip.
Definition: axismodel.hxx:81
std::optional< sal_Int32 > monBaseTimeUnit
Minimum axis value.
Definition: axismodel.hxx:66
bool mbAuto
Type identifier of this axis.
Definition: axismodel.hxx:83
sal_Int32 mnLabelOffset
Tick mark label alignment.
Definition: axismodel.hxx:73
sal_Int32 mnAxisId
Base time unit shown on a date axis.
Definition: axismodel.hxx:67
TitleRef mxTitle
Axis label text formatting.
Definition: axismodel.hxx:55
std::optional< double > mofMax
Logarithmic base for logarithmic axes.
Definition: axismodel.hxx:64
sal_Int32 mnOrientation
Time unit for minor tick marks on date axis.
Definition: axismodel.hxx:78
sal_Int32 mnMinorTickMark
Time unit for major tick marks on date axis.
Definition: axismodel.hxx:76
std::optional< double > mofCrossesAt
Number format for axis tick labels.
Definition: axismodel.hxx:60
sal_Int32 mnMajorTickMark
Tick mark label distance from axis.
Definition: axismodel.hxx:74
sal_Int32 mnMajorTimeUnit
Major tick mark style.
Definition: axismodel.hxx:75
sal_Int32 mnCrossAxisId
Position of the axis (top/bottom/left/right).
Definition: axismodel.hxx:69
ShapeRef mxMajorGridLines
Axis units label.
Definition: axismodel.hxx:57
std::optional< double > mofLogBase
Unit for minor tick marks on date/value axis.
Definition: axismodel.hxx:63
ShapeRef mxMinorGridLines
Major grid lines formatting.
Definition: axismodel.hxx:58
bool mbNoMultiLevel
True = axis has been deleted manually.
Definition: axismodel.hxx:85
sal_Int32 mnCrossMode
This value axis crosses between or inside category.
Definition: axismodel.hxx:71
sal_Int32 mnLabelAlign
Mode this axis crosses another axis (min, max, auto).
Definition: axismodel.hxx:72
std::optional< double > mofMajorUnit
Position on this axis where another axis crosses.
Definition: axismodel.hxx:61
std::optional< double > mofMinorUnit
Unit for major tick marks on date/value axis.
Definition: axismodel.hxx:62
sal_Int32 mnMinorTimeUnit
Minor tick mark style.
Definition: axismodel.hxx:77
bool mbDeleted
True = automatic selection of text/date axis type.
Definition: axismodel.hxx:84
sal_Int32 mnCrossBetween
Identifier of a crossing axis.
Definition: axismodel.hxx:70
std::optional< double > mofMin
Maximum axis value.
Definition: axismodel.hxx:65
TextBodyRef mxTextProp
Axis line formatting.
Definition: axismodel.hxx:54
sal_Int32 mnTickLabelPos
Axis orientation (value order min to max, or max to min).
Definition: axismodel.hxx:79
void setAttributes(const AttributeList &rAttribs)
Definition: modelbase.cxx:32