1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #include "oox/drawingml/chart/chartcontextbase.hxx"
29 
30 #include "oox/drawingml/chart/modelbase.hxx"
31 #include "oox/drawingml/shapepropertiescontext.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 
44 ShapePrWrapperContext::ShapePrWrapperContext( ContextHandler2Helper& rParent, Shape& rModel ) :
45     ContextBase< Shape >( rParent, rModel )
46 {
47 }
48 
49 ShapePrWrapperContext::~ShapePrWrapperContext()
50 {
51 }
52 
53 ContextHandlerRef ShapePrWrapperContext::onCreateContext( sal_Int32 nElement, const AttributeList& )
54 {
55     return (isRootElement() && (nElement == C_TOKEN( spPr ))) ? new ShapePropertiesContext( *this, mrModel ) : 0;
56 }
57 
58 // ============================================================================
59 
60 LayoutContext::LayoutContext( ContextHandler2Helper& rParent, LayoutModel& rModel ) :
61     ContextBase< LayoutModel >( rParent, rModel )
62 {
63 }
64 
65 LayoutContext::~LayoutContext()
66 {
67 }
68 
69 ContextHandlerRef LayoutContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
70 {
71     switch( getCurrentElement() )
72     {
73         case C_TOKEN( layout ):
74             switch( nElement )
75             {
76                 case C_TOKEN( manualLayout ):
77                     mrModel.mbAutoLayout = false;
78                     return this;
79             }
80         break;
81 
82         case C_TOKEN( manualLayout ):
83             switch( nElement )
84             {
85                 case C_TOKEN( x ):
86                     mrModel.mfX = rAttribs.getDouble( XML_val, 0.0 );
87                     return 0;
88                 case C_TOKEN( y ):
89                     mrModel.mfY = rAttribs.getDouble( XML_val, 0.0 );
90                     return 0;
91                 case C_TOKEN( w ):
92                     mrModel.mfW = rAttribs.getDouble( XML_val, 0.0 );
93                     return 0;
94                 case C_TOKEN( h ):
95                     mrModel.mfH = rAttribs.getDouble( XML_val, 0.0 );
96                     return 0;
97                 case C_TOKEN( xMode ):
98                     mrModel.mnXMode = rAttribs.getToken( XML_val, XML_factor );
99                     return 0;
100                 case C_TOKEN( yMode ):
101                     mrModel.mnYMode = rAttribs.getToken( XML_val, XML_factor );
102                     return 0;
103                 case C_TOKEN( wMode ):
104                     mrModel.mnWMode = rAttribs.getToken( XML_val, XML_factor );
105                     return 0;
106                 case C_TOKEN( hMode ):
107                     mrModel.mnHMode = rAttribs.getToken( XML_val, XML_factor );
108                     return 0;
109                 case C_TOKEN( layoutTarget ):
110                     mrModel.mnTarget = rAttribs.getToken( XML_val, XML_outer );
111                     return 0;
112             }
113         break;
114     }
115     return 0;
116 }
117 
118 // ============================================================================
119 
120 } // namespace chart
121 } // namespace drawingml
122 } // namespace oox
123