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/chartcontextbase.hxx"
25 
26 #include "oox/drawingml/chart/modelbase.hxx"
27 #include "oox/drawingml/shapepropertiescontext.hxx"
28 
29 namespace oox {
30 namespace drawingml {
31 namespace chart {
32 
33 // ============================================================================
34 
35 using ::oox::core::ContextHandler2Helper;
36 using ::oox::core::ContextHandlerRef;
37 
38 // ============================================================================
39 
ShapePrWrapperContext(ContextHandler2Helper & rParent,Shape & rModel)40 ShapePrWrapperContext::ShapePrWrapperContext( ContextHandler2Helper& rParent, Shape& rModel ) :
41     ContextBase< Shape >( rParent, rModel )
42 {
43 }
44 
~ShapePrWrapperContext()45 ShapePrWrapperContext::~ShapePrWrapperContext()
46 {
47 }
48 
onCreateContext(sal_Int32 nElement,const AttributeList &)49 ContextHandlerRef ShapePrWrapperContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
50 {
51     return (isRootElement() && (nElement == C_TOKEN( spPr ))) ? new ShapePropertiesContext( *this, mrModel ) : 0;
52 }
53 
54 // ============================================================================
55 
LayoutContext(ContextHandler2Helper & rParent,LayoutModel & rModel)56 LayoutContext::LayoutContext( ContextHandler2Helper& rParent, LayoutModel& rModel ) :
57     ContextBase< LayoutModel >( rParent, rModel )
58 {
59 }
60 
~LayoutContext()61 LayoutContext::~LayoutContext()
62 {
63 }
64 
onCreateContext(sal_Int32 nElement,const AttributeList & rAttribs)65 ContextHandlerRef LayoutContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
66 {
67     switch( getCurrentElement() )
68     {
69         case C_TOKEN( layout ):
70             switch( nElement )
71             {
72                 case C_TOKEN( manualLayout ):
73                     mrModel.mbAutoLayout = false;
74                     return this;
75             }
76         break;
77 
78         case C_TOKEN( manualLayout ):
79             switch( nElement )
80             {
81                 case C_TOKEN( x ):
82                     mrModel.mfX = rAttribs.getDouble( XML_val, 0.0 );
83                     return 0;
84                 case C_TOKEN( y ):
85                     mrModel.mfY = rAttribs.getDouble( XML_val, 0.0 );
86                     return 0;
87                 case C_TOKEN( w ):
88                     mrModel.mfW = rAttribs.getDouble( XML_val, 0.0 );
89                     return 0;
90                 case C_TOKEN( h ):
91                     mrModel.mfH = rAttribs.getDouble( XML_val, 0.0 );
92                     return 0;
93                 case C_TOKEN( xMode ):
94                     mrModel.mnXMode = rAttribs.getToken( XML_val, XML_factor );
95                     return 0;
96                 case C_TOKEN( yMode ):
97                     mrModel.mnYMode = rAttribs.getToken( XML_val, XML_factor );
98                     return 0;
99                 case C_TOKEN( wMode ):
100                     mrModel.mnWMode = rAttribs.getToken( XML_val, XML_factor );
101                     return 0;
102                 case C_TOKEN( hMode ):
103                     mrModel.mnHMode = rAttribs.getToken( XML_val, XML_factor );
104                     return 0;
105                 case C_TOKEN( layoutTarget ):
106                     mrModel.mnTarget = rAttribs.getToken( XML_val, XML_outer );
107                     return 0;
108             }
109         break;
110     }
111     return 0;
112 }
113 
114 // ============================================================================
115 
116 } // namespace chart
117 } // namespace drawingml
118 } // namespace oox
119