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_TRANSPARENCYGROUPACTION_HXX
29 #define _CPPCANVAS_TRANSPARENCYGROUPACTION_HXX
30 
31 #include <cppcanvas/canvas.hxx>
32 #include <cppcanvas/renderer.hxx>
33 #include <action.hxx>
34 
35 #include <memory> // auto_ptr
36 
37 namespace basegfx {
38     class B2DPoint;
39     class B2DVector;
40 }
41 
42 class GDIMetaFile;
43 class Gradient;
44 
45 
46 /* Definition of internal::TransparencyGroupActionFactory class */
47 
48 namespace cppcanvas
49 {
50     namespace internal
51     {
52         struct OutDevState;
53 
54         typedef ::std::auto_ptr< GDIMetaFile >	MtfAutoPtr;
55         typedef ::std::auto_ptr< Gradient > 	GradientAutoPtr;
56 
57         /** Transparency group action.
58 
59 			This action groups a bunch of other actions, to be
60 			rendered with the given transparency setting against the
61 			background.
62 
63             Creates encapsulated converters between GDIMetaFile and
64             XCanvas. The Canvas argument is deliberately placed at the
65             constructor, to force reconstruction of this object for a
66             new canvas. This considerably eases internal state
67             handling, since a lot of the internal state (e.g. fonts,
68             text layout) is Canvas-dependent.
69          */
70         class TransparencyGroupActionFactory
71         {
72         public:
73             /** Create new transparency group action.
74 
75             	@param rGroupMtf
76                 Metafile that groups all actions to be rendered
77                 transparent
78 
79                 @param rParms
80                 Render parameters
81 
82                 @param rDstPoint
83                 Left, top edge of destination, in current state
84                 coordinate system
85 
86                 @param rDstSize
87                 Size of the transparency group object, in current
88                 state coordinate system.
89 
90                 @param nAlpha
91                 Alpha value, must be in the range [0,1]
92              */
93             static ActionSharedPtr createTransparencyGroupAction( MtfAutoPtr&					rGroupMtf,
94                                                                   const Renderer::Parameters& 	rParms,
95                                                                   const ::basegfx::B2DPoint& 	rDstPoint,
96                                                                   const ::basegfx::B2DVector& 	rDstSize,
97                                                                   double 						nAlpha,
98                                                                   const CanvasSharedPtr&		rCanvas,
99                                                                   const OutDevState& 			rState );
100 
101             /** Create new transparency group action.
102 
103             	@param rGroupMtf
104                 Metafile that groups all actions to be rendered
105                 transparent.
106 
107                 @param rAlphaGradient
108                 VCL gradient, to be rendered into the action's alpha
109                 channel.
110 
111                 @param rParms
112                 Render parameters
113 
114                 @param rDstPoint
115                 Left, top edge of destination, in current state
116                 coordinate system
117 
118                 @param rDstSize
119                 Size of the transparency group object, in current
120                 state coordinate system.
121              */
122             static ActionSharedPtr createTransparencyGroupAction( MtfAutoPtr&					rGroupMtf,
123                                                                   GradientAutoPtr&				rAlphaGradient,
124                                                                   const Renderer::Parameters&	rParms,
125                                                                   const ::basegfx::B2DPoint& 	rDstPoint,
126                                                                   const ::basegfx::B2DVector& 	rDstSize,
127                                                                   const CanvasSharedPtr&		rCanvas,
128                                                                   const OutDevState& 			rState );
129 
130         private:
131             // static factory, disable big four
132             TransparencyGroupActionFactory();
133             ~TransparencyGroupActionFactory();
134             TransparencyGroupActionFactory(const TransparencyGroupActionFactory&);
135             TransparencyGroupActionFactory& operator=( const TransparencyGroupActionFactory& );
136         };
137     }
138 }
139 
140 #endif /*_CPPCANVAS_TRANSPARENCYGROUPACTION_HXX */
141