1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #include "oox/drawingml/chart/axiscontext.hxx"
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "oox/drawingml/shapepropertiescontext.hxx"
31*cdf0e10cSrcweir #include "oox/drawingml/textbodycontext.hxx"
32*cdf0e10cSrcweir #include "oox/drawingml/chart/axismodel.hxx"
33*cdf0e10cSrcweir #include "oox/drawingml/chart/titlecontext.hxx"
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir namespace oox {
36*cdf0e10cSrcweir namespace drawingml {
37*cdf0e10cSrcweir namespace chart {
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir // ============================================================================
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir using ::oox::core::ContextHandlerRef;
42*cdf0e10cSrcweir using ::oox::core::ContextHandler2Helper;
43*cdf0e10cSrcweir using ::rtl::OUString;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir // ============================================================================
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir AxisDispUnitsContext::AxisDispUnitsContext( ContextHandler2Helper& rParent, AxisDispUnitsModel& rModel ) :
48*cdf0e10cSrcweir     ContextBase< AxisDispUnitsModel >( rParent, rModel )
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir }
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir AxisDispUnitsContext::~AxisDispUnitsContext()
53*cdf0e10cSrcweir {
54*cdf0e10cSrcweir }
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir ContextHandlerRef AxisDispUnitsContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
57*cdf0e10cSrcweir {
58*cdf0e10cSrcweir     switch( getCurrentElement() )
59*cdf0e10cSrcweir     {
60*cdf0e10cSrcweir         case C_TOKEN( dispUnits ):
61*cdf0e10cSrcweir             switch( nElement )
62*cdf0e10cSrcweir             {
63*cdf0e10cSrcweir                 case C_TOKEN( builtInUnit ):
64*cdf0e10cSrcweir                     mrModel.mnBuiltInUnit = rAttribs.getToken( XML_val, XML_thousands );
65*cdf0e10cSrcweir                     return 0;
66*cdf0e10cSrcweir                 case C_TOKEN( custUnit ):
67*cdf0e10cSrcweir                     mrModel.mfCustomUnit = rAttribs.getDouble( XML_val, 0.0 );
68*cdf0e10cSrcweir                     return 0;
69*cdf0e10cSrcweir                 case C_TOKEN( dispUnitsLbl ):
70*cdf0e10cSrcweir                     return this;
71*cdf0e10cSrcweir             }
72*cdf0e10cSrcweir         break;
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir         case C_TOKEN( dispUnitsLbl ):
75*cdf0e10cSrcweir             switch( nElement )
76*cdf0e10cSrcweir             {
77*cdf0e10cSrcweir                 case C_TOKEN( layout ):
78*cdf0e10cSrcweir                     return new LayoutContext( *this, mrModel.mxLayout.create() );
79*cdf0e10cSrcweir                 case C_TOKEN( spPr ):
80*cdf0e10cSrcweir                     return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
81*cdf0e10cSrcweir                 case C_TOKEN( tx ):
82*cdf0e10cSrcweir                     return new TextContext( *this, mrModel.mxText.create() );
83*cdf0e10cSrcweir                 case C_TOKEN( txPr ):
84*cdf0e10cSrcweir                     return new TextBodyContext( *this, mrModel.mxTextProp.create() );
85*cdf0e10cSrcweir             }
86*cdf0e10cSrcweir         break;
87*cdf0e10cSrcweir     }
88*cdf0e10cSrcweir     return 0;
89*cdf0e10cSrcweir }
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir // ============================================================================
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir AxisContextBase::AxisContextBase( ContextHandler2Helper& rParent, AxisModel& rModel ) :
94*cdf0e10cSrcweir     ContextBase< AxisModel >( rParent, rModel )
95*cdf0e10cSrcweir {
96*cdf0e10cSrcweir }
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir AxisContextBase::~AxisContextBase()
99*cdf0e10cSrcweir {
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir ContextHandlerRef AxisContextBase::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
103*cdf0e10cSrcweir {
104*cdf0e10cSrcweir     switch( getCurrentElement() )
105*cdf0e10cSrcweir     {
106*cdf0e10cSrcweir         case C_TOKEN( catAx ):
107*cdf0e10cSrcweir         case C_TOKEN( dateAx ):
108*cdf0e10cSrcweir         case C_TOKEN( serAx ):
109*cdf0e10cSrcweir         case C_TOKEN( valAx ):
110*cdf0e10cSrcweir             switch( nElement )
111*cdf0e10cSrcweir             {
112*cdf0e10cSrcweir                 case C_TOKEN( axId ):
113*cdf0e10cSrcweir                     mrModel.mnAxisId = rAttribs.getInteger( XML_val, -1 );
114*cdf0e10cSrcweir                     return 0;
115*cdf0e10cSrcweir                 case C_TOKEN( crossAx ):
116*cdf0e10cSrcweir                     mrModel.mnCrossAxisId = rAttribs.getInteger( XML_val, -1 );
117*cdf0e10cSrcweir                     return 0;
118*cdf0e10cSrcweir                 case C_TOKEN( crosses ):
119*cdf0e10cSrcweir                     mrModel.mnCrossMode = rAttribs.getToken( XML_val, XML_autoZero );
120*cdf0e10cSrcweir                     return 0;
121*cdf0e10cSrcweir                 case C_TOKEN( crossesAt ):
122*cdf0e10cSrcweir                     mrModel.mofCrossesAt = rAttribs.getDouble( XML_val, 0.0 );
123*cdf0e10cSrcweir                     return 0;
124*cdf0e10cSrcweir                 case C_TOKEN( delete ):
125*cdf0e10cSrcweir                     // default is 'false', not 'true' as specified
126*cdf0e10cSrcweir                     mrModel.mbDeleted = rAttribs.getBool( XML_val, false );
127*cdf0e10cSrcweir                     return 0;
128*cdf0e10cSrcweir                 case C_TOKEN( majorGridlines ):
129*cdf0e10cSrcweir                     return new ShapePrWrapperContext( *this, mrModel.mxMajorGridLines.create() );
130*cdf0e10cSrcweir                 case C_TOKEN( majorTickMark ):
131*cdf0e10cSrcweir                     // default is 'out', not 'cross' as specified
132*cdf0e10cSrcweir                     mrModel.mnMajorTickMark = rAttribs.getToken( XML_val, XML_out );
133*cdf0e10cSrcweir                     return 0;
134*cdf0e10cSrcweir                 case C_TOKEN( minorGridlines ):
135*cdf0e10cSrcweir                     return new ShapePrWrapperContext( *this, mrModel.mxMinorGridLines.create() );
136*cdf0e10cSrcweir                 case C_TOKEN( minorTickMark ):
137*cdf0e10cSrcweir                     // default is 'none', not 'cross' as specified
138*cdf0e10cSrcweir                     mrModel.mnMinorTickMark = rAttribs.getToken( XML_val, XML_none );
139*cdf0e10cSrcweir                     return 0;
140*cdf0e10cSrcweir                 case C_TOKEN( numFmt ):
141*cdf0e10cSrcweir                     mrModel.maNumberFormat.setAttributes( rAttribs );
142*cdf0e10cSrcweir                     return 0;
143*cdf0e10cSrcweir                 case C_TOKEN( scaling ):
144*cdf0e10cSrcweir                     return this;
145*cdf0e10cSrcweir                 case C_TOKEN( spPr ):
146*cdf0e10cSrcweir                     return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
147*cdf0e10cSrcweir                 case C_TOKEN( tickLblPos ):
148*cdf0e10cSrcweir                     mrModel.mnTickLabelPos = rAttribs.getToken( XML_val, XML_nextTo );
149*cdf0e10cSrcweir                     return 0;
150*cdf0e10cSrcweir                 case C_TOKEN( title ):
151*cdf0e10cSrcweir                     return new TitleContext( *this, mrModel.mxTitle.create() );
152*cdf0e10cSrcweir                 case C_TOKEN( txPr ):
153*cdf0e10cSrcweir                     return new TextBodyContext( *this, mrModel.mxTextProp.create() );
154*cdf0e10cSrcweir             }
155*cdf0e10cSrcweir         break;
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir         case C_TOKEN( scaling ):
158*cdf0e10cSrcweir             switch( nElement )
159*cdf0e10cSrcweir             {
160*cdf0e10cSrcweir                 case C_TOKEN( logBase ):
161*cdf0e10cSrcweir                     mrModel.mofLogBase = rAttribs.getDouble( XML_val, 0.0 );
162*cdf0e10cSrcweir                     return 0;
163*cdf0e10cSrcweir                 case C_TOKEN( max ):
164*cdf0e10cSrcweir                     mrModel.mofMax = rAttribs.getDouble( XML_val, 0.0 );
165*cdf0e10cSrcweir                     return 0;
166*cdf0e10cSrcweir                 case C_TOKEN( min ):
167*cdf0e10cSrcweir                     mrModel.mofMin = rAttribs.getDouble( XML_val, 0.0 );
168*cdf0e10cSrcweir                     return 0;
169*cdf0e10cSrcweir                 case C_TOKEN( orientation ):
170*cdf0e10cSrcweir                     mrModel.mnOrientation = rAttribs.getToken( XML_val, XML_minMax );
171*cdf0e10cSrcweir                     return 0;
172*cdf0e10cSrcweir             }
173*cdf0e10cSrcweir         break;
174*cdf0e10cSrcweir     }
175*cdf0e10cSrcweir     return 0;
176*cdf0e10cSrcweir }
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir // ============================================================================
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir CatAxisContext::CatAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
181*cdf0e10cSrcweir     AxisContextBase( rParent, rModel )
182*cdf0e10cSrcweir {
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir CatAxisContext::~CatAxisContext()
186*cdf0e10cSrcweir {
187*cdf0e10cSrcweir }
188*cdf0e10cSrcweir 
189*cdf0e10cSrcweir ContextHandlerRef CatAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
190*cdf0e10cSrcweir {
191*cdf0e10cSrcweir     if( isRootElement() ) switch( nElement )
192*cdf0e10cSrcweir     {
193*cdf0e10cSrcweir         case C_TOKEN( auto ):
194*cdf0e10cSrcweir             // default is 'false', not 'true' as specified
195*cdf0e10cSrcweir             mrModel.mbAuto = rAttribs.getBool( XML_val, false );
196*cdf0e10cSrcweir             return 0;
197*cdf0e10cSrcweir         case C_TOKEN( axPos ):
198*cdf0e10cSrcweir             mrModel.mnAxisPos = rAttribs.getToken( XML_val, XML_TOKEN_INVALID );
199*cdf0e10cSrcweir             return 0;
200*cdf0e10cSrcweir         case C_TOKEN( lblAlgn ):
201*cdf0e10cSrcweir             mrModel.mnLabelAlign = rAttribs.getToken( XML_val, XML_ctr );
202*cdf0e10cSrcweir             return 0;
203*cdf0e10cSrcweir         case C_TOKEN( lblOffset ):
204*cdf0e10cSrcweir             mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
205*cdf0e10cSrcweir             return 0;
206*cdf0e10cSrcweir         case C_TOKEN( noMultiLvlLbl ):
207*cdf0e10cSrcweir             // default is 'false', not 'true' as specified
208*cdf0e10cSrcweir             mrModel.mbNoMultiLevel = rAttribs.getBool( XML_val, false );
209*cdf0e10cSrcweir             return 0;
210*cdf0e10cSrcweir         case C_TOKEN( tickLblSkip ):
211*cdf0e10cSrcweir             mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
212*cdf0e10cSrcweir             return 0;
213*cdf0e10cSrcweir         case C_TOKEN( tickMarkSkip ):
214*cdf0e10cSrcweir             mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
215*cdf0e10cSrcweir             return 0;
216*cdf0e10cSrcweir     }
217*cdf0e10cSrcweir     return AxisContextBase::onCreateContext( nElement, rAttribs );
218*cdf0e10cSrcweir }
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir // ============================================================================
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir DateAxisContext::DateAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
223*cdf0e10cSrcweir     AxisContextBase( rParent, rModel )
224*cdf0e10cSrcweir {
225*cdf0e10cSrcweir }
226*cdf0e10cSrcweir 
227*cdf0e10cSrcweir DateAxisContext::~DateAxisContext()
228*cdf0e10cSrcweir {
229*cdf0e10cSrcweir }
230*cdf0e10cSrcweir 
231*cdf0e10cSrcweir ContextHandlerRef DateAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
232*cdf0e10cSrcweir {
233*cdf0e10cSrcweir     if( isRootElement() ) switch( nElement )
234*cdf0e10cSrcweir     {
235*cdf0e10cSrcweir         case C_TOKEN( auto ):
236*cdf0e10cSrcweir             // default is 'false', not 'true' as specified
237*cdf0e10cSrcweir             mrModel.mbAuto = rAttribs.getBool( XML_val, false );
238*cdf0e10cSrcweir             return 0;
239*cdf0e10cSrcweir         case C_TOKEN( baseTimeUnit ):
240*cdf0e10cSrcweir             mrModel.monBaseTimeUnit = rAttribs.getToken( XML_val, XML_days );
241*cdf0e10cSrcweir             return 0;
242*cdf0e10cSrcweir         case C_TOKEN( lblOffset ):
243*cdf0e10cSrcweir             mrModel.mnLabelOffset = rAttribs.getInteger( XML_val, 100 );
244*cdf0e10cSrcweir             return 0;
245*cdf0e10cSrcweir         case C_TOKEN( majorTimeUnit ):
246*cdf0e10cSrcweir             mrModel.mnMajorTimeUnit = rAttribs.getToken( XML_val, XML_days );
247*cdf0e10cSrcweir             return 0;
248*cdf0e10cSrcweir         case C_TOKEN( majorUnit ):
249*cdf0e10cSrcweir             mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
250*cdf0e10cSrcweir             return 0;
251*cdf0e10cSrcweir         case C_TOKEN( minorTimeUnit ):
252*cdf0e10cSrcweir             mrModel.mnMinorTimeUnit = rAttribs.getToken( XML_val, XML_days );
253*cdf0e10cSrcweir             return 0;
254*cdf0e10cSrcweir         case C_TOKEN( minorUnit ):
255*cdf0e10cSrcweir             mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
256*cdf0e10cSrcweir             return 0;
257*cdf0e10cSrcweir     }
258*cdf0e10cSrcweir     return AxisContextBase::onCreateContext( nElement, rAttribs );
259*cdf0e10cSrcweir }
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir // ============================================================================
262*cdf0e10cSrcweir 
263*cdf0e10cSrcweir SerAxisContext::SerAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
264*cdf0e10cSrcweir     AxisContextBase( rParent, rModel )
265*cdf0e10cSrcweir {
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir SerAxisContext::~SerAxisContext()
269*cdf0e10cSrcweir {
270*cdf0e10cSrcweir }
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir ContextHandlerRef SerAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
273*cdf0e10cSrcweir {
274*cdf0e10cSrcweir     if( isRootElement() ) switch( nElement )
275*cdf0e10cSrcweir     {
276*cdf0e10cSrcweir         case C_TOKEN( tickLblSkip ):
277*cdf0e10cSrcweir             mrModel.mnTickLabelSkip = rAttribs.getInteger( XML_val, 0 );
278*cdf0e10cSrcweir             return 0;
279*cdf0e10cSrcweir         case C_TOKEN( tickMarkSkip ):
280*cdf0e10cSrcweir             mrModel.mnTickMarkSkip = rAttribs.getInteger( XML_val, 0 );
281*cdf0e10cSrcweir             return 0;
282*cdf0e10cSrcweir     }
283*cdf0e10cSrcweir     return AxisContextBase::onCreateContext( nElement, rAttribs );
284*cdf0e10cSrcweir }
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir // ============================================================================
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir ValAxisContext::ValAxisContext( ContextHandler2Helper& rParent, AxisModel& rModel ) :
289*cdf0e10cSrcweir     AxisContextBase( rParent, rModel )
290*cdf0e10cSrcweir {
291*cdf0e10cSrcweir }
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir ValAxisContext::~ValAxisContext()
294*cdf0e10cSrcweir {
295*cdf0e10cSrcweir }
296*cdf0e10cSrcweir 
297*cdf0e10cSrcweir ContextHandlerRef ValAxisContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
298*cdf0e10cSrcweir {
299*cdf0e10cSrcweir     if( isRootElement() ) switch( nElement )
300*cdf0e10cSrcweir     {
301*cdf0e10cSrcweir         case C_TOKEN( crossBetween ):
302*cdf0e10cSrcweir             mrModel.mnCrossBetween = rAttribs.getToken( XML_val, XML_between );
303*cdf0e10cSrcweir             return 0;
304*cdf0e10cSrcweir         case C_TOKEN( dispUnits ):
305*cdf0e10cSrcweir             return new AxisDispUnitsContext( *this, mrModel.mxDispUnits.create() );
306*cdf0e10cSrcweir         case C_TOKEN( majorUnit ):
307*cdf0e10cSrcweir             mrModel.mofMajorUnit = rAttribs.getDouble( XML_val, 0.0 );
308*cdf0e10cSrcweir             return 0;
309*cdf0e10cSrcweir         case C_TOKEN( minorUnit ):
310*cdf0e10cSrcweir             mrModel.mofMinorUnit = rAttribs.getDouble( XML_val, 0.0 );
311*cdf0e10cSrcweir             return 0;
312*cdf0e10cSrcweir     }
313*cdf0e10cSrcweir     return AxisContextBase::onCreateContext( nElement, rAttribs );
314*cdf0e10cSrcweir }
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir // ============================================================================
317*cdf0e10cSrcweir 
318*cdf0e10cSrcweir } // namespace chart
319*cdf0e10cSrcweir } // namespace drawingml
320*cdf0e10cSrcweir } // namespace oox
321