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 "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"
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
):
50 case C_TOKEN( builtInUnit
):
51 mrModel
.mnBuiltInUnit
= rAttribs
.getString( XML_val
, "thousands" );
53 case C_TOKEN( custUnit
):
54 mrModel
.mfCustomUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
56 case C_TOKEN( dispUnitsLbl
):
61 case C_TOKEN( dispUnitsLbl
):
64 case C_TOKEN( layout
):
65 return new LayoutContext( *this, mrModel
.mxLayout
.create() );
67 return new ShapePropertiesContext( *this, mrModel
.mxShapeProp
.create() );
69 return new TextContext( *this, mrModel
.mxText
.create() );
71 return new TextBodyContext( *this, mrModel
.mxTextProp
.create() );
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
):
99 mrModel
.mnAxisId
= rAttribs
.getInteger( XML_val
, -1 );
101 case C_TOKEN( crossAx
):
102 mrModel
.mnCrossAxisId
= rAttribs
.getInteger( XML_val
, -1 );
104 case C_TOKEN( crosses
):
105 mrModel
.mnCrossMode
= rAttribs
.getToken( XML_val
, XML_autoZero
);
107 case C_TOKEN( crossesAt
):
108 mrModel
.mofCrossesAt
= rAttribs
.getDouble( XML_val
, 0.0 );
110 case C_TOKEN( delete ):
111 mrModel
.mbDeleted
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
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
);
119 mrModel
.mnAxisPos
= rAttribs
.getToken( XML_val
, XML_TOKEN_INVALID
);
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
);
126 case C_TOKEN( numFmt
):
127 mrModel
.maNumberFormat
.setAttributes( rAttribs
);
129 case C_TOKEN( scaling
):
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
);
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() );
147 case C_TOKEN( scaling
):
150 case C_TOKEN( logBase
):
151 mrModel
.mofLogBase
= rAttribs
.getDouble( XML_val
, 0.0 );
154 mrModel
.mofMax
= rAttribs
.getDouble( XML_val
, 0.0 );
157 mrModel
.mofMin
= rAttribs
.getDouble( XML_val
, 0.0 );
159 case C_TOKEN( orientation
):
160 mrModel
.mnOrientation
= rAttribs
.getToken( XML_val
, XML_minMax
);
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
);
185 case C_TOKEN( lblAlgn
):
186 mrModel
.mnLabelAlign
= rAttribs
.getToken( XML_val
, XML_ctr
);
188 case C_TOKEN( lblOffset
):
189 mrModel
.mnLabelOffset
= rAttribs
.getInteger( XML_val
, 100 );
191 case C_TOKEN( noMultiLvlLbl
):
192 mrModel
.mbNoMultiLevel
= rAttribs
.getBool( XML_val
, !bMSO2007Doc
);
194 case C_TOKEN( tickLblSkip
):
195 mrModel
.mnTickLabelSkip
= rAttribs
.getInteger( XML_val
, 0 );
197 case C_TOKEN( tickMarkSkip
):
198 mrModel
.mnTickMarkSkip
= rAttribs
.getInteger( XML_val
, 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
);
221 case C_TOKEN( baseTimeUnit
):
222 mrModel
.monBaseTimeUnit
= rAttribs
.getToken( XML_val
, XML_days
);
224 case C_TOKEN( lblOffset
):
225 mrModel
.mnLabelOffset
= rAttribs
.getInteger( XML_val
, 100 );
227 case C_TOKEN( majorTimeUnit
):
228 mrModel
.mnMajorTimeUnit
= rAttribs
.getToken( XML_val
, XML_days
);
230 case C_TOKEN( majorUnit
):
231 mrModel
.mofMajorUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
233 case C_TOKEN( minorTimeUnit
):
234 mrModel
.mnMinorTimeUnit
= rAttribs
.getToken( XML_val
, XML_days
);
236 case C_TOKEN( minorUnit
):
237 mrModel
.mofMinorUnit
= rAttribs
.getDouble( XML_val
, 0.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 );
259 case C_TOKEN( tickMarkSkip
):
260 mrModel
.mnTickMarkSkip
= rAttribs
.getInteger( XML_val
, 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
);
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 );
287 case C_TOKEN( minorUnit
):
288 mrModel
.mofMinorUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
291 return AxisContextBase::onCreateContext( nElement
, rAttribs
);
295 } // namespace drawingml
298 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */