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 #ifndef OOX_DRAWINGML_CHART_CHARTCONTEXTBASE_HXX
25 #define OOX_DRAWINGML_CHART_CHARTCONTEXTBASE_HXX
26 
27 #include "oox/core/fragmenthandler2.hxx"
28 
29 namespace oox { namespace drawingml { class Shape; } }
30 
31 namespace oox {
32 namespace drawingml {
33 namespace chart {
34 
35 // ============================================================================
36 
37 template< typename ModelType >
38 class ContextBase : public ::oox::core::ContextHandler2
39 {
40 public:
ContextBase(::oox::core::ContextHandler2Helper & rParent,ModelType & rModel)41     inline explicit     ContextBase( ::oox::core::ContextHandler2Helper& rParent, ModelType& rModel ) :
42                             ::oox::core::ContextHandler2( rParent ), mrModel( rModel ) {}
~ContextBase()43     virtual             ~ContextBase() {}
44 
45 protected:
46     ModelType&          mrModel;
47 };
48 
49 // ============================================================================
50 
51 template< typename ModelType >
52 class FragmentBase : public ::oox::core::FragmentHandler2
53 {
54 public:
FragmentBase(::oox::core::XmlFilterBase & rFilter,const::rtl::OUString & rFragmentPath,ModelType & rModel)55     explicit            FragmentBase( ::oox::core::XmlFilterBase& rFilter, const ::rtl::OUString& rFragmentPath, ModelType& rModel ) :
56                             ::oox::core::FragmentHandler2( rFilter, rFragmentPath, false ), mrModel( rModel ) {}
~FragmentBase()57     virtual             ~FragmentBase() {}
58 
59 protected:
60     ModelType&          mrModel;
61 };
62 
63 // ============================================================================
64 
65 /** Help class for all contexts that have only the c:spPr child element.
66  */
67 class ShapePrWrapperContext : public ContextBase< Shape >
68 {
69 public:
70     explicit            ShapePrWrapperContext( ::oox::core::ContextHandler2Helper& rParent, Shape& rModel );
71     virtual             ~ShapePrWrapperContext();
72 
73     virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
74 };
75 
76 // ============================================================================
77 
78 struct LayoutModel;
79 
80 /** Handler for a chart layout context (c:layout element).
81  */
82 class LayoutContext : public ContextBase< LayoutModel >
83 {
84 public:
85     explicit            LayoutContext( ::oox::core::ContextHandler2Helper& rParent, LayoutModel& rModel );
86     virtual             ~LayoutContext();
87 
88     virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
89 };
90 
91 // ============================================================================
92 
93 } // namespace chart
94 } // namespace drawingml
95 } // namespace oox
96 
97 #endif
98