xref: /aoo42x/main/cppcanvas/source/inc/action.hxx (revision 2d788491)
1*2d788491SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2d788491SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2d788491SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2d788491SAndrew Rist  * distributed with this work for additional information
6*2d788491SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2d788491SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2d788491SAndrew Rist  * "License"); you may not use this file except in compliance
9*2d788491SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2d788491SAndrew Rist  *
11*2d788491SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2d788491SAndrew Rist  *
13*2d788491SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2d788491SAndrew Rist  * software distributed under the License is distributed on an
15*2d788491SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2d788491SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2d788491SAndrew Rist  * specific language governing permissions and limitations
18*2d788491SAndrew Rist  * under the License.
19*2d788491SAndrew Rist  *
20*2d788491SAndrew Rist  *************************************************************/
21*2d788491SAndrew Rist 
22*2d788491SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _CPPCANVAS_ACTION_HXX
25cdf0e10cSrcweir #define _CPPCANVAS_ACTION_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <sal/types.h>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
30cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace basegfx
34cdf0e10cSrcweir {
35cdf0e10cSrcweir     class B2DHomMatrix;
36cdf0e10cSrcweir     class B2DRange;
37cdf0e10cSrcweir }
38cdf0e10cSrcweir 
39cdf0e10cSrcweir 
40cdf0e10cSrcweir /* Definition of Action interface */
41cdf0e10cSrcweir 
42cdf0e10cSrcweir namespace cppcanvas
43cdf0e10cSrcweir {
44cdf0e10cSrcweir     namespace internal
45cdf0e10cSrcweir     {
46cdf0e10cSrcweir         /** Interface for internal render actions
47cdf0e10cSrcweir 
48cdf0e10cSrcweir         	This interface is implemented by all objects generated
49cdf0e10cSrcweir         	from the metafile renderer, and corresponds roughly to the
50cdf0e10cSrcweir         	VCL meta action.
51cdf0e10cSrcweir          */
52cdf0e10cSrcweir         class Action
53cdf0e10cSrcweir         {
54cdf0e10cSrcweir         public:
55cdf0e10cSrcweir             /** Used for rendering action subsets
56cdf0e10cSrcweir 
57cdf0e10cSrcweir             	There are several cases where an Action might have
58cdf0e10cSrcweir             	subsettable content, e.g. text, or referenced
59cdf0e10cSrcweir             	metafiles, like the transparent action.
60cdf0e10cSrcweir 
61cdf0e10cSrcweir                 Generally, at the metafile renderer, all actions are
62cdf0e10cSrcweir                 'flattened' out, i.e. a meta action rendering the
63cdf0e10cSrcweir                 string "Hello" counts five indices, and a transparent
64cdf0e10cSrcweir                 action containing a metafile with 100 actions counts
65cdf0e10cSrcweir                 at least 100 indices (contained transparency or text
66cdf0e10cSrcweir                 actions recursively add to this value). From the
67cdf0e10cSrcweir                 outside, the subset to render is referenced via this
68cdf0e10cSrcweir                 flat index range
69cdf0e10cSrcweir              */
70cdf0e10cSrcweir             struct Subset
71cdf0e10cSrcweir             {
72cdf0e10cSrcweir                 /** Denotes start of the subset.
73cdf0e10cSrcweir 
74cdf0e10cSrcweir                 	The index given here specifies the first subaction
75cdf0e10cSrcweir                 	to render.
76cdf0e10cSrcweir                  */
77cdf0e10cSrcweir                 sal_Int32	mnSubsetBegin;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir                 /** Denotes end of the subset
80cdf0e10cSrcweir 
81cdf0e10cSrcweir                 	The index given here specifies the first subaction
82cdf0e10cSrcweir                 	<em>not<em> to render, i.e. one action behind the
83cdf0e10cSrcweir                 	subset to be rendered
84cdf0e10cSrcweir                  */
85cdf0e10cSrcweir                 sal_Int32	mnSubsetEnd;
86cdf0e10cSrcweir             };
87cdf0e10cSrcweir 
~Action()88cdf0e10cSrcweir             virtual ~Action() {}
89cdf0e10cSrcweir 
90cdf0e10cSrcweir             /** Render this action to the associated canvas
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 				@param rTransformation
93cdf0e10cSrcweir                 Transformation matrix to apply before rendering
94cdf0e10cSrcweir 
95cdf0e10cSrcweir                 @return true, if rendering was successful. If
96cdf0e10cSrcweir                 rendering failed, false is returned.
97cdf0e10cSrcweir              */
98cdf0e10cSrcweir             virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir             /** Render the given part of the action to the associated
101cdf0e10cSrcweir                 canvas.
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 				@param rTransformation
104cdf0e10cSrcweir                 Transformation matrix to apply before rendering
105cdf0e10cSrcweir 
106cdf0e10cSrcweir                 @param rSubset
107cdf0e10cSrcweir                 Subset of the action to render. See Subset description
108cdf0e10cSrcweir                 for index semantics.
109cdf0e10cSrcweir 
110cdf0e10cSrcweir                 @return true, if rendering was successful. If the
111cdf0e10cSrcweir                 specified subset is invalid for this action, or if
112cdf0e10cSrcweir                 rendering failed for other reasons, false is returned.
113cdf0e10cSrcweir              */
114cdf0e10cSrcweir             virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation,
115cdf0e10cSrcweir                                  const Subset&					rSubset ) const = 0;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir             /** Query bounds of this action on the associated canvas
118cdf0e10cSrcweir 
119cdf0e10cSrcweir 				@param rTransformation
120cdf0e10cSrcweir                 Transformation matrix to apply
121cdf0e10cSrcweir 
122cdf0e10cSrcweir                 @return the bounds for this action in device
123cdf0e10cSrcweir                 coordinate space.
124cdf0e10cSrcweir              */
125cdf0e10cSrcweir             virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
126cdf0e10cSrcweir 
127cdf0e10cSrcweir             /** Query bounds for the given part of the action on the
128cdf0e10cSrcweir                 associated canvas.
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 				@param rTransformation
131cdf0e10cSrcweir                 Transformation matrix to apply.
132cdf0e10cSrcweir 
133cdf0e10cSrcweir                 @param rSubset
134cdf0e10cSrcweir                 Subset of the action to query. See Subset description
135cdf0e10cSrcweir                 for index semantics.
136cdf0e10cSrcweir 
137cdf0e10cSrcweir                 @return the bounds for the given subset in device
138cdf0e10cSrcweir                 coordinate space.
139cdf0e10cSrcweir              */
140cdf0e10cSrcweir             virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix&	rTransformation,
141cdf0e10cSrcweir                                                    const Subset&					rSubset ) const = 0;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir             /** Query action count.
144cdf0e10cSrcweir 
145cdf0e10cSrcweir             	This method returns the number of subset actions
146cdf0e10cSrcweir             	contained in this action. The render( Subset ) method
147cdf0e10cSrcweir             	must accept subset ranges up to the value returned
148cdf0e10cSrcweir             	here.
149cdf0e10cSrcweir 
150cdf0e10cSrcweir                 @return the number of subset actions
151cdf0e10cSrcweir              */
152cdf0e10cSrcweir             virtual sal_Int32 getActionCount() const = 0;
153cdf0e10cSrcweir         };
154cdf0e10cSrcweir 
155cdf0e10cSrcweir         typedef ::boost::shared_ptr< Action > ActionSharedPtr;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     }
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
160cdf0e10cSrcweir #endif /* _CPPCANVAS_ACTION_HXX */
161