1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: axiscontext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/drawingml/chart/axiscontext.hxx"
32 #include "oox/drawingml/shapepropertiescontext.hxx"
33 #include "oox/drawingml/textbodycontext.hxx"
34 #include "oox/drawingml/chart/axismodel.hxx"
35 #include "oox/drawingml/chart/titlecontext.hxx"
37 using ::rtl::OUString
;
38 using ::oox::core::ContextHandlerRef
;
39 using ::oox::core::ContextHandler2Helper
;
45 // ============================================================================
47 AxisDispUnitsContext::AxisDispUnitsContext( ContextHandler2Helper
& rParent
, AxisDispUnitsModel
& rModel
) :
48 ContextBase
< AxisDispUnitsModel
>( rParent
, rModel
)
52 AxisDispUnitsContext::~AxisDispUnitsContext()
56 ContextHandlerRef
AxisDispUnitsContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
58 switch( getCurrentElement() )
60 case C_TOKEN( dispUnits
):
63 case C_TOKEN( builtInUnit
):
64 mrModel
.mnBuiltInUnit
= rAttribs
.getToken( XML_val
, XML_thousands
);
66 case C_TOKEN( custUnit
):
67 mrModel
.mfCustomUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
69 case C_TOKEN( dispUnitsLbl
):
74 case C_TOKEN( dispUnitsLbl
):
77 case C_TOKEN( layout
):
78 return new LayoutContext( *this, mrModel
.mxLayout
.create() );
80 return new ShapePropertiesContext( *this, mrModel
.mxShapeProp
.create() );
82 return new TextContext( *this, mrModel
.mxText
.create() );
84 return new TextBodyContext( *this, mrModel
.mxTextProp
.create() );
91 // ============================================================================
93 AxisContextBase::AxisContextBase( ContextHandler2Helper
& rParent
, AxisModel
& rModel
) :
94 ContextBase
< AxisModel
>( rParent
, rModel
)
98 AxisContextBase::~AxisContextBase()
102 ContextHandlerRef
AxisContextBase::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
104 switch( getCurrentElement() )
106 case C_TOKEN( catAx
):
107 case C_TOKEN( dateAx
):
108 case C_TOKEN( serAx
):
109 case C_TOKEN( valAx
):
112 case C_TOKEN( axId
):
113 mrModel
.mnAxisId
= rAttribs
.getInteger( XML_val
, -1 );
115 case C_TOKEN( crossAx
):
116 mrModel
.mnCrossAxisId
= rAttribs
.getInteger( XML_val
, -1 );
118 case C_TOKEN( crosses
):
119 mrModel
.mnCrossMode
= rAttribs
.getToken( XML_val
, XML_autoZero
);
121 case C_TOKEN( crossesAt
):
122 mrModel
.mofCrossesAt
= rAttribs
.getDouble( XML_val
, 0.0 );
124 case C_TOKEN( delete ):
125 // default is 'false', not 'true' as specified
126 mrModel
.mbDeleted
= rAttribs
.getBool( XML_val
, false );
128 case C_TOKEN( majorGridlines
):
129 return new ShapePrWrapperContext( *this, mrModel
.mxMajorGridLines
.create() );
130 case C_TOKEN( majorTickMark
):
131 // default is 'out', not 'cross' as specified
132 mrModel
.mnMajorTickMark
= rAttribs
.getToken( XML_val
, XML_out
);
134 case C_TOKEN( minorGridlines
):
135 return new ShapePrWrapperContext( *this, mrModel
.mxMinorGridLines
.create() );
136 case C_TOKEN( minorTickMark
):
137 // default is 'none', not 'cross' as specified
138 mrModel
.mnMinorTickMark
= rAttribs
.getToken( XML_val
, XML_none
);
140 case C_TOKEN( numFmt
):
141 mrModel
.maNumberFormat
.setAttributes( rAttribs
);
143 case C_TOKEN( scaling
):
145 case C_TOKEN( spPr
):
146 return new ShapePropertiesContext( *this, mrModel
.mxShapeProp
.create() );
147 case C_TOKEN( tickLblPos
):
148 mrModel
.mnTickLabelPos
= rAttribs
.getToken( XML_val
, XML_nextTo
);
150 case C_TOKEN( title
):
151 return new TitleContext( *this, mrModel
.mxTitle
.create() );
152 case C_TOKEN( txPr
):
153 return new TextBodyContext( *this, mrModel
.mxTextProp
.create() );
157 case C_TOKEN( scaling
):
160 case C_TOKEN( logBase
):
161 mrModel
.mofLogBase
= rAttribs
.getDouble( XML_val
, 0.0 );
164 mrModel
.mofMax
= rAttribs
.getDouble( XML_val
, 0.0 );
167 mrModel
.mofMin
= rAttribs
.getDouble( XML_val
, 0.0 );
169 case C_TOKEN( orientation
):
170 mrModel
.mnOrientation
= rAttribs
.getToken( XML_val
, XML_minMax
);
178 // ============================================================================
180 CatAxisContext::CatAxisContext( ContextHandler2Helper
& rParent
, AxisModel
& rModel
) :
181 AxisContextBase( rParent
, rModel
)
185 CatAxisContext::~CatAxisContext()
189 ContextHandlerRef
CatAxisContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
191 if( isRootElement() ) switch( nElement
)
193 case C_TOKEN( auto ):
194 // default is 'false', not 'true' as specified
195 mrModel
.mbAuto
= rAttribs
.getBool( XML_val
, false );
197 case C_TOKEN( axPos
):
198 mrModel
.mnAxisPos
= rAttribs
.getToken( XML_val
, XML_TOKEN_INVALID
);
200 case C_TOKEN( lblAlgn
):
201 mrModel
.mnLabelAlign
= rAttribs
.getToken( XML_val
, XML_ctr
);
203 case C_TOKEN( lblOffset
):
204 mrModel
.mnLabelOffset
= rAttribs
.getInteger( XML_val
, 100 );
206 case C_TOKEN( noMultiLvlLbl
):
207 // default is 'false', not 'true' as specified
208 mrModel
.mbNoMultiLevel
= rAttribs
.getBool( XML_val
, false );
210 case C_TOKEN( tickLblSkip
):
211 mrModel
.mnTickLabelSkip
= rAttribs
.getInteger( XML_val
, 0 );
213 case C_TOKEN( tickMarkSkip
):
214 mrModel
.mnTickMarkSkip
= rAttribs
.getInteger( XML_val
, 0 );
217 return AxisContextBase::onCreateContext( nElement
, rAttribs
);
220 // ============================================================================
222 DateAxisContext::DateAxisContext( ContextHandler2Helper
& rParent
, AxisModel
& rModel
) :
223 AxisContextBase( rParent
, rModel
)
227 DateAxisContext::~DateAxisContext()
231 ContextHandlerRef
DateAxisContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
233 if( isRootElement() ) switch( nElement
)
235 case C_TOKEN( auto ):
236 // default is 'false', not 'true' as specified
237 mrModel
.mbAuto
= rAttribs
.getBool( XML_val
, false );
239 case C_TOKEN( baseTimeUnit
):
240 mrModel
.mnBaseTimeUnit
= rAttribs
.getToken( XML_val
, XML_days
);
242 case C_TOKEN( lblOffset
):
243 mrModel
.mnLabelOffset
= rAttribs
.getInteger( XML_val
, 100 );
245 case C_TOKEN( majorTimeUnit
):
246 mrModel
.mnMajorTimeUnit
= rAttribs
.getToken( XML_val
, XML_days
);
248 case C_TOKEN( majorUnit
):
249 mrModel
.mofMajorUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
251 case C_TOKEN( minorTimeUnit
):
252 mrModel
.mnMinorTimeUnit
= rAttribs
.getToken( XML_val
, XML_days
);
254 case C_TOKEN( minorUnit
):
255 mrModel
.mofMinorUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
258 return AxisContextBase::onCreateContext( nElement
, rAttribs
);
261 // ============================================================================
263 SerAxisContext::SerAxisContext( ContextHandler2Helper
& rParent
, AxisModel
& rModel
) :
264 AxisContextBase( rParent
, rModel
)
268 SerAxisContext::~SerAxisContext()
272 ContextHandlerRef
SerAxisContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
274 if( isRootElement() ) switch( nElement
)
276 case C_TOKEN( tickLblSkip
):
277 mrModel
.mnTickLabelSkip
= rAttribs
.getInteger( XML_val
, 0 );
279 case C_TOKEN( tickMarkSkip
):
280 mrModel
.mnTickMarkSkip
= rAttribs
.getInteger( XML_val
, 0 );
283 return AxisContextBase::onCreateContext( nElement
, rAttribs
);
286 // ============================================================================
288 ValAxisContext::ValAxisContext( ContextHandler2Helper
& rParent
, AxisModel
& rModel
) :
289 AxisContextBase( rParent
, rModel
)
293 ValAxisContext::~ValAxisContext()
297 ContextHandlerRef
ValAxisContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
299 if( isRootElement() ) switch( nElement
)
301 case C_TOKEN( crossBetween
):
302 mrModel
.mnCrossBetween
= rAttribs
.getToken( XML_val
, XML_between
);
304 case C_TOKEN( dispUnits
):
305 return new AxisDispUnitsContext( *this, mrModel
.mxDispUnits
.create() );
306 case C_TOKEN( majorUnit
):
307 mrModel
.mofMajorUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
309 case C_TOKEN( minorUnit
):
310 mrModel
.mofMinorUnit
= rAttribs
.getDouble( XML_val
, 0.0 );
313 return AxisContextBase::onCreateContext( nElement
, rAttribs
);
316 // ============================================================================
319 } // namespace drawingml