summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorNoel Power <npower@openoffice.org>2003-08-27 12:57:48 +0000
committerNoel Power <npower@openoffice.org>2003-08-27 12:57:48 +0000
commitab951f9d201e758713c55325305b54725e1eef4d (patch)
tree7e85a644e4e7790df5c6eac8a13b50a859541f23 /scripting
parente2b8a32dd7f98e2b0d8eda86cccbbd4a30f95933 (diff)
#i18637#
Change service spec for MasterScriptProvider as a result of code inspection changes
Diffstat (limited to 'scripting')
-rwxr-xr-xscripting/source/provider/MasterScriptProvider.cxx534
-rw-r--r--scripting/source/provider/MasterScriptProvider.hxx37
2 files changed, 352 insertions, 219 deletions
diff --git a/scripting/source/provider/MasterScriptProvider.cxx b/scripting/source/provider/MasterScriptProvider.cxx
index 586b70c1cb76..bda361a68c38 100755
--- a/scripting/source/provider/MasterScriptProvider.cxx
+++ b/scripting/source/provider/MasterScriptProvider.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: MasterScriptProvider.cxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: npower $ $Date: 2003-08-19 09:46:09 $
+ * last change: $Author: npower $ $Date: 2003-08-27 13:57:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -64,6 +64,7 @@
#include <com/sun/star/frame/XModel.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/lang/EventObject.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
#include <util/scriptingconstants.hxx>
#include <util/util.hxx>
@@ -78,11 +79,14 @@ namespace func_provider
::rtl::OUString s_implName = ::rtl::OUString::createFromAscii(
"drafts.com.sun.star.script.framework.provider.MasterScriptProvider" );
-::rtl::OUString s_serviceName = ::rtl::OUString::createFromAscii(
- "drafts.com.sun.star.script.framework.provider.MasterScriptProvider" );
+const ::rtl::OUString s_serviceNameList[] = {
+ ::rtl::OUString::createFromAscii(
+ "drafts.com.sun.star.script.framework.provider.MasterScriptProvider" ),
+ ::rtl::OUString::createFromAscii(
+ "drafts.com.sun.star.script.framework.provider.ScriptProvider" ) };
Sequence< ::rtl::OUString > s_serviceNames = Sequence <
- ::rtl::OUString > ( &s_serviceName, 1 );
+ ::rtl::OUString > ( s_serviceNameList, 2 );
//::rtl_StandardModuleCount s_moduleCount = MODULE_COUNT_INIT;
@@ -91,8 +95,8 @@ Sequence< ::rtl::OUString > s_serviceNames = Sequence <
// XScriptProvider implementation
//
//*************************************************************************
-MasterScriptProvider::MasterScriptProvider( const Reference< XComponentContext > & xContext ) :
- m_xContext( xContext ), m_bInitialised( false )
+MasterScriptProvider::MasterScriptProvider( const Reference< XComponentContext > & xContext ) throw ( RuntimeException ):
+ m_xContext( xContext ), m_bInitialised( false ), m_bIsValid( false )
{
OSL_TRACE( "< MasterScriptProvider ctor called >\n" );
@@ -127,6 +131,9 @@ MasterScriptProvider::MasterScriptProvider( const Reference< XComponentContext >
"MasterScriptProvider::MasterScriptProvider: could not raise instance of ScriptStorageManager : " );
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
}
+
+ //Sequence< ::rtl::OUString >& providers = getProviderNames();
+ m_bIsValid = true;
}
//*************************************************************************
@@ -148,11 +155,13 @@ throw ( Exception, RuntimeException )
return ;
}
+ m_bIsValid = false;
+
// related to issue 11866
// warning dialog gets launched when adding binding to script in doc
// workaround issue: no functionProvider created on doc open
sal_Int32 len = args.getLength();
- if ( ( len == 0 ) || ( len >=3 ) )
+ if ( len >=3 )
{
throw RuntimeException(
OUSTR( "MasterScriptProvider::initialize: invalid number of arguments" ),
@@ -169,139 +178,143 @@ throw ( Exception, RuntimeException )
}
}
-
- try
+ if ( args.getLength() != 0 )
{
- Reference< XInterface > xInterface;
- if ( sal_False == ( args[ 0 ] >>= xInterface ) )
+ try
{
- throw RuntimeException(
- OUSTR( "MasterScriptProvider::initialize: could not extract xModel from arguments" ),
- Reference< XInterface >() );
- }
- validateXRef( xInterface,
- "MasterScriptProvider::initialize: invalid xModel xinterface" );
+ Reference< XInterface > xInterface;
+ if ( sal_False == ( args[ 0 ] >>= xInterface ) )
+ {
+ throw RuntimeException(
+ OUSTR( "MasterScriptProvider::initialize: could not extract xModel from arguments" ),
+ Reference< XInterface >() );
+ }
+ validateXRef( xInterface,
+ "MasterScriptProvider::initialize: invalid xModel xinterface" );
- m_xModel = Reference< frame::XModel > ( xInterface, UNO_QUERY_THROW );
+ m_xModel = Reference< frame::XModel > ( xInterface, UNO_QUERY_THROW );
- Any propValXModel;
- propValXModel <<= m_xModel;
+ Any propValXModel;
+ propValXModel <<= m_xModel;
- ::rtl::OUString url ( m_xModel->getURL() );
+ ::rtl::OUString url ( m_xModel->getURL() );
- if ( displayDialog == sal_False )
- {
- url = ::rtl::OUString::createFromAscii( "NoDialog::" ).concat( url );
- }
-
- // Initial val, indicates no document script storage
- scripting_constants::ScriptingConstantsPool& scriptingConstantsPool =
- scripting_constants::ScriptingConstantsPool::instance();
- sal_Int32 documentScriptStorageID =
- scriptingConstantsPool.DOC_STORAGE_ID_NOT_SET;
-
- OSL_TRACE( "about to call addStorageAsListener");
- addStorageAsListener();
+ if ( displayDialog == sal_False )
+ {
+ url = ::rtl::OUString::createFromAscii( "NoDialog::" ).concat( url );
+ }
- if ( url.getLength() )
- {
- // If document url is valid (i.e. pointing to a document) we want to get
- // the StorageManager to create a storage component, this will be done
- // by the document in the next rev.
- Reference< XInterface > xInterface = m_xMgr->createInstanceWithContext(
- ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ),
- m_xContext );
- validateXRef( xInterface,
- "MasterScriptProvider::initialise: cannot get SimpleFileAccess Service\n" );
- Reference < ucb::XSimpleFileAccess > xSimpleFileAccess = Reference <
- ucb::XSimpleFileAccess > ( xInterface, UNO_QUERY_THROW );
+ // Initial val, indicates no document script storage
+ scripting_constants::ScriptingConstantsPool& scriptingConstantsPool =
+ scripting_constants::ScriptingConstantsPool::instance();
+ sal_Int32 documentScriptStorageID =
+ scriptingConstantsPool.DOC_STORAGE_ID_NOT_SET;
+ OSL_TRACE( "about to call addStorageAsListener");
+ addStorageAsListener();
- OSL_TRACE( ">>>> About to create storage for %s",
- ::rtl::OUStringToOString( url,
- RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- // ask storage manager to create storage
- try
- {
- documentScriptStorageID =
- m_xScriptStorageMgr->createScriptStorageWithURI(
- xSimpleFileAccess, url );
- OSL_TRACE( ">>>> Created storage %d - for %s ",
- documentScriptStorageID, ::rtl::OUStringToOString(
- url, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- }
- catch ( RuntimeException & e )
+ if ( url.getLength() )
{
- /* No need to rethrow exception because if no storage available
- we continue on...*/
- OSL_TRACE( ">>>> Failed to create document storage for %s: %s",
- ::rtl::OUStringToOString( url,
- RTL_TEXTENCODING_ASCII_US ).pData->buffer,
- ::rtl::OUStringToOString( e.Message,
- RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ // If document url is valid (i.e. pointing to a document) we want to get
+ // the StorageManager to create a storage component, this will be done
+ // by the document in the next rev.
+ Reference< XInterface > xInterface = m_xMgr->createInstanceWithContext(
+ ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ),
+ m_xContext );
+ validateXRef( xInterface,
+ "MasterScriptProvider::initialise: cannot get SimpleFileAccess Service\n" );
+ Reference < ucb::XSimpleFileAccess > xSimpleFileAccess = Reference <
+ ucb::XSimpleFileAccess > ( xInterface, UNO_QUERY_THROW );
+
+
+ OSL_TRACE( ">>>> About to create storage for %s",
+ ::rtl::OUStringToOString( url,
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ // ask storage manager to create storage
+ try
+ {
+ documentScriptStorageID =
+ m_xScriptStorageMgr->createScriptStorageWithURI(
+ xSimpleFileAccess, url );
+ OSL_TRACE( ">>>> Created storage %d - for %s ",
+ documentScriptStorageID, ::rtl::OUStringToOString(
+ url, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ catch ( RuntimeException & e )
+ {
+ /* No need to rethrow exception because if no storage available
+ we continue on...*/
+ OSL_TRACE( ">>>> Failed to create document storage for %s: %s",
+ ::rtl::OUStringToOString( url,
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer,
+ ::rtl::OUStringToOString( e.Message,
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+
}
+ Any propValUrl;
+ propValUrl <<= url;
+
+ Any propValSid;
+ propValSid <<= documentScriptStorageID ;
+
+ OSL_TRACE( "!!** XModel URL inserted into any is %s \n",
+ ::rtl::OUStringToOString( url , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ // set up invocation context.
+ m_XScriptingContext->setPropertyValue( scriptingConstantsPool.DOC_REF,
+ propValXModel );
+ m_XScriptingContext->setPropertyValue( scriptingConstantsPool.DOC_URI,
+ propValUrl );
+ m_XScriptingContext->setPropertyValue( scriptingConstantsPool.DOC_STORAGE_ID,
+ propValSid );
}
-
- Any propValUrl;
- propValUrl <<= url;
-
- Any propValSid;
- propValSid <<= documentScriptStorageID ;
-
- OSL_TRACE( "!!** XModel URL inserted into any is %s \n",
- ::rtl::OUStringToOString( url , RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- // set up invocation context.
- m_XScriptingContext->setPropertyValue( scriptingConstantsPool.DOC_REF,
- propValXModel );
- m_XScriptingContext->setPropertyValue( scriptingConstantsPool.DOC_URI,
- propValUrl );
- m_XScriptingContext->setPropertyValue( scriptingConstantsPool.DOC_STORAGE_ID,
- propValSid );
- }
- catch ( beans::UnknownPropertyException & e )
- {
- ::rtl::OUString temp = OUSTR(
- "MasterScriptProvider::initialize: caught UnknownPropertyException: " );
- throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
- }
- catch ( beans::PropertyVetoException & e )
- {
- ::rtl::OUString temp = OUSTR(
- "MasterScriptProvider::initialize: caught PropertyVetoException: " );
- throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
- }
- catch ( lang::IllegalArgumentException & e )
- {
- ::rtl::OUString temp = OUSTR(
- "MasterScriptProvider::initialize: caught IllegalArgumentException: " );
- throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
- }
- catch ( lang::WrappedTargetException & e )
- {
- ::rtl::OUString temp = OUSTR(
- "MasterScriptProvider::initialize: caught WrappedTargetException: " );
- throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
- }
- catch ( RuntimeException & e )
- {
- ::rtl::OUString temp = OUSTR( "MasterScriptProvider::initialize: " );
- throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
+ catch ( beans::UnknownPropertyException & e )
+ {
+ ::rtl::OUString temp = OUSTR(
+ "MasterScriptProvider::initialize: caught UnknownPropertyException: " );
+ throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
+ }
+ catch ( beans::PropertyVetoException & e )
+ {
+ ::rtl::OUString temp = OUSTR(
+ "MasterScriptProvider::initialize: caught PropertyVetoException: " );
+ throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
+ }
+ catch ( lang::IllegalArgumentException & e )
+ {
+ ::rtl::OUString temp = OUSTR(
+ "MasterScriptProvider::initialize: caught IllegalArgumentException: " );
+ throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
+ }
+ catch ( lang::WrappedTargetException & e )
+ {
+ ::rtl::OUString temp = OUSTR(
+ "MasterScriptProvider::initialize: caught WrappedTargetException: " );
+ throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
+ }
+ catch ( RuntimeException & e )
+ {
+ ::rtl::OUString temp = OUSTR( "MasterScriptProvider::initialize: " );
+ throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
+ }
+ OSL_TRACE( "Initialised XMasterScriptProvider" );
}
- OSL_TRACE( "Initialised XMasterScriptProvider" );
+
m_bInitialised = true;
+ m_bIsValid = true;
}
//*************************************************************************
Reference< provider::XScript >
MasterScriptProvider::getScript( const ::rtl::OUString& scriptURI )
-throw ( RuntimeException )
+throw ( lang::IllegalArgumentException, RuntimeException )
{
- if ( !m_bInitialised )
+ if ( !isValid() )
{
throw RuntimeException(
- OUSTR( "MasterScriptProvider::getScript: XScriptProvider not initialised." ),
+ OUSTR( "MasterScriptProvider::getScript(), service object not initialised properly." ),
Reference< XInterface >() );
}
@@ -309,15 +322,108 @@ throw ( RuntimeException )
OSL_TRACE( "Script URI is %s",
::rtl::OUStringToOString( scriptURI,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+
// need to get the language from the string
+ //::rtl::OUString language = getLanguageFromURI( scriptURI );
+ ::rtl::OUString language;
+
+ if( scriptURI.getLength() == 0 ||
+ ( language = getLanguageFromURI( scriptURI ) ).getLength() == 0 )
+ {
+ ::rtl::OUString errorMsg = OUSTR( "Incorrect format for Script URI: " );
+ errorMsg.concat( scriptURI );
+ throw lang::IllegalArgumentException(
+ OUSTR( "invalid URI: " ).concat( errorMsg ),
+ Reference < XInterface > (), 1 );
+ }
+
+ Reference< provider::XScript > xScript;
+ Reference< provider::XScriptProvider > xScriptProvider;
+ try
+ {
+ // need to pass the scripting context
+ Sequence < Any > aArgs( 1 );
+ aArgs[ 0 ] <<= m_XScriptingContext;
+ xScriptProvider = getScriptProvider( language, aArgs );
+ xScript=xScriptProvider->getScript( scriptURI );
+ }
+ catch ( lang::IllegalArgumentException & e )
+ {
+ ::rtl::OUString temp = OUSTR( "MasterScriptProvider::getScript: can't get XScript for " );
+ temp.concat( scriptURI ).concat( OUSTR( " :" ) ).concat( e.Message );
+ throw lang::IllegalArgumentException( temp,
+ Reference < XInterface > (), 1 );
+ }
+ catch ( RuntimeException & e )
+ {
+ ::rtl::OUString temp = OUSTR( "MasterScriptProvider::getScript: can't get XScript for " );
+ temp.concat(scriptURI);
+ temp.concat( OUSTR( " :" ) );
+ throw RuntimeException( temp.concat( e.Message ),
+ Reference< XInterface >() );
+ }
+ catch ( Exception & e )
+ {
+ ::rtl::OUString temp = OUSTR( "MasterScriptProvider::getScript: catch exception: can't get XScript for " );
+ temp.concat(scriptURI);
+ temp.concat( OUSTR( " :" ) );
+ throw RuntimeException( temp.concat( e.Message ),
+ Reference< XInterface >() );
+ }
+
+ return xScript;
+}
+//*************************************************************************
+bool
+MasterScriptProvider::isValid()
+{
+ return m_bIsValid;
+}
+//*************************************************************************
+void
+MasterScriptProvider::addStorageAsListener() throw ( RuntimeException )
+{
+ try
+ {
+ OSL_TRACE( "IN addStorageAsListener()" );
+ // try get XEventListener from m_xScriptStorageMgr
+ Reference< lang::XEventListener > xEventListener =
+ Reference< lang::XEventListener >( m_xScriptStorageMgr, UNO_QUERY_THROW );
+ validateXRef( xEventListener, "MasterScriptProvider::initialse: storage manager not XEventListener\n" );
+ // try get XComponent from m_xModel, if we can, then
+ // register as listener so we get event when doc is disposed
+ Reference< lang::XComponent > xComponent =
+ Reference< lang::XComponent >( m_xModel, UNO_QUERY_THROW );
+ validateXRef( xComponent, "MasterScriptProvider::initialse: model not XComponent\n" );
+ xComponent->addEventListener( xEventListener );
+ OSL_TRACE( " addStorageAsListener(), successful" );
+
+ }
+ catch ( Exception & e )
+ {
+ ::rtl::OUString errorMsg = OUSTR( "MasterScriptProvider::addStorageAsListene() failed, reason: " );
+ errorMsg.concat( e.Message );
+ OSL_TRACE( "Failed to add listener for storage, reason %s",
+ ::rtl::OUStringToOString( e.Message,
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ throw RuntimeException( errorMsg,
+ Reference< XInterface >() );
+ }
+}
+
+::rtl::OUString
+MasterScriptProvider::getLanguageFromURI( const ::rtl::OUString& scriptURI )
+{
::rtl::OUString language;
::rtl::OUString attr;
sal_Int32 len = scriptURI.indexOf( '?' );
- // if we have a match, then start the search after the ?
- if( len > 0 )
+ if( ( len < 0 ) || ( scriptURI.getLength() == 0 ) )
{
- len++;
+ return language;
}
+ // if we have a match, then start the search after the ?
+
+ len++;
do
{
attr = scriptURI.getToken( 0, '&', len );
@@ -336,29 +442,35 @@ throw ( RuntimeException )
}
}
while ( len >= 0 );
+ return language;
+}
+
+//*************************************************************************
+Reference< provider::XScriptProvider >
+MasterScriptProvider::getScriptProvider(
+ const ::rtl::OUString& language,
+ const Sequence< Any >& aArgs ) throw ( RuntimeException )
+{
Reference< provider::XScriptProvider > xScriptProvider;
try
{
// need to attempt to get the runtime service (not singleton) for the lang
- ::rtl::OUStringBuffer *buf = new ::rtl::OUStringBuffer( 80 );
- buf->appendAscii( "drafts.com.sun.star.script.framework.provider.ScriptProviderFor");
- buf->append( language );
- ::rtl::OUString serviceName = buf->makeStringAndClear();
+ ::rtl::OUStringBuffer buf( 80 );
+ buf.appendAscii( "drafts.com.sun.star.script.framework.provider.ScriptProviderFor");
+ buf.append( language );
+ ::rtl::OUString serviceName = buf.makeStringAndClear();
OSL_TRACE( "Service name is %s",
::rtl::OUStringToOString( serviceName,
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- // need to pass the scripting context
- Sequence < Any > aArgs( 1 );
- aArgs[ 0 ] <<= m_XScriptingContext;
Reference< XInterface > xInterface =
m_xMgr->createInstanceWithArgumentsAndContext(
serviceName, aArgs, m_xContext );
- // need to get the XScriptInvocation interface from the service
+ // need to get the XScriptProvider interface from the service
validateXRef( xInterface,
- "MasterScriptProvider::getScript: cannot get appropriate ScriptRuntime Service");
+ "MasterScriptProvider::getScriptProvider: cannot get appropriate language ScriptProvider Service");
xScriptProvider = Reference< provider::XScriptProvider > ( xInterface,
UNO_QUERY_THROW );
validateXRef( xScriptProvider,
@@ -366,65 +478,86 @@ throw ( RuntimeException )
}
catch ( RuntimeException & e )
{
- ::rtl::OUString temp = OUSTR( "MasterScriptProvider::getScript: no runtime implementation for " );
- temp.concat(language);
+ ::rtl::OUString temp = OUSTR( "MasterScriptProvider::getScriptProvider: can't get ScriptProvider for " );
+ temp.concat( language );
temp.concat( OUSTR( " :" ) );
throw RuntimeException( temp.concat( e.Message ),
Reference< XInterface >() );
}
-
- Reference< provider::XScript > xScript;
+ return xScriptProvider;
+}
+const css::uno::Sequence< ::rtl::OUString >&
+MasterScriptProvider::getProviderNames()
+{
+ OSL_TRACE("In getProviderNames()");
+ static css::uno::Sequence< ::rtl::OUString > providers(0);
try
{
- //xScript = xScriptProvider->getScript( scriptURI );
- xScript=xScriptProvider->getScript( scriptURI );
- }
- catch ( RuntimeException & e )
- {
- ::rtl::OUString temp = OUSTR( "MasterScriptProvider::getScript: can't get XScript for " );
- temp.concat(scriptURI);
- temp.concat( OUSTR( " :" ) );
- throw RuntimeException( temp.concat( e.Message ),
- Reference< XInterface >() );
+ OSL_TRACE("1");
+ Reference < container::XContentEnumerationAccess > xEnum( m_xMgr, UNO_QUERY_THROW );
+ OSL_TRACE("2");
+ //::rtl::OUString langProvider = ::rtl::OUString::createFromAscii( "drafts.com.sun.star.script.framework.provider.LanguageScriptProvider" );
+ ::rtl::OUString langProvider = ::rtl::OUString::createFromAscii( "drafts.com.sun.star.script.framework.provider.ScriptProvider" );
+ OSL_TRACE("3");
+ Reference< container::XEnumeration > providerEnum = xEnum->createContentEnumeration ( langProvider );
+ OSL_TRACE("4");
+ int i = 0;
+ validateXRef( providerEnum,
+ "no XEnumeration" );
+ OSL_TRACE("5");
+ while ( providerEnum->hasMoreElements() == sal_True )
+ {
+ OSL_TRACE("6");
+ ::rtl::OUString sp;
+ if ( sal_False == ( providerEnum->nextElement() >>= sp ) )
+ {
+ OSL_TRACE("Can't extract string from element");
+ }
+ else
+ {
+ OSL_TRACE("Can extract string...");
+ OSL_TRACE(" provider[%n] = %s", i++,
+ ::rtl::OUStringToOString( sp,
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ }
+ }
}
- catch ( Exception & e )
+ catch ( css::uno::Exception& e )
{
- ::rtl::OUString temp = OUSTR( "MasterScriptProvider::getScript: catch exception: can't get XScript for " );
- temp.concat(scriptURI);
- temp.concat( OUSTR( " :" ) );
- throw RuntimeException( temp.concat( e.Message ),
- Reference< XInterface >() );
+ OSL_TRACE("MasterScriptProvider::getProviderNames() %s",
+ ::rtl::OUStringToOString( e.Message,
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+
}
+ return providers;
+}
- return xScript;
+::rtl::OUString SAL_CALL
+MasterScriptProvider::getName()
+ throw ( css::uno::RuntimeException )
+{
+ return ::rtl::OUString();
}
-//*************************************************************************
-void
-MasterScriptProvider::addStorageAsListener()
+Sequence< Reference< browse::XBrowseNode > > SAL_CALL
+MasterScriptProvider::getChildNodes()
+ throw ( css::uno::RuntimeException )
{
- try
- {
- OSL_TRACE( "IN addStorageAsListener()" );
- // try get XEventListener from m_xScriptStorageMgr
- Reference< lang::XEventListener > xEventListener =
- Reference< lang::XEventListener >( m_xScriptStorageMgr, UNO_QUERY_THROW );
- validateXRef( xEventListener, "MasterScriptProvider::initialse: storage manager not XEventListener\n" );
- // try get XComponent from m_xModel, if we can, then
- // register as listener so we get event when doc is disposed
- Reference< lang::XComponent > xComponent =
- Reference< lang::XComponent >( m_xModel, UNO_QUERY_THROW );
- validateXRef( xComponent, "MasterScriptProvider::initialse: model not XComponent\n" );
- xComponent->addEventListener( xEventListener );
- OSL_TRACE( " addStorageAsListener(), successful" );
+ return Sequence< Reference< browse::XBrowseNode > > ( 0 );
+}
- }
- catch ( Exception & e )
- {
- OSL_TRACE( "Failed to add listener for storage, reason %s",
- ::rtl::OUStringToOString( e.Message,
- RTL_TEXTENCODING_ASCII_US ).pData->buffer );
- }
+sal_Bool SAL_CALL
+MasterScriptProvider::hasChildNodes()
+ throw ( css::uno::RuntimeException )
+{
+ return sal_True;
+}
+
+sal_Int16 SAL_CALL
+MasterScriptProvider::getType()
+ throw ( css::uno::RuntimeException )
+{
+ return 0;
}
//*************************************************************************
@@ -453,26 +586,26 @@ throw( RuntimeException )
Sequence< ::rtl::OUString > SAL_CALL MasterScriptProvider::getSupportedServiceNames( )
throw( RuntimeException )
{
- return s_serviceNames;
-}
+ return s_serviceNames;
+ }
-} // namespace func_provider
+ } // namespace func_provider
-namespace scripting_runtimemgr
-{
-//*************************************************************************
-Reference< XInterface > SAL_CALL sp_create(
- const Reference< XComponentContext > & xCompC )
-{
- return ( cppu::OWeakObject * ) new ::func_provider::MasterScriptProvider( xCompC );
-}
+ namespace scripting_runtimemgr
+ {
+ //*************************************************************************
+ Reference< XInterface > SAL_CALL sp_create(
+ const Reference< XComponentContext > & xCompC )
+ {
+ return ( cppu::OWeakObject * ) new ::func_provider::MasterScriptProvider( xCompC );
+ }
-//*************************************************************************
-Sequence< ::rtl::OUString > sp_getSupportedServiceNames( )
-SAL_THROW( () )
-{
- return ::func_provider::s_serviceNames;
+ //*************************************************************************
+ Sequence< ::rtl::OUString > sp_getSupportedServiceNames( )
+ SAL_THROW( () )
+ {
+ return ::func_provider::s_serviceNames;
}
//*************************************************************************
@@ -558,27 +691,6 @@ extern "C"
Reference< registry::XRegistryKey >xKey = pKey->createKey(
OUSTR("drafts.com.sun.star.script.framework.storage.ScriptStorageManager/UNO/SINGLETONS/drafts.com.sun.star.script.framework.storage.theScriptStorageManager"));
xKey->setStringValue( OUSTR("drafts.com.sun.star.script.framework.storage.ScriptStorageManager") );
- // Singleton entries are not handled by the setup process
- // below is the only alternative at the momement which
- // is to programmatically do this.
-
- /* No longer singletons?
- // "Java" Runtime singleton entry
- xKey = pKey->createKey(
- OUSTR("com.sun.star.scripting.runtime.java.ScriptRuntimeForJava$_ScriptRuntimeForJava/UNO/SINGLETONS/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeForJava"));
- xKey->setStringValue( OUSTR("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeForJava") );
-
- // "JavaScript" Runtime singleton entry
- xKey = pKey->createKey(
- OUSTR("com.sun.star.scripting.runtime.javascript.ScriptRuntimeForJavaScript$_ScriptRuntimeForJavaScript/UNO/SINGLETONS/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeForJavaScript"));
- xKey->setStringValue( OUSTR("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeForJavaScript") );
-
- // "BeanShell" Runtime singleton entry
- xKey = pKey->createKey(
- OUSTR("com.sun.star.scripting.runtime.beanshell.ScriptRuntimeForBeanShell$_ScriptRuntimeForBeanShell/UNO/SINGLETONS/drafts.com.sun.star.script.framework.runtime.theScriptRuntimeForBeanShell"));
- xKey->setStringValue( OUSTR("drafts.com.sun.star.script.framework.runtime.ScriptRuntimeForBeanShell") );
- */
-
return sal_True;
}
catch (Exception & exc)
diff --git a/scripting/source/provider/MasterScriptProvider.hxx b/scripting/source/provider/MasterScriptProvider.hxx
index 165e47efebea..a1182a1ecded 100644
--- a/scripting/source/provider/MasterScriptProvider.hxx
+++ b/scripting/source/provider/MasterScriptProvider.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: MasterScriptProvider.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: npower $ $Date: 2003-08-19 09:46:43 $
+ * last change: $Author: npower $ $Date: 2003-08-27 13:57:48 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,7 +63,7 @@
#define _FRAMEWORK_SCRIPT_PROVIDER_XFUNCTIONPROVIDER_HXX_
#include <rtl/ustring>
-#include <cppuhelper/implbase3.hxx>
+#include <cppuhelper/implbase4.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
@@ -71,6 +71,8 @@
#include <drafts/com/sun/star/script/framework/provider/XScriptProvider.hpp>
#include <drafts/com/sun/star/script/framework/runtime/XScriptInvocation.hpp>
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp>
+#include <drafts/com/sun/star/script/framework/browse/XBrowseNode.hpp>
+
#include "ScriptingContext.hxx"
namespace func_provider
@@ -80,18 +82,29 @@ namespace func_provider
#define dcsssf ::drafts::com::sun::star::script::framework
class MasterScriptProvider :
- public ::cppu::WeakImplHelper3 < dcsssf::provider::XScriptProvider,
- css::lang::XServiceInfo, css::lang::XInitialization >
+ public ::cppu::WeakImplHelper4 < dcsssf::provider::XScriptProvider,
+ dcsssf::browse::XBrowseNode, css::lang::XServiceInfo, css::lang::XInitialization >
{
public:
MasterScriptProvider(
const css::uno::Reference< css::uno::XComponentContext >
- & xContext );
+ & xContext ) throw( css::uno::RuntimeException );
~MasterScriptProvider();
// XServiceInfo implementation
virtual ::rtl::OUString SAL_CALL getImplementationName( )
throw( css::uno::RuntimeException );
+
+ // XBrowseNode implementation
+ virtual ::rtl::OUString SAL_CALL getName()
+ throw ( css::uno::RuntimeException );
+ virtual css::uno::Sequence< css::uno::Reference< dcsssf::browse::XBrowseNode > > SAL_CALL getChildNodes()
+ throw ( css::uno::RuntimeException );
+ virtual sal_Bool SAL_CALL hasChildNodes()
+ throw ( css::uno::RuntimeException );
+ virtual sal_Int16 SAL_CALL getType()
+ throw ( css::uno::RuntimeException );
+
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
throw( css::uno::RuntimeException );
virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( )
@@ -100,7 +113,7 @@ public:
// XScriptInvocation implementation
virtual css::uno::Reference < dcsssf::provider::XScript > SAL_CALL
getScript( const ::rtl::OUString& scriptURI )
- throw( css::uno::RuntimeException );
+ throw( css::lang::IllegalArgumentException, css::uno::RuntimeException );
/**
* XInitialise implementation
@@ -111,13 +124,21 @@ public:
virtual void SAL_CALL initialize( css::uno::Sequence < css::uno::Any > const & args )
throw ( css::uno::Exception, css::uno::RuntimeException);
private:
- void addStorageAsListener();
+ void addStorageAsListener() throw( css::uno::RuntimeException );
+ bool isValid();
+ const css::uno::Sequence< ::rtl::OUString >& getProviderNames();
+ ::rtl::OUString getLanguageFromURI(const ::rtl::OUString& scriptURI );
+ css::uno::Reference< dcsssf::provider::XScriptProvider >
+ getScriptProvider( const ::rtl::OUString& language,
+ const css::uno::Sequence< css::uno::Any >& args )
+ throw ( css::uno::RuntimeException );
/* to obtain other services if needed */
css::uno::Reference< css::uno::XComponentContext > m_xContext;
css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
css::uno::Reference< css::frame::XModel > m_xModel;
css::uno::Reference < dcsssf::storage::XScriptStorageManager > m_xScriptStorageMgr;
bool m_bInitialised;
+ bool m_bIsValid;
css::uno::Reference< css::beans::XPropertySet > m_XScriptingContext;
osl::Mutex m_mutex;