1*b1cdbd2cSJim Jagielski /************************************************************** 2*b1cdbd2cSJim Jagielski * 3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one 4*b1cdbd2cSJim Jagielski * or more contributor license agreements. See the NOTICE file 5*b1cdbd2cSJim Jagielski * distributed with this work for additional information 6*b1cdbd2cSJim Jagielski * regarding copyright ownership. The ASF licenses this file 7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the 8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance 9*b1cdbd2cSJim Jagielski * with the License. You may obtain a copy of the License at 10*b1cdbd2cSJim Jagielski * 11*b1cdbd2cSJim Jagielski * http://www.apache.org/licenses/LICENSE-2.0 12*b1cdbd2cSJim Jagielski * 13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing, 14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an 15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b1cdbd2cSJim Jagielski * KIND, either express or implied. See the License for the 17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations 18*b1cdbd2cSJim Jagielski * under the License. 19*b1cdbd2cSJim Jagielski * 20*b1cdbd2cSJim Jagielski *************************************************************/ 21*b1cdbd2cSJim Jagielski 22*b1cdbd2cSJim Jagielski 23*b1cdbd2cSJim Jagielski 24*b1cdbd2cSJim Jagielski #ifndef _NULLCANVAS_SPRITECANVAS_HXX_ 25*b1cdbd2cSJim Jagielski #define _NULLCANVAS_SPRITECANVAS_HXX_ 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski #include <rtl/ref.hxx> 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski #include <com/sun/star/uno/XComponentContext.hpp> 30*b1cdbd2cSJim Jagielski #include <com/sun/star/beans/XPropertySet.hpp> 31*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XServiceName.hpp> 32*b1cdbd2cSJim Jagielski #include <com/sun/star/awt/XWindowListener.hpp> 33*b1cdbd2cSJim Jagielski #include <com/sun/star/rendering/XSpriteCanvas.hpp> 34*b1cdbd2cSJim Jagielski #include <com/sun/star/rendering/XIntegerBitmap.hpp> 35*b1cdbd2cSJim Jagielski #include <com/sun/star/rendering/XGraphicDevice.hpp> 36*b1cdbd2cSJim Jagielski #include <com/sun/star/rendering/XBufferController.hpp> 37*b1cdbd2cSJim Jagielski #include <com/sun/star/lang/XMultiServiceFactory.hpp> 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski #include <cppuhelper/compbase8.hxx> 40*b1cdbd2cSJim Jagielski #include <comphelper/uno3.hxx> 41*b1cdbd2cSJim Jagielski 42*b1cdbd2cSJim Jagielski #include <canvas/base/spritecanvasbase.hxx> 43*b1cdbd2cSJim Jagielski #include <canvas/base/basemutexhelper.hxx> 44*b1cdbd2cSJim Jagielski #include <canvas/base/bufferedgraphicdevicebase.hxx> 45*b1cdbd2cSJim Jagielski 46*b1cdbd2cSJim Jagielski #include "null_spritecanvashelper.hxx" 47*b1cdbd2cSJim Jagielski #include "null_devicehelper.hxx" 48*b1cdbd2cSJim Jagielski #include "null_usagecounter.hxx" 49*b1cdbd2cSJim Jagielski 50*b1cdbd2cSJim Jagielski 51*b1cdbd2cSJim Jagielski namespace nullcanvas 52*b1cdbd2cSJim Jagielski { 53*b1cdbd2cSJim Jagielski typedef ::cppu::WeakComponentImplHelper8< ::com::sun::star::rendering::XSpriteCanvas, 54*b1cdbd2cSJim Jagielski ::com::sun::star::rendering::XIntegerBitmap, 55*b1cdbd2cSJim Jagielski ::com::sun::star::rendering::XGraphicDevice, 56*b1cdbd2cSJim Jagielski ::com::sun::star::lang::XMultiServiceFactory, 57*b1cdbd2cSJim Jagielski ::com::sun::star::rendering::XBufferController, 58*b1cdbd2cSJim Jagielski ::com::sun::star::awt::XWindowListener, 59*b1cdbd2cSJim Jagielski ::com::sun::star::beans::XPropertySet, 60*b1cdbd2cSJim Jagielski ::com::sun::star::lang::XServiceName > WindowGraphicDeviceBase_Base; 61*b1cdbd2cSJim Jagielski typedef ::canvas::BufferedGraphicDeviceBase< ::canvas::BaseMutexHelper< WindowGraphicDeviceBase_Base >, 62*b1cdbd2cSJim Jagielski DeviceHelper, 63*b1cdbd2cSJim Jagielski ::osl::MutexGuard, 64*b1cdbd2cSJim Jagielski ::cppu::OWeakObject > SpriteCanvasBase_Base; 65*b1cdbd2cSJim Jagielski /** Mixin SpriteSurface 66*b1cdbd2cSJim Jagielski 67*b1cdbd2cSJim Jagielski Have to mixin the SpriteSurface before deriving from 68*b1cdbd2cSJim Jagielski ::canvas::SpriteCanvasBase, as this template should already 69*b1cdbd2cSJim Jagielski implement some of those interface methods. 70*b1cdbd2cSJim Jagielski 71*b1cdbd2cSJim Jagielski The reason why this appears kinda convoluted is the fact that 72*b1cdbd2cSJim Jagielski we cannot specify non-IDL types as WeakComponentImplHelperN 73*b1cdbd2cSJim Jagielski template args, and furthermore, don't want to derive 74*b1cdbd2cSJim Jagielski ::canvas::SpriteCanvasBase directly from 75*b1cdbd2cSJim Jagielski ::canvas::SpriteSurface (because derivees of 76*b1cdbd2cSJim Jagielski ::canvas::SpriteCanvasBase have to explicitely forward the 77*b1cdbd2cSJim Jagielski XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS) 78*b1cdbd2cSJim Jagielski anyway). Basically, ::canvas::CanvasCustomSpriteBase should 79*b1cdbd2cSJim Jagielski remain a base class that provides implementation, not to 80*b1cdbd2cSJim Jagielski enforce any specific interface on its derivees. 81*b1cdbd2cSJim Jagielski */ 82*b1cdbd2cSJim Jagielski class SpriteCanvasBaseSpriteSurface_Base : public SpriteCanvasBase_Base, 83*b1cdbd2cSJim Jagielski public ::canvas::SpriteSurface 84*b1cdbd2cSJim Jagielski { 85*b1cdbd2cSJim Jagielski }; 86*b1cdbd2cSJim Jagielski 87*b1cdbd2cSJim Jagielski typedef ::canvas::SpriteCanvasBase< SpriteCanvasBaseSpriteSurface_Base, 88*b1cdbd2cSJim Jagielski SpriteCanvasHelper, 89*b1cdbd2cSJim Jagielski ::osl::MutexGuard, 90*b1cdbd2cSJim Jagielski ::cppu::OWeakObject > SpriteCanvasBaseT; 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski /** Product of this component's factory. 93*b1cdbd2cSJim Jagielski 94*b1cdbd2cSJim Jagielski The SpriteCanvas object combines the actual Window canvas with 95*b1cdbd2cSJim Jagielski the XGraphicDevice interface. This is because there's a 96*b1cdbd2cSJim Jagielski one-to-one relation between them, anyway, since each window 97*b1cdbd2cSJim Jagielski can have exactly one canvas and one associated 98*b1cdbd2cSJim Jagielski XGraphicDevice. And to avoid messing around with circular 99*b1cdbd2cSJim Jagielski references, this is implemented as one single object. 100*b1cdbd2cSJim Jagielski */ 101*b1cdbd2cSJim Jagielski class SpriteCanvas : public SpriteCanvasBaseT, 102*b1cdbd2cSJim Jagielski private UsageCounter< SpriteCanvas > 103*b1cdbd2cSJim Jagielski { 104*b1cdbd2cSJim Jagielski public: 105*b1cdbd2cSJim Jagielski SpriteCanvas( const ::com::sun::star::uno::Sequence< 106*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Any >& aArguments, 107*b1cdbd2cSJim Jagielski const ::com::sun::star::uno::Reference< 108*b1cdbd2cSJim Jagielski ::com::sun::star::uno::XComponentContext >& rxContext ); 109*b1cdbd2cSJim Jagielski 110*b1cdbd2cSJim Jagielski void initialize(); 111*b1cdbd2cSJim Jagielski 112*b1cdbd2cSJim Jagielski #if defined __SUNPRO_CC 113*b1cdbd2cSJim Jagielski using SpriteCanvasBaseT::disposing; 114*b1cdbd2cSJim Jagielski #endif 115*b1cdbd2cSJim Jagielski 116*b1cdbd2cSJim Jagielski /// Dispose all internal references 117*b1cdbd2cSJim Jagielski virtual void SAL_CALL disposing(); 118*b1cdbd2cSJim Jagielski 119*b1cdbd2cSJim Jagielski // Forwarding the XComponent implementation to the 120*b1cdbd2cSJim Jagielski // cppu::ImplHelper templated base 121*b1cdbd2cSJim Jagielski // Classname Base doing refcounting Base implementing the XComponent interface 122*b1cdbd2cSJim Jagielski // | | | 123*b1cdbd2cSJim Jagielski // V V V 124*b1cdbd2cSJim Jagielski DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( SpriteCanvas, WindowGraphicDeviceBase_Base, ::cppu::WeakComponentImplHelperBase ); 125*b1cdbd2cSJim Jagielski 126*b1cdbd2cSJim Jagielski // XBufferController (partial) 127*b1cdbd2cSJim Jagielski virtual ::sal_Bool SAL_CALL showBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 128*b1cdbd2cSJim Jagielski virtual ::sal_Bool SAL_CALL switchBuffer( ::sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 129*b1cdbd2cSJim Jagielski 130*b1cdbd2cSJim Jagielski // XSpriteCanvas (partial) 131*b1cdbd2cSJim Jagielski virtual sal_Bool SAL_CALL updateScreen( sal_Bool bUpdateAll ) throw (::com::sun::star::uno::RuntimeException); 132*b1cdbd2cSJim Jagielski 133*b1cdbd2cSJim Jagielski // XServiceName 134*b1cdbd2cSJim Jagielski virtual ::rtl::OUString SAL_CALL getServiceName( ) throw (::com::sun::star::uno::RuntimeException); 135*b1cdbd2cSJim Jagielski 136*b1cdbd2cSJim Jagielski private: 137*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > maArguments; 138*b1cdbd2cSJim Jagielski ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxComponentContext; 139*b1cdbd2cSJim Jagielski }; 140*b1cdbd2cSJim Jagielski 141*b1cdbd2cSJim Jagielski typedef ::rtl::Reference< SpriteCanvas > SpriteCanvasRef; 142*b1cdbd2cSJim Jagielski typedef ::rtl::Reference< SpriteCanvas > DeviceRef; 143*b1cdbd2cSJim Jagielski } 144*b1cdbd2cSJim Jagielski 145*b1cdbd2cSJim Jagielski #endif 146