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