LCOV - code coverage report
Current view: top level - basic/source/classes - eventatt.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 240 0.0 %
Date: 2014-11-03 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             : 
      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             :     virtual 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 :     firing_impl( aScriptEvent, NULL );
     165           0 : }
     166             : 
     167           0 : Any BasicScriptListener_Impl::approveFiring( const ScriptEvent& aScriptEvent )
     168             :     throw ( InvocationTargetException, RuntimeException, std::exception )
     169             : {
     170           0 :     Any aRetAny;
     171           0 :     firing_impl( aScriptEvent, &aRetAny );
     172           0 :     return aRetAny;
     173             : }
     174             : 
     175             : // Methods XEventListener
     176           0 : void BasicScriptListener_Impl::disposing(const EventObject& ) throw ( RuntimeException, std::exception )
     177             : {
     178             :     // TODO: ???
     179             :     //SolarMutexGuard aGuard;
     180             :     //xSbxObj.Clear();
     181           0 : }
     182             : 
     183             : 
     184           0 : void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet )
     185             : {
     186           0 :     if( aScriptEvent.ScriptType.equalsAscii( "StarBasic" ) )
     187             :     {
     188             :         // Full qualified name?
     189           0 :         OUString aMacro( aScriptEvent.ScriptCode );
     190           0 :         OUString aLibName;
     191           0 :         OUString aLocation;
     192           0 :         if( comphelper::string::getTokenCount(aMacro, '.') == 3 )
     193             :         {
     194           0 :             sal_Int32 nLast = 0;
     195           0 :             OUString aFullLibName = aMacro.getToken( (sal_Int32)0, (sal_Unicode)'.', nLast );
     196             : 
     197           0 :             sal_Int32 nIndex = aFullLibName.indexOf( (sal_Unicode)':' );
     198           0 :             if (nIndex >= 0)
     199             :             {
     200           0 :                 aLocation = aFullLibName.copy( 0, nIndex );
     201           0 :                 aLibName = aFullLibName.copy( nIndex + 1 );
     202             :             }
     203             : 
     204           0 :             aMacro = aMacro.copy( nLast );
     205             :         }
     206             : 
     207           0 :         SbxObject* p = maBasicRef;
     208           0 :         SbxObject* pParent = p->GetParent();
     209           0 :         SbxObject* pParentParent = pParent ? pParent->GetParent() : NULL;
     210             : 
     211           0 :         StarBASICRef xAppStandardBasic;
     212           0 :         StarBASICRef xDocStandardBasic;
     213           0 :         if( pParentParent )
     214             :         {
     215             :             // Own basic must be document library
     216           0 :             xAppStandardBasic = static_cast<StarBASIC*>(pParentParent);
     217           0 :             xDocStandardBasic = static_cast<StarBASIC*>(pParent);
     218             :         }
     219           0 :         else if( pParent )
     220             :         {
     221           0 :             OUString aName = p->GetName();
     222           0 :             if( aName.equalsAscii("Standard") )
     223             :             {
     224             :                 // Own basic is doc standard lib
     225           0 :                 xDocStandardBasic = static_cast<StarBASIC*>(p);
     226             :             }
     227           0 :             xAppStandardBasic = static_cast<StarBASIC*>(pParent);
     228             :         }
     229             :         else
     230             :         {
     231           0 :             xAppStandardBasic = static_cast<StarBASIC*>(p);
     232             :         }
     233             : 
     234           0 :         bool bSearchLib = true;
     235           0 :         StarBASICRef xLibSearchBasic;
     236           0 :         if( aLocation.equalsAscii("application") )
     237             :         {
     238           0 :             xLibSearchBasic = xAppStandardBasic;
     239             :         }
     240           0 :         else if( aLocation.equalsAscii("document") )
     241             :         {
     242           0 :             xLibSearchBasic = xDocStandardBasic;
     243             :         }
     244             :         else
     245             :         {
     246           0 :             bSearchLib = false;
     247             :         }
     248           0 :         SbxVariable* pMethVar = NULL;
     249             :         // Be still tolerant and make default search if no search basic exists
     250           0 :         if( bSearchLib && xLibSearchBasic.Is() )
     251             :         {
     252           0 :             StarBASICRef xLibBasic;
     253           0 :             sal_Int16 nCount = xLibSearchBasic->GetObjects()->Count();
     254           0 :             for( sal_Int16 nObj = -1; nObj < nCount ; nObj++ )
     255             :             {
     256             :                 StarBASIC* pBasic;
     257           0 :                 if( nObj == -1 )
     258             :                 {
     259           0 :                     pBasic = (StarBASIC*)xLibSearchBasic;
     260             :                 }
     261             :                 else
     262             :                 {
     263           0 :                     SbxVariable* pVar = xLibSearchBasic->GetObjects()->Get( nObj );
     264           0 :                     pBasic = PTR_CAST(StarBASIC,pVar);
     265             :                 }
     266           0 :                 if( pBasic )
     267             :                 {
     268           0 :                     OUString aName = pBasic->GetName();
     269           0 :                     if( aName == aLibName )
     270             :                     {
     271             :                         // Search only in the lib, not automatically in application basic
     272           0 :                         SbxFlagBits nFlags = pBasic->GetFlags();
     273           0 :                         pBasic->ResetFlag( SBX_GBLSEARCH );
     274           0 :                         pMethVar = pBasic->Find( aMacro, SbxCLASS_DONTCARE );
     275           0 :                         pBasic->SetFlags( nFlags );
     276           0 :                         break;
     277           0 :                     }
     278             :                 }
     279           0 :             }
     280             :         }
     281             : 
     282             :         // Default: Be tolerant and search everywhere
     283           0 :         if( (!pMethVar || !pMethVar->ISA(SbMethod)) && maBasicRef.Is() )
     284             :         {
     285           0 :             pMethVar = maBasicRef->FindQualified( aMacro, SbxCLASS_DONTCARE );
     286             :         }
     287           0 :         SbMethod* pMeth = PTR_CAST(SbMethod,pMethVar);
     288           0 :         if( !pMeth )
     289             :         {
     290           0 :             return;
     291             :         }
     292             :         // Setup parameters
     293           0 :         SbxArrayRef xArray;
     294           0 :         sal_Int32 nCnt = aScriptEvent.Arguments.getLength();
     295           0 :         if( nCnt )
     296             :         {
     297           0 :             xArray = new SbxArray;
     298           0 :             const Any *pArgs = aScriptEvent.Arguments.getConstArray();
     299           0 :             for( sal_Int32 i = 0; i < nCnt; i++ )
     300             :             {
     301           0 :                 SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
     302           0 :                 unoToSbxValue( (SbxVariable*)xVar, pArgs[i] );
     303           0 :                 xArray->Put( xVar, sal::static_int_cast< sal_uInt16 >(i+1) );
     304           0 :             }
     305             :         }
     306             : 
     307             :         // Call method
     308           0 :         SbxVariableRef xValue = pRet ? new SbxVariable : 0;
     309           0 :         if( xArray.Is() )
     310             :         {
     311           0 :             pMeth->SetParameters( xArray );
     312             :         }
     313           0 :         pMeth->Call( xValue );
     314           0 :         if( pRet )
     315             :         {
     316           0 :             *pRet = sbxToUnoValue( xValue );
     317             :         }
     318           0 :         pMeth->SetParameters( NULL );
     319             :     }
     320             :     else // scripting framework script
     321             :     {
     322             :         //callBasic via scripting framework
     323           0 :         SFURL_firing_impl( aScriptEvent, pRet, m_xModel );
     324             :     }
     325             : }
     326             : 
     327           0 : css::uno::Reference< css::container::XNameContainer > implFindDialogLibForDialog( const Any& rDlgAny, SbxObject* pBasic )
     328             : {
     329           0 :     css::uno::Reference< css::container::XNameContainer > aRetDlgLib;
     330             : 
     331           0 :     SbxVariable* pDlgLibContVar = pBasic->Find(OUString("DialogLibraries"), SbxCLASS_OBJECT);
     332           0 :     if( pDlgLibContVar && pDlgLibContVar->ISA(SbUnoObject) )
     333             :     {
     334           0 :         SbUnoObject* pDlgLibContUnoObj = static_cast<SbUnoObject*>((SbxBase*)pDlgLibContVar);
     335           0 :         Any aDlgLibContAny = pDlgLibContUnoObj->getUnoAny();
     336             : 
     337           0 :         Reference< XLibraryContainer > xDlgLibContNameAccess( aDlgLibContAny, UNO_QUERY );
     338             :         OSL_ENSURE( xDlgLibContNameAccess.is(), "implFindDialogLibForDialog: no lib container for the given dialog!" );
     339           0 :         if( xDlgLibContNameAccess.is() )
     340             :         {
     341           0 :             Sequence< OUString > aLibNames = xDlgLibContNameAccess->getElementNames();
     342           0 :             const OUString* pLibNames = aLibNames.getConstArray();
     343           0 :             sal_Int32 nLibNameCount = aLibNames.getLength();
     344             : 
     345           0 :             for( sal_Int32 iLib = 0 ; iLib < nLibNameCount ; iLib++ )
     346             :             {
     347           0 :                 if ( !xDlgLibContNameAccess->isLibraryLoaded( pLibNames[ iLib ] ) )
     348             :                     // if the library isn't loaded, then the dialog cannot originate from this lib
     349           0 :                     continue;
     350             : 
     351           0 :                 Any aDlgLibAny = xDlgLibContNameAccess->getByName( pLibNames[ iLib ] );
     352             : 
     353           0 :                 Reference< XNameContainer > xDlgLibNameCont( aDlgLibAny, UNO_QUERY );
     354             :                 OSL_ENSURE( xDlgLibNameCont.is(), "implFindDialogLibForDialog: invalid dialog lib!" );
     355           0 :                 if( xDlgLibNameCont.is() )
     356             :                 {
     357           0 :                     Sequence< OUString > aDlgNames = xDlgLibNameCont->getElementNames();
     358           0 :                     const OUString* pDlgNames = aDlgNames.getConstArray();
     359           0 :                     sal_Int32 nDlgNameCount = aDlgNames.getLength();
     360             : 
     361           0 :                     for( sal_Int32 iDlg = 0 ; iDlg < nDlgNameCount ; iDlg++ )
     362             :                     {
     363           0 :                         Any aDlgAny = xDlgLibNameCont->getByName( pDlgNames[ iDlg ] );
     364           0 :                         if( aDlgAny == rDlgAny )
     365             :                         {
     366           0 :                             aRetDlgLib = xDlgLibNameCont;
     367           0 :                             break;
     368             :                         }
     369           0 :                     }
     370             :                 }
     371           0 :             }
     372           0 :         }
     373             :     }
     374             : 
     375           0 :     return aRetDlgLib;
     376             : }
     377             : 
     378           0 : css::uno::Reference< css::container::XNameContainer > implFindDialogLibForDialogBasic( const Any& aAnyISP, SbxObject* pBasic, StarBASIC*& pFoundBasic )
     379             : {
     380           0 :     css::uno::Reference< css::container::XNameContainer > aDlgLib;
     381             :     // Find dialog library for dialog, direct access is not possible here
     382           0 :     StarBASIC* pStartedBasic = static_cast<StarBASIC*>(pBasic);
     383           0 :     SbxObject* pParentBasic = pStartedBasic ? pStartedBasic->GetParent() : NULL;
     384           0 :     SbxObject* pParentParentBasic = pParentBasic ? pParentBasic->GetParent() : NULL;
     385             : 
     386           0 :     SbxObject* pSearchBasic1 = NULL;
     387           0 :     SbxObject* pSearchBasic2 = NULL;
     388           0 :     if( pParentParentBasic )
     389             :     {
     390           0 :         pSearchBasic1 = pParentBasic;
     391           0 :         pSearchBasic2 = pParentParentBasic;
     392             :     }
     393             :     else
     394             :     {
     395           0 :         pSearchBasic1 = pStartedBasic;
     396           0 :         pSearchBasic2 = pParentBasic;
     397             :     }
     398           0 :     if( pSearchBasic1 )
     399             :     {
     400           0 :         aDlgLib = implFindDialogLibForDialog( aAnyISP, pSearchBasic1 );
     401             : 
     402           0 :         if ( aDlgLib.is() )
     403           0 :             pFoundBasic = static_cast<StarBASIC*>(pSearchBasic1);
     404             : 
     405           0 :         else if( pSearchBasic2 )
     406             :         {
     407           0 :             aDlgLib = implFindDialogLibForDialog( aAnyISP, pSearchBasic2 );
     408           0 :             if ( aDlgLib.is() )
     409           0 :                 pFoundBasic = static_cast<StarBASIC*>(pSearchBasic2);
     410             :         }
     411             :     }
     412           0 :     return aDlgLib;
     413             : }
     414             : 
     415           0 : void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, bool bWrite )
     416             : {
     417             :     (void)pBasic;
     418             :     (void)bWrite;
     419             : 
     420           0 :     Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
     421             : 
     422             :     // We need at least 1 parameter
     423           0 :     if ( rPar.Count() < 2 )
     424             :     {
     425           0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
     426           0 :         return;
     427             :     }
     428             : 
     429             :     // Get dialog
     430           0 :     SbxBaseRef pObj = (SbxBase*)rPar.Get( 1 )->GetObject();
     431           0 :     if( !(pObj && pObj->ISA(SbUnoObject)) )
     432             :     {
     433           0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
     434           0 :         return;
     435             :     }
     436           0 :     SbUnoObject* pUnoObj = static_cast<SbUnoObject*>((SbxBase*)pObj);
     437           0 :     Any aAnyISP = pUnoObj->getUnoAny();
     438           0 :     TypeClass eType = aAnyISP.getValueType().getTypeClass();
     439             : 
     440           0 :     if( eType != TypeClass_INTERFACE )
     441             :     {
     442           0 :         StarBASIC::Error( SbERR_BAD_ARGUMENT );
     443           0 :         return;
     444             :     }
     445             : 
     446             :     // Create new uno dialog
     447           0 :     Reference< XNameContainer > xDialogModel( xContext->getServiceManager()->createInstanceWithContext(
     448           0 :                       "com.sun.star.awt.UnoControlDialogModel", xContext), UNO_QUERY );
     449           0 :     if( !xDialogModel.is() )
     450             :     {
     451           0 :         return;
     452             :     }
     453           0 :     Reference< XInputStreamProvider > xISP;
     454           0 :     aAnyISP >>= xISP;
     455           0 :     if( !xISP.is() )
     456             :     {
     457           0 :         return;
     458             :     }
     459             : 
     460             :     // Import the DialogModel
     461           0 :     Reference< XInputStream > xInput( xISP->createInputStream() );
     462             : 
     463             :     // i83963 Force decoration
     464           0 :     uno::Reference< beans::XPropertySet > xDlgModPropSet( xDialogModel, uno::UNO_QUERY );
     465           0 :     if( xDlgModPropSet.is() )
     466             :     {
     467           0 :         bool bDecoration = true;
     468             :         try
     469             :         {
     470           0 :             OUString aDecorationPropName("Decoration");
     471           0 :             Any aDecorationAny = xDlgModPropSet->getPropertyValue( aDecorationPropName );
     472           0 :             aDecorationAny >>= bDecoration;
     473           0 :             if( !bDecoration )
     474             :             {
     475           0 :                 xDlgModPropSet->setPropertyValue( aDecorationPropName, makeAny( true ) );
     476             : 
     477           0 :                 OUString aTitlePropName("Title");
     478           0 :                 xDlgModPropSet->setPropertyValue( aTitlePropName, makeAny( OUString() ) );
     479           0 :             }
     480             :         }
     481           0 :         catch(const UnknownPropertyException& )
     482             :         {}
     483             :     }
     484             : 
     485           0 :     css::uno::Reference< css::container::XNameContainer > aDlgLib;
     486           0 :     bool bDocDialog = false;
     487           0 :     StarBASIC* pFoundBasic = NULL;
     488             :     SAL_INFO("basic", "About to try get a hold of ThisComponent");
     489           0 :     Reference< frame::XModel > xModel = StarBASIC::GetModelFromBasic( GetSbData()->pInst->GetBasic() ) ;
     490           0 :     aDlgLib = implFindDialogLibForDialogBasic( aAnyISP, GetSbData()->pInst->GetBasic(), pFoundBasic );
     491             :     // If we found the dialog then it belongs to the Search basic
     492           0 :     if ( !pFoundBasic )
     493             :     {
     494           0 :         Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create( xContext );
     495           0 :         Reference< container::XEnumeration > xModels;
     496           0 :         Reference< container::XEnumerationAccess > xComponents( xDesktop->getComponents(), UNO_QUERY );
     497           0 :         if ( xComponents.is() )
     498             :         {
     499           0 :             xModels.set( xComponents->createEnumeration(), UNO_QUERY );
     500             :         }
     501           0 :         if ( xModels.is() )
     502             :         {
     503           0 :             while ( xModels->hasMoreElements() )
     504             :             {
     505           0 :                 Reference< frame::XModel > xNextModel( xModels->nextElement(), UNO_QUERY );
     506           0 :                 if ( xNextModel.is() )
     507             :                 {
     508           0 :                     BasicManager* pMgr = basic::BasicManagerRepository::getDocumentBasicManager( xNextModel );
     509           0 :                     if ( pMgr )
     510             :                     {
     511           0 :                         aDlgLib = implFindDialogLibForDialogBasic( aAnyISP, pMgr->GetLib(0), pFoundBasic );
     512             :                     }
     513           0 :                     if ( aDlgLib.is() )
     514             :                     {
     515           0 :                         bDocDialog = true;
     516           0 :                         xModel = xNextModel;
     517           0 :                         break;
     518             :                     }
     519             :                 }
     520           0 :             }
     521           0 :         }
     522             :     }
     523           0 :     if ( pFoundBasic )
     524             :     {
     525           0 :         bDocDialog = pFoundBasic->IsDocBasic();
     526             :     }
     527           0 :     Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( GetSbData()->pInst->GetBasic(), xModel );
     528             : 
     529             :     // Create a "living" Dialog
     530           0 :     Reference< XControl > xCntrl;
     531             :     try
     532             :     {
     533           0 :        Reference< XDialogProvider >  xDlgProv;;
     534           0 :        if( bDocDialog )
     535           0 :            xDlgProv = css::awt::DialogProvider::createWithModelAndScripting( xContext, xModel, xInput, aDlgLib, xScriptListener );
     536             :        else
     537           0 :            xDlgProv = css::awt::DialogProvider::createWithModelAndScripting( xContext, uno::Reference< frame::XModel >(), xInput, aDlgLib, xScriptListener );
     538             : 
     539           0 :        xCntrl.set( xDlgProv->createDialog(OUString() ), UNO_QUERY_THROW );
     540             :        // Add dialog model to dispose vector
     541           0 :        Reference< XComponent > xDlgComponent( xCntrl->getModel(), UNO_QUERY );
     542           0 :        GetSbData()->pInst->getComponentVector().push_back( xDlgComponent );
     543             :        // need ThisCompoent from calling script
     544             :     }
     545             :     // preserve existing bad behaviour, it's possible... but probably
     546             :     // illegal to open 2 dialogs ( they ARE modal ) when this happens, sometimes
     547             :     // create dialog fails.  So, in this case let's not throw, just leave basic
     548             :     // detect the unset object.
     549           0 :     catch(const uno::Exception& )
     550             :     {
     551             :     }
     552             : 
     553             :     // Return dialog
     554           0 :     Any aRetVal;
     555           0 :     aRetVal <<= xCntrl;
     556           0 :     SbxVariableRef refVar = rPar.Get(0);
     557           0 :     unoToSbxValue( (SbxVariable*)refVar, aRetVal );
     558             : }
     559             : 
     560             : 
     561             : 
     562             : 
     563             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10