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/chartspacefragment.hxx"
25 
26 #include "oox/drawingml/shapepropertiescontext.hxx"
27 #include "oox/drawingml/textbodycontext.hxx"
28 #include "oox/drawingml/chart/chartspacemodel.hxx"
29 #include "oox/drawingml/chart/plotareacontext.hxx"
30 #include "oox/drawingml/chart/titlecontext.hxx"
31 
32 namespace oox {
33 namespace drawingml {
34 namespace chart {
35 
36 // ============================================================================
37 
38 using namespace ::oox::core;
39 
40 using ::rtl::OUString;
41 
42 // ============================================================================
43 
ChartSpaceFragment(XmlFilterBase & rFilter,const OUString & rFragmentPath,ChartSpaceModel & rModel)44 ChartSpaceFragment::ChartSpaceFragment( XmlFilterBase& rFilter, const OUString& rFragmentPath, ChartSpaceModel& rModel ) :
45     FragmentBase< ChartSpaceModel >( rFilter, rFragmentPath, rModel )
46 {
47 }
48 
~ChartSpaceFragment()49 ChartSpaceFragment::~ChartSpaceFragment()
50 {
51 }
52 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)53 ContextHandlerRef ChartSpaceFragment::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
54 {
55     switch( getCurrentElement() )
56     {
57         case XML_ROOT_CONTEXT:
58             switch( nElement )
59             {
60                 case C_TOKEN( chartSpace ):
61                     return this;
62             }
63         break;
64 
65         case C_TOKEN( chartSpace ):
66             switch( nElement )
67             {
68                 case C_TOKEN( chart ):
69                     return this;
70                 case C_TOKEN( spPr ):
71                     return new ShapePropertiesContext( *this, mrModel.mxShapeProp.create() );
72                 case C_TOKEN( style ):
73                     mrModel.mnStyle = rAttribs.getInteger( XML_val, 2 );
74                     return 0;
75                 case C_TOKEN( txPr ):
76                     return new TextBodyContext( *this, mrModel.mxTextProp.create() );
77                 case C_TOKEN( userShapes ):
78                     mrModel.maDrawingPath = getFragmentPathFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
79                     return 0;
80                 case C_TOKEN( pivotSource ):
81                     mrModel.mbPivotChart = true;
82                     return 0;
83             }
84         break;
85 
86         case C_TOKEN( chart ):
87             switch( nElement )
88             {
89                 case C_TOKEN( autoTitleDeleted ):
90                     // default is 'false', not 'true' as specified
91                     mrModel.mbAutoTitleDel = rAttribs.getBool( XML_val, false );
92                     return 0;
93                 case C_TOKEN( backWall ):
94                     return new WallFloorContext( *this, mrModel.mxBackWall.create() );
95                 case C_TOKEN( dispBlanksAs ):
96                     mrModel.mnDispBlanksAs = rAttribs.getToken( XML_val, XML_zero );
97                     return 0;
98                 case C_TOKEN( floor ):
99                     return new WallFloorContext( *this, mrModel.mxFloor.create() );
100                 case C_TOKEN( legend ):
101                     return new LegendContext( *this, mrModel.mxLegend.create() );
102                 case C_TOKEN( plotArea ):
103                     return new PlotAreaContext( *this, mrModel.mxPlotArea.create() );
104                 case C_TOKEN( plotVisOnly ):
105                     // default is 'false', not 'true' as specified
106                     mrModel.mbPlotVisOnly = rAttribs.getBool( XML_val, false );
107                     return 0;
108                 case C_TOKEN( showDLblsOverMax ):
109                     // default is 'false', not 'true' as specified
110                     mrModel.mbShowLabelsOverMax = rAttribs.getBool( XML_val, false );
111                     return 0;
112                 case C_TOKEN( sideWall ):
113                     return new WallFloorContext( *this, mrModel.mxSideWall.create() );
114                 case C_TOKEN( title ):
115                     return new TitleContext( *this, mrModel.mxTitle.create() );
116                 case C_TOKEN( view3D ):
117                     return new View3DContext( *this, mrModel.mxView3D.create() );
118             }
119         break;
120     }
121     return 0;
122 }
123 
124 // ============================================================================
125 
126 } // namespace chart
127 } // namespace drawingml
128 } // namespace oox
129