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