xref: /trunk/main/basic/source/classes/eventatt.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_basic.hxx"
26 
27 //#include <stl_queue.h>
28 #include <osl/mutex.hxx>
29 #include <comphelper/processfactory.hxx>
30 
31 
32 #include <com/sun/star/script/XEventAttacher.hpp>
33 #include <com/sun/star/script/XAllListener.hpp>
34 #include <com/sun/star/script/XScriptEventsSupplier.hpp>
35 #include <com/sun/star/script/XScriptEventsAttacher.hpp>
36 #include <com/sun/star/script/ScriptEventDescriptor.hpp>
37 #include <com/sun/star/script/XLibraryContainer.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/container/XNameContainer.hpp>
40 #include <com/sun/star/resource/XStringResourceSupplier.hpp>
41 #include <com/sun/star/resource/XStringResourceManager.hpp>
42 #include <com/sun/star/awt/XControlContainer.hpp>
43 #include <com/sun/star/awt/XControlModel.hpp>
44 #include <com/sun/star/awt/XControl.hpp>
45 #include <com/sun/star/awt/XDialog.hpp>
46 #include <com/sun/star/awt/XWindow.hpp>
47 #include <com/sun/star/script/provider/XScriptProviderFactory.hpp>
48 
49 #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp>
50 #include <com/sun/star/script/provider/XScriptProvider.hpp>
51 #include <com/sun/star/awt/XDialogProvider.hpp>
52 
53 #include <com/sun/star/frame/XModel.hpp>
54 #include <com/sun/star/frame/XDesktop.hpp>
55 #include <com/sun/star/container/XEnumerationAccess.hpp>
56 #include <basic/basicmanagerrepository.hxx>
57 #include <basic/basmgr.hxx>
58 //==================================================================================================
59 
60 #include <xmlscript/xmldlg_imexp.hxx>
61 #include <sbunoobj.hxx>
62 #include <basic/sbstar.hxx>
63 #include <basic/sbmeth.hxx>
64 #include <basic/sbuno.hxx>
65 #include <runtime.hxx>
66 #include <sbintern.hxx>
67 
68 
69 #include <cppuhelper/implbase1.hxx>
70 using namespace ::com::sun::star;
71 using namespace ::com::sun::star::uno;
72 using namespace ::com::sun::star::script;
73 using namespace ::com::sun::star::resource;
74 
75 using namespace ::com::sun::star::uno;
76 using namespace ::com::sun::star::lang;
77 using namespace ::com::sun::star::beans;
78 using namespace ::com::sun::star::script;
79 using namespace ::com::sun::star::container;
80 using namespace ::com::sun::star::reflection;
81 using namespace ::com::sun::star::awt;
82 using namespace ::com::sun::star::io;
83 using namespace ::cppu;
84 using namespace ::osl;
85 
86 
SFURL_firing_impl(const ScriptEvent & aScriptEvent,Any * pRet,const Reference<frame::XModel> & xModel)87 void SFURL_firing_impl( const ScriptEvent& aScriptEvent, Any* pRet, const Reference< frame::XModel >& xModel )
88 {
89         OSL_TRACE("SFURL_firing_impl() processing script url %s",
90             ::rtl::OUStringToOString( aScriptEvent.ScriptCode,
91                 RTL_TEXTENCODING_ASCII_US ).pData->buffer );
92         try
93         {
94             Reference< provider::XScriptProvider > xScriptProvider;
95             if ( xModel.is() )
96             {
97                 Reference< provider::XScriptProviderSupplier > xSupplier( xModel, UNO_QUERY );
98                 OSL_ENSURE( xSupplier.is(), "SFURL_firing_impl: failed to get script provider supplier" );
99                 if ( xSupplier.is() )
100                     xScriptProvider.set( xSupplier->getScriptProvider() );
101             }
102             else
103             {
104                 Reference< XComponentContext > xContext;
105                 Reference< XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY );
106                 OSL_ASSERT( xProps.is() );
107                 OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString::createFromAscii( "DefaultContext" ) ) >>= xContext );
108                 if ( xContext.is() )
109                 {
110                     Reference< provider::XScriptProviderFactory > xFactory(
111                         xContext->getValueByName(
112                         ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory" ) ),
113                         UNO_QUERY );
114                     OSL_ENSURE( xFactory.is(), "SFURL_firing_impl: failed to get master script provider factory" );
115                     if ( xFactory.is() )
116                     {
117                         Any aCtx;
118                         aCtx <<= ::rtl::OUString::createFromAscii( "user" );
119                         xScriptProvider.set( xFactory->createScriptProvider( aCtx ), UNO_QUERY );
120                     }
121                 }
122             }
123 
124             if ( !xScriptProvider.is() )
125             {
126                 OSL_TRACE("SFURL_firing_impl() Failed to create msp");
127                 return;
128             }
129             Sequence< Any > inArgs( 0 );
130             Sequence< Any > outArgs( 0 );
131             Sequence< sal_Int16 > outIndex;
132 
133             // get Arguments for script
134             inArgs = aScriptEvent.Arguments;
135 
136             Reference< provider::XScript > xScript = xScriptProvider->getScript( aScriptEvent.ScriptCode );
137 
138             if ( !xScript.is() )
139             {
140                 OSL_TRACE("SFURL_firing_impl() Failed to obtain XScript");
141                 return;
142             }
143 
144             Any result = xScript->invoke( inArgs, outIndex, outArgs );
145             if ( pRet )
146             {
147                 *pRet = result;
148             }
149         }
150         catch ( RuntimeException& re )
151         {
152             OSL_TRACE("SFURL_firing_impl() Caught RuntimeException reason %s.",
153                 ::rtl::OUStringToOString( re.Message,
154                     RTL_TEXTENCODING_ASCII_US ).pData->buffer );
155         }
156         catch ( Exception& e )
157         {
158             OSL_TRACE("SFURL_firing_impl() Caught Exception reason %s.",
159                 ::rtl::OUStringToOString( e.Message,
160                     RTL_TEXTENCODING_ASCII_US ).pData->buffer );
161         }
162 
163 }
164 
165 
166 class BasicScriptListener_Impl : public WeakImplHelper1< XScriptListener >
167 {
168     StarBASICRef maBasicRef;
169         Reference< frame::XModel > m_xModel;
170 
171     virtual void firing_impl(const ScriptEvent& aScriptEvent, Any* pRet);
172 
173 public:
BasicScriptListener_Impl(StarBASIC * pBasic,const Reference<frame::XModel> & xModel)174     BasicScriptListener_Impl( StarBASIC* pBasic, const Reference< frame::XModel >& xModel )
175         : maBasicRef( pBasic ), m_xModel( xModel ) {}
176 
177     // Methods of XAllListener
178     virtual void SAL_CALL firing(const ScriptEvent& aScriptEvent);
179     virtual Any SAL_CALL approveFiring(const ScriptEvent& aScriptEvent);
180 
181     // Methods of XEventListener
182     virtual void SAL_CALL disposing(const EventObject& Source);
183 };
184 
185 // Methods XAllListener
firing(const ScriptEvent & aScriptEvent)186 void BasicScriptListener_Impl::firing( const ScriptEvent& aScriptEvent )
187 {
188     firing_impl( aScriptEvent, NULL );
189 }
190 
approveFiring(const ScriptEvent & aScriptEvent)191 Any BasicScriptListener_Impl::approveFiring( const ScriptEvent& aScriptEvent )
192 {
193     Any aRetAny;
194     firing_impl( aScriptEvent, &aRetAny );
195     return aRetAny;
196 }
197 
198 // Methods XEventListener
disposing(const EventObject &)199 void BasicScriptListener_Impl::disposing(const EventObject& )
200 {
201     // TODO: ???
202     //vos::OGuard guard( Application::GetSolarMutex() );
203     //xSbxObj.Clear();
204 }
205 
206 
firing_impl(const ScriptEvent & aScriptEvent,Any * pRet)207 void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet )
208 {
209     //Guard< Mutex > aGuard( Mutex::getGlobalMutex() );
210     //{
211     if( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 )
212     {
213         // Full qualified name?
214         String aMacro( aScriptEvent.ScriptCode );
215         String aLibName;
216         String aLocation;
217         if( aMacro.GetTokenCount( '.' ) == 3 )
218         {
219             sal_uInt16 nLast = 0;
220             ::rtl::OUString aFullLibName = aMacro.GetToken( 0, '.', nLast );
221 
222             sal_Int32 nIndex = aFullLibName.indexOf( (sal_Unicode)':' );
223             if (nIndex >= 0)
224             {
225                 aLocation = aFullLibName.copy( 0, nIndex );
226                 aLibName = aFullLibName.copy( nIndex + 1 );
227             }
228 
229             String aModul = aMacro.GetToken( 0, '.', nLast );
230             aMacro.Erase( 0, nLast );
231         }
232 
233         SbxObject* p = maBasicRef;
234         SbxObject* pParent = p->GetParent();
235         SbxObject* pParentParent = pParent ? pParent->GetParent() : NULL;
236 
237         StarBASICRef xAppStandardBasic;
238         StarBASICRef xDocStandardBasic;
239         if( pParentParent )
240         {
241             // Own basic must be document library
242             xAppStandardBasic = (StarBASIC*)pParentParent;
243             xDocStandardBasic = (StarBASIC*)pParent;
244         }
245         else if( pParent )
246         {
247             String aName = p->GetName();
248             if( aName.EqualsAscii("Standard") )
249             {
250                 // Own basic is doc standard lib
251                 xDocStandardBasic = (StarBASIC*)p;
252             }
253             xAppStandardBasic = (StarBASIC*)pParent;
254         }
255         else
256         {
257             xAppStandardBasic = (StarBASIC*)p;
258         }
259 
260         sal_Bool bSearchLib = true;
261         StarBASICRef xLibSearchBasic;
262         if( aLocation.EqualsAscii("application") )
263             xLibSearchBasic = xAppStandardBasic;
264         else if( aLocation.EqualsAscii("document") )
265             xLibSearchBasic = xDocStandardBasic;
266         else
267             bSearchLib = false;
268 
269         SbxVariable* pMethVar = NULL;
270         // Be still tolerant and make default search if no search basic exists
271         if( bSearchLib && xLibSearchBasic.Is() )
272         {
273             StarBASICRef xLibBasic;
274             sal_Int16 nCount = xLibSearchBasic->GetObjects()->Count();
275             for( sal_Int16 nObj = -1; nObj < nCount ; nObj++ )
276             {
277                 StarBASIC* pBasic;
278                 if( nObj == -1 )
279                 {
280                     pBasic = (StarBASIC*)xLibSearchBasic;
281                 }
282                 else
283                 {
284                     SbxVariable* pVar = xLibSearchBasic->GetObjects()->Get( nObj );
285                     pBasic = PTR_CAST(StarBASIC,pVar);
286                 }
287                 if( pBasic )
288                 {
289                     String aName = pBasic->GetName();
290                     if( aName == aLibName )
291                     {
292                         // Search only in the lib, not automatically in application basic
293                         sal_uInt16 nFlags = pBasic->GetFlags();
294                         pBasic->ResetFlag( SBX_GBLSEARCH );
295                         pMethVar = pBasic->Find( aMacro, SbxCLASS_DONTCARE );
296                         pBasic->SetFlags( nFlags );
297                         break;
298                     }
299                 }
300             }
301         }
302 
303         // Default: Be tolerant and search everywhere
304         if( (!pMethVar || !pMethVar->ISA(SbMethod)) && maBasicRef.Is() )
305             pMethVar = maBasicRef->FindQualified( aMacro, SbxCLASS_DONTCARE );
306 
307         SbMethod* pMeth = PTR_CAST(SbMethod,pMethVar);
308         if( !pMeth )
309             return;
310 
311         // Setup parameters
312         SbxArrayRef xArray;
313         String aTmp;
314         sal_Int32 nCnt = aScriptEvent.Arguments.getLength();
315         if( nCnt )
316         {
317             xArray = new SbxArray;
318             const Any *pArgs = aScriptEvent.Arguments.getConstArray();
319             for( sal_Int32 i = 0; i < nCnt; i++ )
320             {
321                 SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
322                 unoToSbxValue( (SbxVariable*)xVar, pArgs[i] );
323                 xArray->Put( xVar, sal::static_int_cast< sal_uInt16 >(i+1) );
324             }
325         }
326 
327         // Call method
328         SbxVariableRef xValue = pRet ? new SbxVariable : 0;
329         if( xArray.Is() )
330             pMeth->SetParameters( xArray );
331         pMeth->Call( xValue );
332         if( pRet )
333             *pRet = sbxToUnoValue( xValue );
334         pMeth->SetParameters( NULL );
335     }
336         else // scripting framework script
337         {
338             //callBasic via scripting framework
339             SFURL_firing_impl( aScriptEvent, pRet, m_xModel );
340 
341         }
342 }
343 
implFindDialogLibForDialog(const Any & rDlgAny,SbxObject * pBasic)344 Any implFindDialogLibForDialog( const Any& rDlgAny, SbxObject* pBasic )
345 {
346     Any aRetDlgLibAny;
347 
348     SbxVariable* pDlgLibContVar = pBasic->Find
349         (  String::CreateFromAscii("DialogLibraries"), SbxCLASS_OBJECT );
350     if( pDlgLibContVar && pDlgLibContVar->ISA(SbUnoObject) )
351     {
352         SbUnoObject* pDlgLibContUnoObj = (SbUnoObject*)(SbxBase*)pDlgLibContVar;
353         Any aDlgLibContAny = pDlgLibContUnoObj->getUnoAny();
354 
355         Reference< XLibraryContainer > xDlgLibContNameAccess( aDlgLibContAny, UNO_QUERY );
356         OSL_ENSURE( xDlgLibContNameAccess.is(), "implFindDialogLibForDialog: no lib container for the given dialog!" );
357         if( xDlgLibContNameAccess.is() )
358         {
359             Sequence< ::rtl::OUString > aLibNames = xDlgLibContNameAccess->getElementNames();
360             const ::rtl::OUString* pLibNames = aLibNames.getConstArray();
361             sal_Int32 nLibNameCount = aLibNames.getLength();
362 
363             for( sal_Int32 iLib = 0 ; iLib < nLibNameCount ; iLib++ )
364             {
365                 if ( !xDlgLibContNameAccess->isLibraryLoaded( pLibNames[ iLib ] ) )
366                     // if the library isn't loaded, then the dialog cannot originate from this lib
367                     continue;
368 
369                 Any aDlgLibAny = xDlgLibContNameAccess->getByName( pLibNames[ iLib ] );
370 
371                 Reference< XNameAccess > xDlgLibNameAccess( aDlgLibAny, UNO_QUERY );
372                 OSL_ENSURE( xDlgLibNameAccess.is(), "implFindDialogLibForDialog: invalid dialog lib!" );
373                 if( xDlgLibNameAccess.is() )
374                 {
375                     Sequence< ::rtl::OUString > aDlgNames = xDlgLibNameAccess->getElementNames();
376                     const ::rtl::OUString* pDlgNames = aDlgNames.getConstArray();
377                     sal_Int32 nDlgNameCount = aDlgNames.getLength();
378 
379                     for( sal_Int32 iDlg = 0 ; iDlg < nDlgNameCount ; iDlg++ )
380                     {
381                         Any aDlgAny = xDlgLibNameAccess->getByName( pDlgNames[ iDlg ] );
382                         if( aDlgAny == rDlgAny )
383                         {
384                             aRetDlgLibAny = aDlgLibAny;
385                             break;
386                         }
387                     }
388                 }
389             }
390         }
391     }
392 
393     return aRetDlgLibAny;
394 }
395 
implFindDialogLibForDialogBasic(const Any & aAnyISP,SbxObject * pBasic,StarBASIC * & pFoundBasic)396 Any implFindDialogLibForDialogBasic( const Any& aAnyISP, SbxObject* pBasic, StarBASIC*& pFoundBasic )
397 {
398     Any aDlgLibAny;
399     // Find dialog library for dialog, direct access is not possible here
400     StarBASIC* pStartedBasic = (StarBASIC*)pBasic;
401     SbxObject* pParentBasic = pStartedBasic ? pStartedBasic->GetParent() : NULL;
402     SbxObject* pParentParentBasic = pParentBasic ? pParentBasic->GetParent() : NULL;
403 
404     SbxObject* pSearchBasic1 = NULL;
405     SbxObject* pSearchBasic2 = NULL;
406     if( pParentParentBasic )
407     {
408         pSearchBasic1 = pParentBasic;
409         pSearchBasic2 = pParentParentBasic;
410     }
411     else
412     {
413         pSearchBasic1 = pStartedBasic;
414         pSearchBasic2 = pParentBasic;
415     }
416     if( pSearchBasic1 )
417     {
418         aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic1 );
419 
420         if ( aDlgLibAny.hasValue() )
421             pFoundBasic = (StarBASIC*)pSearchBasic1;
422 
423         else if( pSearchBasic2 )
424         {
425             aDlgLibAny = implFindDialogLibForDialog( aAnyISP, pSearchBasic2 );
426             if ( aDlgLibAny.hasValue() )
427                 pFoundBasic = (StarBASIC*)pSearchBasic2;
428         }
429     }
430     return aDlgLibAny;
431 }
432 
433 static ::rtl::OUString aDecorationPropName =
434     ::rtl::OUString::createFromAscii( "Decoration" );
435 static ::rtl::OUString aTitlePropName =
436     ::rtl::OUString::createFromAscii( "Title" );
437 
RTL_Impl_CreateUnoDialog(StarBASIC * pBasic,SbxArray & rPar,sal_Bool bWrite)438 void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
439 {
440     static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAscii( "ResourceResolver" );
441 
442     (void)pBasic;
443     (void)bWrite;
444 
445     Reference< XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory() );
446     if( !xMSF.is() )
447         return;
448 
449     // We need at least 1 parameter
450     if ( rPar.Count() < 2 )
451     {
452         StarBASIC::Error( SbERR_BAD_ARGUMENT );
453         return;
454     }
455 
456     // Get dialog
457     SbxBaseRef pObj = (SbxBase*)rPar.Get( 1 )->GetObject();
458     if( !(pObj && pObj->ISA(SbUnoObject)) )
459     {
460         StarBASIC::Error( SbERR_BAD_ARGUMENT );
461         return;
462     }
463     SbUnoObject* pUnoObj = (SbUnoObject*)(SbxBase*)pObj;
464     Any aAnyISP = pUnoObj->getUnoAny();
465     TypeClass eType = aAnyISP.getValueType().getTypeClass();
466 
467     if( eType != TypeClass_INTERFACE )
468     {
469         StarBASIC::Error( SbERR_BAD_ARGUMENT );
470         return;
471     }
472 
473     // Create new uno dialog
474     Reference< XNameContainer > xDialogModel( xMSF->createInstance
475         ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ),
476             UNO_QUERY );
477     if( !xDialogModel.is() )
478         return;
479 
480     Reference< XInputStreamProvider > xISP;
481     aAnyISP >>= xISP;
482     if( !xISP.is() )
483         return;
484 
485     Reference< XComponentContext > xContext;
486     Reference< XPropertySet > xProps( xMSF, UNO_QUERY );
487     OSL_ASSERT( xProps.is() );
488     OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext );
489 
490     // Import the DialogModel
491     Reference< XInputStream > xInput( xISP->createInputStream() );
492 
493     // i83963 Force decoration
494     uno::Reference< beans::XPropertySet > xDlgModPropSet( xDialogModel, uno::UNO_QUERY );
495     if( xDlgModPropSet.is() )
496     {
497         bool bDecoration = true;
498         try
499         {
500             Any aDecorationAny = xDlgModPropSet->getPropertyValue( aDecorationPropName );
501             aDecorationAny >>= bDecoration;
502             if( !bDecoration )
503             {
504                 xDlgModPropSet->setPropertyValue( aDecorationPropName, makeAny( true ) );
505                 xDlgModPropSet->setPropertyValue( aTitlePropName, makeAny( ::rtl::OUString() ) );
506             }
507         }
508         catch( UnknownPropertyException& )
509         {}
510     }
511 
512     Any aDlgLibAny;
513     bool bDocDialog = false;
514     StarBASIC* pFoundBasic = NULL;
515     OSL_TRACE("About to try get a hold of ThisComponent");
516     Reference< frame::XModel > xModel = StarBASIC::GetModelFromBasic( pINST->GetBasic() ) ;
517         aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pINST->GetBasic(), pFoundBasic );
518         // If we found the dialog then it belongs to the Search basic
519         if ( !pFoundBasic )
520     {
521             Reference< frame::XDesktop > xDesktop( xMSF->createInstance
522         ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ),
523             UNO_QUERY );
524             Reference< container::XEnumeration > xModels;
525             if ( xDesktop.is() )
526     {
527                 Reference< container::XEnumerationAccess > xComponents( xDesktop->getComponents(), UNO_QUERY );
528                 if ( xComponents.is() )
529                     xModels.set( xComponents->createEnumeration(), UNO_QUERY );
530                 if ( xModels.is() )
531                 {
532                     while ( xModels->hasMoreElements() )
533                     {
534                         Reference< frame::XModel > xNextModel( xModels->nextElement(), UNO_QUERY );
535                         if ( xNextModel.is() )
536                         {
537                             BasicManager* pMgr = basic::BasicManagerRepository::getDocumentBasicManager( xNextModel );
538                             if ( pMgr )
539                                 aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pMgr->GetLib(0), pFoundBasic );
540                             if ( aDlgLibAny.hasValue() )
541     {
542                                 bDocDialog = true;
543                                 xModel = xNextModel;
544                                 break;
545     }
546                         }
547                     }
548                 }
549             }
550         }
551     if ( pFoundBasic )
552         bDocDialog = pFoundBasic->IsDocBasic();
553        Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( pINST->GetBasic(), xModel );
554 
555     Sequence< Any > aArgs( 4 );
556     if( bDocDialog )
557        aArgs[ 0 ] <<= xModel;
558     else
559        aArgs[ 0 ] <<= uno::Reference< uno::XInterface >();
560     aArgs[ 1 ] <<= xInput;
561     aArgs[ 2 ] = aDlgLibAny;
562     aArgs[ 3 ] <<= xScriptListener;
563     // Create a "living" Dialog
564         Reference< XControl > xCntrl;
565         try
566         {
567         Reference< XDialogProvider >  xDlgProv( xMSF->createInstanceWithArguments( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.scripting.DialogProvider" ) ), aArgs ), UNO_QUERY );
568             xCntrl.set( xDlgProv->createDialog( rtl::OUString() ), UNO_QUERY_THROW );
569            // Add dialog model to dispose vector
570            Reference< XComponent > xDlgComponent( xCntrl->getModel(), UNO_QUERY );
571            pINST->getComponentVector().push_back( xDlgComponent );
572            // need ThisCompoent from calling script
573         }
574         // preserve existing bad behaviour, it's possible... but probably
575         // illegal to open 2 dialogs ( they ARE modal ) when this happens, sometimes
576         // create dialog fails.  So, in this case let's not throw, just leave basic
577         // detect the unset object.
578         catch( uno::Exception& )
579         {
580         }
581 
582     // Return dialog
583     Any aRetVal;
584     aRetVal <<= xCntrl;
585     SbxVariableRef refVar = rPar.Get(0);
586     unoToSbxValue( (SbxVariable*)refVar, aRetVal );
587 }
588 
589 
590 //===================================================================
591