update dev300-m58
[ooovba.git] / canvas / source / vcl / spritecanvas.hxx
blobee20debc9d03b37d43dc60c33019c80a3d563156
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: spritecanvas.hxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _VCLCANVAS_SPRITECANVAS_HXX_
32 #define _VCLCANVAS_SPRITECANVAS_HXX_
34 #include <rtl/ref.hxx>
36 #include <com/sun/star/uno/XComponentContext.hpp>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <com/sun/star/lang/XServiceName.hpp>
39 #include <com/sun/star/awt/XWindowListener.hpp>
40 #include <com/sun/star/util/XUpdatable.hpp>
41 #include <com/sun/star/rendering/XSpriteCanvas.hpp>
42 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
43 #include <com/sun/star/rendering/XGraphicDevice.hpp>
44 #include <com/sun/star/rendering/XBufferController.hpp>
45 #include <com/sun/star/rendering/XParametricPolyPolygon2DFactory.hpp>
47 #include <cppuhelper/compbase9.hxx>
48 #include <comphelper/uno3.hxx>
50 #include <canvas/base/spritecanvasbase.hxx>
51 #include <canvas/base/basemutexhelper.hxx>
52 #include <canvas/base/bufferedgraphicdevicebase.hxx>
54 #include "spritecanvashelper.hxx"
55 #include "impltools.hxx"
56 #include "spritedevicehelper.hxx"
57 #include "repainttarget.hxx"
60 #define SPRITECANVAS_SERVICE_NAME "com.sun.star.rendering.SpriteCanvas.VCL"
61 #define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.VCL"
63 namespace vclcanvas
65 typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas,
66 ::com::sun::star::rendering::XIntegerBitmap,
67 ::com::sun::star::rendering::XGraphicDevice,
68 ::com::sun::star::rendering::XParametricPolyPolygon2DFactory,
69 ::com::sun::star::rendering::XBufferController,
70 ::com::sun::star::awt::XWindowListener,
71 ::com::sun::star::util::XUpdatable,
72 ::com::sun::star::beans::XPropertySet,
73 ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base;
74 typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >,
75 SpriteDeviceHelper,
76 tools::LocalGuard,
77 ::cppu::OWeakObject > SpriteCanvasBase_Base;
79 /** Mixin SpriteSurface
81 Have to mixin the SpriteSurface before deriving from
82 ::canvas::SpriteCanvasBase, as this template should already
83 implement some of those interface methods.
85 The reason why this appears kinda convoluted is the fact that
86 we cannot specify non-IDL types as WeakComponentImplHelperN
87 template args, and furthermore, don't want to derive
88 ::canvas::SpriteCanvasBase directly from
89 ::canvas::SpriteSurface (because derivees of
90 ::canvas::SpriteCanvasBase have to explicitely forward the
91 XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
92 anyway). Basically, ::canvas::CanvasCustomSpriteBase should
93 remain a base class that provides implementation, not to
94 enforce any specific interface on its derivees.
96 class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base,
97 public ::canvas::SpriteSurface
101 typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base,
102 SpriteCanvasHelper,
103 tools::LocalGuard,
104 ::cppu::OWeakObject > SpriteCanvasBaseT;
106 /** Product of this component's factory.
108 The SpriteCanvas object combines the actual Window canvas with
109 the XGraphicDevice interface. This is because there's a
110 one-to-one relation between them, anyway, since each window
111 can have exactly one canvas and one associated
112 XGraphicDevice. And to avoid messing around with circular
113 references, this is implemented as one single object.
115 class SpriteCanvas : public SpriteCanvasBaseT,
116 public RepaintTarget
118 public:
119 SpriteCanvas( const ::com::sun::star::uno::Sequence<
120 ::com::sun::star::uno::Any >& aArguments,
121 const ::com::sun::star::uno::Reference<
122 ::com::sun::star::uno::XComponentContext >& rxContext );
124 void initialize();
126 /// For resource tracking
127 ~SpriteCanvas();
129 #if defined __SUNPRO_CC
130 using SpriteCanvasBaseT::disposing;
131 #endif
133 /// Dispose all internal references
134 virtual void SAL_CALL disposing();
136 // Forwarding the XComponent implementation to the
137 // cppu::ImplHelper templated base
138 // Classname Base doing refcounting Base implementing the XComponent interface
139 // | | |
140 // V V V
141 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase );
143 // XBufferController (partial)
144 virtual ::sal_Bool SAL_CALL showBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
145 virtual ::sal_Bool SAL_CALL switchBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
147 // XSpriteCanvas (partial)
148 virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException);
150 // XServiceName
151 virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException);
153 // RepaintTarget
154 virtual bool repaint( const GraphicObjectSharedPtr& rGrf,
155 const ::com::sun::star::rendering::ViewState& viewState,
156 const ::com::sun::star::rendering::RenderState& renderState,
157 const ::Point& rPt,
158 const ::Size& rSz,
159 const GraphicAttr& rAttr ) const;
161 /// Get backbuffer for this canvas
162 OutDevProviderSharedPtr getFrontBuffer() const { return maDeviceHelper.getOutDev(); }
163 /// Get window for this canvas
164 BackBufferSharedPtr getBackBuffer() const { return maDeviceHelper.getBackBuffer(); }
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;
171 typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef;
172 typedef ::rtl::Reference< SpriteCanvas > DeviceRef;
176 #endif