xref: /trunk/main/canvas/source/vcl/canvas.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
1*91c99ff4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*91c99ff4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*91c99ff4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*91c99ff4SAndrew Rist  * distributed with this work for additional information
6*91c99ff4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*91c99ff4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*91c99ff4SAndrew Rist  * "License"); you may not use this file except in compliance
9*91c99ff4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*91c99ff4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*91c99ff4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*91c99ff4SAndrew Rist  * software distributed under the License is distributed on an
15*91c99ff4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*91c99ff4SAndrew Rist  * KIND, either express or implied.  See the License for the
17*91c99ff4SAndrew Rist  * specific language governing permissions and limitations
18*91c99ff4SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*91c99ff4SAndrew Rist  *************************************************************/
21*91c99ff4SAndrew Rist 
22*91c99ff4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _VCLCANVAS_CANVAS_HXX_
25cdf0e10cSrcweir #define _VCLCANVAS_CANVAS_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <rtl/ref.hxx>
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp>
30cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
31cdf0e10cSrcweir #include <com/sun/star/lang/XServiceName.hpp>
32cdf0e10cSrcweir #include <com/sun/star/util/XUpdatable.hpp>
33cdf0e10cSrcweir #include <com/sun/star/rendering/XBitmapCanvas.hpp>
34cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
35cdf0e10cSrcweir #include <com/sun/star/rendering/XGraphicDevice.hpp>
36cdf0e10cSrcweir #include <com/sun/star/rendering/XBufferController.hpp>
37cdf0e10cSrcweir 
38cdf0e10cSrcweir #include <cppuhelper/compbase7.hxx>
39cdf0e10cSrcweir #include <comphelper/uno3.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include <canvas/base/basemutexhelper.hxx>
42cdf0e10cSrcweir #include <canvas/base/integerbitmapbase.hxx>
43cdf0e10cSrcweir #include <canvas/base/graphicdevicebase.hxx>
44cdf0e10cSrcweir 
45cdf0e10cSrcweir #include "canvashelper.hxx"
46cdf0e10cSrcweir #include "impltools.hxx"
47cdf0e10cSrcweir #include "devicehelper.hxx"
48cdf0e10cSrcweir #include "repainttarget.hxx"
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #define CANVAS_SERVICE_NAME        "com.sun.star.rendering.Canvas.VCL"
51cdf0e10cSrcweir #define CANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.Canvas.VCL"
52cdf0e10cSrcweir 
53cdf0e10cSrcweir namespace vclcanvas
54cdf0e10cSrcweir {
55cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper7< ::com::sun::star::rendering::XBitmapCanvas,
56cdf0e10cSrcweir                                               ::com::sun::star::rendering::XIntegerBitmap,
57cdf0e10cSrcweir                                               ::com::sun::star::rendering::XGraphicDevice,
58cdf0e10cSrcweir                                               ::com::sun::star::lang::XMultiServiceFactory,
59cdf0e10cSrcweir                                               ::com::sun::star::util::XUpdatable,
60cdf0e10cSrcweir                                               ::com::sun::star::beans::XPropertySet,
61cdf0e10cSrcweir                                               ::com::sun::star::lang::XServiceName >    GraphicDeviceBase_Base;
62cdf0e10cSrcweir     typedef ::canvas::GraphicDeviceBase< ::canvas::BaseMutexHelper< GraphicDeviceBase_Base >,
63cdf0e10cSrcweir                                            DeviceHelper,
64cdf0e10cSrcweir                                            tools::LocalGuard,
65cdf0e10cSrcweir                                            ::cppu::OWeakObject >    CanvasBase_Base;
66cdf0e10cSrcweir     typedef ::canvas::IntegerBitmapBase< CanvasBase_Base,
67cdf0e10cSrcweir                                          CanvasHelper,
68cdf0e10cSrcweir                                          tools::LocalGuard,
69cdf0e10cSrcweir                                          ::cppu::OWeakObject >      CanvasBaseT;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     /** Product of this component's factory.
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         The Canvas object combines the actual Window canvas with
74cdf0e10cSrcweir         the XGraphicDevice interface. This is because there's a
75cdf0e10cSrcweir         one-to-one relation between them, anyway, since each window
76cdf0e10cSrcweir         can have exactly one canvas and one associated
77cdf0e10cSrcweir         XGraphicDevice. And to avoid messing around with circular
78cdf0e10cSrcweir         references, this is implemented as one single object.
79cdf0e10cSrcweir      */
80cdf0e10cSrcweir     class Canvas : public CanvasBaseT,
81cdf0e10cSrcweir                    public RepaintTarget
82cdf0e10cSrcweir     {
83cdf0e10cSrcweir     public:
84cdf0e10cSrcweir         Canvas( const ::com::sun::star::uno::Sequence<
85cdf0e10cSrcweir                       ::com::sun::star::uno::Any >&               aArguments,
86cdf0e10cSrcweir                 const ::com::sun::star::uno::Reference<
87cdf0e10cSrcweir                       ::com::sun::star::uno::XComponentContext >& rxContext );
88cdf0e10cSrcweir 
89cdf0e10cSrcweir         void initialize();
90cdf0e10cSrcweir 
91cdf0e10cSrcweir         /// For resource tracking
92cdf0e10cSrcweir         ~Canvas();
93cdf0e10cSrcweir 
94cdf0e10cSrcweir #if defined __SUNPRO_CC
95cdf0e10cSrcweir         using CanvasBaseT::disposing;
96cdf0e10cSrcweir #endif
97cdf0e10cSrcweir 
98cdf0e10cSrcweir         /// Dispose all internal references
99cdf0e10cSrcweir         virtual void SAL_CALL disposing();
100cdf0e10cSrcweir 
101cdf0e10cSrcweir         // Forwarding the XComponent implementation to the
102cdf0e10cSrcweir         // cppu::ImplHelper templated base
103cdf0e10cSrcweir         //                                    Classname     Base doing refcounting        Base implementing the XComponent interface
104cdf0e10cSrcweir         //                                       |                 |                            |
105cdf0e10cSrcweir         //                                       V                 V                            V
106cdf0e10cSrcweir         DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( Canvas,   GraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir         // XServiceName
109cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getServiceName(  ) throw (::com::sun::star::uno::RuntimeException);
110cdf0e10cSrcweir 
111cdf0e10cSrcweir         // RepaintTarget
112cdf0e10cSrcweir         virtual bool repaint( const GraphicObjectSharedPtr&                 rGrf,
113cdf0e10cSrcweir                               const com::sun::star::rendering::ViewState&   viewState,
114cdf0e10cSrcweir                               const com::sun::star::rendering::RenderState& renderState,
115cdf0e10cSrcweir                               const ::Point&                                rPt,
116cdf0e10cSrcweir                               const ::Size&                                 rSz,
117cdf0e10cSrcweir                               const GraphicAttr&                            rAttr ) const;
118cdf0e10cSrcweir 
119cdf0e10cSrcweir     private:
120cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >                maArguments;
121cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext;
122cdf0e10cSrcweir     };
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     typedef ::rtl::Reference< Canvas > CanvasRef;
125cdf0e10cSrcweir }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir #endif
128