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