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