1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "oox/drawingml/chart/plotareacontext.hxx"
25 
26 #include "oox/drawingml/shapepropertiescontext.hxx"
27 #include "oox/drawingml/chart/axiscontext.hxx"
28 #include "oox/drawingml/chart/plotareamodel.hxx"
29 #include "oox/drawingml/chart/seriescontext.hxx"
30 #include "oox/drawingml/chart/titlecontext.hxx"
31 #include "oox/drawingml/chart/typegroupcontext.hxx"
32 
33 namespace oox {
34 namespace drawingml {
35 namespace chart {
36 
37 // ============================================================================
38 
39 using ::oox::core::ContextHandler2Helper;
40 using ::oox::core::ContextHandlerRef;
41 
42 // ============================================================================
43 
View3DContext(ContextHandler2Helper & rParent,View3DModel & rModel)44 View3DContext::View3DContext( ContextHandler2Helper& rParent, View3DModel& rModel ) :
45     ContextBase< View3DModel >( rParent, rModel )
46 {
47 }
48 
~View3DContext()49 View3DContext::~View3DContext()
50 {
51 }
52 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)53 ContextHandlerRef View3DContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
54 {
55     switch( getCurrentElement() )
56     {
57         case C_TOKEN( view3D ):
58             switch( nElement )
59             {
60                 case C_TOKEN( depthPercent ):
61                     mrModel.mnDepthPercent = rAttribs.getInteger( XML_val, 100 );
62                     return 0;
63                 case C_TOKEN( hPercent ):
64                     mrModel.monHeightPercent = rAttribs.getInteger( XML_val, 100 );
65                     return 0;
66                 case C_TOKEN( perspective ):
67                     mrModel.mnPerspective = rAttribs.getInteger( XML_val, 30 );
68                     return 0;
69                 case C_TOKEN( rAngAx ):
70                     // default is 'false', not 'true' as specified
71                     mrModel.mbRightAngled = rAttribs.getBool( XML_val, false );
72                     return 0;
73                 case C_TOKEN( rotX ):
74                     // default value dependent on chart type
75                     mrModel.monRotationX = rAttribs.getInteger( XML_val );
76                     return 0;
77                 case C_TOKEN( rotY ):
78                     // default value dependent on chart type
79                     mrModel.monRotationY = rAttribs.getInteger( XML_val );
80                     return 0;
81             }
82         break;
83     }
84     return 0;
85 }
86 
87 // ============================================================================
88 
WallFloorContext(ContextHandler2Helper & rParent,WallFloorModel & rModel)89 WallFloorContext::WallFloorContext( ContextHandler2Helper& rParent, WallFloorModel& rModel ) :
90     ContextBase< WallFloorModel >( rParent, rModel )
91 {
92 }
93 
~WallFloorContext()94 WallFloorContext::~WallFloorContext()
95 {
96 }
97 
onCreateContext(sal_Int32 nElement,const AttributeList &)98 ContextHandlerRef WallFloorContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
99 {
100     switch( getCurrentElement() )
101     {
102         case C_TOKEN( backWall ):
103         case C_TOKEN( floor ):
104         case C_TOKEN( sideWall ):
105             switch( nElement )
106             {
107                 case C_TOKEN( pictureOptions ):
108                     return new PictureOptionsContext( *this, mrModel.mxPicOptions.create() );
109                 case C_TOKEN( spPr ):
110                     return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
111             }
112         break;
113     }
114     return 0;
115 }
116 
117 // ============================================================================
118 
PlotAreaContext(ContextHandler2Helper & rParent,PlotAreaModel & rModel)119 PlotAreaContext::PlotAreaContext( ContextHandler2Helper& rParent, PlotAreaModel& rModel ) :
120     ContextBase< PlotAreaModel >( rParent, rModel )
121 {
122 }
123 
~PlotAreaContext()124 PlotAreaContext::~PlotAreaContext()
125 {
126 }
127 
onCreateContext(sal_Int32 nElement,const AttributeList &)128 ContextHandlerRef PlotAreaContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
129 {
130     switch( getCurrentElement() )
131     {
132         case C_TOKEN( plotArea ):
133             switch( nElement )
134             {
135                 case C_TOKEN( area3DChart ):
136                 case C_TOKEN( areaChart ):
137                     return new AreaTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement ) );
138                 case C_TOKEN( bar3DChart ):
139                 case C_TOKEN( barChart ):
140                     return new BarTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement ) );
141                 case C_TOKEN( bubbleChart ):
142                     return new BubbleTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement ) );
143                 case C_TOKEN( line3DChart ):
144                 case C_TOKEN( lineChart ):
145                 case C_TOKEN( stockChart ):
146                     return new LineTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement ) );
147                 case C_TOKEN( doughnutChart ):
148                 case C_TOKEN( ofPieChart ):
149                 case C_TOKEN( pie3DChart ):
150                 case C_TOKEN( pieChart ):
151                     return new PieTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement ) );
152                 case C_TOKEN( radarChart ):
153                     return new RadarTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement ) );
154                 case C_TOKEN( scatterChart ):
155                     return new ScatterTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement ) );
156                 case C_TOKEN( surface3DChart ):
157                 case C_TOKEN( surfaceChart ):
158                     return new SurfaceTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement ) );
159 
160                 case C_TOKEN( catAx ):
161                     return new CatAxisContext( *this, mrModel.maAxes.create( nElement ) );
162                 case C_TOKEN( dateAx ):
163                     return new DateAxisContext( *this, mrModel.maAxes.create( nElement ) );
164                 case C_TOKEN( serAx ):
165                     return new SerAxisContext( *this, mrModel.maAxes.create( nElement ) );
166                 case C_TOKEN( valAx ):
167                     return new ValAxisContext( *this, mrModel.maAxes.create( nElement ) );
168 
169                 case C_TOKEN( layout ):
170                     return new LayoutContext( *this, mrModel.mxLayout.create() );
171                 case C_TOKEN( spPr ):
172                     return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
173             }
174         break;
175     }
176     return 0;
177 }
178 
179 // ============================================================================
180 
181 } // namespace chart
182 } // namespace drawingml
183 } // namespace oox
184