diff options
Diffstat (limited to 'scripting/source/basprov')
-rw-r--r-- | scripting/source/basprov/baslibnode.cxx | 13 | ||||
-rw-r--r-- | scripting/source/basprov/baslibnode.hxx | 3 | ||||
-rw-r--r-- | scripting/source/basprov/basmethnode.cxx | 41 | ||||
-rw-r--r-- | scripting/source/basprov/basmethnode.hxx | 3 | ||||
-rw-r--r-- | scripting/source/basprov/basmodnode.cxx | 13 | ||||
-rw-r--r-- | scripting/source/basprov/basmodnode.hxx | 3 | ||||
-rw-r--r-- | scripting/source/basprov/basprov.cxx | 102 | ||||
-rw-r--r-- | scripting/source/basprov/basprov.hxx | 3 | ||||
-rw-r--r-- | scripting/source/basprov/basscript.cxx | 93 | ||||
-rw-r--r-- | scripting/source/basprov/basscript.hxx | 29 |
10 files changed, 213 insertions, 90 deletions
diff --git a/scripting/source/basprov/baslibnode.cxx b/scripting/source/basprov/baslibnode.cxx index 0df822404d..1e805bce43 100644 --- a/scripting/source/basprov/baslibnode.cxx +++ b/scripting/source/basprov/baslibnode.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,7 +31,7 @@ #include "baslibnode.hxx" #include "basmodnode.hxx" #include <com/sun/star/script/browse/BrowseNodeTypes.hpp> -#include <vos/mutex.hxx> +#include <osl/mutex.hxx> #include <vcl/svapp.hxx> #include <basic/basmgr.hxx> #include <basic/sbstar.hxx> @@ -80,7 +81,7 @@ namespace basprov ::rtl::OUString BasicLibraryNodeImpl::getName( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; return m_sLibName; } @@ -89,7 +90,7 @@ namespace basprov Sequence< Reference< browse::XBrowseNode > > BasicLibraryNodeImpl::getChildNodes( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; Sequence< Reference< browse::XBrowseNode > > aChildNodes; @@ -123,7 +124,7 @@ namespace basprov sal_Bool BasicLibraryNodeImpl::hasChildNodes( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; sal_Bool bReturn = sal_False; if ( m_xLibrary.is() ) @@ -136,7 +137,7 @@ namespace basprov sal_Int16 BasicLibraryNodeImpl::getType( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; return browse::BrowseNodeTypes::CONTAINER; } @@ -146,3 +147,5 @@ namespace basprov //......................................................................... } // namespace basprov //......................................................................... + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scripting/source/basprov/baslibnode.hxx b/scripting/source/basprov/baslibnode.hxx index fb74315660..1e9b8167bd 100644 --- a/scripting/source/basprov/baslibnode.hxx +++ b/scripting/source/basprov/baslibnode.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -85,3 +86,5 @@ namespace basprov //......................................................................... #endif // SCRIPTING_BASLIBNODE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scripting/source/basprov/basmethnode.cxx b/scripting/source/basprov/basmethnode.cxx index 49e85cceca..2638a3cc30 100644 --- a/scripting/source/basprov/basmethnode.cxx +++ b/scripting/source/basprov/basmethnode.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,7 +35,7 @@ #include <com/sun/star/frame/XDispatchProvider.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/script/browse/BrowseNodeTypes.hpp> -#include <vos/mutex.hxx> +#include <osl/mutex.hxx> #include <vcl/svapp.hxx> #include <basic/sbstar.hxx> #include <basic/sbmeth.hxx> @@ -86,17 +87,17 @@ namespace basprov StarBASIC* pBasic = static_cast< StarBASIC* >( pModule->GetParent() ); if ( pBasic ) { - m_sURI = ::rtl::OUString::createFromAscii( "vnd.sun.star.script:" ); + m_sURI = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.script:")); m_sURI += pBasic->GetName(); - m_sURI += ::rtl::OUString::createFromAscii( "." ); + m_sURI += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")); m_sURI += pModule->GetName(); - m_sURI += ::rtl::OUString::createFromAscii( "." ); + m_sURI += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")); m_sURI += m_pMethod->GetName(); - m_sURI += ::rtl::OUString::createFromAscii( "?language=Basic&location=" ); + m_sURI += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("?language=Basic&location=")); if ( m_bIsAppScript ) - m_sURI += ::rtl::OUString::createFromAscii( "application" ); + m_sURI += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application")); else - m_sURI += ::rtl::OUString::createFromAscii( "document" ); + m_sURI += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("document")); } } } @@ -129,7 +130,7 @@ namespace basprov ::rtl::OUString BasicMethodNodeImpl::getName( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; ::rtl::OUString sMethodName; if ( m_pMethod ) @@ -142,7 +143,7 @@ namespace basprov Sequence< Reference< browse::XBrowseNode > > BasicMethodNodeImpl::getChildNodes( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; return Sequence< Reference< browse::XBrowseNode > >(); } @@ -151,7 +152,7 @@ namespace basprov sal_Bool BasicMethodNodeImpl::hasChildNodes( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; return sal_False; } @@ -160,7 +161,7 @@ namespace basprov sal_Int16 BasicMethodNodeImpl::getType( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; return browse::BrowseNodeTypes::SCRIPT; } @@ -235,7 +236,7 @@ namespace basprov for ( sal_Int32 i = 0; i < nProps; ++i ) { // TODO: according to MBA the property 'Title' may change in future - if ( pProps[i].Name == ::rtl::OUString::createFromAscii( "Title" ) ) + if ( pProps[i].Name == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Title")) ) { pProps[i].Value >>= sDocURL; break; @@ -279,17 +280,17 @@ namespace basprov if ( xHelper.is() ) { Sequence < PropertyValue > aArgs(7); - aArgs[0].Name = ::rtl::OUString::createFromAscii( "Document" ); + aArgs[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Document")); aArgs[0].Value <<= sDocURL; - aArgs[1].Name = ::rtl::OUString::createFromAscii( "LibName" ); + aArgs[1].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LibName")); aArgs[1].Value <<= sLibName; - aArgs[2].Name = ::rtl::OUString::createFromAscii( "Name" ); + aArgs[2].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")); aArgs[2].Value <<= sModName; - aArgs[3].Name = ::rtl::OUString::createFromAscii( "Type" ); - aArgs[3].Value <<= ::rtl::OUString::createFromAscii( "Module" ); - aArgs[4].Name = ::rtl::OUString::createFromAscii( "Line" ); + aArgs[3].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type")); + aArgs[3].Value <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Module")); + aArgs[4].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Line")); aArgs[4].Value <<= static_cast< sal_uInt32 >( nLine1 ); - xHelper->executeDispatch( xProv, ::rtl::OUString::createFromAscii( ".uno:BasicIDEAppear" ), ::rtl::OUString(), 0, aArgs ); + xHelper->executeDispatch( xProv, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".uno:BasicIDEAppear")), ::rtl::OUString(), 0, aArgs ); } } } @@ -356,3 +357,5 @@ namespace basprov //......................................................................... } // namespace basprov //......................................................................... + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scripting/source/basprov/basmethnode.hxx b/scripting/source/basprov/basmethnode.hxx index 0ef02816dc..298447c2a8 100644 --- a/scripting/source/basprov/basmethnode.hxx +++ b/scripting/source/basprov/basmethnode.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -130,3 +131,5 @@ namespace basprov //......................................................................... #endif // SCRIPTING_BASMETHNODE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scripting/source/basprov/basmodnode.cxx b/scripting/source/basprov/basmodnode.cxx index f56bc33519..0a68d53228 100644 --- a/scripting/source/basprov/basmodnode.cxx +++ b/scripting/source/basprov/basmodnode.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,7 +31,7 @@ #include "basmodnode.hxx" #include "basmethnode.hxx" #include <com/sun/star/script/browse/BrowseNodeTypes.hpp> -#include <vos/mutex.hxx> +#include <osl/mutex.hxx> #include <vcl/svapp.hxx> #include <basic/sbx.hxx> #include <basic/sbstar.hxx> @@ -74,7 +75,7 @@ namespace basprov ::rtl::OUString BasicModuleNodeImpl::getName( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; ::rtl::OUString sModuleName; if ( m_pModule ) @@ -87,7 +88,7 @@ namespace basprov Sequence< Reference< browse::XBrowseNode > > BasicModuleNodeImpl::getChildNodes( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; Sequence< Reference< browse::XBrowseNode > > aChildNodes; @@ -124,7 +125,7 @@ namespace basprov sal_Bool BasicModuleNodeImpl::hasChildNodes( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; sal_Bool bReturn = sal_False; if ( m_pModule ) @@ -141,7 +142,7 @@ namespace basprov sal_Int16 BasicModuleNodeImpl::getType( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; return browse::BrowseNodeTypes::CONTAINER; } @@ -151,3 +152,5 @@ namespace basprov //......................................................................... } // namespace basprov //......................................................................... + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scripting/source/basprov/basmodnode.hxx b/scripting/source/basprov/basmodnode.hxx index 5b2e50b124..7dcfd964ed 100644 --- a/scripting/source/basprov/basmodnode.hxx +++ b/scripting/source/basprov/basmodnode.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -79,3 +80,5 @@ namespace basprov //......................................................................... #endif // SCRIPTING_BASMODNODE_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx index 1cc4b2a889..9341850440 100644 --- a/scripting/source/basprov/basprov.cxx +++ b/scripting/source/basprov/basprov.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -35,13 +36,11 @@ #include <com/sun/star/script/provider/ScriptFrameworkErrorType.hpp> #include <com/sun/star/document/XEmbeddedScripts.hpp> -#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ #include <cppuhelper/implementationentry.hxx> -#endif #include <rtl/uri.hxx> #include <osl/process.h> #include <osl/file.hxx> -#include <vos/mutex.hxx> +#include <osl/mutex.hxx> #include <vcl/svapp.hxx> #include <basic/sbx.hxx> #include <basic/basmgr.hxx> @@ -151,12 +150,12 @@ namespace basprov Reference< lang::XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() ); if ( xSMgr.is() ) { - xUriFac.set( xSMgr->createInstanceWithContext( ::rtl::OUString::createFromAscii( - "com.sun.star.uri.UriReferenceFactory" ), m_xContext ), UNO_QUERY ); + xUriFac.set( xSMgr->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.uri.UriReferenceFactory" )), m_xContext ), UNO_QUERY ); } if ( xUriFac.is() ) - { + { ::rtl::OUString aLinkURL( xLibContainer->getLibraryLinkURL( rLibName ) ); Reference< uri::XUriReference > xUriRef( xUriFac->parse( aLinkURL ), UNO_QUERY ); @@ -174,10 +173,10 @@ namespace basprov { ::rtl::OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) ); aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); - Reference<util::XMacroExpander> xMacroExpander( - m_xContext->getValueByName( - ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ), - UNO_QUERY ); + Reference<util::XMacroExpander> xMacroExpander( + m_xContext->getValueByName( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.util.theMacroExpander")) ), + UNO_QUERY ); if ( xMacroExpander.is() ) aFileURL = xMacroExpander->expandMacros( aDecodedURL ); } @@ -196,7 +195,7 @@ namespace basprov ::rtl::OUString aSearchURL1( RTL_CONSTASCII_USTRINGPARAM( "share/basic" ) ); ::rtl::OUString aSearchURL2( RTL_CONSTASCII_USTRINGPARAM( "share/uno_packages" ) ); - if( aCanonicalFileURL.indexOf( aSearchURL1 ) != -1 || aCanonicalFileURL.indexOf( aSearchURL2 ) != -1 ) + if( aCanonicalFileURL.indexOf( aSearchURL1 ) != -1 || aCanonicalFileURL.indexOf( aSearchURL2 ) != -1 ) bIsShared = true; } } @@ -241,7 +240,7 @@ namespace basprov { // TODO - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; if ( aArguments.getLength() != 1 ) { @@ -329,18 +328,18 @@ namespace basprov // XScriptProvider // ----------------------------------------------------------------------------- - Reference < provider::XScript > BasicProviderImpl::getScript( const ::rtl::OUString& scriptURI ) + Reference < provider::XScript > BasicProviderImpl::getScript( const ::rtl::OUString& scriptURI ) throw ( provider::ScriptFrameworkErrorException, RuntimeException) { // TODO - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; Reference< provider::XScript > xScript; Reference< lang::XMultiComponentFactory > xMcFac ( m_xContext->getServiceManager() ); Reference< uri::XUriReferenceFactory > xFac ( - xMcFac->createInstanceWithContext( rtl::OUString::createFromAscii( - "com.sun.star.uri.UriReferenceFactory"), m_xContext ) , UNO_QUERY ); + xMcFac->createInstanceWithContext( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.uri.UriReferenceFactory")), m_xContext ) , UNO_QUERY ); if ( !xFac.is() ) { @@ -349,7 +348,7 @@ namespace basprov scriptURI, OUSTR("Basic"), provider::ScriptFrameworkErrorType::UNKNOWN ); } - + Reference< uri::XUriReference > uriRef( xFac->parse( scriptURI ), UNO_QUERY ); @@ -357,7 +356,7 @@ namespace basprov if ( !uriRef.is() || !sfUri.is() ) { - ::rtl::OUString errorMsg = ::rtl::OUString::createFromAscii( "BasicProviderImpl::getScript: failed to parse URI: " ); + ::rtl::OUString errorMsg(RTL_CONSTASCII_USTRINGPARAM("BasicProviderImpl::getScript: failed to parse URI: ")); errorMsg = errorMsg.concat( scriptURI ); throw provider::ScriptFrameworkErrorException( errorMsg, Reference< XInterface >(), @@ -365,13 +364,39 @@ namespace basprov provider::ScriptFrameworkErrorType::MALFORMED_URL ); } - + ::rtl::OUString aDescription = sfUri->getName(); - ::rtl::OUString aLocation = sfUri->getParameter( - ::rtl::OUString::createFromAscii( "location" ) ); + ::rtl::OUString aLocation = sfUri->getParameter( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("location")) ); sal_Int32 nIndex = 0; - ::rtl::OUString aLibrary = aDescription.getToken( 0, (sal_Unicode)'.', nIndex ); + // In some strange circumstances the Library name can have an + // apparantly illegal '.' in it ( in imported VBA ) + + BasicManager* pBasicMgr = NULL; + if ( aLocation.equals( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("document")) ) ) + { + pBasicMgr = m_pDocBasicManager; + } + else if ( aLocation.equals( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("application")) ) ) + { + pBasicMgr = m_pAppBasicManager; + } + rtl::OUString sProjectName; + if ( pBasicMgr ) + sProjectName = pBasicMgr->GetName(); + + ::rtl::OUString aLibrary; + if ( sProjectName.getLength() && aDescription.match( sProjectName ) ) + { + OSL_TRACE("LibraryName %s is part of the url %s", + rtl::OUStringToOString( sProjectName, RTL_TEXTENCODING_UTF8 ).getStr(), + rtl::OUStringToOString( aDescription, RTL_TEXTENCODING_UTF8 ).getStr() ); + aLibrary = sProjectName; + nIndex = sProjectName.getLength() + 1; + } + else + aLibrary = aDescription.getToken( 0, (sal_Unicode)'.', nIndex ); ::rtl::OUString aModule; if ( nIndex != -1 ) aModule = aDescription.getToken( 0, (sal_Unicode)'.', nIndex ); @@ -381,15 +406,6 @@ namespace basprov if ( aLibrary.getLength() != 0 && aModule.getLength() != 0 && aMethod.getLength() != 0 && aLocation.getLength() != 0 ) { - BasicManager* pBasicMgr = NULL; - if ( aLocation.equals( ::rtl::OUString::createFromAscii("document") ) ) - { - pBasicMgr = m_pDocBasicManager; - } - else if ( aLocation.equals( ::rtl::OUString::createFromAscii("application") ) ) - { - pBasicMgr = m_pAppBasicManager; - } if ( pBasicMgr ) { @@ -451,23 +467,23 @@ namespace basprov { // TODO - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; - return ::rtl::OUString::createFromAscii( "Basic" ); + return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Basic")); } // ----------------------------------------------------------------------------- Sequence< Reference< browse::XBrowseNode > > BasicProviderImpl::getChildNodes( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; Reference< script::XLibraryContainer > xLibContainer; BasicManager* pBasicManager = NULL; if ( m_bIsAppScriptCtx ) { - xLibContainer = m_xLibContainerApp; + xLibContainer = m_xLibContainerApp; pBasicManager = m_pAppBasicManager; } else @@ -476,7 +492,7 @@ namespace basprov pBasicManager = m_pDocBasicManager; } - Sequence< Reference< browse::XBrowseNode > > aChildNodes; + Sequence< Reference< browse::XBrowseNode > > aChildNodes; if ( pBasicManager && xLibContainer.is() ) { @@ -502,7 +518,7 @@ namespace basprov } if ( bCreate ) { - pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( + pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( m_xContext, m_sScriptingContext, pBasicManager, xLibContainer, pLibNames[i], m_bIsAppScriptCtx ) ); } } @@ -518,13 +534,13 @@ namespace basprov sal_Bool BasicProviderImpl::hasChildNodes( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; sal_Bool bReturn = sal_False; Reference< script::XLibraryContainer > xLibContainer; if ( m_bIsAppScriptCtx ) { - xLibContainer = m_xLibContainerApp; + xLibContainer = m_xLibContainerApp; } else { @@ -540,7 +556,7 @@ namespace basprov sal_Int16 BasicProviderImpl::getType( ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; return browse::BrowseNodeTypes::CONTAINER; } @@ -581,7 +597,7 @@ namespace basprov extern "C" { - SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( + SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ) { (void)ppEnv; @@ -593,7 +609,9 @@ extern "C" const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey ) { - return ::cppu::component_getFactoryHelper( + return ::cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, ::basprov::s_component_entries ); } } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scripting/source/basprov/basprov.hxx b/scripting/source/basprov/basprov.hxx index 9ef21da4d0..8507346561 100644 --- a/scripting/source/basprov/basprov.hxx +++ b/scripting/source/basprov/basprov.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -113,3 +114,5 @@ namespace basprov //......................................................................... #endif // SCRIPTING_BASPROV_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx index 06f58b94bf..d38f78aec2 100644 --- a/scripting/source/basprov/basscript.cxx +++ b/scripting/source/basprov/basscript.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,7 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_scripting.hxx" #include "basscript.hxx" -#include <vos/mutex.hxx> +#include <osl/mutex.hxx> #include <vcl/svapp.hxx> #include <basic/sbx.hxx> #include <basic/sbstar.hxx> @@ -36,7 +37,10 @@ #include <basic/sbmeth.hxx> #include <basic/basmgr.hxx> #include <com/sun/star/script/provider/ScriptFrameworkErrorType.hpp> - +#include "bcholder.hxx" +#include <comphelper/proparrhlp.hxx> +#include <comphelper/propertycontainer.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> #include <map> @@ -45,6 +49,7 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::script; using namespace ::com::sun::star::document; +using namespace ::com::sun::star::beans; extern ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar ); extern void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue ); @@ -54,6 +59,10 @@ extern void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& namespace basprov { //......................................................................... +#define BASSCRIPT_PROPERTY_ID_CALLER 1 +#define BASSCRIPT_PROPERTY_CALLER ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Caller" ) ) + +#define BASSCRIPT_DEFAULT_ATTRIBS() PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap; @@ -64,18 +73,22 @@ namespace basprov // ----------------------------------------------------------------------------- BasicScriptImpl::BasicScriptImpl( const ::rtl::OUString& funcName, SbMethodRef xMethod ) - :m_xMethod( xMethod ) + : ::scripting_helper::OBroadcastHelperHolder( m_aMutex ) + ,OPropertyContainer( GetBroadcastHelper() ) + ,m_xMethod( xMethod ) ,m_funcName( funcName ) ,m_documentBasicManager( NULL ) ,m_xDocumentScriptContext() { + registerProperty( BASSCRIPT_PROPERTY_CALLER, BASSCRIPT_PROPERTY_ID_CALLER, BASSCRIPT_DEFAULT_ATTRIBS(), &m_caller, ::getCppuType( &m_caller ) ); } // ----------------------------------------------------------------------------- BasicScriptImpl::BasicScriptImpl( const ::rtl::OUString& funcName, SbMethodRef xMethod, - BasicManager& documentBasicManager, const Reference< XScriptInvocationContext >& documentScriptContext ) - :m_xMethod( xMethod ) + BasicManager& documentBasicManager, const Reference< XScriptInvocationContext >& documentScriptContext ) : ::scripting_helper::OBroadcastHelperHolder( m_aMutex ) + ,OPropertyContainer( GetBroadcastHelper() ) + ,m_xMethod( xMethod ) ,m_funcName( funcName ) ,m_documentBasicManager( &documentBasicManager ) ,m_xDocumentScriptContext( documentScriptContext ) @@ -110,6 +123,48 @@ namespace basprov } // ----------------------------------------------------------------------------- + // XInterface + // ----------------------------------------------------------------------------- + + IMPLEMENT_FORWARD_XINTERFACE2( BasicScriptImpl, BasicScriptImpl_BASE, OPropertyContainer ) + + // ----------------------------------------------------------------------------- + // XTypeProvider + // ----------------------------------------------------------------------------- + + IMPLEMENT_FORWARD_XTYPEPROVIDER2( BasicScriptImpl, BasicScriptImpl_BASE, OPropertyContainer ) + + // ----------------------------------------------------------------------------- + // OPropertySetHelper + // ----------------------------------------------------------------------------- + + ::cppu::IPropertyArrayHelper& BasicScriptImpl::getInfoHelper( ) + { + return *getArrayHelper(); + } + + // ----------------------------------------------------------------------------- + // OPropertyArrayUsageHelper + // ----------------------------------------------------------------------------- + + ::cppu::IPropertyArrayHelper* BasicScriptImpl::createArrayHelper( ) const + { + Sequence< Property > aProps; + describeProperties( aProps ); + return new ::cppu::OPropertyArrayHelper( aProps ); + } + + // ----------------------------------------------------------------------------- + // XPropertySet + // ----------------------------------------------------------------------------- + + Reference< XPropertySetInfo > BasicScriptImpl::getPropertySetInfo( ) throw (RuntimeException) + { + Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; + } + + // ----------------------------------------------------------------------------- // XScript // ----------------------------------------------------------------------------- @@ -119,7 +174,7 @@ namespace basprov // TODO: throw CannotConvertException // TODO: check length of aOutParamIndex, aOutParam - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + SolarMutexGuard aGuard; Any aReturn; @@ -134,7 +189,7 @@ namespace basprov sal_Int32 nParamsCount = aParams.getLength(); SbxInfo* pInfo = m_xMethod->GetInfo(); if ( pInfo ) - { + { sal_Int32 nSbxOptional = 0; USHORT n = 1; for ( const SbxParamInfo* pParamInfo = pInfo->GetParam( n ); pParamInfo; pParamInfo = pInfo->GetParam( ++n ) ) @@ -148,12 +203,12 @@ namespace basprov if ( nParamsCount < nSbxCount - nSbxOptional ) { throw provider::ScriptFrameworkErrorException( - ::rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( + ::rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( "wrong number of parameters!" ) ), - Reference< XInterface >(), + Reference< XInterface >(), m_funcName, - ::rtl::OUString( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Basic" ) ), provider::ScriptFrameworkErrorType::NO_SUCH_SCRIPT ); } @@ -188,8 +243,14 @@ namespace basprov if ( m_documentBasicManager && m_xDocumentScriptContext.is() ) aOldThisComponent = m_documentBasicManager->SetGlobalUNOConstant( "ThisComponent", makeAny( m_xDocumentScriptContext ) ); + if ( m_caller.getLength() && m_caller[ 0 ].hasValue() ) + { + SbxVariableRef xCallerVar = new SbxVariable( SbxVARIANT ); + unoToSbxValue( static_cast< SbxVariable* >( xCallerVar ), m_caller[ 0 ] ); + nErr = m_xMethod->Call( xReturn, xCallerVar ); + } + else nErr = m_xMethod->Call( xReturn ); - if ( m_documentBasicManager && m_xDocumentScriptContext.is() ) m_documentBasicManager->SetGlobalUNOConstant( "ThisComponent", aOldThisComponent ); } @@ -203,8 +264,8 @@ namespace basprov { SbxInfo* pInfo_ = m_xMethod->GetInfo(); if ( pInfo_ ) - { - OutParamMap aOutParamMap; + { + OutParamMap aOutParamMap; for ( USHORT n = 1, nCount = xSbxParams->Count(); n < nCount; ++n ) { const SbxParamInfo* pParamInfo = pInfo_->GetParam( n ); @@ -238,7 +299,7 @@ namespace basprov m_xMethod->SetParameters( NULL ); } - return aReturn; + return aReturn; } // ----------------------------------------------------------------------------- @@ -246,3 +307,5 @@ namespace basprov //......................................................................... } // namespace basprov //......................................................................... + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/scripting/source/basprov/basscript.hxx b/scripting/source/basprov/basscript.hxx index 99d351ee51..cbdaac88eb 100644 --- a/scripting/source/basprov/basscript.hxx +++ b/scripting/source/basprov/basscript.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,13 +29,15 @@ #ifndef SCRIPTING_BASSCRIPT_HXX #define SCRIPTING_BASSCRIPT_HXX +#include "bcholder.hxx" #include <com/sun/star/script/provider/XScript.hpp> #include <com/sun/star/document/XScriptInvocationContext.hpp> #include <cppuhelper/implbase1.hxx> +#include <comphelper/proparrhlp.hxx> +#include <comphelper/propertycontainer.hxx> #include <basic/sbmeth.hxx> #include <svl/lstner.hxx> - class BasicManager; //......................................................................... @@ -46,7 +49,7 @@ namespace basprov // class BasicScriptImpl // ---------------------------------------------------- - typedef ::cppu::WeakImplHelper1< + typedef ::cppu::WeakImplHelper1< ::com::sun::star::script::provider::XScript > BasicScriptImpl_BASE; @@ -58,6 +61,16 @@ namespace basprov BasicManager* m_documentBasicManager; ::com::sun::star::uno::Reference< ::com::sun::star::document::XScriptInvocationContext > m_xDocumentScriptContext; + // hack, OPropertyContainer doesn't allow you to define a property of unknown + // type ( I guess because an Any can't contain an Any... I've always wondered why? + // as its not unusual to do that in corba ) + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_caller; + protected: + // OPropertySetHelper + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper( ); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; public: BasicScriptImpl( @@ -72,13 +85,19 @@ namespace basprov ); virtual ~BasicScriptImpl(); + // XInterface + DECLARE_XINTERFACE() + + // XTypeProvider + DECLARE_XTYPEPROVIDER() + // XScript virtual ::com::sun::star::uno::Any SAL_CALL invoke( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams, ::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex, ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam ) - throw ( - ::com::sun::star::script::provider::ScriptFrameworkErrorException, + throw ( + ::com::sun::star::script::provider::ScriptFrameworkErrorException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException ); @@ -91,3 +110,5 @@ namespace basprov //......................................................................... #endif // SCRIPTING_BASSCRIPT_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |