xref: /aoo4110/main/cppcanvas/source/inc/action.hxx (revision b1cdbd2c)
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 _CPPCANVAS_ACTION_HXX
25 #define _CPPCANVAS_ACTION_HXX
26 
27 #include <sal/types.h>
28 
29 #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
30 #include <boost/shared_ptr.hpp>
31 #endif
32 
33 namespace basegfx
34 {
35     class B2DHomMatrix;
36     class B2DRange;
37 }
38 
39 
40 /* Definition of Action interface */
41 
42 namespace cppcanvas
43 {
44     namespace internal
45     {
46         /** Interface for internal render actions
47 
48         	This interface is implemented by all objects generated
49         	from the metafile renderer, and corresponds roughly to the
50         	VCL meta action.
51          */
52         class Action
53         {
54         public:
55             /** Used for rendering action subsets
56 
57             	There are several cases where an Action might have
58             	subsettable content, e.g. text, or referenced
59             	metafiles, like the transparent action.
60 
61                 Generally, at the metafile renderer, all actions are
62                 'flattened' out, i.e. a meta action rendering the
63                 string "Hello" counts five indices, and a transparent
64                 action containing a metafile with 100 actions counts
65                 at least 100 indices (contained transparency or text
66                 actions recursively add to this value). From the
67                 outside, the subset to render is referenced via this
68                 flat index range
69              */
70             struct Subset
71             {
72                 /** Denotes start of the subset.
73 
74                 	The index given here specifies the first subaction
75                 	to render.
76                  */
77                 sal_Int32	mnSubsetBegin;
78 
79                 /** Denotes end of the subset
80 
81                 	The index given here specifies the first subaction
82                 	<em>not<em> to render, i.e. one action behind the
83                 	subset to be rendered
84                  */
85                 sal_Int32	mnSubsetEnd;
86             };
87 
~Action()88             virtual ~Action() {}
89 
90             /** Render this action to the associated canvas
91 
92 				@param rTransformation
93                 Transformation matrix to apply before rendering
94 
95                 @return true, if rendering was successful. If
96                 rendering failed, false is returned.
97              */
98             virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
99 
100             /** Render the given part of the action to the associated
101                 canvas.
102 
103 				@param rTransformation
104                 Transformation matrix to apply before rendering
105 
106                 @param rSubset
107                 Subset of the action to render. See Subset description
108                 for index semantics.
109 
110                 @return true, if rendering was successful. If the
111                 specified subset is invalid for this action, or if
112                 rendering failed for other reasons, false is returned.
113              */
114             virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation,
115                                  const Subset&					rSubset ) const = 0;
116 
117             /** Query bounds of this action on the associated canvas
118 
119 				@param rTransformation
120                 Transformation matrix to apply
121 
122                 @return the bounds for this action in device
123                 coordinate space.
124              */
125             virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
126 
127             /** Query bounds for the given part of the action on the
128                 associated canvas.
129 
130 				@param rTransformation
131                 Transformation matrix to apply.
132 
133                 @param rSubset
134                 Subset of the action to query. See Subset description
135                 for index semantics.
136 
137                 @return the bounds for the given subset in device
138                 coordinate space.
139              */
140             virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix&	rTransformation,
141                                                    const Subset&					rSubset ) const = 0;
142 
143             /** Query action count.
144 
145             	This method returns the number of subset actions
146             	contained in this action. The render( Subset ) method
147             	must accept subset ranges up to the value returned
148             	here.
149 
150                 @return the number of subset actions
151              */
152             virtual sal_Int32 getActionCount() const = 0;
153         };
154 
155         typedef ::boost::shared_ptr< Action > ActionSharedPtr;
156 
157     }
158 }
159 
160 #endif /* _CPPCANVAS_ACTION_HXX */
161