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