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
1091c99ff4SAndrew Rist  *
1191c99ff4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1291c99ff4SAndrew Rist  *
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.
1991c99ff4SAndrew Rist  *
2091c99ff4SAndrew Rist  *************************************************************/
2191c99ff4SAndrew Rist 
2291c99ff4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _NULLCANVAS_CANVASCUSTOMSPRITE_HXX
25cdf0e10cSrcweir #define _NULLCANVAS_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 <basegfx/point/b2dpoint.hxx>
37cdf0e10cSrcweir #include <basegfx/vector/b2isize.hxx>
38cdf0e10cSrcweir #include <basegfx/matrix/b2dhommatrix.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <canvas/base/basemutexhelper.hxx>
41cdf0e10cSrcweir #include <canvas/base/canvascustomspritebase.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include "sprite.hxx"
44cdf0e10cSrcweir #include "null_canvashelper.hxx"
45cdf0e10cSrcweir #include "null_spritehelper.hxx"
46cdf0e10cSrcweir #include "null_spritecanvas.hxx"
47cdf0e10cSrcweir #include "null_usagecounter.hxx"
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 
50cdf0e10cSrcweir namespace nullcanvas
51cdf0e10cSrcweir {
52cdf0e10cSrcweir     typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::rendering::XCustomSprite,
53cdf0e10cSrcweir 									 		  ::com::sun::star::rendering::XBitmapCanvas,
54cdf0e10cSrcweir 											  ::com::sun::star::rendering::XIntegerBitmap,
55cdf0e10cSrcweir                          			 		  ::com::sun::star::lang::XServiceInfo >	CanvasCustomSpriteBase_Base;
56cdf0e10cSrcweir 	/** Mixin Sprite
57cdf0e10cSrcweir 
58cdf0e10cSrcweir     	Have to mixin the Sprite interface before deriving from
59cdf0e10cSrcweir     	::canvas::CanvasCustomSpriteBase, as this template should
60cdf0e10cSrcweir     	already implement some of those interface methods.
61cdf0e10cSrcweir 
62cdf0e10cSrcweir         The reason why this appears kinda convoluted is the fact that
63cdf0e10cSrcweir         we cannot specify non-IDL types as WeakComponentImplHelperN
64cdf0e10cSrcweir         template args, and furthermore, don't want to derive
65cdf0e10cSrcweir         ::canvas::CanvasCustomSpriteBase directly from
66cdf0e10cSrcweir         ::canvas::Sprite (because derivees of
67*6d53c851Smseidel         ::canvas::CanvasCustomSpriteBase have to explicitly forward
68cdf0e10cSrcweir         the XInterface methods (e.g. via DECLARE_UNO3_AGG_DEFAULTS)
69cdf0e10cSrcweir         anyway). Basically, ::canvas::CanvasCustomSpriteBase should
70cdf0e10cSrcweir         remain a base class that provides implementation, not to
71cdf0e10cSrcweir         enforce any specific interface on its derivees.
72cdf0e10cSrcweir      */
73cdf0e10cSrcweir 	class CanvasCustomSpriteSpriteBase_Base : public ::canvas::BaseMutexHelper< CanvasCustomSpriteBase_Base >,
74cdf0e10cSrcweir     									   	  public Sprite
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir     };
77cdf0e10cSrcweir 
78cdf0e10cSrcweir 	typedef ::canvas::CanvasCustomSpriteBase< CanvasCustomSpriteSpriteBase_Base,
79cdf0e10cSrcweir                                               SpriteHelper,
80cdf0e10cSrcweir                                               CanvasHelper,
81cdf0e10cSrcweir                                               ::osl::MutexGuard,
82cdf0e10cSrcweir                                               ::cppu::OWeakObject > 					CanvasCustomSpriteBaseT;
83cdf0e10cSrcweir 
84cdf0e10cSrcweir 	/* Definition of CanvasCustomSprite class */
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     class CanvasCustomSprite : public CanvasCustomSpriteBaseT,
87cdf0e10cSrcweir                                private UsageCounter< CanvasCustomSprite >
88cdf0e10cSrcweir     {
89cdf0e10cSrcweir     public:
90cdf0e10cSrcweir         /** Create a custom sprite
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 			@param rSpriteSize
93cdf0e10cSrcweir             Size of the sprite in pixel
94cdf0e10cSrcweir 
95cdf0e10cSrcweir             @param rRefDevice
96cdf0e10cSrcweir             Associated output device
97cdf0e10cSrcweir 
98cdf0e10cSrcweir             @param rSpriteCanvas
99cdf0e10cSrcweir             Target canvas
100cdf0e10cSrcweir 
101cdf0e10cSrcweir             @param rDevice
102cdf0e10cSrcweir             Target DX device
103cdf0e10cSrcweir          */
104cdf0e10cSrcweir         CanvasCustomSprite( const ::com::sun::star::geometry::RealSize2D& 	rSpriteSize,
105cdf0e10cSrcweir                             const SpriteCanvasRef&                          rRefDevice );
106cdf0e10cSrcweir 
107cdf0e10cSrcweir         virtual void SAL_CALL disposing();
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 		// Forwarding the XComponent implementation to the
110cdf0e10cSrcweir         // cppu::ImplHelper templated base
111cdf0e10cSrcweir         //                                    Classname           Base doing refcount          Base implementing the XComponent interface
112cdf0e10cSrcweir         //                                          |                    |                         |
113cdf0e10cSrcweir         //                                          V                    V                         V
114cdf0e10cSrcweir         DECLARE_UNO3_XCOMPONENT_AGG_DEFAULTS( CanvasCustomSprite, CanvasCustomSpriteBase_Base, ::cppu::WeakComponentImplHelperBase );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir         // XServiceInfo
117cdf0e10cSrcweir         virtual ::rtl::OUString SAL_CALL getImplementationName() throw( ::com::sun::star::uno::RuntimeException );
118cdf0e10cSrcweir         virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw( ::com::sun::star::uno::RuntimeException );
119cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()  throw( ::com::sun::star::uno::RuntimeException );
120cdf0e10cSrcweir 
121cdf0e10cSrcweir         // Sprite
122cdf0e10cSrcweir         virtual void redraw() const;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir     private:
125cdf0e10cSrcweir         /** MUST hold here, too, since CanvasHelper only contains a
126cdf0e10cSrcweir             raw pointer (without refcounting)
127cdf0e10cSrcweir         */
128cdf0e10cSrcweir         SpriteCanvasRef mpSpriteCanvas;
129cdf0e10cSrcweir     };
130cdf0e10cSrcweir }
131cdf0e10cSrcweir 
132cdf0e10cSrcweir #endif /* _NULLCANVAS_CANVASCUSTOMSPRITE_HXX */
133