Updates from code review for end of September release
This commit is contained in:
@@ -1,65 +1,64 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* $RCSfile: scripthandler.cxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* last change: $Author: dfoster $ $Date: 2002-09-20 14:33:13 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
*
|
||||
* $RCSfile: scripthandler.cxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:23 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "scripthandler.hxx"
|
||||
|
||||
#include <osl/mutex.hxx>
|
||||
@@ -83,212 +82,267 @@ namespace scripting_protocolhandler
|
||||
{
|
||||
|
||||
const sal_Char * const MYSERVICENAME = "com.sun.star.frame.ProtocolHandler";
|
||||
const sal_Char * const MYIMPLNAME = "com.sun.star.comp.ScriptProtocolHandler";
|
||||
const sal_Char * const MYIMPLNAME = "com.sun.star.comp.ScriptProtocolHandler";
|
||||
const sal_Char * MYSCHEME = "script:";
|
||||
const sal_Int32 MYSCHEME_LEN = 7;
|
||||
|
||||
void SAL_CALL ScriptProtocolHandler::initialize( const css::uno::Sequence < css::uno::Any >& aArguments ) throw ( css::uno::Exception )
|
||||
void SAL_CALL ScriptProtocolHandler::initialize(
|
||||
const css::uno::Sequence < css::uno::Any >& aArguments )
|
||||
throw ( css::uno::Exception )
|
||||
{
|
||||
if (m_bInitialised)
|
||||
if ( m_bInitialised )
|
||||
{
|
||||
OSL_TRACE("ScriptProtocolHandler Already initialised");
|
||||
return;
|
||||
OSL_TRACE( "ScriptProtocolHandler Already initialised" );
|
||||
return ;
|
||||
}
|
||||
// first argument contains a reference to the frame (may be empty or the desktop, but usually it's a "real" frame)
|
||||
aArguments[0] >>= m_xFrame;
|
||||
// first argument contains a reference to the frame (may be empty or the desktop,
|
||||
// but usually it's a "real" frame)
|
||||
aArguments[ 0 ] >>= m_xFrame;
|
||||
|
||||
validateXRef(m_xFactory, "ScriptProtocolHandler::initialize: No Service Manager available");
|
||||
OSL_TRACE("ScriptProtocolHandler::initialize\n " );
|
||||
validateXRef( m_xFactory,
|
||||
"ScriptProtocolHandler::initialize: No Service Manager available" );
|
||||
OSL_TRACE( "ScriptProtocolHandler::initialize\n " );
|
||||
try
|
||||
{
|
||||
css::uno::Sequence < css::uno::Any > args(1);
|
||||
Reference < XModel > xModel;
|
||||
css::uno::Sequence < css::uno::Any > args( 1 );
|
||||
Reference< XModel > xModel;
|
||||
if ( m_xFrame.is() )
|
||||
{
|
||||
Reference < XController > xController = m_xFrame->getController();
|
||||
Reference< XController > xController = m_xFrame->getController();
|
||||
if ( xController .is() )
|
||||
{
|
||||
xModel = xController->getModel();
|
||||
}
|
||||
}
|
||||
|
||||
args[0] <<= xModel;
|
||||
Reference< XInterface > xXinterface = m_xFactory->createInstanceWithArguments(::rtl::OUString::createFromAscii(
|
||||
"drafts.com.sun.star.script.framework.provider.FunctionProvider"),args);
|
||||
validateXRef(xXinterface, "ScriptProtocolHandler::initialize: cannot get instance of FunctionProvider" );
|
||||
args[ 0 ] <<= xModel;
|
||||
Reference< XInterface > xXinterface =
|
||||
m_xFactory->createInstanceWithArguments(
|
||||
::rtl::OUString::createFromAscii(
|
||||
"drafts.com.sun.star.script.framework.provider.FunctionProvider" ),
|
||||
args );
|
||||
validateXRef( xXinterface,
|
||||
"ScriptProtocolHandler::initialize: cannot get instance of FunctionProvider" );
|
||||
|
||||
m_xFunctionProvider = Reference< provider::XFunctionProvider >(xXinterface, UNO_QUERY_THROW);
|
||||
m_xFunctionProvider = Reference< provider::XFunctionProvider >( xXinterface,
|
||||
UNO_QUERY_THROW );
|
||||
m_bInitialised = true;
|
||||
}
|
||||
catch(RuntimeException &e)
|
||||
catch ( RuntimeException & e )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptProtocolHandler::initialize: ") + e.Message, Reference< XInterface >());
|
||||
::rtl::OUString temp = OUSTR( "ScriptProtocolHandler::initialize: " );
|
||||
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
|
||||
}
|
||||
catch (Exception &e)
|
||||
catch ( Exception & e )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptProtocolHandler::initialize: ") + e.Message, Reference< XInterface >());
|
||||
OSL_TRACE("ScriptProtocolHandler::initialise: Caught Exception %s",::rtl::OUStringToOString(e.Message,RTL_TEXTENCODING_ASCII_US).pData->buffer);
|
||||
::rtl::OUString temp = OUSTR( "ScriptProtocolHandler::initialize: " );
|
||||
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
|
||||
OSL_TRACE( "ScriptProtocolHandler::initialise: Caught Exception %s",
|
||||
::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer
|
||||
);
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
catch ( ... )
|
||||
{
|
||||
throw RuntimeException(OUSTR("criptProtocolHandler::initialize: UnknownException: "),
|
||||
Reference<XInterface> ());
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptProtocolHandler::initialize: UnknownException: " ),
|
||||
Reference< XInterface > () );
|
||||
|
||||
OSL_TRACE("ScriptProtocolHandler::initialize: Unknown exception caught");
|
||||
OSL_TRACE( "ScriptProtocolHandler::initialize: Unknown exception caught" );
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Reference< XDispatch > SAL_CALL ScriptProtocolHandler::queryDispatch( const URL& aURL, const ::rtl::OUString& sTargetFrameName,
|
||||
sal_Int32 nSearchFlags ) throw( ::com::sun::star::uno::RuntimeException )
|
||||
Reference< XDispatch > SAL_CALL ScriptProtocolHandler::queryDispatch(
|
||||
const URL& aURL, const ::rtl::OUString& sTargetFrameName, sal_Int32 nSearchFlags )
|
||||
throw( ::com::sun::star::uno::RuntimeException )
|
||||
{
|
||||
Reference< XDispatch > xDispatcher;
|
||||
OSL_TRACE("ScriptProtocolHandler::queryDispatch - 1\n" );
|
||||
OSL_TRACE( "ScriptProtocolHandler::queryDispatch - 1\n" );
|
||||
|
||||
if( aURL.Complete.compareToAscii( ::scripting_protocolhandler::MYSCHEME,
|
||||
::scripting_protocolhandler::MYSCHEME_LEN ) == 0 )
|
||||
if ( aURL.Complete.compareToAscii( ::scripting_protocolhandler::MYSCHEME,
|
||||
::scripting_protocolhandler::MYSCHEME_LEN ) == 0 )
|
||||
{
|
||||
xDispatcher = this;
|
||||
OSL_TRACE("ScriptProtocolHandler::queryDispatch - 2\n" );
|
||||
|
||||
}
|
||||
OSL_TRACE( "ScriptProtocolHandler::queryDispatch - 2\n" );
|
||||
|
||||
return xDispatcher;
|
||||
}
|
||||
|
||||
Sequence< Reference < XDispatch > > SAL_CALL
|
||||
ScriptProtocolHandler::queryDispatches( const Sequence < DispatchDescriptor >& seqDescriptor )
|
||||
Sequence< Reference< XDispatch > > SAL_CALL
|
||||
ScriptProtocolHandler::queryDispatches(
|
||||
const Sequence < DispatchDescriptor >& seqDescriptor )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
sal_Int32 nCount = seqDescriptor.getLength();
|
||||
Sequence< Reference < XDispatch > > lDispatcher(nCount);
|
||||
for( sal_Int32 i=0; i<nCount; ++i )
|
||||
lDispatcher[i] = this->queryDispatch( seqDescriptor[i].FeatureURL,
|
||||
seqDescriptor[i].FrameName,
|
||||
seqDescriptor[i].SearchFlags );
|
||||
OSL_TRACE("ScriptProtocolHandler::queryDispatches \n" );
|
||||
Sequence< Reference< XDispatch > > lDispatcher( nCount );
|
||||
for ( sal_Int32 i = 0; i < nCount; ++i )
|
||||
{
|
||||
lDispatcher[ i ] = this->queryDispatch( seqDescriptor[ i ].FeatureURL,
|
||||
seqDescriptor[ i ].FrameName,
|
||||
seqDescriptor[ i ].SearchFlags );
|
||||
}
|
||||
OSL_TRACE( "ScriptProtocolHandler::queryDispatches \n" );
|
||||
|
||||
return lDispatcher;
|
||||
}
|
||||
|
||||
void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( const URL& aURL, const Sequence < PropertyValue >& lArgs,
|
||||
const Reference< XDispatchResultListener >& xListener ) throw (RuntimeException)
|
||||
void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
|
||||
const URL& aURL, const Sequence < PropertyValue >& lArgs,
|
||||
const Reference< XDispatchResultListener >& xListener )
|
||||
throw ( RuntimeException )
|
||||
{
|
||||
sal_Bool bSuccess = sal_False;
|
||||
Any invokeResult;
|
||||
|
||||
OSL_TRACE("ScriptProtocolHandler::dispatchWithNotification - start \nInput URL %s \n",
|
||||
::rtl::OUStringToOString(aURL.Complete,RTL_TEXTENCODING_ASCII_US).pData->buffer);
|
||||
OSL_TRACE( "ScriptProtocolHandler::dispatchWithNotification - start \nInput URL %s \n",
|
||||
::rtl::OUStringToOString( aURL.Complete, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
||||
if ( m_bInitialised )
|
||||
{
|
||||
try
|
||||
{
|
||||
Reference < provider::XFunction > xFunc = m_xFunctionProvider->getFunction(aURL.Complete);
|
||||
validateXRef(xFunc, "ScriptProtocolHandler::dispatchWithNotification: validate xFunc - unable to obtain XFunction interface");
|
||||
Reference< provider::XFunction > xFunc =
|
||||
m_xFunctionProvider->getFunction( aURL.Complete );
|
||||
validateXRef( xFunc,
|
||||
"ScriptProtocolHandler::dispatchWithNotification: validate xFunc - unable to obtain XFunction interface" );
|
||||
|
||||
Sequence< Any > inArgs(0);
|
||||
Sequence< Any > outArgs(0);
|
||||
Sequence< Any > inArgs( 0 );
|
||||
Sequence< Any > outArgs( 0 );
|
||||
Sequence< sal_Int16 > outIndex;
|
||||
|
||||
invokeResult = xFunc->invoke(inArgs,outIndex,outArgs);
|
||||
invokeResult = xFunc->invoke( inArgs, outIndex, outArgs );
|
||||
bSuccess = sal_True;
|
||||
}
|
||||
|
||||
// Office doesn't handle exceptions rethrown here very well, it cores,
|
||||
// all we can is log them and then set fail for the dispatch event!
|
||||
// (if there is a listener of course)
|
||||
catch(RuntimeException &e)
|
||||
catch ( RuntimeException & e )
|
||||
{
|
||||
OSL_TRACE("ScriptProtocolHandler::dispatchWithNotificationn caught RuntimeException: %s",::rtl::OUStringToOString(e.Message,RTL_TEXTENCODING_ASCII_US).pData->buffer);
|
||||
::rtl::OUString reason;
|
||||
reason.createFromAscii("ScriptProtocolHandler::dispatchWithNotification: caught RuntimeException: ");
|
||||
reason = reason + e.Message;
|
||||
OSL_TRACE( "ScriptProtocolHandler::dispatchWithNotificationn caught RuntimeException: %s",
|
||||
::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer
|
||||
);
|
||||
::rtl::OUString reason = ::rtl::OUString::createFromAscii(
|
||||
"ScriptProtocolHandler::dispatchWithNotification: caught RuntimeException: "
|
||||
);
|
||||
reason.concat( e.Message );
|
||||
invokeResult <<= reason;
|
||||
}
|
||||
catch (Exception &e)
|
||||
catch ( Exception & e )
|
||||
{
|
||||
OSL_TRACE("ScriptProtocolHandler::dispatchWithNotificationn caught Exception: %s",::rtl::OUStringToOString(e.Message,RTL_TEXTENCODING_ASCII_US).pData->buffer);
|
||||
::rtl::OUString reason;
|
||||
reason.createFromAscii("ScriptProtocolHandler::dispatchWithNotification: caught Exception: ");
|
||||
reason = reason + e.Message;
|
||||
OSL_TRACE( "ScriptProtocolHandler::dispatchWithNotificationn caught Exception: %s",
|
||||
::rtl::OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer
|
||||
);
|
||||
::rtl::OUString reason = ::rtl::OUString::createFromAscii(
|
||||
"ScriptProtocolHandler::dispatchWithNotification: caught Exception: "
|
||||
);
|
||||
reason.concat( e.Message );
|
||||
invokeResult <<= reason;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
catch ( ... )
|
||||
{
|
||||
::rtl::OUString reason;
|
||||
reason.createFromAscii("ScriptProtocolHandler::dispatchWithNotification: caught unknown exception ");
|
||||
::rtl::OUString reason = ::rtl::OUString::createFromAscii(
|
||||
"ScriptProtocolHandler::dispatchWithNotification: caught unknown exception "
|
||||
);
|
||||
invokeResult <<= reason;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
OSL_TRACE("ScriptProtocolHandler::dispatchWithNotification: failed, ScriptProtocolHandler not initialised");
|
||||
::rtl::OUString reason;
|
||||
reason.createFromAscii("ScriptProtocolHandler::dispatchWithNotification failed, ScriptProtocolHandler not initialised");
|
||||
OSL_TRACE( "ScriptProtocolHandler::dispatchWithNotification: failed, ScriptProtocolHandler not initialised" );
|
||||
::rtl::OUString reason = ::rtl::OUString::createFromAscii(
|
||||
"ScriptProtocolHandler::dispatchWithNotification failed, ScriptProtocolHandler not initialised"
|
||||
);
|
||||
invokeResult <<= reason;
|
||||
}
|
||||
|
||||
if( xListener.is() )
|
||||
if ( xListener.is() )
|
||||
{
|
||||
// always call dispatchFinished(), because we didn't load a document but
|
||||
// executed a macro instead!
|
||||
::com::sun::star::frame::DispatchResultEvent aEvent;
|
||||
|
||||
aEvent.Source = static_cast< ::cppu::OWeakObject* >(this);
|
||||
aEvent.Source = static_cast< ::cppu::OWeakObject* >( this );
|
||||
aEvent.Result = invokeResult;
|
||||
if( bSuccess )
|
||||
if ( bSuccess )
|
||||
{
|
||||
aEvent.State = ::com::sun::star::frame::DispatchResultState::SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
aEvent.State = ::com::sun::star::frame::DispatchResultState::FAILURE;
|
||||
}
|
||||
|
||||
xListener->dispatchFinished( aEvent ) ;
|
||||
try
|
||||
{
|
||||
xListener->dispatchFinished( aEvent ) ;
|
||||
}
|
||||
catch(RuntimeException & e)
|
||||
{
|
||||
OSL_TRACE(
|
||||
"ScriptProtocolHandler::dispatchWithNotification: caught RuntimeException"
|
||||
"while dispatchFinished %s",
|
||||
::rtl::OUStringToOString( e.Message,
|
||||
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
||||
}
|
||||
}
|
||||
OSL_TRACE("ScriptProtocolHandler::dispatchWithNotification - end\n" );
|
||||
OSL_TRACE( "ScriptProtocolHandler::dispatchWithNotification - end" );
|
||||
|
||||
}
|
||||
|
||||
void SAL_CALL ScriptProtocolHandler::dispatch( const URL& aURL, const Sequence< PropertyValue >& lArgs )
|
||||
void SAL_CALL ScriptProtocolHandler::dispatch(
|
||||
const URL& aURL, const Sequence< PropertyValue >& lArgs )
|
||||
throw ( RuntimeException )
|
||||
{
|
||||
dispatchWithNotification( aURL, lArgs, Reference < XDispatchResultListener >() );
|
||||
dispatchWithNotification( aURL, lArgs, Reference< XDispatchResultListener >() );
|
||||
}
|
||||
|
||||
void SAL_CALL ScriptProtocolHandler::addStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL )
|
||||
throw (RuntimeException)
|
||||
void SAL_CALL ScriptProtocolHandler::addStatusListener(
|
||||
const Reference< XStatusListener >& xControl, const URL& aURL )
|
||||
throw ( RuntimeException )
|
||||
{
|
||||
// implement if status is supported
|
||||
}
|
||||
|
||||
void SAL_CALL ScriptProtocolHandler::removeStatusListener( const Reference< XStatusListener >& xControl, const URL& aURL )
|
||||
throw (RuntimeException)
|
||||
{
|
||||
}
|
||||
void SAL_CALL ScriptProtocolHandler::removeStatusListener(
|
||||
const Reference< XStatusListener >& xControl, const URL& aURL )
|
||||
throw ( RuntimeException )
|
||||
{}
|
||||
|
||||
ScriptProtocolHandler::ScriptProtocolHandler( Reference < css::lang::XMultiServiceFactory > const& rFact )
|
||||
: m_xFactory( rFact ), m_bInitialised(false)
|
||||
ScriptProtocolHandler::ScriptProtocolHandler(
|
||||
Reference< css::lang::XMultiServiceFactory > const& rFact ) :
|
||||
m_xFactory( rFact ), m_bInitialised( false )
|
||||
{
|
||||
OSL_TRACE("ScriptProtocolHandler::ScriptProtocolHandler - ctor\n" );
|
||||
OSL_TRACE( "ScriptProtocolHandler::ScriptProtocolHandler - ctor" );
|
||||
}
|
||||
|
||||
ScriptProtocolHandler::~ScriptProtocolHandler()
|
||||
{
|
||||
OSL_TRACE("ScriptProtocolHandler::ScriptProtocolHandler - dtor\n" );
|
||||
OSL_TRACE( "ScriptProtocolHandler::ScriptProtocolHandler - dtor" );
|
||||
}
|
||||
|
||||
/* XServiceInfo */
|
||||
::rtl::OUString SAL_CALL ScriptProtocolHandler::getImplementationName() throw( RuntimeException )
|
||||
::rtl::OUString SAL_CALL ScriptProtocolHandler::getImplementationName( )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
return impl_getStaticImplementationName();
|
||||
}
|
||||
|
||||
/* XServiceInfo */
|
||||
sal_Bool SAL_CALL ScriptProtocolHandler::supportsService( const ::rtl::OUString& sServiceName ) throw( RuntimeException )
|
||||
sal_Bool SAL_CALL ScriptProtocolHandler::supportsService(
|
||||
const ::rtl::OUString& sServiceName )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
Sequence< ::rtl::OUString > seqServiceNames = getSupportedServiceNames();
|
||||
const ::rtl::OUString* pArray = seqServiceNames.getConstArray();
|
||||
for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
|
||||
for ( sal_Int32 nCounter = 0; nCounter < seqServiceNames.getLength(); nCounter++ )
|
||||
{
|
||||
if ( pArray[nCounter] == sServiceName )
|
||||
if ( pArray[ nCounter ] == sServiceName )
|
||||
{
|
||||
return sal_True ;
|
||||
}
|
||||
@@ -298,7 +352,8 @@ sal_Bool SAL_CALL ScriptProtocolHandler::supportsService( const ::rtl::OUString&
|
||||
}
|
||||
|
||||
/* XServiceInfo */
|
||||
Sequence< ::rtl::OUString > SAL_CALL ScriptProtocolHandler::getSupportedServiceNames() throw( RuntimeException )
|
||||
Sequence< ::rtl::OUString > SAL_CALL ScriptProtocolHandler::getSupportedServiceNames()
|
||||
throw( RuntimeException )
|
||||
{
|
||||
return impl_getStaticSupportedServiceNames();
|
||||
}
|
||||
@@ -308,77 +363,90 @@ Sequence< ::rtl::OUString > ScriptProtocolHandler::impl_getStaticSupportedServic
|
||||
{
|
||||
::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
|
||||
Sequence< ::rtl::OUString > seqServiceNames( 1 );
|
||||
seqServiceNames.getArray() [0] = ::rtl::OUString::createFromAscii( ::scripting_protocolhandler::MYSERVICENAME );
|
||||
seqServiceNames.getArray() [ 0 ] =
|
||||
::rtl::OUString::createFromAscii( ::scripting_protocolhandler::MYSERVICENAME );
|
||||
return seqServiceNames ;
|
||||
}
|
||||
|
||||
/* Helper for XServiceInfo */
|
||||
::rtl::OUString ScriptProtocolHandler::impl_getStaticImplementationName()
|
||||
{
|
||||
return ::rtl::OUString::createFromAscii( ::scripting_protocolhandler::MYIMPLNAME);
|
||||
return ::rtl::OUString::createFromAscii( ::scripting_protocolhandler::MYIMPLNAME );
|
||||
}
|
||||
|
||||
/* Helper for registry */
|
||||
Reference < XInterface > SAL_CALL ScriptProtocolHandler::impl_createInstance( const Reference < css::lang::XMultiServiceFactory >& xServiceManager ) throw( RuntimeException )
|
||||
Reference< XInterface > SAL_CALL ScriptProtocolHandler::impl_createInstance(
|
||||
const Reference< css::lang::XMultiServiceFactory >& xServiceManager )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
return Reference < XInterface > ( *new ScriptProtocolHandler( xServiceManager ) );
|
||||
return Reference< XInterface > ( *new ScriptProtocolHandler( xServiceManager ) );
|
||||
}
|
||||
|
||||
/* Factory for registration */
|
||||
Reference < XSingleServiceFactory > ScriptProtocolHandler::impl_createFactory( const Reference< XMultiServiceFactory >& xServiceManager )
|
||||
Reference< XSingleServiceFactory > ScriptProtocolHandler::impl_createFactory(
|
||||
const Reference< XMultiServiceFactory >& xServiceManager )
|
||||
{
|
||||
Reference < XSingleServiceFactory > xReturn (
|
||||
Reference< XSingleServiceFactory > xReturn (
|
||||
cppu::createSingleFactory( xServiceManager,
|
||||
ScriptProtocolHandler::impl_getStaticImplementationName(),
|
||||
ScriptProtocolHandler::impl_createInstance,
|
||||
ScriptProtocolHandler::impl_getStaticSupportedServiceNames() )
|
||||
ScriptProtocolHandler::impl_getStaticImplementationName(),
|
||||
ScriptProtocolHandler::impl_createInstance,
|
||||
ScriptProtocolHandler::impl_getStaticSupportedServiceNames() )
|
||||
);
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
}// namespace scripting_protocolhandler
|
||||
} // namespace scripting_protocolhandler
|
||||
|
||||
/* exported functions for registration */
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
|
||||
void SAL_CALL component_getImplementationEnvironment( const sal_Char** ppEnvironmentTypeName ,
|
||||
uno_Environment** ppEnvironment )
|
||||
void SAL_CALL component_getImplementationEnvironment(
|
||||
const sal_Char** ppEnvironmentTypeName, uno_Environment** ppEnvironment )
|
||||
{
|
||||
*ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL component_writeInfo( void* pServiceManager ,
|
||||
void* pRegistryKey )
|
||||
sal_Bool SAL_CALL component_writeInfo( void * pServiceManager ,
|
||||
void * pRegistryKey )
|
||||
{
|
||||
Reference< css::registry::XRegistryKey > xKey( reinterpret_cast< css::registry::XRegistryKey* >( pRegistryKey ) ) ;
|
||||
Reference< css::registry::XRegistryKey > xKey(
|
||||
reinterpret_cast< css::registry::XRegistryKey* >( pRegistryKey ) ) ;
|
||||
|
||||
::rtl::OUString aStr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
|
||||
aStr += ::scripting_protocolhandler::ScriptProtocolHandler::impl_getStaticImplementationName();
|
||||
::rtl::OUString aStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) );
|
||||
aStr +=
|
||||
::scripting_protocolhandler::ScriptProtocolHandler::impl_getStaticImplementationName();
|
||||
|
||||
aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
|
||||
aStr += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/UNO/SERVICES" ) );
|
||||
Reference< css::registry::XRegistryKey > xNewKey = xKey->createKey( aStr );
|
||||
xNewKey->createKey( ::rtl::OUString::createFromAscii(::scripting_protocolhandler::MYSERVICENAME) );
|
||||
xNewKey->createKey(
|
||||
::rtl::OUString::createFromAscii( ::scripting_protocolhandler::MYSERVICENAME )
|
||||
);
|
||||
|
||||
return sal_True;
|
||||
}
|
||||
|
||||
void* SAL_CALL component_getFactory( const sal_Char* pImplementationName ,
|
||||
void* pServiceManager ,
|
||||
void* pRegistryKey )
|
||||
void* SAL_CALL component_getFactory( const sal_Char * pImplementationName ,
|
||||
void * pServiceManager ,
|
||||
void * pRegistryKey )
|
||||
{
|
||||
// Set default return value for this operation - if it failed.
|
||||
void* pReturn = NULL ;
|
||||
void * pReturn = NULL ;
|
||||
|
||||
if (
|
||||
( pImplementationName != NULL ) &&
|
||||
( pServiceManager != NULL )
|
||||
( pServiceManager != NULL )
|
||||
)
|
||||
{
|
||||
// Define variables which are used in following macros.
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory ;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xServiceManager( reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager ) ) ;
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::lang::XSingleServiceFactory > xFactory ;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
|
||||
xServiceManager( reinterpret_cast<
|
||||
::com::sun::star::lang::XMultiServiceFactory* >( pServiceManager ) ) ;
|
||||
|
||||
if ( ::scripting_protocolhandler::ScriptProtocolHandler::impl_getStaticImplementationName().equals( ::rtl::OUString::createFromAscii( pImplementationName ) ) )
|
||||
if ( ::scripting_protocolhandler::ScriptProtocolHandler::impl_getStaticImplementationName().equals(
|
||||
::rtl::OUString::createFromAscii( pImplementationName ) ) )
|
||||
{
|
||||
xFactory = ::scripting_protocolhandler::ScriptProtocolHandler::impl_createFactory( xServiceManager );
|
||||
}
|
||||
|
||||
@@ -1,100 +1,75 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* $RCSfile: scripthandler.hxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* last change: $Author: dfoster $ $Date: 2002-09-20 14:33:14 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
*
|
||||
* $RCSfile: scripthandler.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:23 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _SFX2_SCRIPTHANDLER_HXX
|
||||
#define _SFX2_SCRIPTHANDLER_HXX
|
||||
#ifndef _FRAMEWORK_SCRIPT_SCRIPTHANDLER_HXX
|
||||
#define _FRAMEWORK_SCRIPT_SCRIPTHANDLER_HXX
|
||||
|
||||
// .. as always
|
||||
#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
|
||||
#include <com/sun/star/uno/Reference.h>
|
||||
#endif
|
||||
|
||||
#ifndef _COM_SUN_STAR_UNO_RUNTIMEEXCEPTION_HPP_
|
||||
#include <com/sun/star/uno/RuntimeException.hpp>
|
||||
#endif
|
||||
|
||||
// base classes
|
||||
#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
|
||||
#include <com/sun/star/frame/XDispatchProvider.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _COM_SUN_STAR_FRAME_XNOTIFYINGDISPATCJ_HPP_
|
||||
#include <com/sun/star/frame/XNotifyingDispatch.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
|
||||
#include <com/sun/star/lang/XInitialization.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _CPPUHELPER_IMPLBASE4_HXX_
|
||||
#include <cppuhelper/implbase4.hxx>
|
||||
#endif
|
||||
|
||||
#include <drafts/com/sun/star/script/framework/provider/XFunctionProvider.hpp>
|
||||
|
||||
|
||||
namespace rtl
|
||||
{
|
||||
class OUString;
|
||||
@@ -143,47 +118,74 @@ namespace scripting_protocolhandler
|
||||
#define css ::com::sun::star
|
||||
#define dcss ::drafts::com::sun::star
|
||||
|
||||
class ScriptProtocolHandler : public ::cppu::WeakImplHelper4< css::frame::XDispatchProvider, css::frame::XNotifyingDispatch, css::lang::XServiceInfo, css::lang::XInitialization >
|
||||
class ScriptProtocolHandler :
|
||||
public ::cppu::WeakImplHelper4< css::frame::XDispatchProvider,
|
||||
css::frame::XNotifyingDispatch, css::lang::XServiceInfo, css::lang::XInitialization >
|
||||
{
|
||||
private:
|
||||
bool m_bInitialised;
|
||||
css::uno::Reference < css::lang::XMultiServiceFactory > m_xFactory;
|
||||
css::uno::Reference < css::frame::XFrame > m_xFrame;
|
||||
css::uno::Reference < dcss::script::framework::provider::XFunctionProvider > m_xFunctionProvider;
|
||||
css::uno::Reference < dcss::script::framework::provider::XFunctionProvider >
|
||||
m_xFunctionProvider;
|
||||
|
||||
public:
|
||||
ScriptProtocolHandler( const css::uno::Reference < css::lang::XMultiServiceFactory >& xFactory );
|
||||
virtual ~ScriptProtocolHandler();
|
||||
ScriptProtocolHandler( const css::uno::Reference <
|
||||
css::lang::XMultiServiceFactory >& xFactory );
|
||||
virtual ~ScriptProtocolHandler();
|
||||
|
||||
/* XServiceInfo */
|
||||
virtual ::rtl::OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException );
|
||||
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName ) throw( css::uno::RuntimeException );
|
||||
virtual css::uno::Sequence < ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException );
|
||||
virtual ::rtl::OUString SAL_CALL getImplementationName()
|
||||
throw( css::uno::RuntimeException );
|
||||
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& sServiceName )
|
||||
throw( css::uno::RuntimeException );
|
||||
virtual css::uno::Sequence < ::rtl::OUString > SAL_CALL getSupportedServiceNames()
|
||||
throw( css::uno::RuntimeException );
|
||||
|
||||
/* Helper for XServiceInfo */
|
||||
static css::uno::Sequence < ::rtl::OUString > impl_getStaticSupportedServiceNames();
|
||||
static ::rtl::OUString impl_getStaticImplementationName();
|
||||
|
||||
/* Helper for registry */
|
||||
static css::uno::Reference < css::uno::XInterface > SAL_CALL impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ) throw( css::uno::RuntimeException );
|
||||
static css::uno::Reference < css::lang::XSingleServiceFactory > impl_createFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
|
||||
static css::uno::Reference < css::uno::XInterface > SAL_CALL
|
||||
impl_createInstance(
|
||||
const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager )
|
||||
throw( css::uno::RuntimeException );
|
||||
static css::uno::Reference < css::lang::XSingleServiceFactory > impl_createFactory(
|
||||
const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
|
||||
|
||||
/* Implementation for XDispatchProvider */
|
||||
virtual css::uno::Reference < css::frame::XDispatch > SAL_CALL
|
||||
queryDispatch( const css::util::URL& aURL, const ::rtl::OUString& sTargetFrameName,
|
||||
sal_Int32 eSearchFlags ) throw( css::uno::RuntimeException ) ;
|
||||
virtual css::uno::Sequence< css::uno::Reference < css::frame::XDispatch > > SAL_CALL
|
||||
queryDispatches( const css::uno::Sequence < css::frame::DispatchDescriptor >& seqDescriptor )
|
||||
queryDispatches(
|
||||
const css::uno::Sequence < css::frame::DispatchDescriptor >& seqDescriptor )
|
||||
throw( css::uno::RuntimeException );
|
||||
|
||||
/* Implementation for X(Notifying)Dispatch */
|
||||
virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL, const css::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& Listener ) throw (css::uno::RuntimeException);
|
||||
virtual void SAL_CALL dispatch( const css::util::URL& aURL, const css::uno::Sequence< css::beans::PropertyValue >& lArgs ) throw (css::uno::RuntimeException);
|
||||
virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) throw (css::uno::RuntimeException);
|
||||
virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, const css::util::URL& aURL ) throw (css::uno::RuntimeException);
|
||||
virtual void SAL_CALL dispatchWithNotification(
|
||||
const css::util::URL& aURL,
|
||||
const css::uno::Sequence< ::com::sun::star::beans::PropertyValue >& lArgs,
|
||||
const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchResultListener >& Listener )
|
||||
throw ( css::uno::RuntimeException );
|
||||
virtual void SAL_CALL dispatch(
|
||||
const css::util::URL& aURL,
|
||||
const css::uno::Sequence< css::beans::PropertyValue >& lArgs )
|
||||
throw ( css::uno::RuntimeException );
|
||||
virtual void SAL_CALL addStatusListener(
|
||||
const css::uno::Reference< css::frame::XStatusListener >& xControl,
|
||||
const css::util::URL& aURL )
|
||||
throw ( css::uno::RuntimeException );
|
||||
virtual void SAL_CALL removeStatusListener(
|
||||
const css::uno::Reference< css::frame::XStatusListener >& xControl,
|
||||
const css::util::URL& aURL )
|
||||
throw ( css::uno::RuntimeException );
|
||||
|
||||
/* Implementation for XInitialization */
|
||||
virtual void SAL_CALL initialize( const css::uno::Sequence < css::uno::Any >& aArguments ) throw ( css::uno::Exception );
|
||||
virtual void SAL_CALL initialize(
|
||||
const css::uno::Sequence < css::uno::Any >& aArguments )
|
||||
throw ( css::uno::Exception );
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ScriptingContext.cxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: aledoux $ $Date: 2002-09-25 09:14:20 $
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:25 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -59,8 +59,6 @@
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cppuhelper/implementationentry.hxx>
|
||||
#include <cppuhelper/factory.hxx>
|
||||
|
||||
@@ -79,32 +77,29 @@ namespace func_provider
|
||||
// XScriptingContext implementation
|
||||
//
|
||||
//*************************************************************************
|
||||
ScriptingContext::ScriptingContext( const Reference< XComponentContext > & xContext ) : m_xContext( xContext )
|
||||
ScriptingContext::ScriptingContext( const Reference< XComponentContext > & xContext ) :
|
||||
m_xContext( xContext )
|
||||
{
|
||||
OSL_TRACE( "< ScriptingContext ctor called >\n" );
|
||||
|
||||
validateXRef(m_xContext, "ScriptingContext::ScriptingContext: No context available\n");
|
||||
validateXRef( m_xContext,
|
||||
"ScriptingContext::ScriptingContext: No context available\n" );
|
||||
|
||||
//Setup internal hash map
|
||||
Any nullAny;
|
||||
|
||||
/*m_propertyMap[scripting_constants::DOC_REF] = nullAny;
|
||||
m_propertyMap[scripting_constants::DOC_STORAGE_ID] = nullAny;
|
||||
m_propertyMap[scripting_constants::DOC_URI] = nullAny;
|
||||
m_propertyMap[scripting_constants::RESOLVED_STORAGE_ID] = nullAny;*/
|
||||
doc_ref = nullAny;
|
||||
doc_storage_id = nullAny;
|
||||
doc_uri = nullAny;
|
||||
resolved_storage_id = nullAny;
|
||||
m_propertyMap[ scripting_constants::DOC_REF ] = nullAny;
|
||||
m_propertyMap[ scripting_constants::DOC_STORAGE_ID ] = nullAny;
|
||||
m_propertyMap[ scripting_constants::DOC_URI ] = nullAny;
|
||||
m_propertyMap[ scripting_constants::RESOLVED_STORAGE_ID ] = nullAny;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/*bool ScriptingContext::validateKey( const ::rtl::OUString& key)
|
||||
bool ScriptingContext::validateKey( const ::rtl::OUString& key )
|
||||
{
|
||||
::osl::Guard< osl::Mutex > aGuard( m_mutex );
|
||||
|
||||
return ( m_propertyMap.find( key ) != m_propertyMap.end() );
|
||||
}*/
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
ScriptingContext::~ScriptingContext()
|
||||
@@ -114,92 +109,94 @@ ScriptingContext::~ScriptingContext()
|
||||
|
||||
//*************************************************************************
|
||||
// XPropertySet implementation
|
||||
//
|
||||
//*************************************************************************
|
||||
Reference< beans::XPropertySetInfo > SAL_CALL ScriptingContext::getPropertySetInfo( ) throw (RuntimeException)
|
||||
Reference< beans::XPropertySetInfo > SAL_CALL ScriptingContext::getPropertySetInfo( )
|
||||
throw ( RuntimeException )
|
||||
{
|
||||
return Reference< beans::XPropertySetInfo > (); // Not supported
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void SAL_CALL ScriptingContext::setPropertyValue( const ::rtl::OUString& aPropertyName, const Any& aValue ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, RuntimeException)
|
||||
void SAL_CALL ScriptingContext::setPropertyValue( const ::rtl::OUString& aPropertyName,
|
||||
const Any& aValue )
|
||||
throw ( beans::UnknownPropertyException, beans::PropertyVetoException,
|
||||
lang::IllegalArgumentException, lang::WrappedTargetException,
|
||||
RuntimeException )
|
||||
{
|
||||
/*if ( !validateKey(aPropertyName) )
|
||||
if ( !validateKey( aPropertyName ) )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptingContext::setPropertyValue: invalid key"),
|
||||
Reference< XInterface >());
|
||||
}*/
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptingContext::setPropertyValue: invalid key" ),
|
||||
Reference< XInterface >() );
|
||||
}
|
||||
::osl::Guard< osl::Mutex > aGuard( m_mutex );
|
||||
if ( aPropertyName.equals(scripting_constants::DOC_REF) )
|
||||
doc_ref = aValue;
|
||||
if ( aPropertyName.equals(scripting_constants::DOC_STORAGE_ID) )
|
||||
doc_storage_id = aValue;
|
||||
if ( aPropertyName.equals(scripting_constants::DOC_URI) )
|
||||
doc_uri = aValue;
|
||||
if ( aPropertyName.equals(scripting_constants::RESOLVED_STORAGE_ID) )
|
||||
resolved_storage_id = aValue;
|
||||
//m_propertyMap[ aPropertyName ] = aValue;
|
||||
m_propertyMap[ aPropertyName ] = aValue;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
|
||||
|
||||
Any SAL_CALL ScriptingContext::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, RuntimeException)
|
||||
Any SAL_CALL ScriptingContext::getPropertyValue( const ::rtl::OUString& PropertyName )
|
||||
throw ( beans::UnknownPropertyException,
|
||||
lang::WrappedTargetException, RuntimeException )
|
||||
{
|
||||
Any temp;
|
||||
/*if ( !validateKey(PropertyName) )
|
||||
if ( !validateKey( PropertyName ) )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptingContext::getPropertyValue: invalid key"),
|
||||
Reference< XInterface >());
|
||||
}*/
|
||||
if ( PropertyName.equals(scripting_constants::DOC_REF) )
|
||||
return doc_ref;
|
||||
if ( PropertyName.equals(scripting_constants::DOC_STORAGE_ID) )
|
||||
return doc_storage_id;
|
||||
if ( PropertyName.equals(scripting_constants::DOC_URI) )
|
||||
return doc_uri;
|
||||
if ( PropertyName.equals(scripting_constants::RESOLVED_STORAGE_ID) )
|
||||
return resolved_storage_id;
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptingContext::getPropertyValue: invalid key" ),
|
||||
Reference< XInterface >() );
|
||||
}
|
||||
|
||||
return temp;
|
||||
::osl::Guard< osl::Mutex > aGuard( m_mutex );
|
||||
Any returnValue = m_propertyMap[ PropertyName ];
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptingContext::addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const Reference< beans::XPropertyChangeListener >& xListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, RuntimeException)
|
||||
void SAL_CALL ScriptingContext::addPropertyChangeListener(
|
||||
const ::rtl::OUString& aPropertyName,
|
||||
const Reference< beans::XPropertyChangeListener >& xListener )
|
||||
throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
|
||||
RuntimeException )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptingContext::addPropertyChangeListener: method not supported"),
|
||||
Reference< XInterface >());
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptingContext::addPropertyChangeListener: method not supported" ),
|
||||
Reference< XInterface >() );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptingContext::removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const Reference< beans::XPropertyChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, RuntimeException)
|
||||
void SAL_CALL ScriptingContext::removePropertyChangeListener(
|
||||
const ::rtl::OUString& aPropertyName,
|
||||
const Reference< beans::XPropertyChangeListener >& aListener )
|
||||
throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
|
||||
RuntimeException )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptingContext::removePropertyChangeListener: method not supported"),
|
||||
Reference< XInterface >());
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptingContext::removePropertyChangeListener: method not supported" ),
|
||||
Reference< XInterface >() );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptingContext::addVetoableChangeListener( const ::rtl::OUString& PropertyName, const Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, RuntimeException)
|
||||
void SAL_CALL ScriptingContext::addVetoableChangeListener(
|
||||
const ::rtl::OUString& PropertyName,
|
||||
const Reference< beans::XVetoableChangeListener >& aListener )
|
||||
throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
|
||||
RuntimeException )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptingContext::addVetoableChangeListener: method not supported"),
|
||||
Reference< XInterface >());
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptingContext::addVetoableChangeListener: method not supported" ),
|
||||
Reference< XInterface >() );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptingContext::removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const Reference< beans::XVetoableChangeListener >& aListener ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, RuntimeException)
|
||||
void SAL_CALL ScriptingContext::removeVetoableChangeListener(
|
||||
const ::rtl::OUString& PropertyName,
|
||||
const Reference< beans::XVetoableChangeListener >& aListener )
|
||||
throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
|
||||
RuntimeException )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptingContext::removeVetoableChangeListener: method not supported"),
|
||||
Reference< XInterface >());
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptingContext::removeVetoableChangeListener: method not supported" ),
|
||||
Reference< XInterface >() );
|
||||
}
|
||||
|
||||
} // namespace func_provider
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ScriptingContext.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: aledoux $ $Date: 2002-09-25 09:14:20 $
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:25 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -59,10 +59,10 @@
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_PROTOCOLHANDLER_SCRIPTING_CONTEXT_HXX_
|
||||
#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_PROTOCOLHANDLER_SCRIPTING_CONTEXT_HXX_
|
||||
#ifndef _FRAMEWORK_SCRIPT_PROTOCOLHANDLER_SCRIPTING_CONTEXT_HXX_
|
||||
#define _FRAMEWORK_SCRIPT_PROTOCOLHANDLER_SCRIPTING_CONTEXT_HXX_
|
||||
|
||||
//#include <hash_map>
|
||||
#include <hash_map>
|
||||
|
||||
#include <osl/mutex.hxx>
|
||||
#include <rtl/ustring>
|
||||
@@ -76,41 +76,75 @@ namespace func_provider
|
||||
|
||||
//Typedefs
|
||||
//=============================================================================
|
||||
//typedef ::std::hash_map < ::rtl::OUString, ::com::sun::star::uno::Any,
|
||||
//::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
|
||||
//ScriptingConext_hash;
|
||||
//typedef ::std::vector< ::rtl::OUString >
|
||||
//OUString_vec;
|
||||
typedef ::std::hash_map < ::rtl::OUString, ::com::sun::star::uno::Any,
|
||||
::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ScriptingConext_hash;
|
||||
typedef ::std::vector< ::rtl::OUString > OUString_vec;
|
||||
|
||||
class ScriptingContext : public ::cppu::WeakImplHelper1< ::com::sun::star::beans::XPropertySet >
|
||||
class ScriptingContext :
|
||||
public ::cppu::WeakImplHelper1< ::com::sun::star::beans::XPropertySet >
|
||||
{
|
||||
private:
|
||||
// to obtain other services if needed
|
||||
//ScriptingConext_hash m_propertyMap;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
ScriptingConext_hash m_propertyMap;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
|
||||
m_xContext;
|
||||
|
||||
osl::Mutex m_mutex;
|
||||
osl::Mutex m_mutex;
|
||||
|
||||
// Private helper methods
|
||||
//bool validateKey( const ::rtl::OUString& key);
|
||||
::com::sun::star::uno::Any doc_ref;
|
||||
::com::sun::star::uno::Any doc_storage_id;
|
||||
::com::sun::star::uno::Any doc_uri;
|
||||
::com::sun::star::uno::Any resolved_storage_id;
|
||||
bool validateKey( const ::rtl::OUString& key );
|
||||
|
||||
public:
|
||||
ScriptingContext( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext );
|
||||
ScriptingContext( const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::uno::XComponentContext > & xContext );
|
||||
~ScriptingContext();
|
||||
|
||||
// XPropertySet implementation
|
||||
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo >
|
||||
SAL_CALL getPropertySetInfo( )
|
||||
throw ( ::com::sun::star::uno::RuntimeException );
|
||||
virtual void SAL_CALL setPropertyValue(
|
||||
const ::rtl::OUString& aPropertyName,
|
||||
const ::com::sun::star::uno::Any& aValue )
|
||||
throw ( ::com::sun::star::beans::UnknownPropertyException,
|
||||
::com::sun::star::beans::PropertyVetoException,
|
||||
::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException );
|
||||
virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(
|
||||
const ::rtl::OUString& PropertyName )
|
||||
throw ( ::com::sun::star::beans::UnknownPropertyException,
|
||||
::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException );
|
||||
virtual void SAL_CALL addPropertyChangeListener(
|
||||
const ::rtl::OUString& aPropertyName,
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::beans::XPropertyChangeListener >& xListener )
|
||||
throw ( ::com::sun::star::beans::UnknownPropertyException,
|
||||
::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException );
|
||||
virtual void SAL_CALL removePropertyChangeListener(
|
||||
const ::rtl::OUString& aPropertyName,
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::beans::XPropertyChangeListener >& aListener )
|
||||
throw ( ::com::sun::star::beans::UnknownPropertyException,
|
||||
::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException );
|
||||
virtual void SAL_CALL addVetoableChangeListener(
|
||||
const ::rtl::OUString& PropertyName,
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::beans::XVetoableChangeListener >& aListener )
|
||||
throw ( ::com::sun::star::beans::UnknownPropertyException,
|
||||
::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException );
|
||||
virtual void SAL_CALL removeVetoableChangeListener(
|
||||
const ::rtl::OUString& PropertyName,
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::beans::XVetoableChangeListener >& aListener )
|
||||
throw ( ::com::sun::star::beans::UnknownPropertyException,
|
||||
::com::sun::star::lang::WrappedTargetException,
|
||||
::com::sun::star::uno::RuntimeException );
|
||||
|
||||
};
|
||||
}// func_provider
|
||||
#endif //_DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_PROVIDER_XFUNCTIONPROVIDER_HXX_
|
||||
} // func_provider
|
||||
#endif //_FRAMEWORK_SCRIPT_PROVIDER_XFUNCTIONPROVIDER_HXX_
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ScriptNameResolverImpl.cxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: aledoux $ $Date: 2002-09-24 12:59:31 $
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:26 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -59,10 +59,10 @@
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
|
||||
#include <cppuhelper/implementationentry.hxx>
|
||||
|
||||
#include <util/util.hxx>
|
||||
#include <util/scriptingconstants.hxx>
|
||||
|
||||
@@ -77,32 +77,37 @@ using namespace ::drafts::com::sun::star::script::framework;
|
||||
namespace scripting_runtimemgr
|
||||
{
|
||||
|
||||
const sal_Char* const SERVICE_NAME="drafts.com.sun.star.script.framework.DefaultScriptNameResolver";
|
||||
const sal_Char* const IMPL_NAME="drafts.com.sun.star.script.framework.DefaultScriptNameResolver";
|
||||
const sal_Char* const LANGUAGE_TO_RESOLVE_ON="Java"; // should be configurable
|
||||
OUString nrs_implName = OUString::createFromAscii(IMPL_NAME);
|
||||
OUString nrs_serviceName = OUString::createFromAscii(SERVICE_NAME);
|
||||
const sal_Char* const LANGUAGE_TO_RESOLVE_ON = "Java"; // should be configurable
|
||||
OUString nrs_implName = OUString::createFromAscii(
|
||||
"drafts.com.sun.star.script.framework.DefaultScriptNameResolver" );
|
||||
OUString nrs_serviceName = OUString::createFromAscii(
|
||||
"drafts.com.sun.star.script.framework.DefaultScriptNameResolver" );
|
||||
Sequence< OUString > nrs_serviceNames = Sequence< OUString >( &nrs_serviceName, 1 );
|
||||
|
||||
const sal_Int16 SHARED_STORAGE_ID = 1; // should be in constants def file!!!!???? TBD
|
||||
const sal_Int16 USER_STORAGE_ID = 0;
|
||||
const sal_Int16 DOC_STORAGE_ID_NOT_SET = -1;
|
||||
extern ::rtl_StandardModuleCount s_moduleCount;
|
||||
|
||||
// define storages to search
|
||||
::std::vector< int > SEARCHSIDS;
|
||||
static ::std::vector< int >* m_pSearchIDs = NULL;
|
||||
|
||||
//*************************************************************************
|
||||
ScriptNameResolverImpl::ScriptNameResolverImpl(const Reference< XComponentContext > & xContext ):m_xContext(xContext),mStorageFactory(xContext)
|
||||
ScriptNameResolverImpl::ScriptNameResolverImpl(
|
||||
const Reference< XComponentContext > & xContext ) :
|
||||
m_xContext( xContext ), m_StorageFactory( xContext )
|
||||
{
|
||||
OSL_TRACE( "< ScriptNameResolverImpl ctor called >\n" );
|
||||
SEARCHSIDS.clear();
|
||||
SEARCHSIDS.push_back(DOC_STORAGE_ID_NOT_SET);
|
||||
SEARCHSIDS.push_back(USER_STORAGE_ID);
|
||||
SEARCHSIDS.push_back(SHARED_STORAGE_ID);
|
||||
if(!m_pSearchIDs)
|
||||
{
|
||||
osl::Guard< osl::Mutex > aGuard( m_mutex );
|
||||
if(!m_pSearchIDs)
|
||||
{
|
||||
m_pSearchIDs = new ::std::vector< int >();
|
||||
m_pSearchIDs->push_back( ::scripting_constants::DOC_STORAGE_ID_NOT_SET );
|
||||
m_pSearchIDs->push_back( ::scripting_constants::USER_STORAGE_ID );
|
||||
m_pSearchIDs->push_back( ::scripting_constants::SHARED_STORAGE_ID );
|
||||
}
|
||||
}
|
||||
|
||||
s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
|
||||
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@@ -113,18 +118,20 @@ ScriptNameResolverImpl::~ScriptNameResolverImpl()
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Reference< scripturi::XScriptURI >
|
||||
ScriptNameResolverImpl::resolve(const Reference<scripturi::XScriptURI> & scriptURI, Any& invocationCtx)
|
||||
throw (lang::IllegalArgumentException, script::CannotConvertException, RuntimeException)
|
||||
Reference< scripturi::XScriptURI > ScriptNameResolverImpl::resolve(
|
||||
const Reference< scripturi::XScriptURI > & scriptURI, Any& invocationCtx )
|
||||
throw ( lang::IllegalArgumentException, script::CannotConvertException, RuntimeException )
|
||||
{
|
||||
|
||||
Reference <scripturi::XScriptURI> resolvedName;
|
||||
Reference< scripturi::XScriptURI > resolvedName;
|
||||
Reference< beans::XPropertySet > xPropSetScriptingContext;
|
||||
OSL_TRACE( "ScriptNameResolverImpl::resolve: in resolve - start" );
|
||||
|
||||
if (sal_False == (invocationCtx >>= xPropSetScriptingContext))
|
||||
if ( sal_False == ( invocationCtx >>= xPropSetScriptingContext ) )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptNameResolverImpl::resolve : unable to get XScriptingContext from invocationCtx in/out param"), Reference<XInterface> ());
|
||||
throw RuntimeException( OUSTR(
|
||||
"ScriptNameResolverImpl::resolve : unable to get XScriptingContext from param" ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
|
||||
Any any;
|
||||
@@ -136,73 +143,88 @@ throw (lang::IllegalArgumentException, script::CannotConvertException, RuntimeEx
|
||||
OSL_TRACE( "ScriptNameResolverImpl::resolve: in resolve - got anyUri" );
|
||||
if ( sal_False == ( any >>= docUri ) )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptNameResolverImpl::resolve : unable to get doc Uri from xPropSetScriptingContext"), Reference<XInterface> ());
|
||||
throw RuntimeException( OUSTR(
|
||||
"ScriptNameResolverImpl::resolve : unable to get doc Uri from xPropSetScriptingContext" ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
any = xPropSetScriptingContext->getPropertyValue( scripting_constants::DOC_STORAGE_ID );
|
||||
if ( sal_False == ( any >>= docSid ) )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptNameResolverImpl::resolve : unable to get doc storage id from xPropSetScriptingContext"), Reference<XInterface> ());
|
||||
throw RuntimeException( OUSTR(
|
||||
"ScriptNameResolverImpl::resolve : unable to get doc storage id from xPropSetScriptingContext" ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
}
|
||||
catch (Exception & e)
|
||||
catch ( Exception & e )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptNameResolverImpl::resolve : problem with getPropertyValue");
|
||||
throw RuntimeException(temp.concat(e.Message),
|
||||
Reference<XInterface> ());
|
||||
OUString temp = OUSTR(
|
||||
"ScriptNameResolverImpl::resolve : problem with getPropertyValue" );
|
||||
throw RuntimeException( temp.concat( e.Message ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
catch ( ... )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptNameResolverImpl::resolve Unknown Exception caught - RuntimeException rethrown"), Reference<XInterface> ());
|
||||
throw RuntimeException( OUSTR(
|
||||
"ScriptNameResolverImpl::resolve Unknown Exception caught - RuntimeException rethrown" ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
::rtl::OString docUriO(::rtl::OUStringToOString(docUri ,RTL_TEXTENCODING_ASCII_US));
|
||||
fprintf(stderr,"ScriptNameResolverImpl::resolve: *** >>> DOC URI: %s, doc sid is %d\n", docUriO.pData->buffer,docSid);
|
||||
::rtl::OString docUriO(
|
||||
::rtl::OUStringToOString( docUri , RTL_TEXTENCODING_ASCII_US ) );
|
||||
fprintf( stderr,
|
||||
"ScriptNameResolverImpl::resolve: *** >>> DOC URI: %s, doc sid is %d\n",
|
||||
docUriO.pData->buffer, docSid );
|
||||
#endif
|
||||
|
||||
|
||||
OSL_TRACE("ScriptNameResolverImpl::resolve Starting...");
|
||||
SEARCHSIDS[0] = docSid;
|
||||
OSL_TRACE( "ScriptNameResolverImpl::resolve Starting..." );
|
||||
::std::vector< int >& m_vSearchIDs = *m_pSearchIDs;
|
||||
m_vSearchIDs[ 0 ] = docSid;
|
||||
::std::vector< int >::const_iterator iter;
|
||||
::std::vector< int >::const_iterator iterEnd = m_vSearchIDs.end();
|
||||
|
||||
|
||||
for ( iter = SEARCHSIDS.begin() ; iter != SEARCHSIDS.end(); ++iter)
|
||||
for ( iter = m_vSearchIDs.begin() ; iter != iterEnd; ++iter )
|
||||
{
|
||||
try
|
||||
{
|
||||
OSL_TRACE("** about to resolve from storage using id %d from vector of size %d",*iter,SEARCHSIDS.size());
|
||||
if ( (resolvedName = resolveURIFromStorageID(*iter,scriptURI) ).is() )
|
||||
OSL_TRACE( "** about to resolve from storage using id %d from vector of size %d",
|
||||
*iter, m_vSearchIDs.size() );
|
||||
if ( ( resolvedName = resolveURIFromStorageID( *iter, scriptURI ) ).is() )
|
||||
{
|
||||
OSL_TRACE("found match in uri from storage %d",*iter);
|
||||
OSL_TRACE( "found match in uri from storage %d", *iter );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
catch (Exception & e)
|
||||
catch ( Exception & e )
|
||||
{
|
||||
OSL_TRACE("Exception thrown by storage %d, failed to match uri: %s",*iter,::rtl::OUStringToOString(e.Message,RTL_TEXTENCODING_ASCII_US).pData->buffer);
|
||||
OSL_TRACE( "Exception thrown by storage %d, failed to match uri: %s",
|
||||
*iter,
|
||||
::rtl::OUStringToOString( e.Message,
|
||||
RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
catch ( ... )
|
||||
{
|
||||
OSL_TRACE("unknown exception thrown by storage %d, failed to match uri",*iter);
|
||||
OSL_TRACE( "unknown exception thrown by storage %d, failed to match uri",
|
||||
*iter );
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
return resolvedName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL
|
||||
ScriptNameResolverImpl::getImplementationName( )
|
||||
throw(RuntimeException)
|
||||
ScriptNameResolverImpl::getImplementationName( )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
return nrs_implName;
|
||||
}
|
||||
@@ -210,12 +232,12 @@ throw(RuntimeException)
|
||||
//*************************************************************************
|
||||
sal_Bool SAL_CALL
|
||||
ScriptNameResolverImpl::supportsService( const OUString& serviceName )
|
||||
throw(RuntimeException)
|
||||
throw( RuntimeException )
|
||||
{
|
||||
OUString const * pNames = nrs_serviceNames.getConstArray();
|
||||
for ( sal_Int32 nPos = nrs_serviceNames.getLength(); nPos--; )
|
||||
{
|
||||
if (serviceName.equals( pNames[ nPos ] ))
|
||||
if ( serviceName.equals( pNames[ nPos ] ) )
|
||||
{
|
||||
return sal_True;
|
||||
}
|
||||
@@ -226,89 +248,114 @@ throw(RuntimeException)
|
||||
//*************************************************************************
|
||||
|
||||
Reference< scripturi::XScriptURI >
|
||||
ScriptNameResolverImpl::resolveURIFromStorageID(sal_Int16 sid, const Reference< scripturi::XScriptURI >& scriptURI) SAL_THROW ( (lang::IllegalArgumentException, RuntimeException) )
|
||||
ScriptNameResolverImpl::resolveURIFromStorageID
|
||||
( sal_Int16 sid, const Reference< scripturi::XScriptURI >& scriptURI )
|
||||
SAL_THROW ( ( lang::IllegalArgumentException, RuntimeException ) )
|
||||
{
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
::rtl::OString locationO(::rtl::OUStringToOString(scriptURI->getLocation(),RTL_TEXTENCODING_ASCII_US));
|
||||
::rtl::OString languageO(::rtl::OUStringToOString(scriptURI->getLanguage(),RTL_TEXTENCODING_ASCII_US));
|
||||
::rtl::OString functionName(::rtl::OUStringToOString(scriptURI->getFunctionName(),RTL_TEXTENCODING_ASCII_US));
|
||||
::rtl::OString logicalName(::rtl::OUStringToOString(scriptURI->getLogicalName(),RTL_TEXTENCODING_ASCII_US));
|
||||
fprintf(stderr,"trying to resolve URI, {location = %s}, {language = %s}, {funtionName = %s}, {logicalName = %s}\n", locationO.pData->buffer, languageO.pData->buffer,functionName.pData->buffer, logicalName.pData->buffer);
|
||||
::rtl::OString locationO( ::rtl::OUStringToOString(
|
||||
scriptURI->getLocation(), RTL_TEXTENCODING_ASCII_US ) );
|
||||
::rtl::OString languageO( ::rtl::OUStringToOString(
|
||||
scriptURI->getLanguage(), RTL_TEXTENCODING_ASCII_US ) );
|
||||
::rtl::OString functionName( ::rtl::OUStringToOString(
|
||||
scriptURI->getFunctionName(), RTL_TEXTENCODING_ASCII_US ) );
|
||||
::rtl::OString logicalName( ::rtl::OUStringToOString(
|
||||
scriptURI->getLogicalName(), RTL_TEXTENCODING_ASCII_US ) );
|
||||
fprintf( stderr,
|
||||
"trying to resolve URI, {location = %s}, {language = %s}, {funtionName = %s}, {logicalName = %s}\n",
|
||||
locationO.pData->buffer, languageO.pData->buffer,
|
||||
functionName.pData->buffer, logicalName.pData->buffer );
|
||||
#endif
|
||||
|
||||
Reference< scripturi::XScriptURI > resolvedName;
|
||||
if ( sid == DOC_STORAGE_ID_NOT_SET )
|
||||
if ( sid == ::scripting_constants::DOC_STORAGE_ID_NOT_SET )
|
||||
{
|
||||
return resolvedName;
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
Reference<storage::XScriptImplAccess> storage = mStorageFactory.getStorageInstance(sid);
|
||||
validateXRef(storage, "ScriptNameResolverImpl::resolveURIFromStorageID: cannot get XScriptImplAccess");
|
||||
Sequence< Reference< scripturi::XScriptURI > > results = storage->getImplementations(scriptURI);
|
||||
if ( !results.getLength() )
|
||||
Reference< storage::XScriptImplAccess > storage =
|
||||
m_StorageFactory.getStorageInstance( sid );
|
||||
validateXRef( storage,
|
||||
"ScriptNameResolverImpl::resolveURIFromStorageID: cannot get XScriptImplAccess" );
|
||||
Sequence< Reference< scripturi::XScriptURI > > results =
|
||||
storage->getImplementations( scriptURI );
|
||||
|
||||
const sal_Int32 lenght = results.getLength();
|
||||
|
||||
if ( !lenght )
|
||||
{
|
||||
return resolvedName;
|
||||
}
|
||||
|
||||
OSL_TRACE("ScriptNameResolverImpl::resolve Got some results...");
|
||||
for(int index=0;index<results.getLength();index++)
|
||||
OSL_TRACE( "ScriptNameResolverImpl::resolve Got some results..." );
|
||||
for ( sal_Int32 index = 0;index < lenght;index++ )
|
||||
{
|
||||
Reference< scripturi::XScriptURI > uri = results[index];
|
||||
Reference< scripturi::XScriptURI > uri = results[ index ];
|
||||
#ifdef _DEBUG
|
||||
|
||||
::rtl::OString locationO(::rtl::OUStringToOString(uri->getLocation(),RTL_TEXTENCODING_ASCII_US));
|
||||
::rtl::OString languageO(::rtl::OUStringToOString(uri->getLanguage(),RTL_TEXTENCODING_ASCII_US));
|
||||
::rtl::OString functionName(::rtl::OUStringToOString(uri->getFunctionName(),RTL_TEXTENCODING_ASCII_US));
|
||||
::rtl::OString logicalName(::rtl::OUStringToOString(uri->getLogicalName(),RTL_TEXTENCODING_ASCII_US));
|
||||
fprintf(stderr,"[%d] URI, {location = %s}, {language = %s}, {funtionName = %s}, {logicalName = %s}\n",
|
||||
index, locationO.pData->buffer, languageO.pData->buffer,functionName.pData->buffer, logicalName.pData->buffer);
|
||||
::rtl::OString locationO( ::rtl::OUStringToOString( uri->getLocation(),
|
||||
RTL_TEXTENCODING_ASCII_US ) );
|
||||
::rtl::OString languageO( ::rtl::OUStringToOString( uri->getLanguage(),
|
||||
RTL_TEXTENCODING_ASCII_US ) );
|
||||
::rtl::OString functionName( ::rtl::OUStringToOString( uri->getFunctionName(),
|
||||
RTL_TEXTENCODING_ASCII_US ) );
|
||||
::rtl::OString logicalName( ::rtl::OUStringToOString( uri->getLogicalName(),
|
||||
RTL_TEXTENCODING_ASCII_US ) );
|
||||
fprintf( stderr, "[%d] URI, {location = %s}, {language = %s}, {funtionName = %s}, {logicalName = %s}\n",
|
||||
index, locationO.pData->buffer, languageO.pData->buffer,
|
||||
functionName.pData->buffer, logicalName.pData->buffer );
|
||||
#endif
|
||||
|
||||
// just choose first one that has language=LANGUAGE_TO_RESOLVE_ON
|
||||
::rtl::OUString language(uri->getLanguage());
|
||||
::rtl::OUString language( uri->getLanguage() );
|
||||
|
||||
if (( language.compareToAscii(LANGUAGE_TO_RESOLVE_ON)== 0))
|
||||
if ( ( language.compareToAscii( LANGUAGE_TO_RESOLVE_ON ) == 0 ) )
|
||||
{
|
||||
OSL_TRACE("Found desired language\n");
|
||||
OSL_TRACE( "Found desired language\n" );
|
||||
resolvedName = uri;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (lang::IllegalArgumentException & iae)
|
||||
catch ( lang::IllegalArgumentException & iae )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::resolveURIFromStorageID IllegalArgumentException: ");
|
||||
throw lang::IllegalArgumentException(temp.concat(iae.Message),
|
||||
Reference<XInterface> (), iae.ArgumentPosition);
|
||||
OUString temp = OUSTR(
|
||||
"ScriptRuntimeManager::resolveURIFromStorageID IllegalArgumentException: " );
|
||||
throw lang::IllegalArgumentException( temp.concat( iae.Message ),
|
||||
Reference< XInterface > (),
|
||||
iae.ArgumentPosition );
|
||||
}
|
||||
catch (RuntimeException & re)
|
||||
catch ( RuntimeException & re )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::resolveURIFromStorageID RuntimeException: ");
|
||||
throw RuntimeException(temp.concat(re.Message),
|
||||
Reference<XInterface> ());
|
||||
OUString temp = OUSTR(
|
||||
"ScriptRuntimeManager::resolveURIFromStorageID RuntimeException: " );
|
||||
throw RuntimeException( temp.concat( re.Message ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
catch (Exception & e)
|
||||
catch ( Exception & e )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptNameResolverImpl::resolveURIFromStorageID : Unknown Exception caught - RuntimeException rethrown");
|
||||
throw RuntimeException(temp.concat(e.Message),
|
||||
Reference<XInterface> ());
|
||||
OUString temp = OUSTR(
|
||||
"ScriptNameResolverImpl::resolveURIFromStorageID : Exception caught - RuntimeException rethrown" );
|
||||
throw RuntimeException( temp.concat( e.Message ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
catch ( ... )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptNameResolverImpl::resolveURIFromStorageID Unknown exception caught - RuntimeException rethrown"), Reference<XInterface> ());
|
||||
throw RuntimeException( OUSTR(
|
||||
"ScriptNameResolverImpl::resolveURIFromStorageID Unknown exception caught - RuntimeException rethrown" ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
#endif
|
||||
return resolvedName;
|
||||
}
|
||||
//*************************************************************************
|
||||
Sequence<OUString> SAL_CALL
|
||||
ScriptNameResolverImpl::getSupportedServiceNames( )
|
||||
throw(RuntimeException)
|
||||
ScriptNameResolverImpl::getSupportedServiceNames( )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
return nrs_serviceNames;
|
||||
}
|
||||
@@ -316,9 +363,9 @@ throw(RuntimeException)
|
||||
//*************************************************************************
|
||||
Reference< XInterface > SAL_CALL scriptnri_create(
|
||||
Reference< XComponentContext > const & xComponentContext )
|
||||
SAL_THROW( (Exception) )
|
||||
SAL_THROW( ( Exception ) )
|
||||
{
|
||||
return (cppu::OWeakObject *)new ScriptNameResolverImpl( xComponentContext );
|
||||
return ( cppu::OWeakObject * ) new ScriptNameResolverImpl( xComponentContext );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@@ -1,66 +1,66 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* $RCSfile: ScriptNameResolverImpl.hxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* last change: $Author: dfoster $ $Date: 2002-09-20 14:33:30 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
*
|
||||
* $RCSfile: ScriptNameResolverImpl.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:26 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_SCRIPTNAMERESOLVERIMPL_HXX_
|
||||
#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_SCRIPTNAMERESOLVERIMPL_HXX_
|
||||
#ifndef _FRAMEWORK_SCRIPT_SCRIPTNAMERESOLVERIMPL_HXX_
|
||||
#define _FRAMEWORK_SCRIPT_SCRIPTNAMERESOLVERIMPL_HXX_
|
||||
|
||||
#include <cppuhelper/implbase1.hxx> // helper for XInterface, XTypeProvider etc.
|
||||
|
||||
@@ -78,30 +78,28 @@
|
||||
namespace scripting_runtimemgr
|
||||
{
|
||||
|
||||
class ScriptNameResolverImpl : public ::cppu::WeakImplHelper1< ::drafts::com::sun::star::script::framework::XScriptNameResolver >
|
||||
class ScriptNameResolverImpl :
|
||||
public ::cppu::WeakImplHelper1 <
|
||||
::drafts::com::sun::star::script::framework::XScriptNameResolver >
|
||||
{
|
||||
private:
|
||||
::com::sun::star::uno::Reference< ::drafts::com::sun::star::script::framework::scripturi::XScriptURI > resolveURIFromStorageID(sal_Int16 sid, const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::script::framework::scripturi::XScriptURI >& nameToResolve) SAL_THROW ( ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) );
|
||||
/**********************************************
|
||||
Reference< XComponentContext > m_xContext
|
||||
to obtain other services if needed
|
||||
*/
|
||||
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
StorageBridgeFactory mStorageFactory;
|
||||
::osl::Mutex m_mutex;
|
||||
public:
|
||||
/**********************************************
|
||||
ScriptNameResolverImpl Constructor
|
||||
@param the current context
|
||||
*/
|
||||
ScriptNameResolverImpl(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext);
|
||||
ScriptNameResolverImpl(
|
||||
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >&
|
||||
xContext );
|
||||
~ScriptNameResolverImpl();
|
||||
|
||||
// XServiceInfo implementation
|
||||
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual ::rtl::OUString SAL_CALL getImplementationName( )
|
||||
throw( ::com::sun::star::uno::RuntimeException );
|
||||
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
|
||||
throw( ::com::sun::star::uno::RuntimeException );
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
|
||||
getSupportedServiceNames( )
|
||||
throw( ::com::sun::star::uno::RuntimeException );
|
||||
|
||||
/**********************************************
|
||||
resolve method
|
||||
@@ -109,19 +107,41 @@ public:
|
||||
@param invocationCtx the invocation context contains the
|
||||
documentStorageID and document reference for use in script name
|
||||
resolving. On full name resolution it sets the resolvedScriptStorageID to
|
||||
the actual storage location of the fully resolved script. May or may not * be the same as the documentStorageID.
|
||||
the actual storage location of the fully resolved script. May or may not * be the
|
||||
same as the documentStorageID.
|
||||
@exception CannotResolveScriptNameException
|
||||
@exception IllegalArgumentException
|
||||
@exception NullPointerException
|
||||
@return the resolved XScriptURI
|
||||
*/
|
||||
::com::sun::star::uno::Reference< ::drafts::com::sun::star::script::framework::scripturi::XScriptURI > SAL_CALL
|
||||
resolve(const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::script::framework::scripturi::XScriptURI > & scriptURI,
|
||||
::com::sun::star::uno::Any& invocationCtx)
|
||||
throw(::com::sun::star::script::CannotConvertException,
|
||||
::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::uno::RuntimeException);
|
||||
};
|
||||
}// scripting_runtimemgr
|
||||
::com::sun::star::uno::Reference <
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI > SAL_CALL
|
||||
resolve( const ::com::sun::star::uno::Reference <
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI > &
|
||||
scriptURI,
|
||||
::com::sun::star::uno::Any& invocationCtx )
|
||||
throw( ::com::sun::star::script::CannotConvertException,
|
||||
::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::uno::RuntimeException );
|
||||
private:
|
||||
::com::sun::star::uno::Reference <
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI >
|
||||
resolveURIFromStorageID( sal_Int16 sid,
|
||||
const ::com::sun::star::uno::Reference <
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI > &
|
||||
nameToResolve )
|
||||
SAL_THROW ( ( ::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::uno::RuntimeException ) );
|
||||
/**********************************************
|
||||
Reference< XComponentContext > m_xContext
|
||||
to obtain other services if needed
|
||||
*/
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
|
||||
m_xContext;
|
||||
StorageBridgeFactory m_StorageFactory;
|
||||
::osl::Mutex m_mutex;
|
||||
|
||||
#endif //_DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_SCRIPTNAMERESOLVERIMPL_HXX_
|
||||
};
|
||||
} // scripting_runtimemgr
|
||||
|
||||
#endif //_FRAMEWORK_SCRIPT_SCRIPTNAMERESOLVERIMPL_HXX_
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ScriptRuntimeManager.cxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: aledoux $ $Date: 2002-09-24 12:59:32 $
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:26 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -59,12 +59,10 @@
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cppuhelper/implementationentry.hxx>
|
||||
|
||||
#include "ScriptRuntimeManager.hxx"
|
||||
#include "ScriptNameResolverImpl.hxx"
|
||||
#include "ScriptRuntimeManager.hxx"
|
||||
#include <util/util.hxx>
|
||||
|
||||
using namespace ::rtl;
|
||||
@@ -76,19 +74,19 @@ using namespace ::drafts::com::sun::star::script::framework;
|
||||
namespace scripting_runtimemgr
|
||||
{
|
||||
|
||||
static const sal_Char* const SERVICENAME="drafts.com.sun.star.script.framework.ScriptRuntimeManager";
|
||||
static const sal_Char* const IMPLNAME="drafts.com.sun.star.script.framework.ScriptRuntimeManager";
|
||||
|
||||
static OUString s_implName = ::rtl::OUString::createFromAscii(IMPLNAME);
|
||||
static OUString s_serviceName = ::rtl::OUString::createFromAscii(SERVICENAME);
|
||||
static OUString s_implName = ::rtl::OUString::createFromAscii(
|
||||
"drafts.com.sun.star.script.framework.ScriptRuntimeManager" );
|
||||
static OUString s_serviceName = ::rtl::OUString::createFromAscii(
|
||||
"drafts.com.sun.star.script.framework.ScriptRuntimeManager" );
|
||||
static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 );
|
||||
|
||||
::rtl_StandardModuleCount s_moduleCount = MODULE_COUNT_INIT;
|
||||
|
||||
//*************************************************************************
|
||||
// ScriptRuntimeManager Constructor
|
||||
ScriptRuntimeManager::ScriptRuntimeManager(const Reference< XComponentContext > & xContext)
|
||||
: m_xContext( xContext )
|
||||
ScriptRuntimeManager::ScriptRuntimeManager(
|
||||
const Reference< XComponentContext > & xContext ) :
|
||||
m_xContext( xContext )
|
||||
{
|
||||
OSL_TRACE( "< ScriptRuntimeManager ctor called >\n" );
|
||||
s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
|
||||
@@ -104,29 +102,35 @@ ScriptRuntimeManager::~ScriptRuntimeManager()
|
||||
|
||||
//*************************************************************************
|
||||
// Get the proper XScriptInvocation
|
||||
Reference <XScriptInvocation> SAL_CALL ScriptRuntimeManager::getScriptRuntime(const Reference<scripturi::XScriptURI>& scriptURI)
|
||||
throw(RuntimeException)
|
||||
Reference< XScriptInvocation > SAL_CALL ScriptRuntimeManager::getScriptRuntime(
|
||||
const Reference< scripturi::XScriptURI >& scriptURI )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
OSL_TRACE("** ==> ScriptRuntimeManager in getScriptRuntime\n");
|
||||
OSL_TRACE( "** ==> ScriptRuntimeManager in getScriptRuntime\n" );
|
||||
|
||||
Reference< XScriptInvocation > xScriptInvocation;
|
||||
|
||||
validateXRef(m_xContext, "ScriptRuntimeManager::GetScriptRuntime: No context available");
|
||||
validateXRef( m_xContext,
|
||||
"ScriptRuntimeManager::GetScriptRuntime: No context available" );
|
||||
Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
|
||||
validateXRef(xMgr, "ScriptRuntimeManager::GetScriptRuntime: No service manager available");
|
||||
validateXRef( xMgr,
|
||||
"ScriptRuntimeManager::GetScriptRuntime: No service manager available" );
|
||||
|
||||
try
|
||||
{
|
||||
Reference< XInterface > xx;
|
||||
Any a = m_xContext->getValueByName(OUString::createFromAscii("/singletons/drafts.com.sun.star.script.framework.theScriptRuntimeForJava"));
|
||||
Any a = m_xContext->getValueByName( OUString::createFromAscii(
|
||||
"/singletons/drafts.com.sun.star.script.framework.theScriptRuntimeForJava" ) );
|
||||
a >>= xx;
|
||||
validateXRef(xx, "ScriptRuntimeManager::GetScriptRuntime: cannot get ScriptRuntimeForJava Service");
|
||||
xScriptInvocation = Reference<XScriptInvocation>(xx, UNO_QUERY_THROW);
|
||||
validateXRef( xx,
|
||||
"ScriptRuntimeManager::GetScriptRuntime: cannot get ScriptRuntimeForJava Service"
|
||||
);
|
||||
xScriptInvocation = Reference< XScriptInvocation >( xx, UNO_QUERY_THROW );
|
||||
}
|
||||
catch (Exception &e)
|
||||
catch ( Exception & e )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::GetScriptRuntime: ");
|
||||
throw RuntimeException( temp.concat(e.Message), Reference< XInterface >());
|
||||
OUString temp = OUSTR( "ScriptRuntimeManager::GetScriptRuntime: " );
|
||||
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
|
||||
}
|
||||
|
||||
return xScriptInvocation;
|
||||
@@ -134,27 +138,33 @@ throw(RuntimeException)
|
||||
|
||||
//*************************************************************************
|
||||
// Get the proper XScriptNameResolver
|
||||
Reference <XScriptNameResolver> SAL_CALL
|
||||
Reference< XScriptNameResolver > SAL_CALL
|
||||
ScriptRuntimeManager::getScriptNameResolver()
|
||||
throw(RuntimeException)
|
||||
throw( RuntimeException )
|
||||
{
|
||||
OSL_TRACE("** ==> ScriptRuntimeManager in getScriptNameResolver\n");
|
||||
OSL_TRACE( "** ==> ScriptRuntimeManager in getScriptNameResolver\n" );
|
||||
Reference< XScriptNameResolver > xScriptNameResolver;
|
||||
|
||||
validateXRef(m_xContext, "ScriptRuntimeManager::GetScriptNameResolver: No context available");
|
||||
validateXRef( m_xContext,
|
||||
"ScriptRuntimeManager::GetScriptNameResolver: No context available" );
|
||||
Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager();
|
||||
validateXRef(xMgr, "ScriptRuntimeManager::GetScriptRuntime: No Service Manager available");
|
||||
validateXRef( xMgr,
|
||||
"ScriptRuntimeManager::GetScriptRuntime: No Service Manager available" );
|
||||
|
||||
try
|
||||
{
|
||||
Reference< XInterface > xx = xMgr->createInstanceWithContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.DefaultScriptNameResolver"),m_xContext );
|
||||
validateXRef(xx, "ScriptRuntimeManager::GetScriptRuntime: cannot get instance of DefaultScriptNameResolver" );
|
||||
xScriptNameResolver = Reference<XScriptNameResolver>(xx, UNO_QUERY_THROW);
|
||||
Reference< XInterface > xx = xMgr->createInstanceWithContext(
|
||||
OUString::createFromAscii(
|
||||
"drafts.com.sun.star.script.framework.DefaultScriptNameResolver" ),
|
||||
m_xContext );
|
||||
validateXRef( xx,
|
||||
"ScriptRuntimeManager::GetScriptRuntime: cannot get instance of DefaultScriptNameResolver" );
|
||||
xScriptNameResolver = Reference< XScriptNameResolver >( xx, UNO_QUERY_THROW );
|
||||
}
|
||||
catch (Exception &e)
|
||||
catch ( Exception & e )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::GetScriptNameResolver: ");
|
||||
throw RuntimeException( temp.concat(e.Message), Reference< XInterface >());
|
||||
OUString temp = OUSTR( "ScriptRuntimeManager::GetScriptNameResolver: " );
|
||||
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
|
||||
}
|
||||
return xScriptNameResolver;
|
||||
}
|
||||
@@ -162,10 +172,13 @@ throw(RuntimeException)
|
||||
//*************************************************************************
|
||||
// XScriptInvocation implementation
|
||||
Any SAL_CALL ScriptRuntimeManager::invoke(
|
||||
const Reference < scripturi::XScriptURI > & scriptURI,
|
||||
const Any& invocationCtx, const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam ) throw (lang::IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, RuntimeException)
|
||||
const Reference< scripturi::XScriptURI > & scriptURI,
|
||||
const Any& invocationCtx, const Sequence< Any >& aParams,
|
||||
Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam )
|
||||
throw ( lang::IllegalArgumentException, script::CannotConvertException,
|
||||
reflection::InvocationTargetException, RuntimeException )
|
||||
{
|
||||
OSL_TRACE("** ==> ScriptRuntimeManager in runtimemgr invoke\n");
|
||||
OSL_TRACE( "** ==> ScriptRuntimeManager in runtimemgr invoke\n" );
|
||||
Any results;
|
||||
// Initialise resolved context with invocation context,
|
||||
// the resolved context (resolvedCtx will be modified by the
|
||||
@@ -174,45 +187,51 @@ Any SAL_CALL ScriptRuntimeManager::invoke(
|
||||
Any resolvedCtx = invocationCtx;
|
||||
try
|
||||
{
|
||||
Reference< scripturi::XScriptURI > resolvedURI = resolve(scriptURI, resolvedCtx);
|
||||
validateXRef(resolvedURI, "ScriptRuntimeManager::invoke: No resolvedURI" );
|
||||
Reference< scripturi::XScriptURI > resolvedURI = resolve( scriptURI,
|
||||
resolvedCtx );
|
||||
validateXRef( resolvedURI, "ScriptRuntimeManager::invoke: No resolvedURI" );
|
||||
|
||||
Reference< XScriptInvocation > xScriptInvocation = getScriptRuntime(resolvedURI);
|
||||
validateXRef(xScriptInvocation, "ScriptRuntimeManager::invoke: cannot get instance of language specific runtime.");
|
||||
Reference< XScriptInvocation > xScriptInvocation =
|
||||
getScriptRuntime( resolvedURI );
|
||||
validateXRef( xScriptInvocation,
|
||||
"ScriptRuntimeManager::invoke: cannot get instance of language specific runtime." );
|
||||
|
||||
|
||||
results = xScriptInvocation->invoke(resolvedURI,resolvedCtx,aParams,
|
||||
aOutParamIndex,aOutParam);
|
||||
results = xScriptInvocation->invoke( resolvedURI, resolvedCtx, aParams,
|
||||
aOutParamIndex, aOutParam );
|
||||
}
|
||||
catch (lang::IllegalArgumentException & iae)
|
||||
catch ( lang::IllegalArgumentException & iae )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::invoke IllegalArgumentException: ");
|
||||
throw lang::IllegalArgumentException(temp.concat(iae.Message),
|
||||
Reference<XInterface> (), iae.ArgumentPosition);
|
||||
OUString temp = OUSTR( "ScriptRuntimeManager::invoke IllegalArgumentException: " );
|
||||
throw lang::IllegalArgumentException( temp.concat( iae.Message ),
|
||||
Reference< XInterface > (),
|
||||
iae.ArgumentPosition );
|
||||
}
|
||||
catch (script::CannotConvertException & cce)
|
||||
catch ( script::CannotConvertException & cce )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::invoke CannotConvertException: ");
|
||||
throw script::CannotConvertException(temp.concat(cce.Message),
|
||||
Reference<XInterface> (), cce.DestinationTypeClass, cce.Reason, cce.ArgumentIndex);
|
||||
OUString temp = OUSTR( "ScriptRuntimeManager::invoke CannotConvertException: " );
|
||||
throw script::CannotConvertException( temp.concat( cce.Message ),
|
||||
Reference< XInterface > (),
|
||||
cce.DestinationTypeClass, cce.Reason,
|
||||
cce.ArgumentIndex );
|
||||
}
|
||||
catch (reflection::InvocationTargetException & ite)
|
||||
catch ( reflection::InvocationTargetException & ite )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::invoke InvocationTargetException: ");
|
||||
throw reflection::InvocationTargetException(temp.concat(ite.Message),
|
||||
Reference<XInterface> (), ite.TargetException);
|
||||
OUString temp = OUSTR( "ScriptRuntimeManager::invoke InvocationTargetException: " );
|
||||
throw reflection::InvocationTargetException( temp.concat( ite.Message ),
|
||||
Reference< XInterface > (), ite.TargetException );
|
||||
}
|
||||
catch (RuntimeException & re)
|
||||
catch ( RuntimeException & re )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::invoke RuntimeException: ");
|
||||
throw RuntimeException(temp.concat(re.Message),
|
||||
Reference<XInterface> ());
|
||||
OUString temp = OUSTR( "ScriptRuntimeManager::invoke RuntimeException: " );
|
||||
throw RuntimeException( temp.concat( re.Message ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
catch ( ... )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptRuntimeManager::invoke UnknownException: "),
|
||||
Reference<XInterface> ());
|
||||
throw RuntimeException( OUSTR( "ScriptRuntimeManager::invoke UnknownException: " ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
#endif
|
||||
return results;
|
||||
@@ -220,42 +239,50 @@ Any SAL_CALL ScriptRuntimeManager::invoke(
|
||||
|
||||
//*************************************************************************
|
||||
// XScriptNameResolver implementation
|
||||
Reference<scripturi::XScriptURI> SAL_CALL ScriptRuntimeManager::resolve(const Reference<scripturi::XScriptURI>& scriptURI,Any& invocationCtx)
|
||||
throw(lang::IllegalArgumentException, script::CannotConvertException, RuntimeException)
|
||||
Reference< scripturi::XScriptURI > SAL_CALL
|
||||
ScriptRuntimeManager::resolve( const Reference< scripturi::XScriptURI >& scriptURI,
|
||||
Any& invocationCtx )
|
||||
throw( lang::IllegalArgumentException, script::CannotConvertException, RuntimeException )
|
||||
{
|
||||
OSL_TRACE("** ==> ScriptRuntimeManager in resolve\n");
|
||||
OSL_TRACE( "** ==> ScriptRuntimeManager in resolve\n" );
|
||||
Reference< scripturi::XScriptURI > resolvedURI;
|
||||
|
||||
Reference< XScriptNameResolver > xScriptNameResolver = getScriptNameResolver();
|
||||
validateXRef(xScriptNameResolver, "ScriptRuntimeManager::resolve: No ScriptNameResolver");
|
||||
validateXRef( xScriptNameResolver,
|
||||
"ScriptRuntimeManager::resolve: No ScriptNameResolver" );
|
||||
|
||||
try
|
||||
{
|
||||
resolvedURI = xScriptNameResolver->resolve(scriptURI,invocationCtx);
|
||||
resolvedURI = xScriptNameResolver->resolve( scriptURI, invocationCtx );
|
||||
}
|
||||
catch (lang::IllegalArgumentException & iae)
|
||||
catch ( lang::IllegalArgumentException & iae )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::resolve IllegalArgumentException: ");
|
||||
throw lang::IllegalArgumentException(temp.concat(iae.Message),
|
||||
Reference<XInterface> (), iae.ArgumentPosition);
|
||||
OUString temp =
|
||||
OUSTR( "ScriptRuntimeManager::resolve IllegalArgumentException: " );
|
||||
throw lang::IllegalArgumentException( temp.concat( iae.Message ),
|
||||
Reference< XInterface > (),
|
||||
iae.ArgumentPosition );
|
||||
}
|
||||
catch (script::CannotConvertException & cce)
|
||||
catch ( script::CannotConvertException & cce )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::resolve CannotConvertException: ");
|
||||
throw script::CannotConvertException(temp.concat(cce.Message),
|
||||
Reference<XInterface> (), cce.DestinationTypeClass, cce.Reason, cce.ArgumentIndex);
|
||||
OUString temp = OUSTR( "ScriptRuntimeManager::resolve CannotConvertException: " );
|
||||
throw script::CannotConvertException( temp.concat( cce.Message ),
|
||||
Reference< XInterface > (),
|
||||
cce.DestinationTypeClass, cce.Reason,
|
||||
cce.ArgumentIndex );
|
||||
}
|
||||
catch (RuntimeException & re)
|
||||
catch ( RuntimeException & re )
|
||||
{
|
||||
OUString temp = OUSTR("ScriptRuntimeManager::resolve RuntimeException: ");
|
||||
throw RuntimeException(temp.concat(re.Message),
|
||||
Reference<XInterface> ());
|
||||
OUString temp = OUSTR( "ScriptRuntimeManager::resolve RuntimeException: " );
|
||||
throw RuntimeException( temp.concat( re.Message ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
catch ( ... )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptRuntimeManager::resolve UnknownException: "),
|
||||
Reference<XInterface> ());
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptRuntimeManager::resolve UnknownException: " ),
|
||||
Reference< XInterface > () );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -263,20 +290,20 @@ throw(lang::IllegalArgumentException, script::CannotConvertException, RuntimeExc
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptRuntimeManager::getImplementationName( )
|
||||
throw(RuntimeException)
|
||||
OUString SAL_CALL ScriptRuntimeManager::getImplementationName( )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
return s_implName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
sal_Bool SAL_CALL ScriptRuntimeManager::supportsService( const OUString& serviceName )
|
||||
throw(RuntimeException)
|
||||
throw( RuntimeException )
|
||||
{
|
||||
OUString const * pNames = s_serviceNames.getConstArray();
|
||||
for ( sal_Int32 nPos = s_serviceNames.getLength(); nPos--; )
|
||||
{
|
||||
if (serviceName.equals( pNames[ nPos ] ))
|
||||
if ( serviceName.equals( pNames[ nPos ] ) )
|
||||
{
|
||||
return sal_True;
|
||||
}
|
||||
@@ -285,28 +312,28 @@ throw(RuntimeException)
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Sequence<OUString> SAL_CALL ScriptRuntimeManager::getSupportedServiceNames( )
|
||||
throw(RuntimeException)
|
||||
Sequence<OUString> SAL_CALL ScriptRuntimeManager::getSupportedServiceNames( )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
return s_serviceNames;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
static Reference<XInterface> SAL_CALL srm_create(
|
||||
static Reference< XInterface > SAL_CALL srm_create(
|
||||
const Reference< XComponentContext > & xCompC )
|
||||
{
|
||||
return (cppu::OWeakObject *)new ScriptRuntimeManager( xCompC );
|
||||
return ( cppu::OWeakObject * ) new ScriptRuntimeManager( xCompC );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
static Sequence<OUString> srm_getSupportedServiceNames( )
|
||||
static Sequence<OUString> srm_getSupportedServiceNames( )
|
||||
SAL_THROW( () )
|
||||
{
|
||||
return s_serviceNames;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
static OUString srm_getImplementationName( )
|
||||
static OUString srm_getImplementationName( )
|
||||
SAL_THROW( () )
|
||||
{
|
||||
return s_implName;
|
||||
@@ -315,7 +342,7 @@ SAL_THROW( () )
|
||||
//*************************************************************************
|
||||
Reference< XInterface > SAL_CALL scriptnri_create(
|
||||
Reference< XComponentContext > const & xComponentContext )
|
||||
SAL_THROW( (Exception) );
|
||||
SAL_THROW( ( Exception ) );
|
||||
|
||||
//*************************************************************************
|
||||
Sequence< OUString > scriptnri_getSupportedServiceNames() SAL_THROW( () );
|
||||
@@ -340,16 +367,17 @@ static struct cppu::ImplementationEntry s_entries [] =
|
||||
};
|
||||
} // Namespace
|
||||
|
||||
//##################################################################################################
|
||||
//#### EXPORTED ####################################################################################
|
||||
//##################################################################################################
|
||||
//#######################################################################################
|
||||
//#### EXPORTED #########################################################################
|
||||
//#######################################################################################
|
||||
|
||||
/**
|
||||
* Gives the environment this component belongs to.
|
||||
*/
|
||||
extern "C"
|
||||
{
|
||||
void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv)
|
||||
void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName,
|
||||
uno_Environment ** ppEnv )
|
||||
{
|
||||
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
|
||||
}
|
||||
@@ -361,9 +389,11 @@ extern "C"
|
||||
* @param pServiceManager the service manager
|
||||
* @param pRegistryKey the registry key
|
||||
*/
|
||||
sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey)
|
||||
sal_Bool SAL_CALL component_writeInfo( lang::XMultiServiceFactory * pServiceManager,
|
||||
registry::XRegistryKey * pRegistryKey )
|
||||
{
|
||||
return ::cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, ::scripting_runtimemgr::s_entries);
|
||||
return ::cppu::component_writeInfoHelper( pServiceManager, pRegistryKey,
|
||||
::scripting_runtimemgr::s_entries );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,11 +401,15 @@ extern "C"
|
||||
*
|
||||
* @param pImplName name of implementation
|
||||
* @param pServiceManager a service manager, need for component creation
|
||||
* @param pRegistryKey the registry key for this component, need for persistent data
|
||||
* @param pRegistryKey the registry key for this component, need for persistent
|
||||
* data
|
||||
* @return a component factory
|
||||
*/
|
||||
void * SAL_CALL component_getFactory(const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey)
|
||||
void * SAL_CALL component_getFactory( const sal_Char * pImplName,
|
||||
lang::XMultiServiceFactory * pServiceManager,
|
||||
registry::XRegistryKey * pRegistryKey )
|
||||
{
|
||||
return ::cppu::component_getFactoryHelper(pImplName, pServiceManager, pRegistryKey, ::scripting_runtimemgr::s_entries);
|
||||
return ::cppu::component_getFactoryHelper( pImplName, pServiceManager,
|
||||
pRegistryKey, ::scripting_runtimemgr::s_entries );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* $RCSfile: ScriptRuntimeManager.hxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* last change: $Author: dfoster $ $Date: 2002-09-20 14:33:32 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
*
|
||||
* $RCSfile: ScriptRuntimeManager.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:26 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_SCRIPTRUNTIMEMANAGER_HXX_
|
||||
#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_SCRIPTRUNTIMEMANAGER_HXX_
|
||||
#ifndef _FRAMEWORK_SCRIPT_SCRIPTRUNTIMEMANAGER_HXX_
|
||||
#define _FRAMEWORK_SCRIPT_SCRIPTRUNTIMEMANAGER_HXX_
|
||||
|
||||
#include <osl/mutex.hxx>
|
||||
|
||||
@@ -82,20 +82,26 @@ namespace scripting_runtimemgr
|
||||
/**
|
||||
* Class responsible for managing the various ScriptRuntime implementations.
|
||||
*/
|
||||
class ScriptRuntimeManager : public ::cppu::WeakImplHelper3< ::drafts::com::sun::star::script::framework::XScriptInvocation, ::com::sun::star::lang::XServiceInfo, ::drafts::com::sun::star::script::framework::XScriptNameResolver >
|
||||
class ScriptRuntimeManager :
|
||||
public ::cppu::WeakImplHelper3<
|
||||
::drafts::com::sun::star::script::framework::XScriptInvocation,
|
||||
::com::sun::star::lang::XServiceInfo,
|
||||
::drafts::com::sun::star::script::framework::XScriptNameResolver >
|
||||
{
|
||||
// to obtain other services if needed
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
::osl::Mutex m_mutex;
|
||||
public:
|
||||
ScriptRuntimeManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext );
|
||||
explicit ScriptRuntimeManager( const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::uno::XComponentContext > & xContext );
|
||||
~ScriptRuntimeManager();
|
||||
|
||||
|
||||
// XServiceInfo implementation
|
||||
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual ::rtl::OUString SAL_CALL getImplementationName( )
|
||||
throw( ::com::sun::star::uno::RuntimeException );
|
||||
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
|
||||
throw( ::com::sun::star::uno::RuntimeException );
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
|
||||
getSupportedServiceNames( )
|
||||
throw( ::com::sun::star::uno::RuntimeException );
|
||||
|
||||
/**
|
||||
* implements XScriptInvocation, invokes the script named in scriptURI
|
||||
@@ -108,7 +114,8 @@ public:
|
||||
Invoke
|
||||
@param scriptUri script uri describing the script
|
||||
@param invocationCtx
|
||||
the invocation context contains the documentStorageID and document reference for use in script name resolving
|
||||
the invocation context contains the documentStorageID and document reference
|
||||
for use in script name resolving
|
||||
|
||||
@param aParams all parameters; pure, out params are undefined in sequence,
|
||||
i.e., the value has to be ignored by the callee
|
||||
@@ -126,12 +133,21 @@ public:
|
||||
of the invokee
|
||||
|
||||
@throws InvocationTargetException
|
||||
if the running script throws an exception this information is captured and rethrown as this exception type.
|
||||
if the running script throws an exception this information is captured and
|
||||
rethrown as this exception type.
|
||||
|
||||
*/
|
||||
virtual ::com::sun::star::uno::Any SAL_CALL invoke(
|
||||
const ::com::sun::star::uno::Reference < ::drafts::com::sun::star::script::framework::scripturi::XScriptURI > & scriptUri,
|
||||
const ::com::sun::star::uno::Any& invocationCtx, 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::lang::IllegalArgumentException, ::com::sun::star::script::CannotConvertException, ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI > & scriptUri,
|
||||
const ::com::sun::star::uno::Any& invocationCtx,
|
||||
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::lang::IllegalArgumentException,
|
||||
::com::sun::star::script::CannotConvertException,
|
||||
::com::sun::star::reflection::InvocationTargetException,
|
||||
::com::sun::star::uno::RuntimeException );
|
||||
|
||||
/**
|
||||
* implements XScriptNameResolver, attempts to resolve the script URI
|
||||
@@ -141,19 +157,34 @@ public:
|
||||
* @param invocationCtx the invocation context contains the
|
||||
* documentStorageID and document reference for use in script name
|
||||
* resolving. On full name resolution it sets the resolvedScriptStorageID to
|
||||
* the actual storage location of the fully resolved script. May or may not * be the same as the documentStorageID.
|
||||
* the actual storage location of the fully resolved script. May or may not * be the
|
||||
same as the documentStorageID.
|
||||
* @return the resolved URI
|
||||
*/
|
||||
virtual ::com::sun::star::uno::Reference < ::drafts::com::sun::star::script::framework::scripturi::XScriptURI > SAL_CALL
|
||||
resolve( const ::com::sun::star::uno::Reference < ::drafts::com::sun::star::script::framework::scripturi::XScriptURI >& scriptUri ,::com::sun::star::uno::Any& invocationCtx)
|
||||
throw(::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::script::CannotConvertException,
|
||||
::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI > SAL_CALL
|
||||
resolve(
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI >& scriptUri ,
|
||||
::com::sun::star::uno::Any& invocationCtx )
|
||||
throw( ::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::script::CannotConvertException,
|
||||
::com::sun::star::uno::RuntimeException );
|
||||
|
||||
private:
|
||||
::com::sun::star::uno::Reference < ::drafts::com::sun::star::script::framework::XScriptInvocation > SAL_CALL getScriptRuntime(const ::com::sun::star::uno::Reference < ::drafts::com::sun::star::script::framework::scripturi::XScriptURI > & scriptUri) throw( ::com::sun::star::uno::RuntimeException);
|
||||
::com::sun::star::uno::Reference < ::drafts::com::sun::star::script::framework::XScriptNameResolver > SAL_CALL getScriptNameResolver() throw( ::com::sun::star::uno::RuntimeException);
|
||||
::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::XScriptInvocation > SAL_CALL
|
||||
getScriptRuntime( const ::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI > & scriptUri )
|
||||
throw( ::com::sun::star::uno::RuntimeException );
|
||||
::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::XScriptNameResolver > SAL_CALL
|
||||
getScriptNameResolver() throw( ::com::sun::star::uno::RuntimeException );
|
||||
// to obtain other services if needed
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
|
||||
m_xContext;
|
||||
::osl::Mutex m_mutex;
|
||||
};
|
||||
} // scripting_runtimemgr
|
||||
|
||||
#endif //_COM_SUN_STAR_SCRIPTING_SCRIPTRUNTIMEMANAGER_HXX_
|
||||
#endif //_FRAMEWORK_SCRIPT_SCRIPTRUNTIMEMANAGER_HXX_
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: StorageBridge.cxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: aledoux $ $Date: 2002-09-24 12:59:32 $
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:26 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -59,11 +59,6 @@
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <rtl/ustring.hxx>
|
||||
#include <osl/diagnose.h>
|
||||
|
||||
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
|
||||
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp>
|
||||
|
||||
@@ -79,77 +74,91 @@ using namespace ::drafts::com::sun::star::script::framework;
|
||||
namespace scripting_runtimemgr
|
||||
{
|
||||
|
||||
const char* const SCRIPTIMPLACCESS_SERVICE = "drafts.com.sun.star.script.framework.storage.StorageProxy";
|
||||
const char* const SCRIPTSTORAGEMANAGER_SERVICE = "/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager";
|
||||
const char* const SCRIPTIMPLACCESS_SERVICE =
|
||||
"drafts.com.sun.star.script.framework.storage.StorageProxy";
|
||||
const char* const SCRIPTSTORAGEMANAGER_SERVICE =
|
||||
"/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager";
|
||||
const int STORAGEID = 0;
|
||||
const int STORAGEPROXY = 0;
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
// StorageBridge Constructor
|
||||
StorageBridge::StorageBridge( const Reference< XComponentContext >& xContext, sal_Int16 sid ):m_xContext(xContext),m_sid(sid)
|
||||
StorageBridge::StorageBridge( const Reference< XComponentContext >& xContext,
|
||||
sal_uInt16 sid ) : m_xContext( xContext ), m_sid( sid )
|
||||
{
|
||||
try
|
||||
{
|
||||
initStorage();
|
||||
}
|
||||
catch(RuntimeException& re)
|
||||
catch ( RuntimeException & re )
|
||||
{
|
||||
OUString temp = OUSTR("StorageBridge::StorageBridge(salIn32&): ");
|
||||
throw RuntimeException( temp.concat(re.Message), Reference< XInterface >());
|
||||
OUString temp = OUSTR( "StorageBridge::StorageBridge(salIn32&): " );
|
||||
throw RuntimeException( temp.concat( re.Message ), Reference< XInterface >() );
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void
|
||||
StorageBridge::initStorage() throw (::com::sun::star::uno::RuntimeException)
|
||||
StorageBridge::initStorage() throw ( ::com::sun::star::uno::RuntimeException )
|
||||
{
|
||||
try
|
||||
{
|
||||
Reference< lang::XMultiComponentFactory > xMultiComFac = m_xContext->getServiceManager();
|
||||
validateXRef(xMultiComFac, "StorageBridge::StorageBridge: cannot get multicomponentfactory from multiservice factory");
|
||||
Reference< lang::XMultiComponentFactory > xMultiComFac =
|
||||
m_xContext->getServiceManager();
|
||||
validateXRef( xMultiComFac,
|
||||
"StorageBridge::StorageBridge: cannot get multicomponentfactory from multiservice factory" );
|
||||
Reference< XInterface > temp;
|
||||
|
||||
if(STORAGEPROXY)
|
||||
if ( STORAGEPROXY )
|
||||
{
|
||||
temp = xMultiComFac->createInstanceWithContext(OUString::createFromAscii(SCRIPTIMPLACCESS_SERVICE),m_xContext);
|
||||
validateXRef(temp, "StorageBridge::StorageBridge: cannot get Storage service");
|
||||
m_xScriptImplAccess = Reference< storage::XScriptImplAccess > (temp, UNO_QUERY_THROW);
|
||||
temp = xMultiComFac->createInstanceWithContext(
|
||||
OUString::createFromAscii( SCRIPTIMPLACCESS_SERVICE ), m_xContext );
|
||||
validateXRef( temp, "StorageBridge::StorageBridge: cannot get Storage service" );
|
||||
m_xScriptImplAccess = Reference< storage::XScriptImplAccess > ( temp,
|
||||
UNO_QUERY_THROW );
|
||||
}
|
||||
else
|
||||
{
|
||||
Any a = m_xContext->getValueByName(OUString::createFromAscii(SCRIPTSTORAGEMANAGER_SERVICE));
|
||||
Any a = m_xContext->getValueByName(
|
||||
OUString::createFromAscii( SCRIPTSTORAGEMANAGER_SERVICE ) );
|
||||
a >>= temp;
|
||||
validateXRef(temp, "StorageBridge::StorageBridge: cannot get Storage service");
|
||||
Reference < storage::XScriptStorageManager > xScriptStorageManager = Reference< storage::XScriptStorageManager > (temp, UNO_QUERY_THROW);
|
||||
validateXRef(xScriptStorageManager, "StorageBridge::StorageBridge: cannot get Script Storage Manager service");
|
||||
Reference < XInterface > xScriptStorage = xScriptStorageManager->getScriptStorage(m_sid);
|
||||
validateXRef(xScriptStorage, "StorageBridge::StorageBridge: cannot get Script Storage service");
|
||||
m_xScriptImplAccess = Reference< storage::XScriptImplAccess > (xScriptStorage, UNO_QUERY_THROW);
|
||||
validateXRef( temp,
|
||||
"StorageBridge::StorageBridge: cannot get Storage service" );
|
||||
Reference< storage::XScriptStorageManager > xScriptStorageManager =
|
||||
Reference< storage::XScriptStorageManager > ( temp, UNO_QUERY_THROW );
|
||||
validateXRef( xScriptStorageManager,
|
||||
"StorageBridge::StorageBridge: cannot get Script Storage Manager service" );
|
||||
Reference< XInterface > xScriptStorage =
|
||||
xScriptStorageManager->getScriptStorage( m_sid );
|
||||
validateXRef( xScriptStorage,
|
||||
"StorageBridge::StorageBridge: cannot get Script Storage service" );
|
||||
m_xScriptImplAccess =
|
||||
Reference< storage::XScriptImplAccess > ( xScriptStorage, UNO_QUERY_THROW );
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch ( Exception e )
|
||||
{
|
||||
OUString temp = OUSTR("StorageBridge::StorageBridge: ");
|
||||
throw RuntimeException( temp.concat(e.Message), Reference< XInterface >());
|
||||
OUString temp = OUSTR( "StorageBridge::StorageBridge: " );
|
||||
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
|
||||
}
|
||||
}
|
||||
//*************************************************************************
|
||||
Sequence < Reference< scripturi::XScriptURI > >
|
||||
StorageBridge::getImplementations(const Reference< scripturi::XScriptURI >& queryURI )
|
||||
throw (lang::IllegalArgumentException, RuntimeException)
|
||||
StorageBridge::getImplementations( const Reference< scripturi::XScriptURI >& queryURI )
|
||||
throw ( lang::IllegalArgumentException, RuntimeException )
|
||||
{
|
||||
OSL_TRACE("In StorageBridge getImplementations...\n");
|
||||
OSL_TRACE( "In StorageBridge getImplementations...\n" );
|
||||
Sequence < Reference< scripturi::XScriptURI > > results;
|
||||
try
|
||||
{
|
||||
results = m_xScriptImplAccess->getImplementations(queryURI);
|
||||
results = m_xScriptImplAccess->getImplementations( queryURI );
|
||||
}
|
||||
catch (Exception e)
|
||||
catch ( Exception e )
|
||||
{
|
||||
OUString temp = OUSTR("StorageBridge::getImplementations: ");
|
||||
throw RuntimeException( temp.concat(e.Message), Reference< XInterface >());
|
||||
OUString temp = OUSTR( "StorageBridge::getImplementations: " );
|
||||
throw RuntimeException( temp.concat( e.Message ), Reference< XInterface >() );
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
}// namespace
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* $RCSfile: StorageBridge.hxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* last change: $Author: dfoster $ $Date: 2002-09-20 14:33:33 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
*
|
||||
* $RCSfile: StorageBridge.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:26 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGEBRIDGE_HXX_
|
||||
#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGEBRIDGE_HXX_
|
||||
#ifndef _FRAMEWORK_SCRIPT_STORAGEBRIDGE_HXX_
|
||||
#define _FRAMEWORK_SCRIPT_STORAGEBRIDGE_HXX_
|
||||
|
||||
#include <cppuhelper/implbase1.hxx>
|
||||
#include <com/sun/star/uno/XComponentContext.hpp>
|
||||
@@ -71,18 +71,41 @@
|
||||
|
||||
namespace scripting_runtimemgr
|
||||
{
|
||||
class StorageBridge : public ::cppu::WeakImplHelper1< ::drafts::com::sun::star::script::framework::storage::XScriptImplAccess >
|
||||
class StorageBridge :
|
||||
public ::cppu::WeakImplHelper1<
|
||||
::drafts::com::sun::star::script::framework::storage::XScriptImplAccess >
|
||||
{
|
||||
friend class StorageBridgeFactory;
|
||||
public:
|
||||
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::drafts::com::sun::star::script::framework::scripturi::XScriptURI > > SAL_CALL getImplementations( const ::com::sun::star::uno::Reference< ::drafts::com::sun::star::script::framework::scripturi::XScriptURI >& queryURI ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
|
||||
//XScriptImplAccess
|
||||
//=========================================================================
|
||||
/**
|
||||
* Get the implementations for a given URI
|
||||
*
|
||||
* @param queryURI
|
||||
* The URI to get the implementations for
|
||||
*
|
||||
* @return XScriptURI
|
||||
* The URIs of the implementations
|
||||
*/
|
||||
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI > > SAL_CALL
|
||||
getImplementations(
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI >& queryURI )
|
||||
throw ( ::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::uno::RuntimeException );
|
||||
private:
|
||||
StorageBridge(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, sal_Int16 sid );
|
||||
StorageBridge( const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::uno::XComponentContext >& xContext, sal_uInt16 sid );
|
||||
|
||||
void initStorage() throw (::com::sun::star::uno::RuntimeException);
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
::com::sun::star::uno::Reference< ::drafts::com::sun::star::script::framework::storage::XScriptImplAccess > m_xScriptImplAccess;
|
||||
sal_Int16 m_sid;
|
||||
void initStorage() throw ( ::com::sun::star::uno::RuntimeException );
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
|
||||
m_xContext;
|
||||
::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::storage::XScriptImplAccess >
|
||||
m_xScriptImplAccess;
|
||||
sal_uInt16 m_sid;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,99 +1,100 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* $RCSfile: StorageBridgeFactory.cxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* last change: $Author: dfoster $ $Date: 2002-09-20 14:33:34 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
*
|
||||
* $RCSfile: StorageBridgeFactory.cxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:27 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#include "StorageBridgeFactory.hxx"
|
||||
|
||||
#include "StorageBridge.hxx"
|
||||
|
||||
|
||||
using namespace ::drafts::com::sun::star::script::framework;
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
|
||||
namespace scripting_runtimemgr
|
||||
{
|
||||
|
||||
//*************************************************************************
|
||||
StorageBridgeFactory::StorageBridgeFactory( const Reference< XComponentContext >& xContext ):
|
||||
m_xContext(xContext)
|
||||
{
|
||||
}
|
||||
StorageBridgeFactory::StorageBridgeFactory(
|
||||
const Reference< XComponentContext >& xContext ) :
|
||||
m_xContext( xContext )
|
||||
{}
|
||||
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
// StorageBridge is a bridge between us an storage, the StorageBridge implements the XScriptImplAccess
|
||||
// interface, it allows both the "real" storage and a java test storage component to be configured.
|
||||
// StorageBridge is a bridge between us an storage, the StorageBridge implements the
|
||||
// XScriptImplAccess
|
||||
// interface, it allows both the "real" storage and a java test storage component to be
|
||||
// configured.
|
||||
// @param location contains a url for the document.
|
||||
// @returns a storage instance for the location "location".
|
||||
// @see StorageBridge.cxx for flag "STORAGEPROXY", set to use java "test" component or use "real" storage.
|
||||
|
||||
// @see StorageBridge.cxx for flag "STORAGEPROXY", set to use java "test" component or
|
||||
// use "real" storage.
|
||||
|
||||
Reference< storage::XScriptImplAccess >
|
||||
StorageBridgeFactory::getStorageInstance(sal_Int16 sid)
|
||||
StorageBridgeFactory::getStorageInstance( sal_Int16 sid )
|
||||
{
|
||||
|
||||
Reference <storage::XScriptImplAccess> storage = new StorageBridge(m_xContext,sid) ;
|
||||
Reference< storage::XScriptImplAccess > storage = new StorageBridge( m_xContext,
|
||||
sid ) ;
|
||||
return storage;
|
||||
}
|
||||
} //scripting_runtimemgr
|
||||
|
||||
@@ -1,67 +1,67 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* $RCSfile: StorageBridgeFactory.hxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
*
|
||||
* last change: $Author: dfoster $ $Date: 2002-09-20 14:33:34 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
*
|
||||
* $RCSfile: StorageBridgeFactory.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:27 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGEBRIDGEFACTORY_HXX_
|
||||
#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGEBRIDGEFACTORY_HXX_
|
||||
#ifndef _FRAMEWORK_SCRIPT_STORAGEBRIDGEFACTORY_HXX_
|
||||
#define _FRAMEWORK_SCRIPT_STORAGEBRIDGEFACTORY_HXX_
|
||||
|
||||
#include <rtl/ustring>
|
||||
|
||||
@@ -76,11 +76,16 @@ class StorageBridgeFactory
|
||||
{
|
||||
|
||||
public:
|
||||
StorageBridgeFactory(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
|
||||
::com::sun::star::uno::Reference< ::drafts::com::sun::star::script::framework::storage::XScriptImplAccess > getStorageInstance(sal_Int16 sid);
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
explicit StorageBridgeFactory( const ::com::sun::star::uno::Reference <
|
||||
::com::sun::star::uno::XComponentContext > & xContext
|
||||
);
|
||||
::com::sun::star::uno::Reference <
|
||||
::drafts::com::sun::star::script::framework::storage::XScriptImplAccess >
|
||||
getStorageInstance( sal_Int16 sid );
|
||||
private:
|
||||
StorageBridgeFactory();// No definition for default ctor
|
||||
StorageBridgeFactory(); // No definition for default ctor
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >
|
||||
m_xContext;
|
||||
};
|
||||
}// scripting_runtimemgr
|
||||
#endif //_DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_NAMERESOLVER_HXX_
|
||||
} // scripting_runtimemgr
|
||||
#endif //_FRAMEWORK_SCRIPT_NAMERESOLVER_HXX_
|
||||
|
||||
@@ -1,332 +1,326 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* $RCSfile: ScriptInfo.cxx,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: dsherwin $ $Date: 2002-09-23 16:30:52 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cppuhelper/implementationentry.hxx>
|
||||
|
||||
#include <util/util.hxx>
|
||||
#include <ScriptInfo.hxx>
|
||||
#include <osl/file.hxx>
|
||||
|
||||
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGE_XSCRIPTSTORAGEMANAGER_HPP_
|
||||
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp>
|
||||
#endif
|
||||
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGE_XPARCELINVOCATIONPREP_HPP_
|
||||
#include <drafts/com/sun/star/script/framework/storage/XParcelInvocationPrep.hpp>
|
||||
#endif
|
||||
|
||||
using namespace ::rtl;
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace com::sun::star::beans;
|
||||
using namespace ::drafts::com::sun::star::script::framework;
|
||||
using namespace ::drafts::com::sun::star::script::framework::storage;
|
||||
|
||||
namespace scripting_impl
|
||||
{
|
||||
|
||||
const sal_Char* const SI_SERVICE_NAME="drafts.com.sun.star.script.framework.storage.ScriptInfo";
|
||||
const sal_Char* const SI_IMPL_NAME="drafts.com.sun.star.script.framework.storage.ScriptInfo";
|
||||
|
||||
static OUString si_implName = OUString::createFromAscii(SI_IMPL_NAME);
|
||||
static OUString si_serviceName = OUString::createFromAscii(SI_SERVICE_NAME);
|
||||
static Sequence< OUString > si_serviceNames = Sequence< OUString >( &si_serviceName, 1 );
|
||||
|
||||
extern ::rtl_StandardModuleCount s_moduleCount;
|
||||
|
||||
static sal_Char docUriPrefix [] = "vnd.sun.star.pkg";
|
||||
|
||||
//*************************************************************************
|
||||
ScriptInfo::ScriptInfo( const Reference< XComponentContext > & xContext )
|
||||
: m_xContext( xContext )
|
||||
{
|
||||
OSL_TRACE( "< ++++++ ScriptInfo ctor called >\n" );
|
||||
s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
ScriptInfo::~ScriptInfo()
|
||||
{
|
||||
OSL_TRACE( "< ScriptInfo dtor called >\n" );
|
||||
s_moduleCount.modCnt.release( &s_moduleCount.modCnt );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void ScriptInfo::initialize(Sequence <Any> const & args)
|
||||
throw (RuntimeException, Exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (((args[0] >>= m_scriptImplInfo) == sal_False) ||
|
||||
((args[1] >>= m_storageID) == sal_False)) {
|
||||
throw RuntimeException(OUSTR("ScriptInfo: initialize(): "), Reference< XInterface >());
|
||||
}
|
||||
}
|
||||
catch (Exception &e)
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptInfo: initialize(): ") + e.Message, Reference< XInterface >());
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getLogicalName( ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
return m_scriptImplInfo.logicalName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptInfo::setLogicalName( const OUString& name ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
m_scriptImplInfo.logicalName = name;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getDescription( ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
return m_scriptImplInfo.scriptDescription;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptInfo::setDescription( const OUString& desc ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
m_scriptImplInfo.scriptDescription = desc;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getLanguage( ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
return m_scriptImplInfo.scriptLanguage;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptInfo::setLanguage( const OUString& language ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
m_scriptImplInfo.scriptLanguage = language;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getScriptLocation()
|
||||
throw ( RuntimeException )
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
return m_scriptImplInfo.scriptLocation;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
sal_Bool SAL_CALL ScriptInfo::hasSource( ) throw (RuntimeException)
|
||||
{
|
||||
return m_scriptImplInfo.scriptSource;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getLanguageSpecificName( ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
return m_scriptImplInfo.functionName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptInfo::setLanguageSpecificName( const OUString& langName ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
m_scriptImplInfo.functionName = langName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getRoot( ) throw (RuntimeException)
|
||||
{
|
||||
return m_scriptImplInfo.scriptRoot;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Sequence< OUString > SAL_CALL ScriptInfo::getDependencies( ) throw (RuntimeException)
|
||||
{
|
||||
storage::ScriptDepFile *pArray = m_scriptImplInfo.scriptDependencies.getArray();
|
||||
int len = m_scriptImplInfo.scriptDependencies.getLength();
|
||||
Sequence< OUString > r_deps(len);
|
||||
for(int i = 0; i < len; i++)
|
||||
{
|
||||
r_deps[i] = pArray[i].fileName;
|
||||
}
|
||||
|
||||
return r_deps;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getLocation( ) throw (RuntimeException)
|
||||
{
|
||||
OUString location = OUString::createFromAscii("need to be done");
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Reference< XPropertySet > SAL_CALL ScriptInfo::extraProperties( ) throw (RuntimeException)
|
||||
{
|
||||
Reference <XPropertySet> x;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getImplementationName( )
|
||||
throw(RuntimeException)
|
||||
{
|
||||
return si_implName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/**
|
||||
* This function prepares the script for invocation and returns the full path
|
||||
* to the prepared parcel folder
|
||||
*
|
||||
*/
|
||||
::rtl::OUString SAL_CALL ScriptInfo::prepareForInvocation() throw(RuntimeException)
|
||||
{
|
||||
OSL_TRACE("******* In ScriptInfo::prepareForInvocation() *************\n");
|
||||
try
|
||||
{
|
||||
if (m_scriptImplInfo.parcelURI.compareToAscii(docUriPrefix, 16) != 0) {
|
||||
return m_scriptImplInfo.parcelURI;
|
||||
}
|
||||
|
||||
validateXRef(m_xContext, "ScriptInfo::prepareForInvocation(): invalid context");
|
||||
Any aAny=m_xContext->getValueByName(
|
||||
OUString::createFromAscii(
|
||||
"/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager"));
|
||||
Reference <XInterface> xx;
|
||||
if ((aAny >>= xx) == sal_False) {
|
||||
throw RuntimeException(OUSTR("ScriptInfo::prepareForInvocation(): could not get ScriptStorageManager"), Reference< XInterface >());
|
||||
}
|
||||
|
||||
validateXRef(xx, "ScriptInfo::prepareForInvocation(): could not get XInterface");
|
||||
Reference<XScriptStorageManager> xSSM(xx,UNO_QUERY);
|
||||
validateXRef(xSSM, "ScriptInfo::prepareForInvocation(): could not get XScriptStorageManager");
|
||||
xx = xSSM->getScriptStorage(m_storageID);
|
||||
validateXRef(xx, "ScriptInfo::prepareForInvocation(): could not get XInterface");
|
||||
Reference <XParcelInvocationPrep> xPIP(xx, UNO_QUERY);
|
||||
validateXRef(xPIP, "ScriptInfo::prepareForInvocation(): could not get XParcelInvocationPrep");
|
||||
return xPIP->prepareForInvocation(m_scriptImplInfo.parcelURI);
|
||||
}
|
||||
catch(RuntimeException &e)
|
||||
{
|
||||
OUString temp = OUSTR(
|
||||
"ScriptInfo::prepareForInvocation RuntimeException: ");
|
||||
throw RuntimeException(temp.concat(e.Message),
|
||||
Reference<XInterface> ());
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
catch ( ... )
|
||||
{
|
||||
throw RuntimeException(OUSTR(
|
||||
"ScriptInfo::prepareForInvocation UnknownException: "),
|
||||
Reference<XInterface> ());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
sal_Bool SAL_CALL ScriptInfo::supportsService( const OUString& serviceName )
|
||||
throw(RuntimeException)
|
||||
{
|
||||
OUString const * pNames = si_serviceNames.getConstArray();
|
||||
for ( sal_Int32 nPos = si_serviceNames.getLength(); nPos--; )
|
||||
{
|
||||
if (serviceName.equals( pNames[ nPos ] ))
|
||||
{
|
||||
return sal_True;
|
||||
}
|
||||
}
|
||||
return sal_False;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Sequence<OUString> SAL_CALL ScriptInfo::getSupportedServiceNames( )
|
||||
throw(RuntimeException)
|
||||
{
|
||||
return si_serviceNames;
|
||||
}
|
||||
//*************************************************************************
|
||||
Reference<XInterface> SAL_CALL si_create(
|
||||
const Reference< XComponentContext > & xCompC )
|
||||
{
|
||||
return (cppu::OWeakObject *)new ScriptInfo( xCompC );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Sequence<OUString> si_getSupportedServiceNames( )
|
||||
SAL_THROW( () )
|
||||
{
|
||||
return si_serviceNames;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString si_getImplementationName( )
|
||||
SAL_THROW( () )
|
||||
{
|
||||
return si_implName;
|
||||
}
|
||||
}
|
||||
/*************************************************************************
|
||||
*
|
||||
* $RCSfile: ScriptInfo.cxx,v $
|
||||
*
|
||||
* $Revision: 1.4 $
|
||||
*
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:28 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
#include <cppuhelper/implementationentry.hxx>
|
||||
|
||||
#include <util/util.hxx>
|
||||
#include <ScriptInfo.hxx>
|
||||
#include <osl/file.hxx>
|
||||
|
||||
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp>
|
||||
#include <drafts/com/sun/star/script/framework/storage/XParcelInvocationPrep.hpp>
|
||||
|
||||
using namespace ::rtl;
|
||||
using namespace com::sun::star;
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::drafts::com::sun::star::script::framework;
|
||||
using namespace ::drafts::com::sun::star::script::framework::storage;
|
||||
|
||||
namespace scripting_impl
|
||||
{
|
||||
|
||||
const sal_Char* const SI_SERVICE_NAME="drafts.com.sun.star.script.framework.storage.ScriptInfo";
|
||||
const sal_Char* const SI_IMPL_NAME="drafts.com.sun.star.script.framework.storage.ScriptInfo";
|
||||
|
||||
static OUString si_implName = OUString::createFromAscii(SI_IMPL_NAME);
|
||||
static OUString si_serviceName = OUString::createFromAscii(SI_SERVICE_NAME);
|
||||
static Sequence< OUString > si_serviceNames = Sequence< OUString >( &si_serviceName, 1 );
|
||||
|
||||
extern ::rtl_StandardModuleCount s_moduleCount;
|
||||
|
||||
static sal_Char docUriPrefix [] = "vnd.sun.star.pkg";
|
||||
|
||||
//*************************************************************************
|
||||
ScriptInfo::ScriptInfo( const Reference< XComponentContext > & xContext )
|
||||
: m_xContext( xContext )
|
||||
{
|
||||
OSL_TRACE( "< ++++++ ScriptInfo ctor called >\n" );
|
||||
s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
ScriptInfo::~ScriptInfo()
|
||||
{
|
||||
OSL_TRACE( "< ScriptInfo dtor called >\n" );
|
||||
s_moduleCount.modCnt.release( &s_moduleCount.modCnt );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void ScriptInfo::initialize(Sequence <Any> const & args)
|
||||
throw (RuntimeException, Exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (((args[0] >>= m_scriptImplInfo) == sal_False) ||
|
||||
((args[1] >>= m_storageID) == sal_False)) {
|
||||
throw RuntimeException(OUSTR("ScriptInfo: initialize(): "), Reference< XInterface >());
|
||||
}
|
||||
}
|
||||
catch (Exception &e)
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptInfo: initialize(): ").concat(e.Message), Reference< XInterface >());
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getLogicalName( ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
return m_scriptImplInfo.logicalName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptInfo::setLogicalName( const OUString& name ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
m_scriptImplInfo.logicalName = name;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getDescription( ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
return m_scriptImplInfo.scriptDescription;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptInfo::setDescription( const OUString& desc ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
m_scriptImplInfo.scriptDescription = desc;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getLanguage( ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
return m_scriptImplInfo.scriptLanguage;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptInfo::setLanguage( const OUString& language ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
m_scriptImplInfo.scriptLanguage = language;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getScriptLocation()
|
||||
throw ( RuntimeException )
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
return m_scriptImplInfo.scriptLocation;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
sal_Bool SAL_CALL ScriptInfo::hasSource( ) throw (RuntimeException)
|
||||
{
|
||||
return m_scriptImplInfo.scriptSource;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getLanguageSpecificName( ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
return m_scriptImplInfo.functionName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptInfo::setLanguageSpecificName( const OUString& langName ) throw (RuntimeException)
|
||||
{
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
m_scriptImplInfo.functionName = langName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getRoot( ) throw (RuntimeException)
|
||||
{
|
||||
return m_scriptImplInfo.scriptRoot;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Sequence< OUString > SAL_CALL ScriptInfo::getDependencies( ) throw (RuntimeException)
|
||||
{
|
||||
storage::ScriptDepFile *pArray = m_scriptImplInfo.scriptDependencies.getArray();
|
||||
sal_Int32 len = m_scriptImplInfo.scriptDependencies.getLength();
|
||||
Sequence< OUString > r_deps(len);
|
||||
for(sal_Int32 i = 0; i < len; i++)
|
||||
{
|
||||
r_deps[i] = pArray[i].fileName;
|
||||
}
|
||||
|
||||
return r_deps;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getLocation( ) throw (RuntimeException)
|
||||
{
|
||||
OUString location = OUString::createFromAscii("need to be done");
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Reference< beans::XPropertySet > SAL_CALL ScriptInfo::extraProperties( ) throw (RuntimeException)
|
||||
{
|
||||
Reference < beans::XPropertySet > x;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptInfo::getImplementationName( )
|
||||
throw(RuntimeException)
|
||||
{
|
||||
return si_implName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/**
|
||||
* This function prepares the script for invocation and returns the full path
|
||||
* to the prepared parcel folder
|
||||
*
|
||||
*/
|
||||
::rtl::OUString SAL_CALL ScriptInfo::prepareForInvocation() throw(RuntimeException)
|
||||
{
|
||||
OSL_TRACE("******* In ScriptInfo::prepareForInvocation() *************\n");
|
||||
try
|
||||
{
|
||||
if (m_scriptImplInfo.parcelURI.compareToAscii(docUriPrefix, 16) != 0) {
|
||||
return m_scriptImplInfo.parcelURI;
|
||||
}
|
||||
|
||||
validateXRef(m_xContext, "ScriptInfo::prepareForInvocation(): invalid context");
|
||||
Any aAny=m_xContext->getValueByName(
|
||||
OUString::createFromAscii(
|
||||
"/singletons/drafts.com.sun.star.script.framework.storage.theScriptStorageManager"));
|
||||
Reference <XInterface> xx;
|
||||
if ((aAny >>= xx) == sal_False) {
|
||||
throw RuntimeException(OUSTR("ScriptInfo::prepareForInvocation(): could not get ScriptStorageManager"), Reference< XInterface >());
|
||||
}
|
||||
|
||||
validateXRef(xx, "ScriptInfo::prepareForInvocation(): could not get XInterface");
|
||||
Reference<XScriptStorageManager> xSSM(xx,UNO_QUERY);
|
||||
validateXRef(xSSM, "ScriptInfo::prepareForInvocation(): could not get XScriptStorageManager");
|
||||
xx = xSSM->getScriptStorage(m_storageID);
|
||||
validateXRef(xx, "ScriptInfo::prepareForInvocation(): could not get XInterface");
|
||||
Reference <XParcelInvocationPrep> xPIP(xx, UNO_QUERY);
|
||||
validateXRef(xPIP, "ScriptInfo::prepareForInvocation(): could not get XParcelInvocationPrep");
|
||||
return xPIP->prepareForInvocation(m_scriptImplInfo.parcelURI);
|
||||
}
|
||||
catch(RuntimeException &e)
|
||||
{
|
||||
OUString temp = OUSTR(
|
||||
"ScriptInfo::prepareForInvocation RuntimeException: ");
|
||||
throw RuntimeException(temp.concat(e.Message),
|
||||
Reference<XInterface> ());
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
catch ( ... )
|
||||
{
|
||||
throw RuntimeException(OUSTR(
|
||||
"ScriptInfo::prepareForInvocation UnknownException: "),
|
||||
Reference<XInterface> ());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
sal_Bool SAL_CALL ScriptInfo::supportsService( const OUString& serviceName )
|
||||
throw(RuntimeException)
|
||||
{
|
||||
OUString const * pNames = si_serviceNames.getConstArray();
|
||||
for ( sal_Int32 nPos = si_serviceNames.getLength(); nPos--; )
|
||||
{
|
||||
if (serviceName.equals( pNames[ nPos ] ))
|
||||
{
|
||||
return sal_True;
|
||||
}
|
||||
}
|
||||
return sal_False;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Sequence<OUString> SAL_CALL ScriptInfo::getSupportedServiceNames( )
|
||||
throw(RuntimeException)
|
||||
{
|
||||
return si_serviceNames;
|
||||
}
|
||||
//*************************************************************************
|
||||
Reference<XInterface> SAL_CALL si_create(
|
||||
const Reference< XComponentContext > & xCompC )
|
||||
{
|
||||
return (cppu::OWeakObject *)new ScriptInfo( xCompC );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Sequence<OUString> si_getSupportedServiceNames( )
|
||||
SAL_THROW( () )
|
||||
{
|
||||
return si_serviceNames;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString si_getImplementationName( )
|
||||
SAL_THROW( () )
|
||||
{
|
||||
return si_implName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ScriptInfo.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: lkovacs $ $Date: 2002-09-23 14:08:29 $
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:29 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -70,26 +70,19 @@
|
||||
|
||||
#include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
|
||||
#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp>
|
||||
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_XSCRIPTINVOCATIONPREP_HPP_
|
||||
#include <drafts/com/sun/star/script/framework/storage/XScriptInvocationPrep.hpp>
|
||||
#endif
|
||||
|
||||
namespace scripting_impl {
|
||||
|
||||
class ScriptInfo : public ::cppu::WeakImplHelper4< ::com::sun::star::lang::XServiceInfo, ::com::sun::star::lang::XInitialization, ::drafts::com::sun::star::script::framework::storage::XScriptInfo, ::drafts::com::sun::star::script::framework::storage::XScriptInvocationPrep >
|
||||
class ScriptInfo :
|
||||
public ::cppu::WeakImplHelper4<
|
||||
::com::sun::star::lang::XServiceInfo,
|
||||
::com::sun::star::lang::XInitialization,
|
||||
::drafts::com::sun::star::script::framework::storage::XScriptInfo,
|
||||
::drafts::com::sun::star::script::framework::storage::XScriptInvocationPrep >
|
||||
{
|
||||
// private member
|
||||
private:
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext;
|
||||
|
||||
::osl::Mutex m_mutex;
|
||||
|
||||
::drafts::com::sun::star::script::framework::storage::ScriptImplInfo m_scriptImplInfo;
|
||||
sal_uInt16 m_storageID;
|
||||
|
||||
// public interface
|
||||
public:
|
||||
explicit ScriptInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& );
|
||||
explicit ScriptInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext);
|
||||
virtual ~ScriptInfo();
|
||||
|
||||
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
|
||||
@@ -123,6 +116,14 @@ public:
|
||||
*/
|
||||
virtual ::rtl::OUString SAL_CALL prepareForInvocation() throw (::com::sun::star::uno::RuntimeException);
|
||||
|
||||
private:
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext;
|
||||
|
||||
::osl::Mutex m_mutex;
|
||||
|
||||
::drafts::com::sun::star::script::framework::storage::ScriptImplInfo m_scriptImplInfo;
|
||||
sal_uInt16 m_storageID;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ScriptStorage.hxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: lkovacs $ $Date: 2002-09-23 14:17:49 $
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:29 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -70,6 +70,11 @@
|
||||
#include <com/sun/star/uno/XComponentContext.hpp>
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#include <com/sun/star/lang/XInitialization.hpp>
|
||||
#include <com/sun/star/io/XInputStream.hpp>
|
||||
#include <com/sun/star/io/XOutputStream.hpp>
|
||||
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
|
||||
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
|
||||
|
||||
#include <drafts/com/sun/star/script/framework/storage/XScriptAccessManager.hpp>
|
||||
#include <drafts/com/sun/star/script/framework/storage/XScriptImplAccess.hpp>
|
||||
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageExport.hpp>
|
||||
@@ -77,25 +82,18 @@
|
||||
#include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp>
|
||||
#include <drafts/com/sun/star/script/framework/storage/NoSuchView.hpp>
|
||||
#include <drafts/com/sun/star/script/framework/scripturi/XScriptURI.hpp>
|
||||
#include <com/sun/star/io/XInputStream.hpp>
|
||||
#include <com/sun/star/io/XOutputStream.hpp>
|
||||
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
|
||||
#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp>
|
||||
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGE_XPARCELINVOCATIONPREP_HPP_
|
||||
#include <drafts/com/sun/star/script/framework/storage/XParcelInvocationPrep.hpp>
|
||||
#endif
|
||||
|
||||
namespace scripting_impl
|
||||
{
|
||||
|
||||
//Typedefs
|
||||
//=============================================================================
|
||||
typedef ::std::vector< ::drafts::com::sun::star::script::framework::storage::ScriptImplInfo >
|
||||
Impls_vec;
|
||||
typedef ::std::vector<
|
||||
::drafts::com::sun::star::script::framework::storage::ScriptImplInfo > Impls_vec;
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef ::std::hash_map < ::rtl::OUString, Impls_vec,
|
||||
::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
|
||||
ScriptInfo_hash;
|
||||
typedef ::std::hash_map < ::rtl::OUString,
|
||||
Impls_vec, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ScriptInfo_hash;
|
||||
//-----------------------------------------------------------------------------
|
||||
typedef ::std::hash_map < ::rtl::OUString,
|
||||
::com::sun::star::uno::Reference<
|
||||
@@ -113,36 +111,6 @@ class ScriptStorage
|
||||
::drafts::com::sun::star::script::framework::storage::XScriptAccessManager,
|
||||
::drafts::com::sun::star::script::framework::storage::XParcelInvocationPrep >
|
||||
{
|
||||
// private member
|
||||
private:
|
||||
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > m_xSimpleFileAccess;
|
||||
|
||||
::std::vector < ::rtl::OUString > mv_logicalNames;
|
||||
ScriptInfo_hash mh_implementations;
|
||||
ScriptOutput_hash mh_parcels;
|
||||
sal_uInt16 m_scriptStorageID;
|
||||
|
||||
osl::Mutex m_mutex;
|
||||
|
||||
void updateMaps(Impls_vec vScriptII);
|
||||
void writeMetadataHeader(::com::sun::star::uno::Reference < ::com::sun::star::xml::sax::XExtendedDocumentHandler > & );
|
||||
/**
|
||||
This function copies the contents of the source folder into the
|
||||
destination folder. If the destination folder does not exist, it
|
||||
is created. If the destination folder exists, it is deleted and then
|
||||
created. All URIs supported by the relevant XSimpleFileAccess
|
||||
implementation are supported.
|
||||
|
||||
@params src
|
||||
the source folder (file URI)
|
||||
|
||||
@params dest
|
||||
the destination folder (file URI)
|
||||
*/
|
||||
void copyFolder(const ::rtl::OUString & src, const ::rtl::OUString & dest) throw (::com::sun::star::uno::RuntimeException);
|
||||
|
||||
public:
|
||||
//Constructors and Destructors
|
||||
//=========================================================================
|
||||
@@ -154,26 +122,28 @@ public:
|
||||
|
||||
// XServiceInfo impl
|
||||
//=========================================================================
|
||||
virtual ::rtl::OUString SAL_CALL getImplementationName()
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual ::rtl::OUString SAL_CALL
|
||||
getImplementationName()
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
//-------------------------------------------------------------------------
|
||||
virtual sal_Bool SAL_CALL supportsService(
|
||||
const ::rtl::OUString & ServiceName )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual sal_Bool SAL_CALL
|
||||
supportsService( const ::rtl::OUString & ServiceName )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
//-------------------------------------------------------------------------
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString >
|
||||
SAL_CALL getSupportedServiceNames()
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
|
||||
getSupportedServiceNames()
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
//-------------------------------------------------------------------------
|
||||
static ::com::sun::star::uno::Sequence< ::rtl::OUString >
|
||||
SAL_CALL getSupportedServiceNames_Static();
|
||||
static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
|
||||
getSupportedServiceNames_Static();
|
||||
//=========================================================================
|
||||
|
||||
// XInitialization impl
|
||||
//=========================================================================
|
||||
virtual void SAL_CALL initialize( ::com::sun::star::uno::Sequence
|
||||
< ::com::sun::star::uno::Any > const & args )
|
||||
throw (::com::sun::star::uno::Exception);
|
||||
virtual void SAL_CALL
|
||||
initialize( ::com::sun::star::uno::Sequence<
|
||||
::com::sun::star::uno::Any > const & args )
|
||||
throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::uno::Exception);
|
||||
//=========================================================================
|
||||
|
||||
// XScriptAccessManager impl
|
||||
@@ -189,11 +159,10 @@ public:
|
||||
* A sequence of XScriptInfos which represent the implementations
|
||||
* of the passed in logical name
|
||||
*/
|
||||
virtual ::com::sun::star::uno::Sequence<
|
||||
::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::storage::XScriptInfo > >
|
||||
SAL_CALL getScriptInfoService( const ::rtl::OUString & name )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::storage::XScriptInfo > > SAL_CALL
|
||||
getScriptInfoService( const ::rtl::OUString & name )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
//=========================================================================
|
||||
|
||||
//XScriptImplAccess
|
||||
@@ -209,10 +178,11 @@ public:
|
||||
*/
|
||||
virtual ::com::sun::star::uno::Sequence<
|
||||
::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI > >
|
||||
SAL_CALL getImplementations( const ::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI >& queryURI )
|
||||
throw (::com::sun::star::lang::IllegalArgumentException,
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI > > SAL_CALL
|
||||
getImplementations( const ::com::sun::star::uno::Reference<
|
||||
::drafts::com::sun::star::script::framework::scripturi::XScriptURI >&
|
||||
queryURI )
|
||||
throw (::com::sun::star::lang::IllegalArgumentException,
|
||||
::com::sun::star::uno::RuntimeException);
|
||||
//=========================================================================
|
||||
|
||||
@@ -229,14 +199,15 @@ public:
|
||||
* The view of the hierarchy
|
||||
*/
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
|
||||
ScriptStorage::getView( const ::rtl::OUString& viewName )
|
||||
throw (::drafts::com::sun::star::script::framework::storage::NoSuchView,
|
||||
getView( const ::rtl::OUString& viewName )
|
||||
throw (::drafts::com::sun::star::script::framework::storage::NoSuchView,
|
||||
::com::sun::star::uno::RuntimeException);
|
||||
//=========================================================================
|
||||
|
||||
// XScriptStorageExport
|
||||
void SAL_CALL save()
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
void SAL_CALL
|
||||
save()
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
//=========================================================================
|
||||
|
||||
//XParcelInvocationPrep
|
||||
@@ -250,9 +221,48 @@ public:
|
||||
@return
|
||||
<type>::rtl::OUString</type> the new location of the parcel (file URI)
|
||||
*/
|
||||
::rtl::OUString SAL_CALL prepareForInvocation( const ::rtl::OUString& parcelURI )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
::rtl::OUString SAL_CALL
|
||||
prepareForInvocation( const ::rtl::OUString& parcelURI )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
//=========================================================================
|
||||
private:
|
||||
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::ucb::XSimpleFileAccess > m_xSimpleFileAccess;
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::lang::XMultiComponentFactory > m_xMgr;
|
||||
|
||||
::std::vector < ::rtl::OUString > mv_logicalNames;
|
||||
ScriptInfo_hash mh_implementations;
|
||||
ScriptOutput_hash mh_parcels;
|
||||
sal_uInt16 m_scriptStorageID;
|
||||
|
||||
osl::Mutex m_mutex;
|
||||
bool m_bInitialised;
|
||||
|
||||
void updateMaps(const Impls_vec & vScriptImplInfos);
|
||||
void writeMetadataHeader(
|
||||
::com::sun::star::uno::Reference <
|
||||
::com::sun::star::xml::sax::XExtendedDocumentHandler > & );
|
||||
/**
|
||||
This function copies the contents of the source folder into the
|
||||
destination folder. If the destination folder does not exist, it
|
||||
is created. If the destination folder exists, it is deleted and then
|
||||
created. All URIs supported by the relevant XSimpleFileAccess
|
||||
implementation are supported.
|
||||
|
||||
@params src
|
||||
the source folder (file URI)
|
||||
|
||||
@params dest
|
||||
the destination folder (file URI)
|
||||
*/
|
||||
void
|
||||
copyFolder(const ::rtl::OUString & src, const ::rtl::OUString & dest)
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
|
||||
}
|
||||
; // class ScriptingStorage
|
||||
|
||||
|
||||
@@ -1,63 +1,63 @@
|
||||
/*************************************************************************
|
||||
*
|
||||
* $RCSfile: ScriptStorageManager.cxx,v $
|
||||
*
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: dfoster $ $Date: 2002-09-25 10:18:12 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
*
|
||||
* $RCSfile: ScriptStorageManager.cxx,v $
|
||||
*
|
||||
* $Revision: 1.3 $
|
||||
*
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:30 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
*
|
||||
* - GNU Lesser General Public License Version 2.1
|
||||
* - Sun Industry Standards Source License Version 1.1
|
||||
*
|
||||
* Sun Microsystems Inc., October, 2000
|
||||
*
|
||||
* GNU Lesser General Public License Version 2.1
|
||||
* =============================================
|
||||
* Copyright 2000 by Sun Microsystems, Inc.
|
||||
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License version 2.1, as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
*
|
||||
* Sun Industry Standards Source License Version 1.1
|
||||
* =================================================
|
||||
* The contents of this file are subject to the Sun Industry Standards
|
||||
* Source License Version 1.1 (the "License"); You may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of the
|
||||
* License at http://www.openoffice.org/license.html.
|
||||
*
|
||||
* Software provided under this License is provided on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
||||
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
||||
* See the License for the specific provisions governing your rights and
|
||||
* obligations concerning the Software.
|
||||
*
|
||||
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
||||
*
|
||||
* Copyright: 2000 by Sun Microsystems, Inc.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): _______________________________________
|
||||
*
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -80,89 +80,145 @@ using namespace ::drafts::com::sun::star::script::framework;
|
||||
namespace scripting_impl
|
||||
{
|
||||
|
||||
static const sal_Char* const SERVICENAME="drafts.com.sun.star.script.framework.storage.ScriptStorageManager";
|
||||
static const sal_Char* const IMPLNAME="drafts.com.sun.star.script.framework.storage.ScriptStorageManager";
|
||||
|
||||
static OUString s_implName = ::rtl::OUString::createFromAscii(IMPLNAME);
|
||||
static OUString s_serviceName = ::rtl::OUString::createFromAscii(SERVICENAME);
|
||||
static OUString s_implName =
|
||||
::rtl::OUString::createFromAscii(
|
||||
"drafts.com.sun.star.script.framework.storage.ScriptStorageManager" );
|
||||
static OUString s_serviceName =
|
||||
::rtl::OUString::createFromAscii(
|
||||
"drafts.com.sun.star.script.framework.storage.ScriptStorageManager" );
|
||||
static Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 );
|
||||
|
||||
::rtl_StandardModuleCount s_moduleCount = MODULE_COUNT_INIT;
|
||||
extern ::rtl_StandardModuleCount s_moduleCount = MODULE_COUNT_INIT;
|
||||
|
||||
//*************************************************************************
|
||||
// ScriptStorageManager Constructor
|
||||
ScriptStorageManager::ScriptStorageManager(const Reference< XComponentContext > & xContext)
|
||||
: m_xContext( xContext )
|
||||
ScriptStorageManager::ScriptStorageManager( const Reference< XComponentContext > & xContext )
|
||||
: m_xContext( xContext ), m_count( 0 )
|
||||
SAL_THROW ( ( RuntimeException ) )
|
||||
{
|
||||
OSL_TRACE( "< ScriptStorageManager ctor called >\n" );
|
||||
s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt );
|
||||
|
||||
validateXRef( m_xContext, "ScriptStorageManager::ScriptStorageManager : cannot get component context" );
|
||||
|
||||
m_xMgr = m_xContext->getServiceManager();
|
||||
validateXRef( m_xMgr, "ScriptStorageManager::ScriptStorageManager : cannot get service manager" );
|
||||
|
||||
try
|
||||
{
|
||||
count=0;
|
||||
// obtain the macro expander singleton to use in determining the
|
||||
// location of the application script storage
|
||||
Any aAny = m_xContext->getValueByName(OUString::createFromAscii("/singletons/com.sun.star.util.theMacroExpander"));
|
||||
Any aAny = m_xContext->getValueByName( OUString::createFromAscii(
|
||||
"/singletons/com.sun.star.util.theMacroExpander" ) );
|
||||
Reference<util::XMacroExpander> xME;
|
||||
OSL_ASSERT(sal_False!=(aAny>>=xME));
|
||||
OSL_ASSERT(xME.is());
|
||||
validateXRef(xME,"ScriptStorageManager constructor: Can't get MacroExpander");
|
||||
if ( sal_False == ( aAny >>= xME ) )
|
||||
{
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptStorageManager::ScriptStorageManager: can't get XMacroExpander" ),
|
||||
Reference< XInterface >() );
|
||||
}
|
||||
validateXRef( xME, "ScriptStorageManager constructor: can't get MacroExpander" );
|
||||
|
||||
// get the MultiComponentFactory and use it to create a
|
||||
// SimpleFileAccess component
|
||||
Reference<lang::XMultiComponentFactory> xMCF = m_xContext->getServiceManager();
|
||||
validateXRef(xMCF,"ScriptStorageManager::ScriptStorageManager : cannot get service manager");
|
||||
Reference<XInterface> xx = xMCF->createInstanceWithContext(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess"), m_xContext);
|
||||
Reference<ucb::XSimpleFileAccess> xSFA(xx,UNO_QUERY);
|
||||
OUString base = OUString::createFromAscii(
|
||||
SAL_CONFIGFILE( "${$SYSBINDIR/bootstrap" ) );
|
||||
|
||||
setupAppStorage( xME,
|
||||
base.concat( OUString::createFromAscii( "::BaseInstallation}/share" ) ) );
|
||||
setupAppStorage( xME,
|
||||
base.concat( OUString::createFromAscii( "::UserInstallation}/user" ) ) );
|
||||
|
||||
}
|
||||
catch ( Exception & e )
|
||||
{
|
||||
throw RuntimeException( OUSTR( "ScriptStorageManager::ScriptStorageManager: " ) + e.Message, Reference< XInterface >() );
|
||||
}
|
||||
OSL_ASSERT( m_count == 2 );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// ScriptStorageManager setupAppStorage
|
||||
void
|
||||
ScriptStorageManager::setupAppStorage(
|
||||
const Reference<util::XMacroExpander> & xME,
|
||||
const OUString & storageStr )
|
||||
SAL_THROW ( ( RuntimeException ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
Reference<XInterface> xInterface =
|
||||
m_xMgr->createInstanceWithContext(
|
||||
OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ), m_xContext );
|
||||
validateXRef( xInterface,
|
||||
"ScriptStorageManager constructor: can't get SimpleFileAccess XInterface" );
|
||||
Reference<ucb::XSimpleFileAccess> xSFA( xInterface, UNO_QUERY_THROW );
|
||||
|
||||
setupAnyStorage( xSFA, xME->expandMacros( storageStr ) );
|
||||
}
|
||||
catch ( Exception & e )
|
||||
{
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptStorageManager::setupAppStorage: " ).concat( e.Message ),
|
||||
Reference< XInterface >() );
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// ScriptStorageManager setupAnyStorage
|
||||
sal_uInt16
|
||||
ScriptStorageManager::setupAnyStorage(
|
||||
const Reference< ucb::XSimpleFileAccess > & xSFA,
|
||||
const OUString & storageStr )
|
||||
SAL_THROW ( ( RuntimeException ) )
|
||||
{
|
||||
// Required for scope of fnc to protect all access read and writes to m_count
|
||||
::osl::Guard< ::osl::Mutex > aGuard( m_mutex );
|
||||
try
|
||||
{
|
||||
|
||||
// create a ScriptingStorage using the SimpleFileAccess, the storageID // (from the count), and the URL to the application's shared area
|
||||
Sequence <Any> aArgs(3);
|
||||
OUString base=OUString::createFromAscii( SAL_CONFIGFILE("${$SYSBINDIR/bootstrap"));
|
||||
aArgs[0] <<= xSFA;
|
||||
aArgs[1] <<= count;
|
||||
aArgs[2] <<= xME->expandMacros(base.concat(OUString::createFromAscii("::BaseInstallation}/share")));
|
||||
Sequence <Any> aArgs( 3 );
|
||||
aArgs[ 0 ] <<= xSFA;
|
||||
aArgs[ 1 ] <<= m_count;
|
||||
aArgs[ 2 ] <<= storageStr;
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
fprintf(stderr,"creating storage for: %s\n",::rtl::OUStringToOString(xME->expandMacros(base.concat(OUString::createFromAscii("::BaseInstallation}/share"))),RTL_TEXTENCODING_ASCII_US).pData->buffer);
|
||||
fprintf( stderr, "creating storage for: %s\n",
|
||||
::rtl::OUStringToOString(
|
||||
storageStr, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
|
||||
#endif
|
||||
|
||||
xx = xMCF->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.storage.ScriptStorage"), aArgs, m_xContext);
|
||||
OSL_ASSERT(xx.is());
|
||||
xx->acquire();
|
||||
validateXRef(xx,"ScriptStorageManager constructor: Can't create ScriptStorage for share");
|
||||
Reference<XInterface> xInterface =
|
||||
m_xMgr->createInstanceWithArgumentsAndContext(
|
||||
OUString::createFromAscii(
|
||||
"drafts.com.sun.star.script.framework.storage.ScriptStorage" ),
|
||||
aArgs, m_xContext );
|
||||
|
||||
validateXRef( xInterface, "ScriptStorageManager:: setupAnyStorage: Can't create ScriptStorage for share" );
|
||||
|
||||
// and place it in the hash_map. Increment the counter
|
||||
m_ScriptStorageHash[count++]=xx;
|
||||
m_ScriptStorageHash[ m_count++ ] = xInterface;
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
fprintf(stderr,"\tcreated with ID=%d\n",count-1);
|
||||
#endif
|
||||
//Repeat the procedure with the application user area
|
||||
aArgs[1] <<= count;
|
||||
aArgs[2] <<= xME->expandMacros(base.concat(OUString::createFromAscii("::UserInstallation}/user")));
|
||||
#ifdef _DEBUG
|
||||
|
||||
fprintf(stderr,"creating storage for: %s\n",::rtl::OUStringToOString(xME->expandMacros(base.concat(OUString::createFromAscii("::UserInstallation}/user"))),RTL_TEXTENCODING_ASCII_US).pData->buffer);
|
||||
#endif
|
||||
|
||||
xx = xMCF->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.storage.ScriptStorage"), aArgs, m_xContext);
|
||||
OSL_ASSERT(xx.is());
|
||||
xx->acquire();
|
||||
validateXRef(xx,"ScriptStorageManager constructor: Can't create ScriptStorage for share");
|
||||
m_ScriptStorageHash[count++]=xx;
|
||||
#ifdef _DEBUG
|
||||
|
||||
fprintf(stderr,"\tcreated with ID=%d\n",count-1);
|
||||
fprintf( stderr, "\tcreated with ID=%d\n", m_count - 1 );
|
||||
#endif
|
||||
|
||||
}
|
||||
catch (Exception &e)
|
||||
catch ( Exception & e )
|
||||
{
|
||||
throw RuntimeException(OUSTR("ScriptStorageManager::ScriptStorageManager: ").concat(e.Message), Reference< XInterface >());
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptStorageManager::setupAnyStorage: " ).concat( e.Message ),
|
||||
Reference< XInterface >() );
|
||||
}
|
||||
|
||||
return m_count -1;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
// ScriptStorageManager Destructor
|
||||
ScriptStorageManager::~ScriptStorageManager()
|
||||
SAL_THROW ( () )
|
||||
{
|
||||
OSL_TRACE( "< ScriptStorageManager dtor called >\n" );
|
||||
s_moduleCount.modCnt.release( &s_moduleCount.modCnt );
|
||||
@@ -171,73 +227,68 @@ ScriptStorageManager::~ScriptStorageManager()
|
||||
//*************************************************************************
|
||||
// This method assumes that the XSimpleFileAccess knows it's on root URL
|
||||
// and can be used with relative URLs
|
||||
sal_uInt16 SAL_CALL ScriptStorageManager::createScriptStorage( const Reference< ucb::XSimpleFileAccess >& xSFA ) throw (RuntimeException)
|
||||
sal_uInt16 SAL_CALL
|
||||
ScriptStorageManager::createScriptStorage(
|
||||
const Reference< ucb::XSimpleFileAccess >& xSFA )
|
||||
throw ( RuntimeException )
|
||||
{
|
||||
OSL_TRACE("** ==> ScriptStorageManager in createScriptingStorage\n");
|
||||
validateXRef(xSFA, "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid");
|
||||
Sequence <Any> aArgs(2);
|
||||
aArgs[0] <<= xSFA;
|
||||
aArgs[1] <<= count;
|
||||
Reference<lang::XMultiComponentFactory> xMCF = m_xContext->getServiceManager();
|
||||
validateXRef(xMCF,"ScriptStorageManager::createScriptStorage");
|
||||
Reference<XInterface>xx = xMCF->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.storage.ScriptStorage"), aArgs, m_xContext);
|
||||
OSL_ASSERT(xx.is());
|
||||
m_ScriptStorageHash[count++]=xx;
|
||||
#ifdef _DEBUG
|
||||
OSL_TRACE( "** ==> ScriptStorageManager in createScriptingStorage\n" );
|
||||
validateXRef( xSFA,
|
||||
"ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" );
|
||||
|
||||
fprintf(stderr,"\tcreated with ID=%d\n",count-1);
|
||||
#endif
|
||||
|
||||
return count-1;
|
||||
return setupAnyStorage( xSFA, ::rtl::OUString::createFromAscii( "" ) );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
sal_uInt16 SAL_CALL ScriptStorageManager::createScriptStorageWithURI( const Reference< ucb::XSimpleFileAccess >& xSFA, const OUString & stringURI ) throw (RuntimeException)
|
||||
sal_uInt16 SAL_CALL
|
||||
ScriptStorageManager::createScriptStorageWithURI(
|
||||
const Reference< ucb::XSimpleFileAccess >& xSFA, const OUString & stringURI )
|
||||
throw ( RuntimeException )
|
||||
{
|
||||
OSL_TRACE("** ==> ScriptStorageManager in createScriptingStorageWithURI\n");
|
||||
validateXRef(xSFA, "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid");
|
||||
Sequence <Any> aArgs(3);
|
||||
aArgs[0] <<= xSFA;
|
||||
aArgs[1] <<= count;
|
||||
aArgs[2] <<= stringURI;
|
||||
Reference<lang::XMultiComponentFactory> xMCF = m_xContext->getServiceManager();
|
||||
validateXRef(xMCF,"ScriptStorageManager::createScriptStorageWithURI");
|
||||
Reference<XInterface> xx = xMCF->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.storage.ScriptStorage"), aArgs, m_xContext);
|
||||
OSL_ASSERT(xx.is());
|
||||
m_ScriptStorageHash[count++]=xx;
|
||||
#ifdef _DEBUG
|
||||
OSL_TRACE( "** ==> ScriptStorageManager in createScriptingStorageWithURI\n" );
|
||||
validateXRef( xSFA, "ScriptStorageManager::createScriptStorage: XSimpleFileAccess is not valid" );
|
||||
|
||||
fprintf(stderr,"\tcreated with ID=%d\n",count-1);
|
||||
#endif
|
||||
|
||||
return count-1;
|
||||
return setupAnyStorage( xSFA, stringURI );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Reference <XInterface> SAL_CALL ScriptStorageManager::getScriptStorage(sal_uInt16 scriptStorageID)
|
||||
throw(RuntimeException)
|
||||
Reference <XInterface> SAL_CALL
|
||||
ScriptStorageManager::getScriptStorage( sal_uInt16 scriptStorageID )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
OSL_TRACE("** ==> ScriptStorageManager in getStorageInstance\n");
|
||||
Reference<XInterface> result=m_ScriptStorageHash[scriptStorageID];
|
||||
validateXRef(result, "ScriptStorageManager::getScriptStorage: Cannot get ScriptStorage from ScriptStorageHash");
|
||||
return result;
|
||||
OSL_TRACE( "** ==> ScriptStorageManager in getStorageInstance\n" );
|
||||
|
||||
ScriptStorage_hash::const_iterator itr =
|
||||
m_ScriptStorageHash.find( scriptStorageID );
|
||||
|
||||
if ( itr == m_ScriptStorageHash.end() )
|
||||
{
|
||||
throw RuntimeException(
|
||||
OUSTR( "ScriptStorageManager::getScriptStorage: invalid storage ID" ),
|
||||
Reference< XInterface >() );
|
||||
}
|
||||
validateXRef( itr->second,
|
||||
"ScriptStorageManager::getScriptStorage: Cannot get ScriptStorage from ScriptStorageHash" );
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
OUString SAL_CALL ScriptStorageManager::getImplementationName( )
|
||||
throw(RuntimeException)
|
||||
OUString SAL_CALL
|
||||
ScriptStorageManager::getImplementationName( )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
return s_implName;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
sal_Bool SAL_CALL ScriptStorageManager::supportsService( const OUString& serviceName )
|
||||
throw(RuntimeException)
|
||||
sal_Bool SAL_CALL
|
||||
ScriptStorageManager::supportsService( const OUString& serviceName )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
OUString const * pNames = s_serviceNames.getConstArray();
|
||||
for ( sal_Int32 nPos = s_serviceNames.getLength(); nPos--; )
|
||||
{
|
||||
if (serviceName.equals( pNames[ nPos ] ))
|
||||
if ( serviceName.equals( pNames[ nPos ] ) )
|
||||
{
|
||||
return sal_True;
|
||||
}
|
||||
@@ -246,34 +297,40 @@ throw(RuntimeException)
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
Sequence<OUString> SAL_CALL ScriptStorageManager::getSupportedServiceNames( )
|
||||
throw(RuntimeException)
|
||||
Sequence<OUString> SAL_CALL
|
||||
ScriptStorageManager::getSupportedServiceNames( )
|
||||
throw( RuntimeException )
|
||||
{
|
||||
return s_serviceNames;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
void SAL_CALL ScriptStorageManager::disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
|
||||
void SAL_CALL
|
||||
ScriptStorageManager::disposing( const ::com::sun::star::lang::EventObject& Source )
|
||||
throw ( ::com::sun::star::uno::RuntimeException )
|
||||
{
|
||||
OSL_TRACE("ScriptStorageManager::disposing started");
|
||||
OSL_TRACE( "ScriptStorageManager::disposing started" );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
static Reference<XInterface> SAL_CALL ssm_create(
|
||||
static Reference<XInterface> SAL_CALL
|
||||
ssm_create(
|
||||
const Reference< XComponentContext > & xCompC )
|
||||
{
|
||||
return (cppu::OWeakObject *)new ScriptStorageManager( xCompC );
|
||||
return ( cppu::OWeakObject * ) new ScriptStorageManager( xCompC );
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
static Sequence<OUString> ssm_getSupportedServiceNames( )
|
||||
static Sequence<OUString>
|
||||
ssm_getSupportedServiceNames( )
|
||||
SAL_THROW( () )
|
||||
{
|
||||
return s_serviceNames;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
static OUString ssm_getImplementationName( )
|
||||
static OUString
|
||||
ssm_getImplementationName( )
|
||||
SAL_THROW( () )
|
||||
{
|
||||
return s_implName;
|
||||
@@ -281,15 +338,15 @@ SAL_THROW( () )
|
||||
//*************************************************************************
|
||||
Reference<XInterface> SAL_CALL ss_create( const Reference< XComponentContext > & xCompC );
|
||||
//*************************************************************************
|
||||
Sequence<OUString> ss_getSupportedServiceNames( ) SAL_THROW( () );
|
||||
Sequence<OUString> ss_getSupportedServiceNames( ) SAL_THROW( () );
|
||||
//*************************************************************************
|
||||
OUString ss_getImplementationName( ) SAL_THROW( () );
|
||||
OUString ss_getImplementationName( ) SAL_THROW( () );
|
||||
//*************************************************************************
|
||||
Reference<XInterface> SAL_CALL si_create( const Reference< XComponentContext > & xCompC );
|
||||
//*************************************************************************
|
||||
Sequence<OUString> si_getSupportedServiceNames( ) SAL_THROW( () );
|
||||
Sequence<OUString> si_getSupportedServiceNames( ) SAL_THROW( () );
|
||||
//*************************************************************************
|
||||
OUString si_getImplementationName( ) SAL_THROW( () );
|
||||
OUString si_getImplementationName( ) SAL_THROW( () );
|
||||
//*************************************************************************
|
||||
static struct cppu::ImplementationEntry s_entries [] =
|
||||
{
|
||||
@@ -321,7 +378,7 @@ static struct cppu::ImplementationEntry s_entries [] =
|
||||
*/
|
||||
extern "C"
|
||||
{
|
||||
void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv)
|
||||
void SAL_CALL component_getImplementationEnvironment( const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
|
||||
{
|
||||
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
|
||||
}
|
||||
@@ -333,9 +390,9 @@ extern "C"
|
||||
* @param pServiceManager the service manager
|
||||
* @param pRegistryKey the registry key
|
||||
*/
|
||||
sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey)
|
||||
sal_Bool SAL_CALL component_writeInfo( lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
|
||||
{
|
||||
return ::cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, ::scripting_impl::s_entries);
|
||||
return ::cppu::component_writeInfoHelper( pServiceManager, pRegistryKey, ::scripting_impl::s_entries );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,8 +403,8 @@ extern "C"
|
||||
* @param pRegistryKey the registry key for this component, need for persistent data
|
||||
* @return a component factory
|
||||
*/
|
||||
void * SAL_CALL component_getFactory(const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey)
|
||||
void * SAL_CALL component_getFactory( const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
|
||||
{
|
||||
return ::cppu::component_getFactoryHelper(pImplName, pServiceManager, pRegistryKey, ::scripting_impl::s_entries);
|
||||
return ::cppu::component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, ::scripting_impl::s_entries );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: ScriptStorageManager.hxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: dfoster $ $Date: 2002-09-20 14:33:54 $
|
||||
* last change: $Author: jmrice $ $Date: 2002-09-27 12:16:30 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -63,14 +63,15 @@
|
||||
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGE_SCRIPTSTORAGEMANAGER_HXX_
|
||||
#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGE_SCRIPTSTORAGEMANAGER_HXX_
|
||||
|
||||
#include <osl/mutex.hxx>
|
||||
#include <hash_map>
|
||||
|
||||
#include <osl/mutex.hxx>
|
||||
#include <cppuhelper/implbase3.hxx>
|
||||
|
||||
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||
#include <com/sun/star/lang/XEventListener.hpp>
|
||||
#include <com/sun/star/uno/RuntimeException.hpp>
|
||||
|
||||
#include <drafts/com/sun/star/script/framework/scripturi/XScriptURI.hpp>
|
||||
#include <drafts/com/sun/star/script/framework/storage/XScriptStorageManager.hpp>
|
||||
|
||||
@@ -78,27 +79,39 @@ namespace scripting_impl
|
||||
{
|
||||
|
||||
// Define a hash_map used to store the ScriptingStorages key;d by ID
|
||||
typedef ::std::hash_map < sal_Int16, ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > > ScriptStorage_hash;
|
||||
typedef ::std::hash_map <
|
||||
sal_Int16,
|
||||
::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > >
|
||||
ScriptStorage_hash;
|
||||
|
||||
class ScriptStorageManager : public ::cppu::WeakImplHelper3< ::drafts::com::sun::star::script::framework::storage::XScriptStorageManager, ::com::sun::star::lang::XServiceInfo, ::com::sun::star::lang::XEventListener>
|
||||
class ScriptStorageManager :
|
||||
public ::cppu::WeakImplHelper3<
|
||||
::drafts::com::sun::star::script::framework::storage::XScriptStorageManager,
|
||||
::com::sun::star::lang::XServiceInfo, ::com::sun::star::lang::XEventListener >
|
||||
{
|
||||
// to obtain other services if needed
|
||||
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
::osl::Mutex m_mutex;
|
||||
ScriptStorage_hash m_ScriptStorageHash;
|
||||
sal_Int16 count;
|
||||
public:
|
||||
ScriptStorageManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext );
|
||||
~ScriptStorageManager();
|
||||
explicit ScriptStorageManager(
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::uno::XComponentContext > & xContext )
|
||||
SAL_THROW ( (RuntimeException) );
|
||||
;
|
||||
|
||||
~ScriptStorageManager() SAL_THROW ( () );
|
||||
|
||||
// XServiceInfo implementation
|
||||
//======================================================================
|
||||
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual ::rtl::OUString SAL_CALL
|
||||
getImplementationName()
|
||||
throw(::com::sun::star::uno::RuntimeException);
|
||||
//----------------------------------------------------------------------
|
||||
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual sal_Bool SAL_CALL
|
||||
supportsService(
|
||||
const ::rtl::OUString& ServiceName )
|
||||
throw(::com::sun::star::uno::RuntimeException);
|
||||
//----------------------------------------------------------------------
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL
|
||||
getSupportedServiceNames()
|
||||
throw(::com::sun::star::uno::RuntimeException);
|
||||
//======================================================================
|
||||
|
||||
//XScriptStorageManager
|
||||
@@ -114,7 +127,11 @@ public:
|
||||
@returns an unsigned short ScriptStorage ID, which can be used in the
|
||||
getScriptStorage method
|
||||
*/
|
||||
virtual sal_uInt16 SAL_CALL createScriptStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFA ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual sal_uInt16 SAL_CALL
|
||||
createScriptStorage(
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::ucb::XSimpleFileAccess > & xSFA )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
//----------------------------------------------------------------------
|
||||
/**
|
||||
create a ScriptStorage using the XSimpleFileAccess, and a string URL
|
||||
@@ -129,7 +146,12 @@ public:
|
||||
@returns an unsigned short ScriptStorage ID, which can be used in the
|
||||
getScriptStorage method
|
||||
*/
|
||||
virtual sal_uInt16 SAL_CALL createScriptStorageWithURI( const ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >& xSFA, const ::rtl::OUString& stringURI ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual sal_uInt16 SAL_CALL
|
||||
createScriptStorageWithURI(
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::ucb::XSimpleFileAccess >& xSFA,
|
||||
const ::rtl::OUString& stringURI )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
//----------------------------------------------------------------------
|
||||
/**
|
||||
get a ScriptStorage component using its scriptStorageID
|
||||
@@ -142,13 +164,47 @@ public:
|
||||
@returns an XInterface to a component that implements the ScriptStorage
|
||||
service
|
||||
*/
|
||||
virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getScriptStorage( sal_uInt16 scriptStorageID ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::uno::XInterface > SAL_CALL
|
||||
getScriptStorage( sal_uInt16 scriptStorageID )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
//======================================================================
|
||||
|
||||
|
||||
//XEventListener
|
||||
//======================================================================
|
||||
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
|
||||
virtual void SAL_CALL
|
||||
disposing( const ::com::sun::star::lang::EventObject& Source )
|
||||
throw (::com::sun::star::uno::RuntimeException);
|
||||
|
||||
static const sal_uInt16 APP_SHARE_STORAGE_ID = 0;
|
||||
static const sal_uInt16 APP_USER_STORAGE_ID = 1;
|
||||
|
||||
private:
|
||||
ScriptStorageManager(const ScriptStorageManager & );
|
||||
ScriptStorageManager& operator= (const ScriptStorageManager &);
|
||||
|
||||
// to obtain other services if needed
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::uno::XComponentContext > m_xContext;
|
||||
::com::sun::star::uno::Reference<
|
||||
::com::sun::star::lang::XMultiComponentFactory > m_xMgr;
|
||||
::osl::Mutex m_mutex;
|
||||
ScriptStorage_hash m_ScriptStorageHash;
|
||||
sal_Int16 m_count;
|
||||
|
||||
void setupAppStorage(
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::util::XMacroExpander > & xME,
|
||||
const ::rtl::OUString & storageStr )
|
||||
SAL_THROW ( ( ::com::sun::star::uno::RuntimeException ) );
|
||||
|
||||
sal_uInt16 setupAnyStorage(
|
||||
const ::com::sun::star::uno::Reference<
|
||||
::com::sun::star::ucb::XSimpleFileAccess> & xSFA,
|
||||
const ::rtl::OUString & storageStr )
|
||||
SAL_THROW ( ( ::com::sun::star::uno::RuntimeException ) );
|
||||
|
||||
};
|
||||
} // scripting_impl
|
||||
|
||||
|
||||
Reference in New Issue
Block a user