merge the formfield patch from ooo-build
[ooovba.git] / avmedia / source / framework / soundhandler.hxx
blob8aa6780099e53f73f36f7935a77c8236b5a63e7b
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: soundhandler.hxx,v $
10 * $Revision: 1.3 $
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 __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
32 #define __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_
34 //_________________________________________________________________________________________________________________
35 // interface includes
36 //_________________________________________________________________________________________________________________
38 #include <com/sun/star/lang/XTypeProvider.hpp>
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/frame/XNotifyingDispatch.hpp>
41 #include <com/sun/star/frame/XStatusListener.hpp>
42 #include <com/sun/star/frame/XFrame.hpp>
43 #include <com/sun/star/document/XExtendedFilterDetection.hpp>
44 #include <com/sun/star/media/XPlayer.hpp>
45 #include <com/sun/star/beans/PropertyValue.hpp>
46 #include <com/sun/star/util/URL.hpp>
48 #include <com/sun/star/lang/XServiceInfo.hpp>
49 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
51 //_________________________________________________________________________________________________________________
52 // other includes
53 //_________________________________________________________________________________________________________________
54 #include <cppuhelper/weak.hxx>
56 #include <vcl/timer.hxx>
57 #include <tools/link.hxx>
58 #include <avmedia/mediawindow.hxx>
59 #include <vos/mutex.hxx>
61 namespace css = ::com::sun::star;
63 //_________________________________________________________________________________________________________________
64 // namespace
65 //_________________________________________________________________________________________________________________
67 namespace avmedia{
69 //_________________________________________________________________________________________________________________
70 // exported const
71 //_________________________________________________________________________________________________________________
73 //_________________________________________________________________________________________________________________
74 // exported definitions
75 //_________________________________________________________________________________________________________________
77 struct ThreadHelpBase
79 public:
80 mutable ::vos::OMutex m_aLock;
83 /*-************************************************************************************************************//**
84 @short handler to detect and play sounds ("wav" and "au" only!)
85 @descr Register this implementation as a content handler to detect and/or play wav- and au-sounds.
86 It doesn't depend from the target platform. But one instance of this class
87 can play one sound at the same time only. Means every new dispatch request will stop the
88 might still running one. So we support one operation/one URL/one listener at the same time
89 only.
91 @devstatus ready
92 @threadsafe yes
93 *//*-*************************************************************************************************************/
94 class SoundHandler : // interfaces
95 public css::lang::XTypeProvider
96 , public css::lang::XServiceInfo
97 , public css::frame::XNotifyingDispatch // => XDispatch
98 , public css::document::XExtendedFilterDetection
99 // baseclasses
100 // Order is neccessary for right initialization!
101 , private ThreadHelpBase
102 , public ::cppu::OWeakObject
104 //-------------------------------------------------------------------------------------------------------------
105 // public methods
106 //-------------------------------------------------------------------------------------------------------------
107 public:
109 //---------------------------------------------------------------------------------------------------------
110 // constructor / destructor
111 //---------------------------------------------------------------------------------------------------------
112 SoundHandler( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
113 virtual ~SoundHandler( );
115 //---------------------------------------------------------------------------------------------------------
116 // XInterface, XTypeProvider, XServiceInfo
117 //---------------------------------------------------------------------------------------------------------
118 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) throw( css::uno::RuntimeException );
119 virtual void SAL_CALL acquire() throw();
120 virtual void SAL_CALL release() throw();
121 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes () throw( css::uno::RuntimeException );
122 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw( css::uno::RuntimeException );
125 /* interface XServiceInfo */
126 virtual ::rtl::OUString SAL_CALL getImplementationName ( ) throw( css::uno::RuntimeException );
127 virtual sal_Bool SAL_CALL supportsService ( const ::rtl::OUString& sServiceName ) throw( css::uno::RuntimeException );
128 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames ( ) throw( css::uno::RuntimeException );
129 /* Helper for XServiceInfo */
130 static css::uno::Sequence< ::rtl::OUString > SAL_CALL impl_getStaticSupportedServiceNames( );
131 static ::rtl::OUString SAL_CALL impl_getStaticImplementationName ( );
132 /* Helper for registry */
133 static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::Exception );
134 static css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
135 /* Helper for initialization of service by using own reference! */
136 virtual void SAL_CALL impl_initService ( );
138 //---------------------------------------------------------------------------------------------------------
139 // XNotifyingDispatch
140 //---------------------------------------------------------------------------------------------------------
141 virtual void SAL_CALL dispatchWithNotification(const css::util::URL& aURL ,
142 const css::uno::Sequence< css::beans::PropertyValue >& lArguments,
143 const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) throw(css::uno::RuntimeException);
145 //---------------------------------------------------------------------------------------------------------
146 // XDispatch
147 //---------------------------------------------------------------------------------------------------------
148 virtual void SAL_CALL dispatch ( const css::util::URL& aURL ,
149 const css::uno::Sequence< css::beans::PropertyValue >& lArguments ) throw( css::uno::RuntimeException );
150 // not supported !
151 virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ ,
152 const css::util::URL& /*aURL*/ ) throw( css::uno::RuntimeException ) {};
153 virtual void SAL_CALL removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& /*xListener*/ ,
154 const css::util::URL& /*aURL*/ ) throw( css::uno::RuntimeException ) {};
156 //---------------------------------------------------------------------------------------------------------
157 // XExtendedFilterDetection
158 //---------------------------------------------------------------------------------------------------------
159 virtual ::rtl::OUString SAL_CALL detect ( css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ) throw( css::uno::RuntimeException );
161 //-------------------------------------------------------------------------------------------------------------
162 // protected methods
163 //-------------------------------------------------------------------------------------------------------------
164 protected:
166 //-------------------------------------------------------------------------------------------------------------
167 // private methods
168 //-------------------------------------------------------------------------------------------------------------
169 private:
170 DECL_LINK( implts_PlayerNotify, void* );
172 //-------------------------------------------------------------------------------------------------------------
173 // variables
174 // (should be private everyway!)
175 //-------------------------------------------------------------------------------------------------------------
176 private:
178 bool m_bError;
179 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// global uno service factory to create new services
180 css::uno::Reference< css::uno::XInterface > m_xSelfHold ; /// we must protect us against dieing during async(!) dispatch() call!
181 css::uno::Reference< css::media::XPlayer > m_xPlayer ; /// uses avmedia player to play sounds ...
183 css::uno::Reference< css::frame::XDispatchResultListener > m_xListener ;
184 Timer m_aUpdateTimer;
186 }; // class SoundHandler
188 } // namespace avmedia
190 #endif // #ifndef __FRAMEWORK_HANDLER_SOUNDHANDLER_HXX_