xref: /aoo42x/main/cppcanvas/source/inc/action.hxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _CPPCANVAS_ACTION_HXX
29*cdf0e10cSrcweir #define _CPPCANVAS_ACTION_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <sal/types.h>
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir #ifndef BOOST_SHARED_PTR_HPP_INCLUDED
34*cdf0e10cSrcweir #include <boost/shared_ptr.hpp>
35*cdf0e10cSrcweir #endif
36*cdf0e10cSrcweir 
37*cdf0e10cSrcweir namespace basegfx
38*cdf0e10cSrcweir {
39*cdf0e10cSrcweir     class B2DHomMatrix;
40*cdf0e10cSrcweir     class B2DRange;
41*cdf0e10cSrcweir }
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir /* Definition of Action interface */
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir namespace cppcanvas
47*cdf0e10cSrcweir {
48*cdf0e10cSrcweir     namespace internal
49*cdf0e10cSrcweir     {
50*cdf0e10cSrcweir         /** Interface for internal render actions
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir         	This interface is implemented by all objects generated
53*cdf0e10cSrcweir         	from the metafile renderer, and corresponds roughly to the
54*cdf0e10cSrcweir         	VCL meta action.
55*cdf0e10cSrcweir          */
56*cdf0e10cSrcweir         class Action
57*cdf0e10cSrcweir         {
58*cdf0e10cSrcweir         public:
59*cdf0e10cSrcweir             /** Used for rendering action subsets
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir             	There are several cases where an Action might have
62*cdf0e10cSrcweir             	subsettable content, e.g. text, or referenced
63*cdf0e10cSrcweir             	metafiles, like the transparent action.
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir                 Generally, at the metafile renderer, all actions are
66*cdf0e10cSrcweir                 'flattened' out, i.e. a meta action rendering the
67*cdf0e10cSrcweir                 string "Hello" counts five indices, and a transparent
68*cdf0e10cSrcweir                 action containing a metafile with 100 actions counts
69*cdf0e10cSrcweir                 at least 100 indices (contained transparency or text
70*cdf0e10cSrcweir                 actions recursively add to this value). From the
71*cdf0e10cSrcweir                 outside, the subset to render is referenced via this
72*cdf0e10cSrcweir                 flat index range
73*cdf0e10cSrcweir              */
74*cdf0e10cSrcweir             struct Subset
75*cdf0e10cSrcweir             {
76*cdf0e10cSrcweir                 /** Denotes start of the subset.
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir                 	The index given here specifies the first subaction
79*cdf0e10cSrcweir                 	to render.
80*cdf0e10cSrcweir                  */
81*cdf0e10cSrcweir                 sal_Int32	mnSubsetBegin;
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir                 /** Denotes end of the subset
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir                 	The index given here specifies the first subaction
86*cdf0e10cSrcweir                 	<em>not<em> to render, i.e. one action behind the
87*cdf0e10cSrcweir                 	subset to be rendered
88*cdf0e10cSrcweir                  */
89*cdf0e10cSrcweir                 sal_Int32	mnSubsetEnd;
90*cdf0e10cSrcweir             };
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir             virtual ~Action() {}
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir             /** Render this action to the associated canvas
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 				@param rTransformation
97*cdf0e10cSrcweir                 Transformation matrix to apply before rendering
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir                 @return true, if rendering was successful. If
100*cdf0e10cSrcweir                 rendering failed, false is returned.
101*cdf0e10cSrcweir              */
102*cdf0e10cSrcweir             virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir             /** Render the given part of the action to the associated
105*cdf0e10cSrcweir                 canvas.
106*cdf0e10cSrcweir 
107*cdf0e10cSrcweir 				@param rTransformation
108*cdf0e10cSrcweir                 Transformation matrix to apply before rendering
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir                 @param rSubset
111*cdf0e10cSrcweir                 Subset of the action to render. See Subset description
112*cdf0e10cSrcweir                 for index semantics.
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir                 @return true, if rendering was successful. If the
115*cdf0e10cSrcweir                 specified subset is invalid for this action, or if
116*cdf0e10cSrcweir                 rendering failed for other reasons, false is returned.
117*cdf0e10cSrcweir              */
118*cdf0e10cSrcweir             virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation,
119*cdf0e10cSrcweir                                  const Subset&					rSubset ) const = 0;
120*cdf0e10cSrcweir 
121*cdf0e10cSrcweir             /** Query bounds of this action on the associated canvas
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 				@param rTransformation
124*cdf0e10cSrcweir                 Transformation matrix to apply
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir                 @return the bounds for this action in device
127*cdf0e10cSrcweir                 coordinate space.
128*cdf0e10cSrcweir              */
129*cdf0e10cSrcweir             virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir             /** Query bounds for the given part of the action on the
132*cdf0e10cSrcweir                 associated canvas.
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 				@param rTransformation
135*cdf0e10cSrcweir                 Transformation matrix to apply.
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir                 @param rSubset
138*cdf0e10cSrcweir                 Subset of the action to query. See Subset description
139*cdf0e10cSrcweir                 for index semantics.
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir                 @return the bounds for the given subset in device
142*cdf0e10cSrcweir                 coordinate space.
143*cdf0e10cSrcweir              */
144*cdf0e10cSrcweir             virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix&	rTransformation,
145*cdf0e10cSrcweir                                                    const Subset&					rSubset ) const = 0;
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir             /** Query action count.
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir             	This method returns the number of subset actions
150*cdf0e10cSrcweir             	contained in this action. The render( Subset ) method
151*cdf0e10cSrcweir             	must accept subset ranges up to the value returned
152*cdf0e10cSrcweir             	here.
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir                 @return the number of subset actions
155*cdf0e10cSrcweir              */
156*cdf0e10cSrcweir             virtual sal_Int32 getActionCount() const = 0;
157*cdf0e10cSrcweir         };
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir         typedef ::boost::shared_ptr< Action > ActionSharedPtr;
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir     }
162*cdf0e10cSrcweir }
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir #endif /* _CPPCANVAS_ACTION_HXX */
165