Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / oox / source / drawingml / chart / plotareacontext.cxx
blobc02b640a162cd3dc0cc0e67bce07996c39e689c9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/plotareacontext.hxx>
22 #include <drawingml/shapepropertiescontext.hxx>
23 #include <drawingml/chart/axiscontext.hxx>
24 #include <drawingml/chart/plotareamodel.hxx>
25 #include <drawingml/chart/seriescontext.hxx>
26 #include <drawingml/chart/titlecontext.hxx>
27 #include <drawingml/chart/typegroupcontext.hxx>
28 #include <oox/core/xmlfilterbase.hxx>
29 #include <oox/helper/attributelist.hxx>
30 #include <oox/token/namespaces.hxx>
31 #include <oox/token/tokens.hxx>
33 namespace oox {
34 namespace drawingml {
35 namespace chart {
37 using ::oox::core::ContextHandler2Helper;
38 using ::oox::core::ContextHandlerRef;
40 View3DContext::View3DContext( ContextHandler2Helper& rParent, View3DModel& rModel ) :
41 ContextBase< View3DModel >( rParent, rModel )
45 View3DContext::~View3DContext()
49 ContextHandlerRef View3DContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
51 bool bMSO2007Doc = getFilter().isMSO2007Document();
52 switch( getCurrentElement() )
54 case C_TOKEN( view3D ):
55 switch( nElement )
57 case C_TOKEN( depthPercent ):
58 mrModel.mnDepthPercent = rAttribs.getInteger( XML_val, 100 );
59 return nullptr;
60 case C_TOKEN( hPercent ):
61 mrModel.monHeightPercent = rAttribs.getInteger( XML_val, 100 );
62 return nullptr;
63 case C_TOKEN( perspective ):
64 mrModel.mnPerspective = rAttribs.getInteger( XML_val, 30 );
65 return nullptr;
66 case C_TOKEN( rAngAx ):
67 mrModel.mbRightAngled = rAttribs.getBool( XML_val, !bMSO2007Doc );
68 return nullptr;
69 case C_TOKEN( rotX ):
70 // default value dependent on chart type
71 mrModel.monRotationX = rAttribs.getInteger( XML_val );
72 return nullptr;
73 case C_TOKEN( rotY ):
74 // default value dependent on chart type
75 mrModel.monRotationY = rAttribs.getInteger( XML_val );
76 return nullptr;
78 break;
80 return nullptr;
83 WallFloorContext::WallFloorContext( ContextHandler2Helper& rParent, WallFloorModel& rModel ) :
84 ContextBase< WallFloorModel >( rParent, rModel )
88 WallFloorContext::~WallFloorContext()
92 ContextHandlerRef WallFloorContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
94 bool bMSO2007Doc = getFilter().isMSO2007Document();
95 switch( getCurrentElement() )
97 case C_TOKEN( backWall ):
98 case C_TOKEN( floor ):
99 case C_TOKEN( sideWall ):
100 switch( nElement )
102 case C_TOKEN( pictureOptions ):
103 return new PictureOptionsContext( *this, mrModel.mxPicOptions.create(bMSO2007Doc) );
104 case C_TOKEN( spPr ):
105 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
107 break;
109 return nullptr;
112 DataTableContext::DataTableContext( ContextHandler2Helper& rParent, DataTableModel& rModel ) :
113 ContextBase< DataTableModel >( rParent, rModel )
117 DataTableContext::~DataTableContext()
121 ContextHandlerRef DataTableContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs)
123 switch( getCurrentElement() )
125 case C_TOKEN( dTable ):
126 switch( nElement )
128 case C_TOKEN( showHorzBorder ):
129 mrModel.mbShowHBorder = rAttribs.getBool( XML_val, false );
130 break;
131 case C_TOKEN( showVertBorder ):
132 mrModel.mbShowVBorder = rAttribs.getBool( XML_val, false );
133 break;
134 case C_TOKEN( showOutline ):
135 mrModel.mbShowOutline = rAttribs.getBool( XML_val, false );
136 break;
138 break;
140 return nullptr;
143 PlotAreaContext::PlotAreaContext( ContextHandler2Helper& rParent, PlotAreaModel& rModel ) :
144 ContextBase< PlotAreaModel >( rParent, rModel )
148 PlotAreaContext::~PlotAreaContext()
152 ContextHandlerRef PlotAreaContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
154 bool bMSO2007Doc = getFilter().isMSO2007Document();
155 switch( getCurrentElement() )
157 case C_TOKEN( plotArea ):
158 switch( nElement )
160 case C_TOKEN( area3DChart ):
161 case C_TOKEN( areaChart ):
162 return new AreaTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement, bMSO2007Doc ) );
163 case C_TOKEN( bar3DChart ):
164 case C_TOKEN( barChart ):
165 return new BarTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement, bMSO2007Doc ) );
166 case C_TOKEN( bubbleChart ):
167 return new BubbleTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement, bMSO2007Doc ) );
168 case C_TOKEN( line3DChart ):
169 case C_TOKEN( lineChart ):
170 case C_TOKEN( stockChart ):
171 return new LineTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement, bMSO2007Doc ) );
172 case C_TOKEN( doughnutChart ):
173 case C_TOKEN( ofPieChart ):
174 case C_TOKEN( pie3DChart ):
175 case C_TOKEN( pieChart ):
176 return new PieTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement, bMSO2007Doc ) );
177 case C_TOKEN( radarChart ):
178 return new RadarTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement, bMSO2007Doc ) );
179 case C_TOKEN( scatterChart ):
180 return new ScatterTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement, bMSO2007Doc ) );
181 case C_TOKEN( surface3DChart ):
182 case C_TOKEN( surfaceChart ):
183 return new SurfaceTypeGroupContext( *this, mrModel.maTypeGroups.create( nElement, bMSO2007Doc ) );
185 case C_TOKEN( catAx ):
186 return new CatAxisContext( *this, mrModel.maAxes.create( nElement, bMSO2007Doc ) );
187 case C_TOKEN( dateAx ):
188 return new DateAxisContext( *this, mrModel.maAxes.create( nElement, bMSO2007Doc ) );
189 case C_TOKEN( serAx ):
190 return new SerAxisContext( *this, mrModel.maAxes.create( nElement, bMSO2007Doc ) );
191 case C_TOKEN( valAx ):
192 return new ValAxisContext( *this, mrModel.maAxes.create( nElement, bMSO2007Doc ) );
194 case C_TOKEN( layout ):
195 return new LayoutContext( *this, mrModel.mxLayout.create() );
196 case C_TOKEN( spPr ):
197 return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
198 case C_TOKEN(dTable):
199 return new DataTableContext( *this, mrModel.mxDataTable.create() );
201 break;
203 return nullptr;
206 } // namespace chart
207 } // namespace drawingml
208 } // namespace oox
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */