LCOV - code coverage report
Current view: top level - basic/source/classes - eventatt.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 242 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11