diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2004-07-23 13:07:20 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2004-07-23 13:07:20 +0000 |
commit | 1d3c247e889fd5c4bac1402915c495c91565afae (patch) | |
tree | 51b935d56b0c4a67cacfecd1a60f0e9f9beddd4e /scripting | |
parent | c7ab666f15f124132b92f716e9d45bdfcedc2f7f (diff) |
INTEGRATION: CWS scriptingf7 (1.10.4); FILE MERGED
2004/07/09 18:11:56 npower 1.10.4.3: #i25260# Changed exception handling as per new exception specification for Xscript::inovke and XScriptProvider::getScript.
2004/07/02 09:07:51 npower 1.10.4.2: #i25269# Uncomment throw for invalid argument type.
Issue number:
Submitted by:
Reviewed by:
2004/06/12 08:43:52 npower 1.10.4.1: i25269 as part of changes to support pkgchk context from MSP is now passed as sting ( user/hare or tdoc url )
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/source/basprov/basprov.cxx | 97 |
1 files changed, 48 insertions, 49 deletions
diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx index 10aa205ab66b..216642d890f8 100644 --- a/scripting/source/basprov/basprov.cxx +++ b/scripting/source/basprov/basprov.cxx @@ -2,9 +2,9 @@ * * $RCSfile: basprov.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: rt $ $Date: 2004-05-19 08:26:50 $ + * last change: $Author: hr $ $Date: 2004-07-23 14:07:20 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -76,6 +76,10 @@ #ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_BROWSE_BROWSENODETYPES_HPP_ #include <drafts/com/sun/star/script/browse/BrowseNodeTypes.hpp> #endif +#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_PROVIDER_SCRIPTFRAMEWORKERRORTYPE_HPP_ +#include <drafts/com/sun/star/script/provider/ScriptFrameworkErrorType.hpp> +#endif + #ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ #include <cppuhelper/implementationentry.hxx> #endif @@ -108,12 +112,15 @@ #include <com/sun/star/uri/XUriReferenceFactory.hpp> #include <com/sun/star/uri/XVndSunStarScriptUrl.hpp> +#include <util/util.hxx> +#include <util/MiscUtils.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using namespace ::drafts::com::sun::star::script; - +using namespace ::sf_misc; //......................................................................... namespace basprov @@ -169,13 +176,9 @@ namespace basprov ,m_xLibContainerApp( 0 ) ,m_xLibContainerDoc( 0 ) ,m_xContext( xContext ) - ,m_xScriptingContext( 0 ) ,m_bIsAppScriptCtx( true ) ,m_bIsUserCtx(true) { - // TODO - if ( !m_pAppBasicManager ) - m_pAppBasicManager = SFX_APP()->GetBasicManager(); } // ----------------------------------------------------------------------------- @@ -227,32 +230,16 @@ namespace basprov { // Provider has been created with application context for user // or share - ::rtl::OUString sTmp; - aArguments[0] >>= sTmp; - Any aAny = m_xContext->getValueByName( ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ); - Reference< util::XMacroExpander > xME; - aAny >>= xME; - ::rtl::OUString base = ::rtl::OUString::createFromAscii( - SAL_CONFIGFILE( "${$SYSBINDIR/bootstrap" ) ); - ::rtl::OUString user = ::rtl::OUString::createFromAscii( "::UserInstallation}/user" ); - ::rtl::OUString share = ::rtl::OUString::createFromAscii( "::BaseInstallation}/share" ); - ::rtl::OUString userDirString = xME->expandMacros( base.concat( user ) ); - if ( !sTmp.equals( userDirString ) ) - { - m_bIsUserCtx = false; - } - } + aArguments[0] >>= m_sScriptingContext; - else if ( aArguments.getLength() == 1 && aArguments[0].getValueType() == ::getCppuType( ( const Reference< beans::XPropertySet >* ) NULL )) - { - // Provider has been created with document context - aArguments[0] >>= m_xScriptingContext; + ::rtl::OUString sUser = OUSTR("user"); + ::rtl::OUString sShare = OUSTR("share"); + ::rtl::OUString sDoc = OUSTR("vnd.sun.star.tdoc"); - if ( m_xScriptingContext.is() ) + if ( m_sScriptingContext.indexOf( sDoc ) == 0 ) { - Reference< frame::XModel > xModel; + Reference< frame::XModel > xModel = MiscUtils::tDocUrlToModel( m_sScriptingContext ); // TODO: use ScriptingContantsPool for SCRIPTING_DOC_REF - m_xScriptingContext->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SCRIPTING_DOC_REF" ) ) ) >>= xModel; if ( xModel.is() ) { @@ -262,11 +249,17 @@ namespace basprov { m_pDocBasicManager = pObjShell->GetBasicManager(); m_xLibContainerDoc = Reference< script::XLibraryContainer >( pObjShell->GetBasicContainer(), UNO_QUERY ); + break; } } - m_bIsAppScriptCtx = sal_False; } + m_bIsAppScriptCtx = false; + } + + else if ( !m_sScriptingContext.equals( sUser ) ) + { + m_bIsUserCtx = false; } else { @@ -279,13 +272,17 @@ namespace basprov } else { - /* + throw RuntimeException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicProviderImpl::initialize: incorrect number of arguments!" ) ), + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicProviderImpl::initialize: incorrect argument type " ) ).concat( aArguments[0].getValueType().getTypeName() ), Reference< XInterface >() ); - */ + } + // TODO + if ( !m_pAppBasicManager ) + m_pAppBasicManager = SFX_APP()->GetBasicManager(); + if ( !m_xLibContainerApp.is() ) m_xLibContainerApp = Reference< script::XLibraryContainer >( SFX_APP()->GetBasicContainer(), UNO_QUERY ); } @@ -296,7 +293,7 @@ namespace basprov // ----------------------------------------------------------------------------- Reference < provider::XScript > BasicProviderImpl::getScript( const ::rtl::OUString& scriptURI ) - throw (IllegalArgumentException, RuntimeException) + throw ( provider::ScriptFrameworkErrorException, RuntimeException) { // TODO @@ -310,9 +307,10 @@ namespace basprov if ( !xFac.is() ) { - throw RuntimeException( - ::rtl::OUString::createFromAscii( "BasicProviderImpl::getScript(), could not instatiate UriReferenceFactory." ), - Reference< XInterface >() ); + throw provider::ScriptFrameworkErrorException( + OUSTR( "Failed to instantiate UriReferenceFactory" ), Reference< XInterface >(), + scriptURI, OUSTR("Basic"), + provider::ScriptFrameworkErrorType::UNKNOWN ); } Reference< uri::XUriReference > uriRef( @@ -323,9 +321,11 @@ namespace basprov if ( !uriRef.is() || !sfUri.is() ) { ::rtl::OUString errorMsg = ::rtl::OUString::createFromAscii( "BasicProviderImpl::getScript: failed to parse URI: " ); - errorMsg.concat( scriptURI ); - throw IllegalArgumentException( errorMsg, - Reference< XInterface >(), 1 ); + errorMsg = errorMsg.concat( scriptURI ); + throw provider::ScriptFrameworkErrorException( + errorMsg, Reference< XInterface >(), + scriptURI, OUSTR("Basic"), + provider::ScriptFrameworkErrorType::UNKNOWN ); } @@ -379,9 +379,7 @@ namespace basprov { SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Find( aMethod, SbxCLASS_METHOD ) ); if ( pMethod ) - { - xScript = static_cast< provider::XScript* >( new BasicScriptImpl( pMethod ) ); - } + xScript = static_cast< provider::XScript* >( new BasicScriptImpl( aDescription, pMethod ) ); } } } @@ -390,9 +388,10 @@ namespace basprov if ( !xScript.is() ) { - throw IllegalArgumentException( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicProviderImpl::getScript: no script!" ) ), - Reference< XInterface >(), 1 ); + throw provider::ScriptFrameworkErrorException( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicProviderImpl::getScript: no script!" ) ), Reference< XInterface >(), + scriptURI, OUSTR("Basic"), + provider::ScriptFrameworkErrorType::UNKNOWN ); } return xScript; @@ -475,18 +474,18 @@ namespace basprov if ( m_bIsUserCtx && ( isLibLink == sal_False ) ) { - pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( m_xContext, m_xScriptingContext, pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) ); + pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( m_xContext, m_sScriptingContext, pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) ); continue; } if ( !m_bIsUserCtx && ( isLibLink == sal_True ) ) { - pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( m_xContext, m_xScriptingContext, pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) ); + pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( m_xContext, m_sScriptingContext, pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) ); continue; } } else { - pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( m_xContext, m_xScriptingContext, pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) ); + pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( m_xContext, m_sScriptingContext, pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) ); } } if ( i != childsFound ) |