Update ooo320-m1
[ooovba.git] / canvas / source / cairo / cairo_canvascustomsprite.hxx
blob4e507c82f04236662b3d6f32f43f4d7593a5b17d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cairo_canvascustomsprite.hxx,v $
10 * $Revision: 1.4 $
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 _CAIROCANVAS_CANVASCUSTOMSPRITE_HXX
32 #define _CAIROCANVAS_CANVASCUSTOMSPRITE_HXX
34 #include <cppuhelper/compbase4.hxx>
35 #include <comphelper/uno3.hxx>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
38 #include <com/sun/star/lang/XComponent.hpp>
39 #include <com/sun/star/rendering/XCustomSprite.hpp>
40 #include <com/sun/star/rendering/XIntegerBitmap.hpp>
41 #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
43 #include <basegfx/point/b2dpoint.hxx>
44 #include <basegfx/vector/b2isize.hxx>
45 #include <basegfx/matrix/b2dhommatrix.hxx>
47 #include <canvas/base/basemutexhelper.hxx>
48 #include <canvas/base/canvascustomspritebase.hxx>
50 #include "cairo_sprite.hxx"
51 #include "cairo_cairo.hxx"
52 #include "cairo_canvashelper.hxx"
53 #include "cairo_repainttarget.hxx"
54 #include "cairo_spritehelper.hxx"
55 #include "cairo_spritecanvas.hxx"
58 namespace cairocanvas
60 typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XCustomSprite,
61 ::com::sun::star::rendering::XBitmapCanvas,
62 ::com::sun::star::rendering::XIntegerBitmap,
63 ::com::sun::star::lang::XServiceInfo > CanvasCustomSpriteBase_Base;
64 /** Mixin Sprite
66 Have to mixin the Sprite interface before deriving from
67 ::canvas::CanvasCustomSpriteBase, as this template should
68 already implement some of those interface methods.
70 The reason why this appears kinda convoluted is the fact that
71 we cannot specify non-IDL types as WeakComponentImplHelperN
72 template args, and furthermore, don't want to derive
73 ::canvas::CanvasCustomSpriteBase directly from
74 ::canvas::Sprite (because derivees of
75 ::canvas::CanvasCustomSpriteBase have to explicitely forward
76 the XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
77 anyway). Basically, ::canvas::CanvasCustomSpriteBase should
78 remain a base class that provides implementation, not to
79 enforce any specific interface on its derivees.
81 class CanvasCustomSpriteSpriteBase_Base : public ::canvas::BaseMutexHelper< CanvasCustomSpriteBase_Base >,
82 public Sprite,
83 public SurfaceProvider
87 typedef ::canvas::CanvasCustomSpriteBase< CanvasCustomSpriteSpriteBase_Base,
88 SpriteHelper,
89 CanvasHelper,
90 ::osl::MutexGuard,
91 ::cppu::OWeakObject > CanvasCustomSpriteBaseT;
93 /* Definition of CanvasCustomSprite class */
95 class CanvasCustomSprite : public CanvasCustomSpriteBaseT,
96 public RepaintTarget
98 public:
99 /** Create a custom sprite
101 @param rSpriteSize
102 Size of the sprite in pixel
104 @param rRefDevice
105 Associated output device
107 @param rSpriteCanvas
108 Target canvas
110 @param rDevice
111 Target DX device
113 CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& rSpriteSize,
114 const SpriteCanvasRef& rRefDevice );
116 virtual void SAL_CALL disposing();
118 // Forwarding the XComponent implementation to the
119 // cppu::ImplHelper templated base
120 // Classname Base doing refcount Base implementing the XComponent interface
121 // | | |
122 // V V V
123 DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSpriteBase_Base, ::cppu::WeakComponentImplHelperBase );
125 // XServiceInfo
126 virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
127 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
128 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( ::com::sun::star::uno::RuntimeException );
130 // Sprite
131 virtual void redraw( const ::cairo::CairoSharedPtr& pCairo,
132 bool bBufferedUpdate ) const;
133 virtual void redraw( const ::cairo::CairoSharedPtr& pCairo,
134 const ::basegfx::B2DPoint& rOrigOutputPos,
135 bool bBufferedUpdate ) const;
137 // RepaintTarget
138 virtual bool repaint( const ::cairo::SurfaceSharedPtr& pSurface,
139 const ::com::sun::star::rendering::ViewState& viewState,
140 const ::com::sun::star::rendering::RenderState& renderState );
142 // SurfaceProvider
143 virtual SurfaceSharedPtr getSurface();
144 virtual SurfaceSharedPtr createSurface( const ::basegfx::B2ISize& rSize, Content aContent = CAIRO_CONTENT_COLOR_ALPHA );
145 virtual SurfaceSharedPtr createSurface( ::Bitmap& rBitmap );
146 virtual SurfaceSharedPtr changeSurface( bool bHasAlpha, bool bCopyContent );
147 virtual OutputDevice* getOutputDevice();
149 private:
150 /** MUST hold here, too, since CanvasHelper only contains a
151 raw pointer (without refcounting)
153 SpriteCanvasRef mpSpriteCanvas;
154 ::cairo::SurfaceSharedPtr mpBufferSurface;
155 ::basegfx::B2ISize maSize;
159 #endif /* _CAIROCANVAS_CANVASCUSTOMSPRITE_HXX */