1*2c696243SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2c696243SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2c696243SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2c696243SAndrew Rist  * distributed with this work for additional information
6*2c696243SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2c696243SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2c696243SAndrew Rist  * "License"); you may not use this file except in compliance
9*2c696243SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2c696243SAndrew Rist  *
11*2c696243SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2c696243SAndrew Rist  *
13*2c696243SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2c696243SAndrew Rist  * software distributed under the License is distributed on an
15*2c696243SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2c696243SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2c696243SAndrew Rist  * specific language governing permissions and limitations
18*2c696243SAndrew Rist  * under the License.
19*2c696243SAndrew Rist  *
20*2c696243SAndrew Rist  *************************************************************/
21*2c696243SAndrew Rist 
22*2c696243SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_scripting.hxx"
26cdf0e10cSrcweir #include "dlgevtatt.hxx"
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "dlgprov.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include <sfx2/sfx.hrc>
31cdf0e10cSrcweir #include <sfx2/app.hxx>
32cdf0e10cSrcweir #include <vcl/msgbox.hxx>
33cdf0e10cSrcweir #include <tools/diagnose_ex.h>
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <com/sun/star/awt/XControl.hpp>
36cdf0e10cSrcweir #include <com/sun/star/awt/XDialogEventHandler.hpp>
37cdf0e10cSrcweir #include <com/sun/star/awt/XContainerWindowEventHandler.hpp>
38cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
39cdf0e10cSrcweir #include <com/sun/star/script/ScriptEventDescriptor.hpp>
40cdf0e10cSrcweir #include <com/sun/star/script/XScriptEventsSupplier.hpp>
41cdf0e10cSrcweir #include <com/sun/star/script/provider/XScriptProvider.hpp>
42cdf0e10cSrcweir #include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
43cdf0e10cSrcweir #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
44cdf0e10cSrcweir #include <com/sun/star/script/vba/XVBACompatibility.hpp>
45cdf0e10cSrcweir #include <com/sun/star/lang/NoSuchMethodException.hpp>
46cdf0e10cSrcweir #include <com/sun/star/reflection/XIdlMethod.hpp>
47cdf0e10cSrcweir #include <com/sun/star/beans/MethodConcept.hpp>
48cdf0e10cSrcweir #include <com/sun/star/beans/XMaterialHolder.hpp>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir #include <ooo/vba/XVBAToOOEventDescGen.hpp>
51cdf0e10cSrcweir 
52cdf0e10cSrcweir using namespace ::com::sun::star;
53cdf0e10cSrcweir using namespace ::com::sun::star::awt;
54cdf0e10cSrcweir using namespace ::com::sun::star::beans;
55cdf0e10cSrcweir using namespace ::com::sun::star::lang;
56cdf0e10cSrcweir using namespace ::com::sun::star::script;
57cdf0e10cSrcweir using namespace ::com::sun::star::uno;
58cdf0e10cSrcweir using namespace ::com::sun::star::script;
59cdf0e10cSrcweir using namespace ::com::sun::star::reflection;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir 
62cdf0e10cSrcweir //.........................................................................
63cdf0e10cSrcweir namespace dlgprov
64cdf0e10cSrcweir {
65cdf0e10cSrcweir 
66cdf0e10cSrcweir   class DialogSFScriptListenerImpl : public DialogScriptListenerImpl
67cdf0e10cSrcweir     {
68cdf0e10cSrcweir         protected:
69cdf0e10cSrcweir         Reference< frame::XModel >  m_xModel;
70cdf0e10cSrcweir         virtual void firing_impl( const script::ScriptEvent& aScriptEvent, uno::Any* pRet );
71cdf0e10cSrcweir         public:
DialogSFScriptListenerImpl(const Reference<XComponentContext> & rxContext,const Reference<frame::XModel> & rxModel)72cdf0e10cSrcweir         DialogSFScriptListenerImpl( const Reference< XComponentContext >& rxContext, const Reference< frame::XModel >& rxModel ) : DialogScriptListenerImpl( rxContext ), m_xModel( rxModel ) {}
73cdf0e10cSrcweir     };
74cdf0e10cSrcweir 
75cdf0e10cSrcweir   class DialogLegacyScriptListenerImpl : public DialogSFScriptListenerImpl
76cdf0e10cSrcweir     {
77cdf0e10cSrcweir         protected:
78cdf0e10cSrcweir         virtual void firing_impl( const script::ScriptEvent& aScriptEvent, uno::Any* pRet );
79cdf0e10cSrcweir         public:
DialogLegacyScriptListenerImpl(const Reference<XComponentContext> & rxContext,const Reference<frame::XModel> & rxModel)80cdf0e10cSrcweir         DialogLegacyScriptListenerImpl( const Reference< XComponentContext >& rxContext, const Reference< frame::XModel >& rxModel ) : DialogSFScriptListenerImpl( rxContext, rxModel ){}
81cdf0e10cSrcweir     };
82cdf0e10cSrcweir 
83cdf0e10cSrcweir   class DialogUnoScriptListenerImpl : public DialogSFScriptListenerImpl
84cdf0e10cSrcweir     {
85cdf0e10cSrcweir 	Reference< awt::XControl > m_xControl;
86cdf0e10cSrcweir         Reference< XInterface >	m_xHandler;
87cdf0e10cSrcweir 	Reference< beans::XIntrospectionAccess > m_xIntrospectionAccess;
88cdf0e10cSrcweir 	bool m_bDialogProviderMode;
89cdf0e10cSrcweir 
90cdf0e10cSrcweir         virtual void firing_impl( const script::ScriptEvent& aScriptEvent, uno::Any* pRet );
91cdf0e10cSrcweir 
92cdf0e10cSrcweir     public:
93cdf0e10cSrcweir         DialogUnoScriptListenerImpl( const Reference< XComponentContext >& rxContext,
94cdf0e10cSrcweir             const Reference< frame::XModel >& rxModel,
95cdf0e10cSrcweir 			const Reference< awt::XControl >& rxControl,
96cdf0e10cSrcweir 			const Reference< XInterface >& rxHandler,
97cdf0e10cSrcweir 			const Reference< beans::XIntrospectionAccess >& rxIntrospectionAccess,
98cdf0e10cSrcweir 			bool bDialogProviderMode );		// false: ContainerWindowProvider mode
99cdf0e10cSrcweir 
100cdf0e10cSrcweir     };
101cdf0e10cSrcweir 
102cdf0e10cSrcweir   class DialogVBAScriptListenerImpl : public DialogScriptListenerImpl
103cdf0e10cSrcweir     {
104cdf0e10cSrcweir         protected:
105cdf0e10cSrcweir         rtl::OUString msDialogCodeName;
106cdf0e10cSrcweir         Reference<  script::XScriptListener > mxListener;
107cdf0e10cSrcweir         virtual void firing_impl( const script::ScriptEvent& aScriptEvent, uno::Any* pRet );
108cdf0e10cSrcweir         public:
109cdf0e10cSrcweir         DialogVBAScriptListenerImpl( const Reference< XComponentContext >& rxContext, const Reference< awt::XControl >& rxControl, const Reference< frame::XModel >& xModel );
110cdf0e10cSrcweir     };
111cdf0e10cSrcweir 
DialogVBAScriptListenerImpl(const Reference<XComponentContext> & rxContext,const Reference<awt::XControl> & rxControl,const Reference<frame::XModel> & xModel)112cdf0e10cSrcweir     DialogVBAScriptListenerImpl::DialogVBAScriptListenerImpl( const Reference< XComponentContext >& rxContext, const Reference< awt::XControl >& rxControl, const Reference< frame::XModel >& xModel ) : DialogScriptListenerImpl( rxContext )
113cdf0e10cSrcweir     {
114cdf0e10cSrcweir         Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
115cdf0e10cSrcweir         Sequence< Any > args(1);
116cdf0e10cSrcweir         if ( xSMgr.is() )
117cdf0e10cSrcweir         {
118cdf0e10cSrcweir             args[0] <<= xModel;
119cdf0e10cSrcweir             mxListener = Reference< XScriptListener >( xSMgr->createInstanceWithArgumentsAndContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.EventListener" ) ), args, m_xContext ), UNO_QUERY );
120cdf0e10cSrcweir         }
121cdf0e10cSrcweir         if ( rxControl.is() )
122cdf0e10cSrcweir         {
123cdf0e10cSrcweir             try
124cdf0e10cSrcweir             {
125cdf0e10cSrcweir                 Reference< XPropertySet > xProps( rxControl->getModel(), UNO_QUERY_THROW );
126cdf0e10cSrcweir                 xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= msDialogCodeName;
127cdf0e10cSrcweir                 xProps.set( mxListener, UNO_QUERY_THROW );
128cdf0e10cSrcweir                 xProps->setPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Model") ), args[ 0 ] );
129cdf0e10cSrcweir             }
130cdf0e10cSrcweir             catch( const Exception& )
131cdf0e10cSrcweir             {
132cdf0e10cSrcweir             	DBG_UNHANDLED_EXCEPTION();
133cdf0e10cSrcweir             }
134cdf0e10cSrcweir         }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir 
firing_impl(const script::ScriptEvent & aScriptEvent,uno::Any *)138cdf0e10cSrcweir     void DialogVBAScriptListenerImpl::firing_impl( const script::ScriptEvent& aScriptEvent, uno::Any* )
139cdf0e10cSrcweir     {
140cdf0e10cSrcweir         if ( aScriptEvent.ScriptType.equals( rtl::OUString::createFromAscii("VBAInterop") ) && mxListener.is() )
141cdf0e10cSrcweir         {
142cdf0e10cSrcweir             ScriptEvent aScriptEventCopy( aScriptEvent );
143cdf0e10cSrcweir             aScriptEventCopy.ScriptCode = msDialogCodeName;
144cdf0e10cSrcweir             try
145cdf0e10cSrcweir             {
146cdf0e10cSrcweir                 mxListener->firing( aScriptEventCopy );
147cdf0e10cSrcweir             }
148cdf0e10cSrcweir             catch( const Exception& )
149cdf0e10cSrcweir             {
150cdf0e10cSrcweir             	DBG_UNHANDLED_EXCEPTION();
151cdf0e10cSrcweir             }
152cdf0e10cSrcweir         }
153cdf0e10cSrcweir     }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir //.........................................................................
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     // =============================================================================
158cdf0e10cSrcweir     // DialogEventsAttacherImpl
159cdf0e10cSrcweir     // =============================================================================
160cdf0e10cSrcweir 
DialogEventsAttacherImpl(const Reference<XComponentContext> & rxContext,const Reference<frame::XModel> & rxModel,const Reference<awt::XControl> & rxControl,const Reference<XInterface> & rxHandler,const Reference<beans::XIntrospectionAccess> & rxIntrospect,bool bProviderMode,const Reference<script::XScriptListener> & rxRTLListener)161cdf0e10cSrcweir     DialogEventsAttacherImpl::DialogEventsAttacherImpl( const Reference< XComponentContext >& rxContext, const Reference< frame::XModel >& rxModel, const Reference< awt::XControl >& rxControl, const Reference< XInterface >& rxHandler, const Reference< beans::XIntrospectionAccess >& rxIntrospect, bool bProviderMode, const Reference< script::XScriptListener >& rxRTLListener   )
162cdf0e10cSrcweir         :mbUseFakeVBAEvents( false ), m_xContext( rxContext )
163cdf0e10cSrcweir     {
164cdf0e10cSrcweir         // key listeners by protocol when ScriptType = 'Script'
165cdf0e10cSrcweir         // otherwise key is the ScriptType e.g. StarBasic
166cdf0e10cSrcweir         if ( rxRTLListener.is() ) // set up handler for RTL_BASIC
167cdf0e10cSrcweir             listernersForTypes[ rtl::OUString::createFromAscii("StarBasic") ] = rxRTLListener;
168cdf0e10cSrcweir         else
169cdf0e10cSrcweir             listernersForTypes[ rtl::OUString::createFromAscii("StarBasic") ] = new DialogLegacyScriptListenerImpl( rxContext, rxModel );
170cdf0e10cSrcweir         // handler for Script & ::rtl::OUString::createFromAscii( "vnd.sun.star.UNO:" )
171cdf0e10cSrcweir         listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.UNO") ] = new DialogUnoScriptListenerImpl( rxContext, rxModel, rxControl, rxHandler, rxIntrospect, bProviderMode );
172cdf0e10cSrcweir         listernersForTypes[ rtl::OUString::createFromAscii("vnd.sun.star.script") ] = new DialogSFScriptListenerImpl( rxContext, rxModel );
173cdf0e10cSrcweir 
174cdf0e10cSrcweir         // determine the VBA compatibility mode from the Basic library container
175cdf0e10cSrcweir         try
176cdf0e10cSrcweir         {
177cdf0e10cSrcweir             uno::Reference< beans::XPropertySet > xModelProps( rxModel, uno::UNO_QUERY_THROW );
178cdf0e10cSrcweir             uno::Reference< script::vba::XVBACompatibility > xVBACompat(
179cdf0e10cSrcweir                 xModelProps->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ), uno::UNO_QUERY_THROW );
180cdf0e10cSrcweir             mbUseFakeVBAEvents = xVBACompat->getVBACompatibilityMode();
181cdf0e10cSrcweir         }
182cdf0e10cSrcweir         catch( uno::Exception& )
183cdf0e10cSrcweir         {
184cdf0e10cSrcweir         }
185cdf0e10cSrcweir         if ( mbUseFakeVBAEvents )
186cdf0e10cSrcweir             listernersForTypes[ rtl::OUString::createFromAscii("VBAInterop") ] = new DialogVBAScriptListenerImpl( rxContext, rxControl, rxModel );
187cdf0e10cSrcweir     }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     // -----------------------------------------------------------------------------
190cdf0e10cSrcweir 
~DialogEventsAttacherImpl()191cdf0e10cSrcweir     DialogEventsAttacherImpl::~DialogEventsAttacherImpl()
192cdf0e10cSrcweir     {
193cdf0e10cSrcweir     }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     // -----------------------------------------------------------------------------
196cdf0e10cSrcweir     Reference< script::XScriptListener >
getScriptListenerForKey(const rtl::OUString & sKey)197cdf0e10cSrcweir     DialogEventsAttacherImpl::getScriptListenerForKey( const rtl::OUString& sKey ) throw ( RuntimeException )
198cdf0e10cSrcweir     {
199cdf0e10cSrcweir         ListenerHash::iterator it = listernersForTypes.find( sKey );
200cdf0e10cSrcweir         if ( it == listernersForTypes.end() )
201cdf0e10cSrcweir             throw RuntimeException(); // more text info here please
202cdf0e10cSrcweir         return it->second;
203cdf0e10cSrcweir     }
getFakeVbaEventsSupplier(const Reference<XControl> & xControl,rtl::OUString & sControlName)204cdf0e10cSrcweir     Reference< XScriptEventsSupplier > DialogEventsAttacherImpl::getFakeVbaEventsSupplier( const Reference< XControl >& xControl, rtl::OUString& sControlName )
205cdf0e10cSrcweir     {
206cdf0e10cSrcweir         Reference< XScriptEventsSupplier > xEventsSupplier;
207cdf0e10cSrcweir         Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
208cdf0e10cSrcweir         if ( xSMgr.is() )
209cdf0e10cSrcweir         {
210cdf0e10cSrcweir             Reference< ooo::vba::XVBAToOOEventDescGen > xVBAToOOEvtDesc( xSMgr->createInstanceWithContext( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAToOOEventDesc" ) ), m_xContext ), UNO_QUERY );
211cdf0e10cSrcweir             if ( xVBAToOOEvtDesc.is() )
212cdf0e10cSrcweir                 xEventsSupplier.set( xVBAToOOEvtDesc->getEventSupplier( xControl, sControlName ), UNO_QUERY );
213cdf0e10cSrcweir         }
214cdf0e10cSrcweir         return xEventsSupplier;
215cdf0e10cSrcweir     }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     // -----------------------------------------------------------------------------
attachEventsToControl(const Reference<XControl> & xControl,const Reference<XScriptEventsSupplier> & xEventsSupplier,const Any & Helper)218cdf0e10cSrcweir     void SAL_CALL DialogEventsAttacherImpl::attachEventsToControl( const Reference< XControl>& xControl, const Reference< XScriptEventsSupplier >& xEventsSupplier, const Any& Helper )
219cdf0e10cSrcweir     {
220cdf0e10cSrcweir         if ( xEventsSupplier.is() )
221cdf0e10cSrcweir         {
222cdf0e10cSrcweir             Reference< container::XNameContainer > xEventCont = xEventsSupplier->getEvents();
223cdf0e10cSrcweir 
224cdf0e10cSrcweir             Reference< XControlModel > xControlModel = xControl->getModel();
225cdf0e10cSrcweir             if ( xEventCont.is() )
226cdf0e10cSrcweir             {
227cdf0e10cSrcweir                 Sequence< ::rtl::OUString > aNames = xEventCont->getElementNames();
228cdf0e10cSrcweir                 const ::rtl::OUString* pNames = aNames.getConstArray();
229cdf0e10cSrcweir                 sal_Int32 nNameCount = aNames.getLength();
230cdf0e10cSrcweir 
231cdf0e10cSrcweir                 for ( sal_Int32 j = 0; j < nNameCount; ++j )
232cdf0e10cSrcweir                 {
233cdf0e10cSrcweir                     ScriptEventDescriptor aDesc;
234cdf0e10cSrcweir 
235cdf0e10cSrcweir                     Any aElement = xEventCont->getByName( pNames[ j ] );
236cdf0e10cSrcweir                     aElement >>= aDesc;
237cdf0e10cSrcweir                     rtl::OUString sKey = aDesc.ScriptType;
238cdf0e10cSrcweir                     if ( aDesc.ScriptType.equals( rtl::OUString::createFromAscii("Script" ) ) || aDesc.ScriptType.equals( rtl::OUString::createFromAscii("UNO" ) ) )
239cdf0e10cSrcweir                     {
240cdf0e10cSrcweir                         sal_Int32 nIndex = aDesc.ScriptCode.indexOf( ':' );
241cdf0e10cSrcweir                         sKey = aDesc.ScriptCode.copy( 0, nIndex );
242cdf0e10cSrcweir                     }
243cdf0e10cSrcweir                     Reference< XAllListener > xAllListener =
244cdf0e10cSrcweir                         new DialogAllListenerImpl( getScriptListenerForKey( sKey ), aDesc.ScriptType, aDesc.ScriptCode );
245cdf0e10cSrcweir 
246cdf0e10cSrcweir                     // try first to attach event to the ControlModel
247cdf0e10cSrcweir                     bool bSuccess = false;
248cdf0e10cSrcweir                     try
249cdf0e10cSrcweir                     {
250cdf0e10cSrcweir                         Reference< XEventListener > xListener_ = m_xEventAttacher->attachSingleEventListener(
251cdf0e10cSrcweir                             xControlModel, xAllListener, Helper, aDesc.ListenerType,
252cdf0e10cSrcweir                             aDesc.AddListenerParam, aDesc.EventMethod );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir                         if ( xListener_.is() )
255cdf0e10cSrcweir                             bSuccess = true;
256cdf0e10cSrcweir                     }
257cdf0e10cSrcweir                     catch ( const Exception& )
258cdf0e10cSrcweir                     {
259cdf0e10cSrcweir                         DBG_UNHANDLED_EXCEPTION();
260cdf0e10cSrcweir                     }
261cdf0e10cSrcweir 
262cdf0e10cSrcweir                     try
263cdf0e10cSrcweir                     {
264cdf0e10cSrcweir                         // if we had no success, try to attach to the control
265cdf0e10cSrcweir                         if ( !bSuccess )
266cdf0e10cSrcweir                         {
267cdf0e10cSrcweir                             Reference< XEventListener > xListener_ = m_xEventAttacher->attachSingleEventListener(
268cdf0e10cSrcweir                                 xControl, xAllListener, Helper, aDesc.ListenerType,
269cdf0e10cSrcweir                                 aDesc.AddListenerParam, aDesc.EventMethod );
270cdf0e10cSrcweir                         }
271cdf0e10cSrcweir                     }
272cdf0e10cSrcweir                     catch ( const Exception& )
273cdf0e10cSrcweir                     {
274cdf0e10cSrcweir                         DBG_UNHANDLED_EXCEPTION();
275cdf0e10cSrcweir                     }
276cdf0e10cSrcweir                 }
277cdf0e10cSrcweir             }
278cdf0e10cSrcweir         }
279cdf0e10cSrcweir     }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir     // -----------------------------------------------------------------------------
282cdf0e10cSrcweir     // XScriptEventsAttacher
283cdf0e10cSrcweir     // -----------------------------------------------------------------------------
284cdf0e10cSrcweir 
attachEvents(const Sequence<Reference<XInterface>> & Objects,const com::sun::star::uno::Reference<com::sun::star::script::XScriptListener> &,const Any & Helper)285cdf0e10cSrcweir     void SAL_CALL DialogEventsAttacherImpl::attachEvents( const Sequence< Reference< XInterface > >& Objects,
286cdf0e10cSrcweir         const com::sun::star::uno::Reference<com::sun::star::script::XScriptListener>&,
287cdf0e10cSrcweir         const Any& Helper )
288cdf0e10cSrcweir         throw (IllegalArgumentException, IntrospectionException, CannotCreateAdapterException,
289cdf0e10cSrcweir                ServiceNotRegisteredException, RuntimeException)
290cdf0e10cSrcweir     {
291cdf0e10cSrcweir         // get EventAttacher
292cdf0e10cSrcweir         {
293cdf0e10cSrcweir             ::osl::MutexGuard aGuard( getMutex() );
294cdf0e10cSrcweir 
295cdf0e10cSrcweir             if ( !m_xEventAttacher.is() )
296cdf0e10cSrcweir             {
297cdf0e10cSrcweir                 Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
298cdf0e10cSrcweir                 if ( xSMgr.is() )
299cdf0e10cSrcweir                 {
300cdf0e10cSrcweir                     m_xEventAttacher = Reference< XEventAttacher >( xSMgr->createInstanceWithContext(
301cdf0e10cSrcweir                         ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.EventAttacher" ) ), m_xContext ), UNO_QUERY );
302cdf0e10cSrcweir 
303cdf0e10cSrcweir                     if ( !m_xEventAttacher.is() )
304cdf0e10cSrcweir                         throw ServiceNotRegisteredException();
305cdf0e10cSrcweir                 }
306cdf0e10cSrcweir                 else
307cdf0e10cSrcweir                 {
308cdf0e10cSrcweir                     throw RuntimeException();
309cdf0e10cSrcweir                 }
310cdf0e10cSrcweir 
311cdf0e10cSrcweir             }
312cdf0e10cSrcweir         }
313cdf0e10cSrcweir 
314cdf0e10cSrcweir         // go over all objects
315cdf0e10cSrcweir         const Reference< XInterface >* pObjects = Objects.getConstArray();
316cdf0e10cSrcweir         sal_Int32 nObjCount = Objects.getLength();
317cdf0e10cSrcweir         Reference< awt::XControl > xDlgControl( Objects[ nObjCount - 1 ], uno::UNO_QUERY ); // last object is the dialog
318cdf0e10cSrcweir         rtl::OUString sDialogCodeName;
319cdf0e10cSrcweir         if ( xDlgControl.is() )
320cdf0e10cSrcweir         {
321cdf0e10cSrcweir             Reference< XPropertySet > xProps( xDlgControl->getModel(), UNO_QUERY );
322cdf0e10cSrcweir             try
323cdf0e10cSrcweir             {
324cdf0e10cSrcweir                 xProps->getPropertyValue( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name") ) ) >>= sDialogCodeName;
325cdf0e10cSrcweir             }
326cdf0e10cSrcweir             catch( Exception& ){}
327cdf0e10cSrcweir         }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir         for ( sal_Int32 i = 0; i < nObjCount; ++i )
330cdf0e10cSrcweir         {
331cdf0e10cSrcweir             // We know that we have to do with instances of XControl.
332cdf0e10cSrcweir             // Otherwise this is not the right implementation for
333cdf0e10cSrcweir             // XScriptEventsAttacher and we have to give up.
334cdf0e10cSrcweir             Reference< XControl > xControl( pObjects[ i ], UNO_QUERY );
335cdf0e10cSrcweir             if ( !xControl.is() )
336cdf0e10cSrcweir                 throw IllegalArgumentException();
337cdf0e10cSrcweir 
338cdf0e10cSrcweir             // get XEventsSupplier from control model
339cdf0e10cSrcweir             Reference< XControlModel > xControlModel = xControl->getModel();
340cdf0e10cSrcweir             Reference< XScriptEventsSupplier > xEventsSupplier( xControlModel, UNO_QUERY );
341cdf0e10cSrcweir             attachEventsToControl( xControl, xEventsSupplier, Helper );
342cdf0e10cSrcweir             if ( mbUseFakeVBAEvents )
343cdf0e10cSrcweir             {
344cdf0e10cSrcweir                 xEventsSupplier.set( getFakeVbaEventsSupplier( xControl, sDialogCodeName ) );
345cdf0e10cSrcweir                 attachEventsToControl( xControl, xEventsSupplier, Helper );
346cdf0e10cSrcweir             }
347cdf0e10cSrcweir         }
348cdf0e10cSrcweir     }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     // =============================================================================
352cdf0e10cSrcweir     // DialogAllListenerImpl
353cdf0e10cSrcweir     // =============================================================================
354cdf0e10cSrcweir 
DialogAllListenerImpl(const Reference<XScriptListener> & rxListener,const::rtl::OUString & rScriptType,const::rtl::OUString & rScriptCode)355cdf0e10cSrcweir     DialogAllListenerImpl::DialogAllListenerImpl( const Reference< XScriptListener >& rxListener,
356cdf0e10cSrcweir         const ::rtl::OUString& rScriptType, const ::rtl::OUString& rScriptCode )
357cdf0e10cSrcweir         :m_xScriptListener( rxListener )
358cdf0e10cSrcweir         ,m_sScriptType( rScriptType )
359cdf0e10cSrcweir         ,m_sScriptCode( rScriptCode )
360cdf0e10cSrcweir     {
361cdf0e10cSrcweir     }
362cdf0e10cSrcweir 
363cdf0e10cSrcweir     // -----------------------------------------------------------------------------
364cdf0e10cSrcweir 
~DialogAllListenerImpl()365cdf0e10cSrcweir     DialogAllListenerImpl::~DialogAllListenerImpl()
366cdf0e10cSrcweir     {
367cdf0e10cSrcweir     }
368cdf0e10cSrcweir 
369cdf0e10cSrcweir     // -----------------------------------------------------------------------------
370cdf0e10cSrcweir 
firing_impl(const AllEventObject & Event,Any * pRet)371cdf0e10cSrcweir     void DialogAllListenerImpl::firing_impl( const AllEventObject& Event, Any* pRet )
372cdf0e10cSrcweir     {
373cdf0e10cSrcweir         ScriptEvent aScriptEvent;
374cdf0e10cSrcweir         aScriptEvent.Source         = (OWeakObject *)this;  // get correct XInterface
375cdf0e10cSrcweir         aScriptEvent.ListenerType   = Event.ListenerType;
376cdf0e10cSrcweir         aScriptEvent.MethodName     = Event.MethodName;
377cdf0e10cSrcweir         aScriptEvent.Arguments      = Event.Arguments;
378cdf0e10cSrcweir         aScriptEvent.Helper         = Event.Helper;
379cdf0e10cSrcweir         aScriptEvent.ScriptType     = m_sScriptType;
380cdf0e10cSrcweir         aScriptEvent.ScriptCode     = m_sScriptCode;
381cdf0e10cSrcweir 
382cdf0e10cSrcweir         if ( m_xScriptListener.is() )
383cdf0e10cSrcweir         {
384cdf0e10cSrcweir             if ( pRet )
385cdf0e10cSrcweir                 *pRet = m_xScriptListener->approveFiring( aScriptEvent );
386cdf0e10cSrcweir             else
387cdf0e10cSrcweir                 m_xScriptListener->firing( aScriptEvent );
388cdf0e10cSrcweir         }
389cdf0e10cSrcweir     }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir     // -----------------------------------------------------------------------------
392cdf0e10cSrcweir     // XEventListener
393cdf0e10cSrcweir     // -----------------------------------------------------------------------------
394cdf0e10cSrcweir 
disposing(const EventObject &)395cdf0e10cSrcweir     void DialogAllListenerImpl::disposing(const EventObject& ) throw ( RuntimeException )
396cdf0e10cSrcweir     {
397cdf0e10cSrcweir     }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir     // -----------------------------------------------------------------------------
400cdf0e10cSrcweir     // XAllListener
401cdf0e10cSrcweir     // -----------------------------------------------------------------------------
402cdf0e10cSrcweir 
firing(const AllEventObject & Event)403cdf0e10cSrcweir     void DialogAllListenerImpl::firing( const AllEventObject& Event ) throw ( RuntimeException )
404cdf0e10cSrcweir     {
405cdf0e10cSrcweir         ::osl::MutexGuard aGuard( getMutex() );
406cdf0e10cSrcweir 
407cdf0e10cSrcweir         firing_impl( Event, NULL );
408cdf0e10cSrcweir     }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir     // -----------------------------------------------------------------------------
411cdf0e10cSrcweir 
approveFiring(const AllEventObject & Event)412cdf0e10cSrcweir     Any DialogAllListenerImpl::approveFiring( const AllEventObject& Event )
413cdf0e10cSrcweir         throw ( reflection::InvocationTargetException, RuntimeException )
414cdf0e10cSrcweir     {
415cdf0e10cSrcweir         ::osl::MutexGuard aGuard( getMutex() );
416cdf0e10cSrcweir 
417cdf0e10cSrcweir         Any aReturn;
418cdf0e10cSrcweir         firing_impl( Event, &aReturn );
419cdf0e10cSrcweir         return aReturn;
420cdf0e10cSrcweir     }
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 
423cdf0e10cSrcweir     // =============================================================================
424cdf0e10cSrcweir     // DialogScriptListenerImpl
425cdf0e10cSrcweir     // =============================================================================
426cdf0e10cSrcweir 
DialogUnoScriptListenerImpl(const Reference<XComponentContext> & rxContext,const Reference<::com::sun::star::frame::XModel> & rxModel,const Reference<::com::sun::star::awt::XControl> & rxControl,const Reference<::com::sun::star::uno::XInterface> & rxHandler,const Reference<::com::sun::star::beans::XIntrospectionAccess> & rxIntrospectionAccess,bool bDialogProviderMode)427cdf0e10cSrcweir     DialogUnoScriptListenerImpl::DialogUnoScriptListenerImpl( const Reference< XComponentContext >& rxContext,
428cdf0e10cSrcweir             const Reference< ::com::sun::star::frame::XModel >& rxModel,
429cdf0e10cSrcweir 			const Reference< ::com::sun::star::awt::XControl >& rxControl,
430cdf0e10cSrcweir 			const Reference< ::com::sun::star::uno::XInterface >& rxHandler,
431cdf0e10cSrcweir 			const Reference< ::com::sun::star::beans::XIntrospectionAccess >& rxIntrospectionAccess,
432cdf0e10cSrcweir 			bool bDialogProviderMode )
433cdf0e10cSrcweir         : DialogSFScriptListenerImpl( rxContext, rxModel )
434cdf0e10cSrcweir         ,m_xControl( rxControl )
435cdf0e10cSrcweir         ,m_xHandler( rxHandler )
436cdf0e10cSrcweir         ,m_xIntrospectionAccess( rxIntrospectionAccess )
437cdf0e10cSrcweir 		,m_bDialogProviderMode( bDialogProviderMode )
438cdf0e10cSrcweir     {
439cdf0e10cSrcweir     }
440cdf0e10cSrcweir 
441cdf0e10cSrcweir     // -----------------------------------------------------------------------------
442cdf0e10cSrcweir 
~DialogScriptListenerImpl()443cdf0e10cSrcweir     DialogScriptListenerImpl::~DialogScriptListenerImpl()
444cdf0e10cSrcweir     {
445cdf0e10cSrcweir     }
446cdf0e10cSrcweir 
447cdf0e10cSrcweir     // -----------------------------------------------------------------------------
firing_impl(const ScriptEvent & aScriptEvent,Any * pRet)448cdf0e10cSrcweir     void DialogSFScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet )
449cdf0e10cSrcweir     {
450cdf0e10cSrcweir         try
451cdf0e10cSrcweir         {
452cdf0e10cSrcweir             Reference< provider::XScriptProvider > xScriptProvider;
453cdf0e10cSrcweir             if ( m_xModel.is() )
454cdf0e10cSrcweir             {
455cdf0e10cSrcweir                 Reference< provider::XScriptProviderSupplier > xSupplier( m_xModel, UNO_QUERY );
456cdf0e10cSrcweir                 OSL_ENSURE( xSupplier.is(), "DialogScriptListenerImpl::firing_impl: failed to get script provider supplier" );
457cdf0e10cSrcweir                 if ( xSupplier.is() )
458cdf0e10cSrcweir                     xScriptProvider.set( xSupplier->getScriptProvider() );
459cdf0e10cSrcweir             }
460cdf0e10cSrcweir             else
461cdf0e10cSrcweir             {
462cdf0e10cSrcweir                 OSL_ASSERT( m_xContext.is() );
463cdf0e10cSrcweir                 if ( m_xContext.is() )
464cdf0e10cSrcweir                 {
465cdf0e10cSrcweir                     Reference< provider::XScriptProviderFactory > xFactory(
466cdf0e10cSrcweir                         m_xContext->getValueByName(
467cdf0e10cSrcweir                         ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory" ) ),
468cdf0e10cSrcweir                         UNO_QUERY );
469cdf0e10cSrcweir                     OSL_ENSURE( xFactory.is(), "SFURL_firing_impl: failed to get master script provider factory" );
470cdf0e10cSrcweir                     if ( xFactory.is() )
471cdf0e10cSrcweir                     {
472cdf0e10cSrcweir                         Any aCtx;
473cdf0e10cSrcweir                         aCtx <<= ::rtl::OUString::createFromAscii( "user" );
474cdf0e10cSrcweir                         xScriptProvider.set( xFactory->createScriptProvider( aCtx ), UNO_QUERY );
475cdf0e10cSrcweir                     }
476cdf0e10cSrcweir                 }
477cdf0e10cSrcweir             }
478cdf0e10cSrcweir 
479cdf0e10cSrcweir             OSL_ENSURE( xScriptProvider.is(), "DialogScriptListenerImpl::firing_impl: failed to get script provider" );
480cdf0e10cSrcweir 
481cdf0e10cSrcweir             if ( xScriptProvider.is() )
482cdf0e10cSrcweir             {
483cdf0e10cSrcweir                 Reference< provider::XScript > xScript = xScriptProvider->getScript( aScriptEvent.ScriptCode );
484cdf0e10cSrcweir                 OSL_ENSURE( xScript.is(), "DialogScriptListenerImpl::firing_impl: failed to get script" );
485cdf0e10cSrcweir 
486cdf0e10cSrcweir                 if ( xScript.is() )
487cdf0e10cSrcweir                 {
488cdf0e10cSrcweir                     Sequence< Any > aInParams;
489cdf0e10cSrcweir                     Sequence< sal_Int16 > aOutParamsIndex;
490cdf0e10cSrcweir                     Sequence< Any > aOutParams;
491cdf0e10cSrcweir 
492cdf0e10cSrcweir                     // get arguments for script
493cdf0e10cSrcweir                     aInParams = aScriptEvent.Arguments;
494cdf0e10cSrcweir 
495cdf0e10cSrcweir                     Any aResult = xScript->invoke( aInParams, aOutParamsIndex, aOutParams );
496cdf0e10cSrcweir                     if ( pRet )
497cdf0e10cSrcweir                         *pRet = aResult;
498cdf0e10cSrcweir                 }
499cdf0e10cSrcweir             }
500cdf0e10cSrcweir         }
501cdf0e10cSrcweir         catch ( const Exception& )
502cdf0e10cSrcweir         {
503cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
504cdf0e10cSrcweir         }
505cdf0e10cSrcweir     }
506cdf0e10cSrcweir 
firing_impl(const ScriptEvent & aScriptEvent,Any * pRet)507cdf0e10cSrcweir     void DialogLegacyScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet )
508cdf0e10cSrcweir     {
509cdf0e10cSrcweir         ::rtl::OUString sScriptURL;
510cdf0e10cSrcweir         ::rtl::OUString sScriptCode( aScriptEvent.ScriptCode );
511cdf0e10cSrcweir 
512cdf0e10cSrcweir 	    if ( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 )
513cdf0e10cSrcweir 	    {
514cdf0e10cSrcweir 		    // StarBasic script: convert ScriptCode to scriptURL
515cdf0e10cSrcweir 		    sal_Int32 nIndex = sScriptCode.indexOf( ':' );
516cdf0e10cSrcweir 		    if ( nIndex >= 0 && nIndex < sScriptCode.getLength() )
517cdf0e10cSrcweir 		    {
518cdf0e10cSrcweir 			    sScriptURL = ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" );
519cdf0e10cSrcweir 			    sScriptURL += sScriptCode.copy( nIndex + 1 );
520cdf0e10cSrcweir 			    sScriptURL += ::rtl::OUString::createFromAscii( "?language=Basic&location=" );
521cdf0e10cSrcweir 			    sScriptURL += sScriptCode.copy( 0, nIndex );
522cdf0e10cSrcweir 		    }
523cdf0e10cSrcweir 		    ScriptEvent aSFScriptEvent( aScriptEvent );
524cdf0e10cSrcweir 		    aSFScriptEvent.ScriptCode = sScriptURL;
525cdf0e10cSrcweir 		    DialogSFScriptListenerImpl::firing_impl( aSFScriptEvent, pRet );
526cdf0e10cSrcweir 	    }
527cdf0e10cSrcweir     }
528cdf0e10cSrcweir 
firing_impl(const ScriptEvent & aScriptEvent,Any * pRet)529cdf0e10cSrcweir 	void DialogUnoScriptListenerImpl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet )
530cdf0e10cSrcweir 	{
531cdf0e10cSrcweir 		static ::rtl::OUString sUnoURLScheme = ::rtl::OUString::createFromAscii( "vnd.sun.star.UNO:" );
532cdf0e10cSrcweir 
533cdf0e10cSrcweir         ::rtl::OUString sScriptCode( aScriptEvent.ScriptCode );
534cdf0e10cSrcweir 		::rtl::OUString aMethodName = aScriptEvent.ScriptCode.copy( sUnoURLScheme.getLength() );
535cdf0e10cSrcweir 
536cdf0e10cSrcweir 		const Any* pArguments = aScriptEvent.Arguments.getConstArray();
537cdf0e10cSrcweir 		Any aEventObject = pArguments[0];
538cdf0e10cSrcweir 
539cdf0e10cSrcweir 		bool bHandled = false;
540cdf0e10cSrcweir 		if( m_xHandler.is() )
541cdf0e10cSrcweir 		{
542cdf0e10cSrcweir 			if( m_bDialogProviderMode )
543cdf0e10cSrcweir 			{
544cdf0e10cSrcweir 				Reference< XDialogEventHandler > xDialogEventHandler( m_xHandler, UNO_QUERY );
545cdf0e10cSrcweir 				if( xDialogEventHandler.is() )
546cdf0e10cSrcweir 				{
547cdf0e10cSrcweir 					Reference< XDialog > xDialog( m_xControl, UNO_QUERY );
548cdf0e10cSrcweir 					bHandled = xDialogEventHandler->callHandlerMethod( xDialog, aEventObject, aMethodName );
549cdf0e10cSrcweir 				}
550cdf0e10cSrcweir 			}
551cdf0e10cSrcweir 			else
552cdf0e10cSrcweir 			{
553cdf0e10cSrcweir 				Reference< XContainerWindowEventHandler > xContainerWindowEventHandler( m_xHandler, UNO_QUERY );
554cdf0e10cSrcweir 				if( xContainerWindowEventHandler.is() )
555cdf0e10cSrcweir 				{
556cdf0e10cSrcweir 					Reference< XWindow > xWindow( m_xControl, UNO_QUERY );
557cdf0e10cSrcweir 					bHandled = xContainerWindowEventHandler->callHandlerMethod( xWindow, aEventObject, aMethodName );
558cdf0e10cSrcweir 				}
559cdf0e10cSrcweir 			}
560cdf0e10cSrcweir 		}
561cdf0e10cSrcweir 
562cdf0e10cSrcweir 		Any aRet;
563cdf0e10cSrcweir 		if( !bHandled && m_xIntrospectionAccess.is() )
564cdf0e10cSrcweir 		{
565cdf0e10cSrcweir 			try
566cdf0e10cSrcweir 			{
567cdf0e10cSrcweir 				// Methode ansprechen
568cdf0e10cSrcweir 				const Reference< XIdlMethod >& rxMethod = m_xIntrospectionAccess->
569cdf0e10cSrcweir 					getMethod( aMethodName, MethodConcept::ALL - MethodConcept::DANGEROUS );
570cdf0e10cSrcweir 
571cdf0e10cSrcweir 				Reference< XMaterialHolder > xMaterialHolder =
572cdf0e10cSrcweir 					Reference< XMaterialHolder >::query( m_xIntrospectionAccess );
573cdf0e10cSrcweir 				Any aHandlerObject = xMaterialHolder->getMaterial();
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 				Sequence< Reference< XIdlClass > > aParamTypeSeq = rxMethod->getParameterTypes();
576cdf0e10cSrcweir 		        sal_Int32 nParamCount = aParamTypeSeq.getLength();
577cdf0e10cSrcweir 				if( nParamCount == 0 )
578cdf0e10cSrcweir 				{
579cdf0e10cSrcweir 					Sequence<Any> args;
580cdf0e10cSrcweir 					rxMethod->invoke( aHandlerObject, args );
581cdf0e10cSrcweir 					bHandled = true;
582cdf0e10cSrcweir 				}
583cdf0e10cSrcweir 				else if( nParamCount == 2 )
584cdf0e10cSrcweir 				{
585cdf0e10cSrcweir 					// Signature check automatically done by reflection
586cdf0e10cSrcweir 					Sequence<Any> Args(2);
587cdf0e10cSrcweir 					Any* pArgs = Args.getArray();
588cdf0e10cSrcweir 					if( m_bDialogProviderMode )
589cdf0e10cSrcweir 					{
590cdf0e10cSrcweir 						Reference< XDialog > xDialog( m_xControl, UNO_QUERY );
591cdf0e10cSrcweir 						pArgs[0] <<= xDialog;
592cdf0e10cSrcweir 					}
593cdf0e10cSrcweir 					else
594cdf0e10cSrcweir 					{
595cdf0e10cSrcweir 						Reference< XWindow > xWindow( m_xControl, UNO_QUERY );
596cdf0e10cSrcweir 						pArgs[0] <<= xWindow;
597cdf0e10cSrcweir 					}
598cdf0e10cSrcweir 					pArgs[1] = aEventObject;
599cdf0e10cSrcweir 					aRet = rxMethod->invoke( aHandlerObject, Args );
600cdf0e10cSrcweir 					bHandled = true;
601cdf0e10cSrcweir 				}
602cdf0e10cSrcweir 			}
603cdf0e10cSrcweir             catch( const Exception& )
604cdf0e10cSrcweir             {
605cdf0e10cSrcweir             	DBG_UNHANDLED_EXCEPTION();
606cdf0e10cSrcweir             }
607cdf0e10cSrcweir 		}
608cdf0e10cSrcweir 
609cdf0e10cSrcweir 		if( bHandled )
610cdf0e10cSrcweir 		{
611cdf0e10cSrcweir 			if( pRet )
612cdf0e10cSrcweir 				*pRet = aRet;
613cdf0e10cSrcweir 		}
614cdf0e10cSrcweir 		else
615cdf0e10cSrcweir 		{
616cdf0e10cSrcweir 			ResMgr* pResMgr = SFX_APP()->GetSfxResManager();
617cdf0e10cSrcweir 			if( pResMgr )
618cdf0e10cSrcweir 			{
619cdf0e10cSrcweir 			    String aRes( ResId(STR_ERRUNOEVENTBINDUNG, *pResMgr) );
620cdf0e10cSrcweir 				::rtl::OUString aQuoteChar( RTL_CONSTASCII_USTRINGPARAM( "\"" ) );
621cdf0e10cSrcweir 
622cdf0e10cSrcweir                 ::rtl::OUString aOURes = aRes;
623cdf0e10cSrcweir 				sal_Int32 nIndex = aOURes.indexOf( '%' );
624cdf0e10cSrcweir 
625cdf0e10cSrcweir                 ::rtl::OUString aOUFinal;
626cdf0e10cSrcweir 				aOUFinal += aOURes.copy( 0, nIndex );
627cdf0e10cSrcweir 				aOUFinal += aQuoteChar;
628cdf0e10cSrcweir 				aOUFinal += aMethodName;
629cdf0e10cSrcweir 				aOUFinal += aQuoteChar;
630cdf0e10cSrcweir 				aOUFinal += aOURes.copy( nIndex + 2 );
631cdf0e10cSrcweir 
632cdf0e10cSrcweir 				ErrorBox( NULL, WinBits( WB_OK ), aOUFinal ).Execute();
633cdf0e10cSrcweir 			}
634cdf0e10cSrcweir 		}
635cdf0e10cSrcweir 	}
636cdf0e10cSrcweir 
637cdf0e10cSrcweir     // -----------------------------------------------------------------------------
638cdf0e10cSrcweir     // XEventListener
639cdf0e10cSrcweir     // -----------------------------------------------------------------------------
640cdf0e10cSrcweir 
disposing(const EventObject &)641cdf0e10cSrcweir     void DialogScriptListenerImpl::disposing(const EventObject& ) throw ( RuntimeException )
642cdf0e10cSrcweir     {
643cdf0e10cSrcweir     }
644cdf0e10cSrcweir 
645cdf0e10cSrcweir     // -----------------------------------------------------------------------------
646cdf0e10cSrcweir     // XScriptListener
647cdf0e10cSrcweir     // -----------------------------------------------------------------------------
648cdf0e10cSrcweir 
firing(const ScriptEvent & aScriptEvent)649cdf0e10cSrcweir     void DialogScriptListenerImpl::firing( const ScriptEvent& aScriptEvent ) throw ( RuntimeException )
650cdf0e10cSrcweir     {
651cdf0e10cSrcweir         ::osl::MutexGuard aGuard( getMutex() );
652cdf0e10cSrcweir 
653cdf0e10cSrcweir         firing_impl( aScriptEvent, NULL );
654cdf0e10cSrcweir     }
655cdf0e10cSrcweir 
656cdf0e10cSrcweir     // -----------------------------------------------------------------------------
657cdf0e10cSrcweir 
approveFiring(const ScriptEvent & aScriptEvent)658cdf0e10cSrcweir     Any DialogScriptListenerImpl::approveFiring( const ScriptEvent& aScriptEvent )
659cdf0e10cSrcweir         throw ( reflection::InvocationTargetException, RuntimeException )
660cdf0e10cSrcweir     {
661cdf0e10cSrcweir         ::osl::MutexGuard aGuard( getMutex() );
662cdf0e10cSrcweir 
663cdf0e10cSrcweir         Any aReturn;
664cdf0e10cSrcweir         firing_impl( aScriptEvent, &aReturn );
665cdf0e10cSrcweir         return aReturn;
666cdf0e10cSrcweir     }
667cdf0e10cSrcweir 
668cdf0e10cSrcweir     // -----------------------------------------------------------------------------
669cdf0e10cSrcweir 
670cdf0e10cSrcweir //.........................................................................
671cdf0e10cSrcweir }	// namespace dlgprov
672cdf0e10cSrcweir //.........................................................................
673