191c99ff4SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 391c99ff4SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 491c99ff4SAndrew Rist * or more contributor license agreements. See the NOTICE file 591c99ff4SAndrew Rist * distributed with this work for additional information 691c99ff4SAndrew Rist * regarding copyright ownership. The ASF licenses this file 791c99ff4SAndrew Rist * to you under the Apache License, Version 2.0 (the 891c99ff4SAndrew Rist * "License"); you may not use this file except in compliance 991c99ff4SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 1191c99ff4SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 1391c99ff4SAndrew Rist * Unless required by applicable law or agreed to in writing, 1491c99ff4SAndrew Rist * software distributed under the License is distributed on an 1591c99ff4SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1691c99ff4SAndrew Rist * KIND, either express or implied. See the License for the 1791c99ff4SAndrew Rist * specific language governing permissions and limitations 1891c99ff4SAndrew Rist * under the License. 19cdf0e10cSrcweir * 2091c99ff4SAndrew Rist *************************************************************/ 2191c99ff4SAndrew Rist 2291c99ff4SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef _VCLCANVAS_CANVASCUSTOMSPRITE_HXX 25cdf0e10cSrcweir #define _VCLCANVAS_CANVASCUSTOMSPRITE_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx> 28cdf0e10cSrcweir #include <comphelper/uno3.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 31cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 32cdf0e10cSrcweir #include <com/sun/star/rendering/XCustomSprite.hpp> 33cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp> 34cdf0e10cSrcweir #include <com/sun/star/rendering/XPolyPolygon2D.hpp> 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include <vcl/virdev.hxx> 37cdf0e10cSrcweir 38cdf0e10cSrcweir #include <canvas/vclwrapper.hxx> 39cdf0e10cSrcweir #include <canvas/base/basemutexhelper.hxx> 40cdf0e10cSrcweir #include <canvas/base/spritesurface.hxx> 41cdf0e10cSrcweir #include <canvas/base/canvascustomspritebase.hxx> 42cdf0e10cSrcweir 43cdf0e10cSrcweir #include "sprite.hxx" 44cdf0e10cSrcweir #include "canvashelper.hxx" 45cdf0e10cSrcweir #include "spritehelper.hxx" 46cdf0e10cSrcweir #include "backbuffer.hxx" 47cdf0e10cSrcweir #include "impltools.hxx" 48cdf0e10cSrcweir #include "spritecanvas.hxx" 49cdf0e10cSrcweir #include "repainttarget.hxx" 50cdf0e10cSrcweir 51cdf0e10cSrcweir 52cdf0e10cSrcweir namespace vclcanvas 53cdf0e10cSrcweir { 54cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XCustomSprite, 55cdf0e10cSrcweir ::com::sun::star::rendering::XBitmapCanvas, 56cdf0e10cSrcweir ::com::sun::star::rendering::XIntegerBitmap, 57cdf0e10cSrcweir ::com::sun::star::lang::XServiceInfo > CanvasCustomSpriteBase_Base; 58cdf0e10cSrcweir /** Mixin Sprite 59cdf0e10cSrcweir 60cdf0e10cSrcweir Have to mixin the Sprite interface before deriving from 61cdf0e10cSrcweir ::canvas::CanvasCustomSpriteBase, as this template should 62cdf0e10cSrcweir already implement some of those interface methods. 63cdf0e10cSrcweir 64cdf0e10cSrcweir The reason why this appears kinda convoluted is the fact that 65cdf0e10cSrcweir we cannot specify non-IDL types as WeakComponentImplHelperN 66cdf0e10cSrcweir template args, and furthermore, don't want to derive 67cdf0e10cSrcweir ::canvas::CanvasCustomSpriteBase directly from 68cdf0e10cSrcweir ::canvas::Sprite (because derivees of 69*56b8eddcSmseidel ::canvas::CanvasCustomSpriteBase have to explicitly forward 70cdf0e10cSrcweir the XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS) 71cdf0e10cSrcweir anyway). Basically, ::canvas::CanvasCustomSpriteBase should 72cdf0e10cSrcweir remain a base class that provides implementation, not to 73cdf0e10cSrcweir enforce any specific interface on its derivees. 74cdf0e10cSrcweir */ 75cdf0e10cSrcweir class CanvasCustomSpriteSpriteBase_Base : public ::canvas::BaseMutexHelper< CanvasCustomSpriteBase_Base >, 76cdf0e10cSrcweir public Sprite 77cdf0e10cSrcweir { 78cdf0e10cSrcweir }; 79cdf0e10cSrcweir 80cdf0e10cSrcweir typedef ::canvas::CanvasCustomSpriteBase< CanvasCustomSpriteSpriteBase_Base, 81cdf0e10cSrcweir SpriteHelper, 82cdf0e10cSrcweir CanvasHelper, 83cdf0e10cSrcweir tools::LocalGuard, 84cdf0e10cSrcweir ::cppu::OWeakObject > CanvasCustomSpriteBaseT; 85cdf0e10cSrcweir 86cdf0e10cSrcweir /* Definition of CanvasCustomSprite class */ 87cdf0e10cSrcweir 88cdf0e10cSrcweir class CanvasCustomSprite : public CanvasCustomSpriteBaseT, 89cdf0e10cSrcweir public RepaintTarget 90cdf0e10cSrcweir { 91cdf0e10cSrcweir public: 92cdf0e10cSrcweir CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize, 93cdf0e10cSrcweir ::com::sun::star::rendering::XGraphicDevice& rDevice, 94cdf0e10cSrcweir const ::canvas::SpriteSurface::Reference& rOwningSpriteCanvas, 95cdf0e10cSrcweir const OutDevProviderSharedPtr& rOutDevProvider, 96cdf0e10cSrcweir bool bShowSpriteBounds ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir virtual void SAL_CALL disposing(); 99cdf0e10cSrcweir 100cdf0e10cSrcweir // Forwarding the XComponent implementation to the 101cdf0e10cSrcweir // cppu::ImplHelper templated base 102cdf0e10cSrcweir // Classname Base doing refcount Base implementing the XComponent interface 103cdf0e10cSrcweir // | | | 104cdf0e10cSrcweir // V V V 105cdf0e10cSrcweir DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSpriteBase_Base, ::cppu::WeakComponentImplHelperBase ); 106cdf0e10cSrcweir 107cdf0e10cSrcweir // XServiceInfo 108cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException ); 109cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException ); 110cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException ); 111cdf0e10cSrcweir 112cdf0e10cSrcweir // Sprite 113cdf0e10cSrcweir virtual void redraw( OutputDevice& rOutDev, 114cdf0e10cSrcweir bool bBufferedUpdate ) const; 115cdf0e10cSrcweir virtual void redraw( OutputDevice& rOutDev, 116cdf0e10cSrcweir const ::basegfx::B2DPoint& rPos, 117cdf0e10cSrcweir bool bBufferedUpdate ) const; 118cdf0e10cSrcweir 119cdf0e10cSrcweir // RepaintTarget 120cdf0e10cSrcweir virtual bool repaint( const GraphicObjectSharedPtr& rGrf, 121cdf0e10cSrcweir const ::com::sun::star::rendering::ViewState& viewState, 122cdf0e10cSrcweir const ::com::sun::star::rendering::RenderState& renderState, 123cdf0e10cSrcweir const ::Point& rPt, 124cdf0e10cSrcweir const ::Size& rSz, 125cdf0e10cSrcweir const GraphicAttr& rAttr ) const; 126cdf0e10cSrcweir }; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir #endif /* _VCLCANVAS_CANVASCUSTOMSPRITE_HXX */ 130