1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dx_spritecanvas.hxx,v $
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 _DXCANVAS_SPRITECANVAS_HXX_
32 #define _DXCANVAS_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 "dx_bitmapprovider.hxx"
55 #include "dx_spritecanvashelper.hxx"
56 #include "dx_surfacebitmap.hxx"
57 #include "dx_impltools.hxx"
58 #include "dx_spritedevicehelper.hxx"
63 typedef ::cppu::WeakComponentImplHelper9
< ::com::sun::star::rendering::XSpriteCanvas
,
64 ::com::sun::star::rendering::XIntegerBitmap
,
65 ::com::sun::star::rendering::XGraphicDevice
,
66 ::com::sun::star::rendering::XParametricPolyPolygon2DFactory
,
67 ::com::sun::star::rendering::XBufferController
,
68 ::com::sun::star::awt::XWindowListener
,
69 ::com::sun::star::util::XUpdatable
,
70 ::com::sun::star::beans::XPropertySet
,
71 ::com::sun::star::lang::XServiceName
> WindowGraphicDeviceBase_Base
;
72 typedef ::canvas::BufferedGraphicDeviceBase
< ::canvas::BaseMutexHelper
< WindowGraphicDeviceBase_Base
>,
75 ::cppu::OWeakObject
> SpriteCanvasBase_Base
;
76 /** Mixin SpriteSurface
78 Have to mixin the SpriteSurface before deriving from
79 ::canvas::SpriteCanvasBase, as this template should already
80 implement some of those interface methods.
82 The reason why this appears kinda convoluted is the fact that
83 we cannot specify non-IDL types as WeakComponentImplHelperN
84 template args, and furthermore, don't want to derive
85 ::canvas::SpriteCanvasBase directly from
86 ::canvas::SpriteSurface (because derivees of
87 ::canvas::SpriteCanvasBase have to explicitely forward the
88 XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
89 anyway). Basically, ::canvas::CanvasCustomSpriteBase should
90 remain a base class that provides implementation, not to
91 enforce any specific interface on its derivees.
93 class SpriteCanvasBaseSpriteSurface_Base
: public SpriteCanvasBase_Base
,
94 public ::canvas::SpriteSurface
98 typedef ::canvas::SpriteCanvasBase
< SpriteCanvasBaseSpriteSurface_Base
,
101 ::cppu::OWeakObject
> SpriteCanvasBaseT
;
103 /** Product of this component's factory.
105 The SpriteCanvas object combines the actual Window canvas with
106 the XGraphicDevice interface. This is because there's a
107 one-to-one relation between them, anyway, since each window
108 can have exactly one canvas and one associated
109 XGraphicDevice. And to avoid messing around with circular
110 references, this is implemented as one single object.
112 class SpriteCanvas
: public SpriteCanvasBaseT
, public BitmapProvider
115 SpriteCanvas( const ::com::sun::star::uno::Sequence
<
116 ::com::sun::star::uno::Any
>& aArguments
,
117 const ::com::sun::star::uno::Reference
<
118 ::com::sun::star::uno::XComponentContext
>& rxContext
);
122 /// Dispose all internal references
123 virtual void SAL_CALL
disposing();
125 // Forwarding the XComponent implementation to the
126 // cppu::ImplHelper templated base
127 // Classname Base doing refcounting Base implementing the XComponent interface
130 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas
, WindowGraphicDeviceBase_Base
, ::cppu::WeakComponentImplHelperBase
);
132 // XBufferController (partial)
133 virtual ::sal_Bool SAL_CALL
showBuffer( ::sal_Bool bUpdateAll
) throw (::com::sun::star::uno::RuntimeException
);
134 virtual ::sal_Bool SAL_CALL
switchBuffer( ::sal_Bool bUpdateAll
) throw (::com::sun::star::uno::RuntimeException
);
136 // XSpriteCanvas (partial)
137 virtual sal_Bool SAL_CALL
updateScreen( sal_Bool bUpdateAll
) throw (::com::sun::star::uno::RuntimeException
);
140 virtual ::rtl::OUString SAL_CALL
getServiceName( ) throw (::com::sun::star::uno::RuntimeException
);
142 /// Retrieve rendermodule object for this Canvas
143 const IDXRenderModuleSharedPtr
& getRenderModule() const;
145 /// Get backbuffer for this canvas
146 const DXSurfaceBitmapSharedPtr
& getBackBuffer() const;
149 virtual IBitmapSharedPtr
getBitmap() const;
152 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> maArguments
;
153 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> mxComponentContext
;
156 typedef ::rtl::Reference
< SpriteCanvas
> SpriteCanvasRef
;