1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _NULLCANVAS_CANVASCUSTOMSPRITE_HXX
29*cdf0e10cSrcweir #define _NULLCANVAS_CANVASCUSTOMSPRITE_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <cppuhelper/compbase4.hxx>
32*cdf0e10cSrcweir #include <comphelper/uno3.hxx>
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/rendering/XCustomSprite.hpp>
37*cdf0e10cSrcweir #include <com/sun/star/rendering/XIntegerBitmap.hpp>
38*cdf0e10cSrcweir #include <com/sun/star/rendering/XPolyPolygon2D.hpp>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <basegfx/point/b2dpoint.hxx>
41*cdf0e10cSrcweir #include <basegfx/vector/b2isize.hxx>
42*cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir #include <canvas/base/basemutexhelper.hxx>
45*cdf0e10cSrcweir #include <canvas/base/canvascustomspritebase.hxx>
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir #include "sprite.hxx"
48*cdf0e10cSrcweir #include "null_canvashelper.hxx"
49*cdf0e10cSrcweir #include "null_spritehelper.hxx"
50*cdf0e10cSrcweir #include "null_spritecanvas.hxx"
51*cdf0e10cSrcweir #include "null_usagecounter.hxx"
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir namespace nullcanvas
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XCustomSprite,
57*cdf0e10cSrcweir 									 		  ::com::sun::star::rendering::XBitmapCanvas,
58*cdf0e10cSrcweir 											  ::com::sun::star::rendering::XIntegerBitmap,
59*cdf0e10cSrcweir                          			 		  ::com::sun::star::lang::XServiceInfo >	CanvasCustomSpriteBase_Base;
60*cdf0e10cSrcweir 	/** Mixin Sprite
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir     	Have to mixin the Sprite interface before deriving from
63*cdf0e10cSrcweir     	::canvas::CanvasCustomSpriteBase, as this template should
64*cdf0e10cSrcweir     	already implement some of those interface methods.
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir         The reason why this appears kinda convoluted is the fact that
67*cdf0e10cSrcweir         we cannot specify non-IDL types as WeakComponentImplHelperN
68*cdf0e10cSrcweir         template args, and furthermore, don't want to derive
69*cdf0e10cSrcweir         ::canvas::CanvasCustomSpriteBase directly from
70*cdf0e10cSrcweir         ::canvas::Sprite (because derivees of
71*cdf0e10cSrcweir         ::canvas::CanvasCustomSpriteBase have to explicitely forward
72*cdf0e10cSrcweir         the XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
73*cdf0e10cSrcweir         anyway). Basically, ::canvas::CanvasCustomSpriteBase should
74*cdf0e10cSrcweir         remain a base class that provides implementation, not to
75*cdf0e10cSrcweir         enforce any specific interface on its derivees.
76*cdf0e10cSrcweir      */
77*cdf0e10cSrcweir 	class CanvasCustomSpriteSpriteBase_Base : public ::canvas::BaseMutexHelper< CanvasCustomSpriteBase_Base >,
78*cdf0e10cSrcweir     									   	  public Sprite
79*cdf0e10cSrcweir     {
80*cdf0e10cSrcweir     };
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir 	typedef ::canvas::CanvasCustomSpriteBase< CanvasCustomSpriteSpriteBase_Base,
83*cdf0e10cSrcweir                                               SpriteHelper,
84*cdf0e10cSrcweir                                               CanvasHelper,
85*cdf0e10cSrcweir                                               ::osl::MutexGuard,
86*cdf0e10cSrcweir                                               ::cppu::OWeakObject > 					CanvasCustomSpriteBaseT;
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir 	/* Definition of CanvasCustomSprite class */
89*cdf0e10cSrcweir 
90*cdf0e10cSrcweir     class CanvasCustomSprite : public CanvasCustomSpriteBaseT,
91*cdf0e10cSrcweir                                private UsageCounter< CanvasCustomSprite >
92*cdf0e10cSrcweir     {
93*cdf0e10cSrcweir     public:
94*cdf0e10cSrcweir         /** Create a custom sprite
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 			@param rSpriteSize
97*cdf0e10cSrcweir             Size of the sprite in pixel
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir             @param rRefDevice
100*cdf0e10cSrcweir             Associated output device
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir             @param rSpriteCanvas
103*cdf0e10cSrcweir             Target canvas
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir             @param rDevice
106*cdf0e10cSrcweir             Target DX device
107*cdf0e10cSrcweir          */
108*cdf0e10cSrcweir         CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& 	rSpriteSize,
109*cdf0e10cSrcweir                             const SpriteCanvasRef&                          rRefDevice );
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir         virtual void SAL_CALL disposing();
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 		// Forwarding the XComponent implementation to the
114*cdf0e10cSrcweir         // cppu::ImplHelper templated base
115*cdf0e10cSrcweir         //                                    Classname           Base doing refcount          Base implementing the XComponent interface
116*cdf0e10cSrcweir         //                                          |                    |                         |
117*cdf0e10cSrcweir         //                                          V                    V                         V
118*cdf0e10cSrcweir         DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSpriteBase_Base, ::cppu::WeakComponentImplHelperBase );
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir         // XServiceInfo
121*cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
122*cdf0e10cSrcweir         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
123*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()  throw( ::com::sun::star::uno::RuntimeException );
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir         // Sprite
126*cdf0e10cSrcweir         virtual void redraw() const;
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir     private:
129*cdf0e10cSrcweir         /** MUST hold here, too, since CanvasHelper only contains a
130*cdf0e10cSrcweir             raw pointer (without refcounting)
131*cdf0e10cSrcweir         */
132*cdf0e10cSrcweir         SpriteCanvasRef mpSpriteCanvas;
133*cdf0e10cSrcweir     };
134*cdf0e10cSrcweir }
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir #endif /* _NULLCANVAS_CANVASCUSTOMSPRITE_HXX */
137