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