xref: /trunk/main/canvas/source/vcl/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 _VCLCANVAS_CANVAS_HXX_
29 #define _VCLCANVAS_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 <comphelper/uno3.hxx>
44 
45 #include <canvas/base/basemutexhelper.hxx>
46 #include <canvas/base/integerbitmapbase.hxx>
47 #include <canvas/base/graphicdevicebase.hxx>
48 
49 #include "canvashelper.hxx"
50 #include "impltools.hxx"
51 #include "devicehelper.hxx"
52 #include "repainttarget.hxx"
53 
54 #define CANVAS_SERVICE_NAME        "com.sun.star.rendering.Canvas.VCL"
55 #define CANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.Canvas.VCL"
56 
57 namespace vclcanvas
58 {
59     typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas,
60                                               ::com::sun::star::rendering::XIntegerBitmap,
61                                      		  ::com::sun::star::rendering::XGraphicDevice,
62                                               ::com::sun::star::lang::XMultiServiceFactory,
63 											  ::com::sun::star::util::XUpdatable,
64                                               ::com::sun::star::beans::XPropertySet,
65                                               ::com::sun::star::lang::XServiceName >	GraphicDeviceBase_Base;
66     typedef ::canvas::GraphicDeviceBase< ::canvas::BaseMutexHelper< GraphicDeviceBase_Base >,
67                                            DeviceHelper,
68                                            tools::LocalGuard,
69                                            ::cppu::OWeakObject > 	CanvasBase_Base;
70 	typedef ::canvas::IntegerBitmapBase< CanvasBase_Base,
71                                          CanvasHelper,
72                                          tools::LocalGuard,
73                                          ::cppu::OWeakObject >		CanvasBaseT;
74 
75     /** Product of this component's factory.
76 
77 		The Canvas object combines the actual Window canvas with
78 		the XGraphicDevice interface. This is because there's a
79 		one-to-one relation between them, anyway, since each window
80 		can have exactly one canvas and one associated
81 		XGraphicDevice. And to avoid messing around with circular
82 		references, this is implemented as one single object.
83      */
84     class Canvas : public CanvasBaseT,
85                    public RepaintTarget
86     {
87     public:
88         Canvas( const ::com::sun::star::uno::Sequence<
89                       ::com::sun::star::uno::Any >&               aArguments,
90                 const ::com::sun::star::uno::Reference<
91                       ::com::sun::star::uno::XComponentContext >& rxContext );
92 
93         void initialize();
94 
95         /// For resource tracking
96         ~Canvas();
97 
98 #if defined __SUNPRO_CC
99         using CanvasBaseT::disposing;
100 #endif
101 
102         /// Dispose all internal references
103         virtual void SAL_CALL disposing();
104 
105 		// Forwarding the XComponent implementation to the
106         // cppu::ImplHelper templated base
107         //                                    Classname     Base doing refcounting        Base implementing the XComponent interface
108         //                                       |                 |                            |
109         //                                       V                 V                            V
110         DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( Canvas,   GraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase );
111 
112         // XServiceName
113         virtual ::rtl::OUString SAL_CALL getServiceName(  ) throw (::com::sun::star::uno::RuntimeException);
114 
115         // RepaintTarget
116         virtual bool repaint( const GraphicObjectSharedPtr&                 rGrf,
117                               const com::sun::star::rendering::ViewState&   viewState,
118                               const com::sun::star::rendering::RenderState& renderState,
119                               const ::Point&                                rPt,
120                               const ::Size&                                 rSz,
121                               const GraphicAttr&                            rAttr ) const;
122 
123     private:
124         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >                maArguments;
125         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext;
126     };
127 
128     typedef ::rtl::Reference< Canvas > CanvasRef;
129 }
130 
131 #endif
132