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 _DXCANVAS_SPRITECANVAS_HXX_ 29 #define _DXCANVAS_SPRITECANVAS_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/awt/XWindowListener.hpp> 37 #include <com/sun/star/util/XUpdatable.hpp> 38 #include <com/sun/star/rendering/XSpriteCanvas.hpp> 39 #include <com/sun/star/rendering/XIntegerBitmap.hpp> 40 #include <com/sun/star/rendering/XGraphicDevice.hpp> 41 #include <com/sun/star/rendering/XBufferController.hpp> 42 43 #include <cppuhelper/compbase9.hxx> 44 #include <comphelper/uno3.hxx> 45 46 #include <canvas/base/spritecanvasbase.hxx> 47 #include <canvas/base/basemutexhelper.hxx> 48 #include <canvas/base/bufferedgraphicdevicebase.hxx> 49 50 #include "dx_bitmapprovider.hxx" 51 #include "dx_spritecanvashelper.hxx" 52 #include "dx_surfacebitmap.hxx" 53 #include "dx_impltools.hxx" 54 #include "dx_spritedevicehelper.hxx" 55 56 57 namespace dxcanvas 58 { 59 typedef ::cppu::WeakComponentImplHelper9< ::com::sun::star::rendering::XSpriteCanvas, 60 ::com::sun::star::rendering::XIntegerBitmap, 61 ::com::sun::star::rendering::XGraphicDevice, 62 ::com::sun::star::lang::XMultiServiceFactory, 63 ::com::sun::star::rendering::XBufferController, 64 ::com::sun::star::awt::XWindowListener, 65 ::com::sun::star::util::XUpdatable, 66 ::com::sun::star::beans::XPropertySet, 67 ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base; 68 typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >, 69 SpriteDeviceHelper, 70 ::osl::MutexGuard, 71 ::cppu::OWeakObject > SpriteCanvasBase_Base; 72 /** Mixin SpriteSurface 73 74 Have to mixin the SpriteSurface before deriving from 75 ::canvas::SpriteCanvasBase, as this template should already 76 implement some of those interface methods. 77 78 The reason why this appears kinda convoluted is the fact that 79 we cannot specify non-IDL types as WeakComponentImplHelperN 80 template args, and furthermore, don't want to derive 81 ::canvas::SpriteCanvasBase directly from 82 ::canvas::SpriteSurface (because derivees of 83 ::canvas::SpriteCanvasBase have to explicitely forward the 84 XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS) 85 anyway). Basically, ::canvas::CanvasCustomSpriteBase should 86 remain a base class that provides implementation, not to 87 enforce any specific interface on its derivees. 88 */ 89 class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base, 90 public ::canvas::SpriteSurface 91 { 92 }; 93 94 typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base, 95 SpriteCanvasHelper, 96 ::osl::MutexGuard, 97 ::cppu::OWeakObject > SpriteCanvasBaseT; 98 99 /** Product of this component's factory. 100 101 The SpriteCanvas object combines the actual Window canvas with 102 the XGraphicDevice interface. This is because there's a 103 one-to-one relation between them, anyway, since each window 104 can have exactly one canvas and one associated 105 XGraphicDevice. And to avoid messing around with circular 106 references, this is implemented as one single object. 107 */ 108 class SpriteCanvas : public SpriteCanvasBaseT, public BitmapProvider 109 { 110 public: 111 SpriteCanvas( const ::com::sun::star::uno::Sequence< 112 ::com::sun::star::uno::Any >& aArguments, 113 const ::com::sun::star::uno::Reference< 114 ::com::sun::star::uno::XComponentContext >& rxContext ); 115 116 void initialize(); 117 118 /// Dispose all internal references 119 virtual void SAL_CALL disposing(); 120 121 // Forwarding the XComponent implementation to the 122 // cppu::ImplHelper templated base 123 // Classname Base doing refcounting Base implementing the XComponent interface 124 // | | | 125 // V V V 126 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase ); 127 128 // XBufferController (partial) 129 virtual ::sal_Bool SAL_CALL showBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 130 virtual ::sal_Bool SAL_CALL switchBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 131 132 // XSpriteCanvas (partial) 133 virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 134 135 // XServiceName 136 virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException); 137 138 /// Retrieve rendermodule object for this Canvas 139 const IDXRenderModuleSharedPtr& getRenderModule() const; 140 141 /// Get backbuffer for this canvas 142 const DXSurfaceBitmapSharedPtr& getBackBuffer() const; 143 144 // BitmapProvider 145 virtual IBitmapSharedPtr getBitmap() const; 146 147 private: 148 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > maArguments; 149 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext; 150 }; 151 152 typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef; 153 } 154 155 #endif 156