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 _DXCANVAS_CANVAS_HXX_
25 #define _DXCANVAS_CANVAS_HXX_
26 
27 #include <rtl/ref.hxx>
28 
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/lang/XServiceName.hpp>
32 #include <com/sun/star/util/XUpdatable.hpp>
33 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
34 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
35 #include <com/sun/star/rendering/XGraphicDevice.hpp>
36 #include <com/sun/star/rendering/XBufferController.hpp>
37 
38 #include <cppuhelper/compbase7.hxx>
39 #include <cppuhelper/compbase6.hxx>
40 #include <comphelper/uno3.hxx>
41 
42 #include <canvas/base/integerbitmapbase.hxx>
43 #include <canvas/base/basemutexhelper.hxx>
44 #include <canvas/base/graphicdevicebase.hxx>
45 
46 #include "dx_bitmapprovider.hxx"
47 #include "dx_canvashelper.hxx"
48 #include "dx_bitmapcanvashelper.hxx"
49 #include "dx_impltools.hxx"
50 #include "dx_devicehelper.hxx"
51 
52 
53 namespace dxcanvas
54 {
55     typedef ::cppu::WeakComponentImplHelper6< ::com::sun::star::rendering::XCanvas,
56                                      		  ::com::sun::star::rendering::XGraphicDevice,
57                                               ::com::sun::star::lang::XMultiServiceFactory,
58 											  ::com::sun::star::util::XUpdatable,
59                                               ::com::sun::star::beans::XPropertySet,
60                                               ::com::sun::star::lang::XServiceName >	GraphicDeviceBase1_Base;
61     typedef ::canvas::GraphicDeviceBase< ::canvas::BaseMutexHelper< GraphicDeviceBase1_Base >,
62                                            DeviceHelper,
63                                            ::osl::MutexGuard,
64                                            ::cppu::OWeakObject > 	CanvasBase1_Base;
65 	typedef ::canvas::CanvasBase< CanvasBase1_Base,
66                                   CanvasHelper,
67                                   ::osl::MutexGuard,
68                                   ::cppu::OWeakObject >		CanvasBaseT;
69 
70     /** Product of this component's factory.
71 
72 		The Canvas object combines the actual Window canvas with
73 		the XGraphicDevice interface. This is because there's a
74 		one-to-one relation between them, anyway, since each window
75 		can have exactly one canvas and one associated
76 		XGraphicDevice. And to avoid messing around with circular
77 		references, this is implemented as one single object.
78      */
79     class Canvas : public CanvasBaseT
80     {
81     public:
82         Canvas( const ::com::sun::star::uno::Sequence<
83                       ::com::sun::star::uno::Any >&               aArguments,
84                 const ::com::sun::star::uno::Reference<
85                       ::com::sun::star::uno::XComponentContext >& rxContext );
86 
87         void initialize();
88 
89         /// Dispose all internal references
90         virtual void SAL_CALL disposing();
91 
92 		// Forwarding the XComponent implementation to the
93         // cppu::ImplHelper templated base
94         //                                    Classname   Base doing refcounting    Base implementing the XComponent interface
95         //                                       |                 |                            |
96         //                                       V                 V                            V
97         DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( Canvas, GraphicDeviceBase1_Base, ::cppu::WeakComponentImplHelperBase );
98 
99         // XServiceName
100         virtual ::rtl::OUString SAL_CALL getServiceName(  ) throw (::com::sun::star::uno::RuntimeException);
101 
102     private:
103         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >                maArguments;
104         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext;
105     };
106 
107     typedef ::rtl::Reference< Canvas > CanvasRef;
108 
109     //////////////////////////////////////////////////////////////////////////////////////////////////////
110 
111     typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas,
112 			                         		  ::com::sun::star::rendering::XIntegerBitmap,
113                                      		  ::com::sun::star::rendering::XGraphicDevice,
114                                               ::com::sun::star::lang::XMultiServiceFactory,
115 											  ::com::sun::star::util::XUpdatable,
116                                               ::com::sun::star::beans::XPropertySet,
117                                               ::com::sun::star::lang::XServiceName >	GraphicDeviceBase2_Base;
118     typedef ::canvas::GraphicDeviceBase< ::canvas::BaseMutexHelper< GraphicDeviceBase2_Base >,
119                                            DeviceHelper,
120                                            ::osl::MutexGuard,
121                                            ::cppu::OWeakObject > 	CanvasBase2_Base;
122 	typedef ::canvas::IntegerBitmapBase< CanvasBase2_Base,
123                                          BitmapCanvasHelper,
124                                          ::osl::MutexGuard,
125                                          ::cppu::OWeakObject >		BitmapCanvasBaseT;
126 
127     /** Product of this component's factory.
128 
129 		The Canvas object combines the actual Window canvas with
130 		the XGraphicDevice interface. This is because there's a
131 		one-to-one relation between them, anyway, since each window
132 		can have exactly one canvas and one associated
133 		XGraphicDevice. And to avoid messing around with circular
134 		references, this is implemented as one single object.
135      */
136     class BitmapCanvas : public BitmapCanvasBaseT, public BitmapProvider
137     {
138     public:
139         BitmapCanvas( const ::com::sun::star::uno::Sequence<
140                       	::com::sun::star::uno::Any >&               aArguments,
141                       const ::com::sun::star::uno::Reference<
142                       	::com::sun::star::uno::XComponentContext >& rxContext );
143 
144         void initialize();
145 
146         /// Dispose all internal references
147         virtual void SAL_CALL disposing();
148 
149 		// Forwarding the XComponent implementation to the
150         // cppu::ImplHelper templated base
151         //                                    Classname   Base doing refcounting    Base implementing the XComponent interface
152         //                                       |                 |                            |
153         //                                       V                 V                            V
154         DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( BitmapCanvas, GraphicDeviceBase2_Base, ::cppu::WeakComponentImplHelperBase );
155 
156         // XServiceName
157         virtual ::rtl::OUString SAL_CALL getServiceName(  ) throw (::com::sun::star::uno::RuntimeException);
158 
159         // BitmapProvider
160         virtual IBitmapSharedPtr getBitmap() const;
161 
162      private:
163         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >                maArguments;
164         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext;
165         IBitmapSharedPtr                                                             mpTarget;
166     };
167 
168     typedef ::rtl::Reference< BitmapCanvas > BitmapCanvasRef;
169 }
170 
171 #endif
172