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

Generated by: LCOV version 1.10