diff options
Diffstat (limited to 'scripting/source')
36 files changed, 6223 insertions, 0 deletions
diff --git a/scripting/source/protocolhandler/exports.dxp b/scripting/source/protocolhandler/exports.dxp new file mode 100644 index 0000000000000..9630d7e067687 --- /dev/null +++ b/scripting/source/protocolhandler/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/scripting/source/protocolhandler/makefile.mk b/scripting/source/protocolhandler/makefile.mk new file mode 100644 index 0000000000000..ca772a0974a25 --- /dev/null +++ b/scripting/source/protocolhandler/makefile.mk @@ -0,0 +1,99 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: dfoster $ $Date: 2002-09-20 14:33:11 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME= scripting +TARGET= protocolhandler +USE_DEFFILE= TRUE +NO_BSYMBOLIC= TRUE +ENABLE_EXCEPTIONS=TRUE +COMP1TYPELIST=$(TARGET) + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# ------------------------------------------------------------------ + +.INCLUDE : ..$/cppumaker.mk + +SLOFILES=\ + $(SLO)$/scripthandler.obj\ + +SHL1TARGET= $(TARGET) + +SHL1STDLIBS= \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/scripting/source/protocolhandler/protocolhandler.xml b/scripting/source/protocolhandler/protocolhandler.xml new file mode 100755 index 0000000000000..ccc46fca0606b --- /dev/null +++ b/scripting/source/protocolhandler/protocolhandler.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name> ScriptProtocolHandler </module-name> + <component-description> + <author> Noel Power</author> + <name> com.sun.star.frame.ProtocolHandler</name> + <description> + This component is part of the Scripting Framework +</description> + <loader-name> com.sun.star.loader.SharedLibrary </loader-name> + <language> c++ </language> + <status value="com"/> + <supported-service> com.sun.star.frame.ProtocolHandler </supported-service> + <type> com.sun.star.frame.XDispatchProvider </type> + <type> com.sun.star.frame.XNotifyingDispatch </type> + <type> com.sun.star.lang.XServiceInfo </type> + <type> com.sun.star.lang.XInitialization </type> + <type> com.sun.star.io.IOException </type> + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + <runtime-module-dependency> cppuhelper2$(COM) </runtime-module-dependency> + <runtime-module-dependency> cppu2 </runtime-module-dependency> + <runtime-module-dependency> sal2 </runtime-module-dependency> +</module-description> diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx new file mode 100644 index 0000000000000..32302bf13f79d --- /dev/null +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -0,0 +1,399 @@ +/************************************************************************* + * + * $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): _______________________________________ + * + * + ************************************************************************/ + +#include <stdio.h> +#include "scripthandler.hxx" + +#include <osl/mutex.hxx> +#include <com/sun/star/frame/DispatchResultEvent.hpp> +#include <com/sun/star/frame/DispatchResultState.hpp> +#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> + +#include <cppuhelper/factory.hxx> +#include <util/util.hxx> + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::util; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; +using namespace ::drafts::com::sun::star::script::framework; + +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 * 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 ) +{ + if (m_bInitialised) + { + 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; + + 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; + if ( m_xFrame.is() ) + { + 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" ); + + m_xFunctionProvider = Reference< provider::XFunctionProvider >(xXinterface, UNO_QUERY_THROW); + m_bInitialised = true; + } + catch(RuntimeException &e) + { + throw RuntimeException(OUSTR("ScriptProtocolHandler::initialize: ") + e.Message, Reference< XInterface >()); + } + 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); + } +#ifdef _DEBUG + catch ( ... ) + { + throw RuntimeException(OUSTR("criptProtocolHandler::initialize: UnknownException: "), + Reference<XInterface> ()); + + 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 > xDispatcher; + OSL_TRACE("ScriptProtocolHandler::queryDispatch - 1\n" ); + + if( aURL.Complete.compareToAscii( ::scripting_protocolhandler::MYSCHEME, + ::scripting_protocolhandler::MYSCHEME_LEN ) == 0 ) + xDispatcher = this; + OSL_TRACE("ScriptProtocolHandler::queryDispatch - 2\n" ); + + + return xDispatcher; +} + +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" ); + + return lDispatcher; +} + +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); + if ( m_bInitialised ) + { + try + { + 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< sal_Int16 > outIndex; + + 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) + { + 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; + invokeResult <<= reason; + } + 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; + invokeResult <<= reason; + } +#ifdef _DEBUG + catch ( ... ) + { + ::rtl::OUString reason; + reason.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"); + invokeResult <<= reason; + } + + 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.Result = invokeResult; + if( bSuccess ) + aEvent.State = ::com::sun::star::frame::DispatchResultState::SUCCESS; + else + aEvent.State = ::com::sun::star::frame::DispatchResultState::FAILURE; + + xListener->dispatchFinished( aEvent ) ; + } + OSL_TRACE("ScriptProtocolHandler::dispatchWithNotification - end\n" ); + +} + +void SAL_CALL ScriptProtocolHandler::dispatch( const URL& aURL, const Sequence< PropertyValue >& lArgs ) +throw ( RuntimeException ) +{ + dispatchWithNotification( aURL, lArgs, Reference < XDispatchResultListener >() ); +} + +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) +{ +} + +ScriptProtocolHandler::ScriptProtocolHandler( Reference < css::lang::XMultiServiceFactory > const& rFact ) + : m_xFactory( rFact ), m_bInitialised(false) +{ + OSL_TRACE("ScriptProtocolHandler::ScriptProtocolHandler - ctor\n" ); +} + +ScriptProtocolHandler::~ScriptProtocolHandler() +{ + OSL_TRACE("ScriptProtocolHandler::ScriptProtocolHandler - dtor\n" ); +} + +/* XServiceInfo */ +::rtl::OUString SAL_CALL ScriptProtocolHandler::getImplementationName() throw( RuntimeException ) +{ + return impl_getStaticImplementationName(); +} + +/* XServiceInfo */ +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++ ) + { + if ( pArray[nCounter] == sServiceName ) + { + return sal_True ; + } + } + + return sal_False ; +} + +/* XServiceInfo */ +Sequence< ::rtl::OUString > SAL_CALL ScriptProtocolHandler::getSupportedServiceNames() throw( RuntimeException ) +{ + return impl_getStaticSupportedServiceNames(); +} + +/* Helper for XServiceInfo */ +Sequence< ::rtl::OUString > ScriptProtocolHandler::impl_getStaticSupportedServiceNames() +{ + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + Sequence< ::rtl::OUString > seqServiceNames( 1 ); + 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); +} + +/* Helper for registry */ +Reference < XInterface > SAL_CALL ScriptProtocolHandler::impl_createInstance( const Reference < css::lang::XMultiServiceFactory >& xServiceManager ) throw( RuntimeException ) +{ + return Reference < XInterface > ( *new ScriptProtocolHandler( xServiceManager ) ); +} + +/* Factory for registration */ +Reference < XSingleServiceFactory > ScriptProtocolHandler::impl_createFactory( const Reference< XMultiServiceFactory >& xServiceManager ) +{ + Reference < XSingleServiceFactory > xReturn ( + cppu::createSingleFactory( xServiceManager, + ScriptProtocolHandler::impl_getStaticImplementationName(), + ScriptProtocolHandler::impl_createInstance, + ScriptProtocolHandler::impl_getStaticSupportedServiceNames() ) + ); + return xReturn; +} + +}// namespace scripting_protocolhandler + +/* exported functions for registration */ +extern "C" { + + 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 ) + { + 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(); + + aStr += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); + Reference< css::registry::XRegistryKey > xNewKey = xKey->createKey( aStr ); + xNewKey->createKey( ::rtl::OUString::createFromAscii(::scripting_protocolhandler::MYSERVICENAME) ); + + return sal_True; + } + + 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 ; + + if ( + ( pImplementationName != 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 ) ) ; + + if ( ::scripting_protocolhandler::ScriptProtocolHandler::impl_getStaticImplementationName().equals( ::rtl::OUString::createFromAscii( pImplementationName ) ) ) + { + xFactory = ::scripting_protocolhandler::ScriptProtocolHandler::impl_createFactory( xServiceManager ); + } + + // Factory is valid - service was found. + if ( xFactory.is() ) + { + xFactory->acquire(); + pReturn = xFactory.get(); + } + } + + // Return with result of this operation. + return pReturn ; + } +} // extern "C" + + diff --git a/scripting/source/protocolhandler/scripthandler.hxx b/scripting/source/protocolhandler/scripthandler.hxx new file mode 100644 index 0000000000000..ed4b16fa66caa --- /dev/null +++ b/scripting/source/protocolhandler/scripthandler.hxx @@ -0,0 +1,190 @@ +/************************************************************************* + * + * $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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SFX2_SCRIPTHANDLER_HXX +#define _SFX2_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; +}; + +namespace com +{ +namespace sun +{ +namespace star +{ +namespace uno +{ +class Any; +} +namespace lang +{ +class XMultiServiceFactory; +class XSingleServiceFactory; +} +namespace frame +{ +class XFrame; +class XModel; +class XDispatch; +class XNotifyingDispatch; +class XDispatchResultListener; +struct DispatchDescriptor; +} +namespace beans +{ +struct PropertyValue; +} +namespace util +{ +struct URL; +} +} +} +} + +namespace scripting_protocolhandler +{ + +// for simplification +#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 > +{ +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; + +public: + 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 ); + + /* 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 ); + + /* 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 ) + 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); + + /* Implementation for XInitialization */ + virtual void SAL_CALL initialize( const css::uno::Sequence < css::uno::Any >& aArguments ) throw ( css::uno::Exception ); +}; + +} +#endif diff --git a/scripting/source/provider/ScriptingContext.cxx b/scripting/source/provider/ScriptingContext.cxx new file mode 100755 index 0000000000000..eaac772c11067 --- /dev/null +++ b/scripting/source/provider/ScriptingContext.cxx @@ -0,0 +1,178 @@ +/************************************************************************* + * + * $RCSfile: ScriptingContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:20 $ + * + * 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 <cppuhelper/factory.hxx> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> + +#include <util/scriptingconstants.hxx> +#include <util/util.hxx> + +#include "ScriptingContext.hxx" + +using namespace com::sun::star::uno; +using namespace com::sun::star; + +namespace func_provider +{ + + +//************************************************************************* +// XScriptingContext implementation +// +//************************************************************************* +ScriptingContext::ScriptingContext( const Reference< XComponentContext > & xContext ) : m_xContext( xContext ) +{ + OSL_TRACE( "< ScriptingContext ctor called >\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; +} + +//************************************************************************* +bool ScriptingContext::validateKey( const ::rtl::OUString& key) +{ + ::osl::Guard< osl::Mutex > aGuard( m_mutex ); + + return ( m_propertyMap.find( key ) != m_propertyMap.end() ); +} + +//************************************************************************* +ScriptingContext::~ScriptingContext() +{ + OSL_TRACE( "< ScriptingContext dtor called >\n" ); +} + +//************************************************************************* +// XPropertySet implementation +// +//************************************************************************* +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) +{ + if ( !validateKey(aPropertyName) ) + { + throw RuntimeException(OUSTR("ScriptingContext::setPropertyValue: invalid key"), + Reference< XInterface >()); + } + ::osl::Guard< osl::Mutex > aGuard( m_mutex ); + m_propertyMap[ aPropertyName ] = aValue; +} + +//************************************************************************* +Any SAL_CALL ScriptingContext::getPropertyValue( const ::rtl::OUString& PropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, RuntimeException) +{ + if ( !validateKey(PropertyName) ) + { + throw RuntimeException(OUSTR("ScriptingContext::getPropertyValue: invalid key"), + Reference< XInterface >()); + } + return m_propertyMap[ PropertyName ]; +} + +//************************************************************************* +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 >()); +} + +//************************************************************************* +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 >()); +} + +//************************************************************************* +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 >()); +} + +//************************************************************************* +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 >()); +} + +} // namespace func_provider + + + diff --git a/scripting/source/provider/ScriptingContext.hxx b/scripting/source/provider/ScriptingContext.hxx new file mode 100644 index 0000000000000..8dc08947d2135 --- /dev/null +++ b/scripting/source/provider/ScriptingContext.hxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * $RCSfile: ScriptingContext.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:21 $ + * + * 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_PROTOCOLHANDLER_SCRIPTING_CONTEXT_HXX_ +#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_PROTOCOLHANDLER_SCRIPTING_CONTEXT_HXX_ + +#include <hash_map> + +#include <osl/mutex.hxx> +#include <rtl/ustring> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +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; + +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; + + osl::Mutex m_mutex; + + // Private helper methods + bool validateKey( const ::rtl::OUString& key); + +public: + 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); + +}; +}// func_provider +#endif //_DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_PROVIDER_XFUNCTIONPROVIDER_HXX_ diff --git a/scripting/source/provider/exports.dxp b/scripting/source/provider/exports.dxp new file mode 100644 index 0000000000000..9630d7e067687 --- /dev/null +++ b/scripting/source/provider/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/scripting/source/provider/makefile.mk b/scripting/source/provider/makefile.mk new file mode 100644 index 0000000000000..4d3f2f26ed937 --- /dev/null +++ b/scripting/source/provider/makefile.mk @@ -0,0 +1,104 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: dfoster $ $Date: 2002-09-20 14:33:24 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME= scripting +TARGET= provider +USE_DEFFILE= TRUE +NO_BSYMBOLIC= TRUE +ENABLE_EXCEPTIONS=TRUE +COMP1TYPELIST=$(TARGET) + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# ------------------------------------------------------------------ + +.INCLUDE : ..$/cppumaker.mk + +SLOFILES=\ + $(SLO)$/ScriptingContext.obj\ + $(SLO)$/FunctionImpl.obj\ + $(SLO)$/FunctionProvider.obj\ + +SHL1TARGET= $(TARGET) + +SHL1STDLIBS= \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SALLIB) + +# If you want our own way of debug uncomment this flag... +# ENVCFLAGS= -DDEBUG + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/scripting/source/provider/provider.xml b/scripting/source/provider/provider.xml new file mode 100755 index 0000000000000..05224d498d786 --- /dev/null +++ b/scripting/source/provider/provider.xml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name> ScriptRuntimeManager </module-name> + <component-description> + <author> Noel Power</author> + <name> drafts.com.sun.star.script.framework.provider.FunctionProvider </name> + <description> + This component is part of the Scripting Framework +</description> + <loader-name> com.sun.star.loader.SharedLibrary </loader-name> + <language> c++ </language> + <status value="drafts"/> + <supported-service> drafts.com.sun.star.script.framework.provider.FunctionProvider </supported-service> + <type> com.sun.star.beans.XPropertySet </type> + <type> com.sun.star.uno.Exception </type> + <type> com.sun.star.io.IOException </type> + <type> com.sun.star.io.XStream </type> + <type> drafts.com.sun.star.script.framework.provider.XFunction </type> + <type> drafts.com.sun.star.script.framework.provider.XFunctionProvider </type> + <type> drafts.com.sun.star.script.framework.XScriptInvocation </type> + <type> drafts.com.sun.star.script.framework.scripturi.XScriptURI </type> + + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + <runtime-module-dependency> cppuhelper2$(COM) </runtime-module-dependency> + <runtime-module-dependency> cppu2 </runtime-module-dependency> + <runtime-module-dependency> sal2 </runtime-module-dependency> +</module-description> diff --git a/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx b/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx new file mode 100644 index 0000000000000..e14f1b43710c9 --- /dev/null +++ b/scripting/source/runtimemgr/ScriptNameResolverImpl.cxx @@ -0,0 +1,330 @@ +/************************************************************************* + * + * $RCSfile: ScriptNameResolverImpl.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:29 $ + * + * 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 <vector> + +#include <cppuhelper/implementationentry.hxx> +#include <util/util.hxx> +#include <util/scriptingconstants.hxx> + +#include "ScriptNameResolverImpl.hxx" +#include "ScriptRuntimeManager.hxx" + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +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); +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; + +//************************************************************************* +ScriptNameResolverImpl::ScriptNameResolverImpl(const Reference< XComponentContext > & xContext ):m_xContext(xContext),mStorageFactory(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); + + s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt ); + +} + +//************************************************************************* +ScriptNameResolverImpl::~ScriptNameResolverImpl() +{ + OSL_TRACE( "< ScriptNameResolverImpl dtor called >\n" ); + s_moduleCount.modCnt.release( &s_moduleCount.modCnt ); +} + +//************************************************************************* +Reference< scripturi::XScriptURI > +ScriptNameResolverImpl::resolve(const Reference<scripturi::XScriptURI> & scriptURI, Any& invocationCtx) +throw (lang::IllegalArgumentException, script::CannotConvertException, RuntimeException) +{ + + Reference <scripturi::XScriptURI> resolvedName; + Reference< beans::XPropertySet > xPropSetScriptingContext; + OSL_TRACE( "ScriptNameResolverImpl::resolve: in resolve - start" ); + + if (sal_False == (invocationCtx >>= xPropSetScriptingContext)) + { + throw RuntimeException(OUSTR("ScriptNameResolverImpl::resolve : unable to get XScriptingContext from invocationCtx in/out param"), Reference<XInterface> ()); + } + + Any any; + OUString docUri; + sal_Int16 docSid; + try + { + any = xPropSetScriptingContext->getPropertyValue( scripting_constants::DOC_URI ); + 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> ()); + } + 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> ()); + } + } + catch (Exception & e) + { + throw RuntimeException(OUSTR("ScriptNameResolverImpl::resolve : problem with getPropertyValue")+e.Message, + Reference<XInterface> ()); + } +#ifdef _DEBUG + catch ( ... ) + { + 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); +#endif + + + OSL_TRACE("ScriptNameResolverImpl::resolve Starting..."); + SEARCHSIDS[0] = docSid; + ::std::vector< int >::const_iterator iter; + + + for ( iter = SEARCHSIDS.begin() ; iter != SEARCHSIDS.end(); ++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("found match in uri from storage %d",*iter); + break; + } + + } + + 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); + } +#ifdef _DEBUG + catch ( ... ) + { + OSL_TRACE("unknown exception thrown by storage %d, failed to match uri",*iter); + } +#endif + } + + + return resolvedName; +} + +//************************************************************************* +OUString SAL_CALL +ScriptNameResolverImpl::getImplementationName( ) +throw(RuntimeException) +{ + return nrs_implName; +} + +//************************************************************************* +sal_Bool SAL_CALL +ScriptNameResolverImpl::supportsService( const OUString& serviceName ) +throw(RuntimeException) +{ + OUString const * pNames = nrs_serviceNames.getConstArray(); + for ( sal_Int32 nPos = nrs_serviceNames.getLength(); nPos--; ) + { + if (serviceName.equals( pNames[ nPos ] )) + { + return sal_True; + } + } + return sal_False; +} + +//************************************************************************* + +Reference< scripturi::XScriptURI > +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); +#endif + + Reference< scripturi::XScriptURI > resolvedName; + if ( sid == 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() ) + { + return resolvedName; + } + + OSL_TRACE("ScriptNameResolverImpl::resolve Got some results..."); + for(int index=0;index<results.getLength();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); +#endif + + // just choose first one that has language=LANGUAGE_TO_RESOLVE_ON + ::rtl::OUString language(uri->getLanguage()); + + if (( language.compareToAscii(LANGUAGE_TO_RESOLVE_ON)== 0)) + { + OSL_TRACE("Found desired language\n"); + resolvedName = uri; + break; + } + } + } + catch (lang::IllegalArgumentException & iae) + { + throw lang::IllegalArgumentException(OUSTR("ScriptRuntimeManager::resolveURIFromStorageID IllegalArgumentException: ")+iae.Message, + Reference<XInterface> (), iae.ArgumentPosition); + } + catch (RuntimeException & re) + { + throw RuntimeException(OUSTR("ScriptRuntimeManager::resolveURIFromStorageID RuntimeException: ")+re.Message, + Reference<XInterface> ()); + } + catch (Exception & e) + { + throw RuntimeException(OUSTR("ScriptNameResolverImpl::resolveURIFromStorageID : Unknown Exception caught - RuntimeException rethrown")+e.Message, + Reference<XInterface> ()); + } +#ifdef _DEBUG + catch ( ... ) + { + throw RuntimeException(OUSTR("ScriptNameResolverImpl::resolveURIFromStorageID Unknown exception caught - RuntimeException rethrown"), Reference<XInterface> ()); + } +#endif + return resolvedName; +} +//************************************************************************* +Sequence<OUString> SAL_CALL +ScriptNameResolverImpl::getSupportedServiceNames( ) +throw(RuntimeException) +{ + return nrs_serviceNames; +} + +//************************************************************************* +Reference< XInterface > SAL_CALL scriptnri_create( + Reference< XComponentContext > const & xComponentContext ) +SAL_THROW( (Exception) ) +{ + return (cppu::OWeakObject *)new ScriptNameResolverImpl( xComponentContext ); +} + +//************************************************************************* +Sequence< OUString > scriptnri_getSupportedServiceNames() SAL_THROW( () ) +{ + return nrs_serviceNames; +} + +//************************************************************************* +OUString scriptnri_getImplementationName() SAL_THROW( () ) +{ + return nrs_implName; +} +} // namespace scripting_runtimemgr diff --git a/scripting/source/runtimemgr/ScriptNameResolverImpl.hxx b/scripting/source/runtimemgr/ScriptNameResolverImpl.hxx new file mode 100644 index 0000000000000..96cfcc48b18ed --- /dev/null +++ b/scripting/source/runtimemgr/ScriptNameResolverImpl.hxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * $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): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_SCRIPTNAMERESOLVERIMPL_HXX_ +#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_SCRIPTNAMERESOLVERIMPL_HXX_ + +#include <cppuhelper/implbase1.hxx> // helper for XInterface, XTypeProvider etc. + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/script/CannotConvertException.hpp> +#include <com/sun/star/reflection/InvocationTargetException.hpp> + +#include <drafts/com/sun/star/script/framework/XScriptNameResolver.hpp> +#include <drafts/com/sun/star/script/framework/scripturi/XScriptURI.hpp> + +#include "StorageBridgeFactory.hxx" + +namespace scripting_runtimemgr +{ + +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(); + + // 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); + + /********************************************** + resolve method + @param scriptURI this is the given ScriptURI + @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. + @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 + +#endif //_DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_SCRIPTNAMERESOLVERIMPL_HXX_ diff --git a/scripting/source/runtimemgr/ScriptRuntimeManager.cxx b/scripting/source/runtimemgr/ScriptRuntimeManager.cxx new file mode 100755 index 0000000000000..858ea33ae472e --- /dev/null +++ b/scripting/source/runtimemgr/ScriptRuntimeManager.cxx @@ -0,0 +1,372 @@ +/************************************************************************* + * + * $RCSfile: ScriptRuntimeManager.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:31 $ + * + * 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 "ScriptRuntimeManager.hxx" +#include "ScriptNameResolverImpl.hxx" +#include <util/util.hxx> + +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +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 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 ) +{ + OSL_TRACE( "< ScriptRuntimeManager ctor called >\n" ); + s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt ); +} + +//************************************************************************* +// ScriptRuntimeManager Destructor +ScriptRuntimeManager::~ScriptRuntimeManager() +{ + OSL_TRACE( "< ScriptRuntimeManager dtor called >\n" ); + s_moduleCount.modCnt.release( &s_moduleCount.modCnt ); +} + +//************************************************************************* +// Get the proper XScriptInvocation +Reference <XScriptInvocation> SAL_CALL ScriptRuntimeManager::getScriptRuntime(const Reference<scripturi::XScriptURI>& scriptURI) +throw(RuntimeException) +{ + OSL_TRACE("** ==> ScriptRuntimeManager in getScriptRuntime\n"); + + Reference< XScriptInvocation > xScriptInvocation; + + validateXRef(m_xContext, "ScriptRuntimeManager::GetScriptRuntime: No context available"); + Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); + 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")); + a >>= xx; + validateXRef(xx, "ScriptRuntimeManager::GetScriptRuntime: cannot get ScriptRuntimeForJava Service"); + xScriptInvocation = Reference<XScriptInvocation>(xx, UNO_QUERY_THROW); + } + catch (Exception &e) + { + throw RuntimeException(OUSTR("ScriptRuntimeManager::GetScriptRuntime: ") + e.Message, Reference< XInterface >()); + } + + return xScriptInvocation; +} + +//************************************************************************* +// Get the proper XScriptNameResolver +Reference <XScriptNameResolver> SAL_CALL +ScriptRuntimeManager::getScriptNameResolver() +throw(RuntimeException) +{ + OSL_TRACE("** ==> ScriptRuntimeManager in getScriptNameResolver\n"); + Reference< XScriptNameResolver > xScriptNameResolver; + + validateXRef(m_xContext, "ScriptRuntimeManager::GetScriptNameResolver: No context available"); + Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); + 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); + } + catch (Exception &e) + { + throw RuntimeException(OUSTR("ScriptRuntimeManager::GetScriptNameResolver: ") + e.Message, Reference< XInterface >()); + } + return xScriptNameResolver; +} + +//************************************************************************* +// 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) +{ + OSL_TRACE("** ==> ScriptRuntimeManager in runtimemgr invoke\n"); + Any results; + // Initialise resolved context with invocation context, + // the resolved context (resolvedCtx will be modified by the + // resolve method to contain the storage where the script code is + // stored + Any resolvedCtx = invocationCtx; + try + { + 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."); + + + results = xScriptInvocation->invoke(resolvedURI,resolvedCtx,aParams, + aOutParamIndex,aOutParam); + } + catch (lang::IllegalArgumentException & iae) + { + throw lang::IllegalArgumentException(OUSTR("ScriptRuntimeManager::invoke IllegalArgumentException: ")+iae.Message, + Reference<XInterface> (), iae.ArgumentPosition); + } + catch (script::CannotConvertException & cce) + { + throw script::CannotConvertException(OUSTR("ScriptRuntimeManager::invoke CannotConvertException: ")+cce.Message, + Reference<XInterface> (), cce.DestinationTypeClass, cce.Reason, cce.ArgumentIndex); + } + catch (reflection::InvocationTargetException & ite) + { + throw reflection::InvocationTargetException(OUSTR("ScriptRuntimeManager::invoke InvocationTargetException: ")+ite.Message, + Reference<XInterface> (), ite.TargetException); + } + catch (RuntimeException & re) + { + throw RuntimeException(OUSTR("ScriptRuntimeManager::invoke RuntimeException: ")+re.Message, + Reference<XInterface> ()); + } +#ifdef _DEBUG + catch ( ... ) + { + throw RuntimeException(OUSTR("ScriptRuntimeManager::invoke UnknownException: "), + Reference<XInterface> ()); + } +#endif + return results; +} + +//************************************************************************* +// XScriptNameResolver implementation +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"); + Reference< scripturi::XScriptURI > resolvedURI; + + Reference< XScriptNameResolver > xScriptNameResolver = getScriptNameResolver(); + validateXRef(xScriptNameResolver, "ScriptRuntimeManager::resolve: No ScriptNameResolver"); + + try + { + resolvedURI = xScriptNameResolver->resolve(scriptURI,invocationCtx); + } + catch (lang::IllegalArgumentException & iae) + { + throw lang::IllegalArgumentException(OUSTR("ScriptRuntimeManager::resolve IllegalArgumentException: ")+iae.Message, + Reference<XInterface> (), iae.ArgumentPosition); + } + catch (script::CannotConvertException & cce) + { + throw script::CannotConvertException(OUSTR("ScriptRuntimeManager::resolve CannotConvertException: ")+cce.Message, + Reference<XInterface> (), cce.DestinationTypeClass, cce.Reason, cce.ArgumentIndex); + } + catch (RuntimeException & re) + { + throw RuntimeException(OUSTR("ScriptRuntimeManager::resolve RuntimeException: ")+re.Message, + Reference<XInterface> ()); + } +#ifdef _DEBUG + catch ( ... ) + { + throw RuntimeException(OUSTR("ScriptRuntimeManager::resolve UnknownException: "), + Reference<XInterface> ()); + } +#endif + + return resolvedURI; +} + +//************************************************************************* +OUString SAL_CALL ScriptRuntimeManager::getImplementationName( ) +throw(RuntimeException) +{ + return s_implName; +} + +//************************************************************************* +sal_Bool SAL_CALL ScriptRuntimeManager::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 ] )) + { + return sal_True; + } + } + return sal_False; +} + +//************************************************************************* +Sequence<OUString> SAL_CALL ScriptRuntimeManager::getSupportedServiceNames( ) +throw(RuntimeException) +{ + return s_serviceNames; +} + +//************************************************************************* +static Reference<XInterface> SAL_CALL srm_create( + const Reference< XComponentContext > & xCompC ) +{ + return (cppu::OWeakObject *)new ScriptRuntimeManager( xCompC ); +} + +//************************************************************************* +static Sequence<OUString> srm_getSupportedServiceNames( ) +SAL_THROW( () ) +{ + return s_serviceNames; +} + +//************************************************************************* +static OUString srm_getImplementationName( ) +SAL_THROW( () ) +{ + return s_implName; +} + +//************************************************************************* +Reference< XInterface > SAL_CALL scriptnri_create( + Reference< XComponentContext > const & xComponentContext ) +SAL_THROW( (Exception) ); + +//************************************************************************* +Sequence< OUString > scriptnri_getSupportedServiceNames() SAL_THROW( () ); + +//************************************************************************* +OUString scriptnri_getImplementationName() SAL_THROW( () ); + +//************************************************************************* +static struct cppu::ImplementationEntry s_entries [] = + { + { + srm_create, srm_getImplementationName, + srm_getSupportedServiceNames, cppu::createSingleComponentFactory, + &s_moduleCount.modCnt, 0 + }, + { + scriptnri_create, scriptnri_getImplementationName, + scriptnri_getSupportedServiceNames, cppu::createSingleComponentFactory, + &s_moduleCount.modCnt, 0 + }, + { 0, 0, 0, 0, 0, 0 } + }; +} // Namespace + +//################################################################################################## +//#### EXPORTED #################################################################################### +//################################################################################################## + +/** + * Gives the environment this component belongs to. + */ +extern "C" +{ + void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv) + { + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; + } + + /** + * This function creates an implementation section in the registry and another subkey + * + * for each supported service. + * @param pServiceManager the service manager + * @param pRegistryKey the registry key + */ + sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey) + { + return ::cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, ::scripting_runtimemgr::s_entries); + } + + /** + * This function is called to get service factories for an implementation. + * + * @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 + * @return a component factory + */ + 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); + } +} diff --git a/scripting/source/runtimemgr/ScriptRuntimeManager.hxx b/scripting/source/runtimemgr/ScriptRuntimeManager.hxx new file mode 100644 index 0000000000000..e375e519b2a5a --- /dev/null +++ b/scripting/source/runtimemgr/ScriptRuntimeManager.hxx @@ -0,0 +1,159 @@ +/************************************************************************* + * + * $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): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_SCRIPTRUNTIMEMANAGER_HXX_ +#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_SCRIPTRUNTIMEMANAGER_HXX_ + +#include <osl/mutex.hxx> + +#include <cppuhelper/implbase3.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/uno/RuntimeException.hpp> +#include <com/sun/star/script/CannotConvertException.hpp> +#include <com/sun/star/reflection/InvocationTargetException.hpp> + +#include <drafts/com/sun/star/script/framework/XScriptInvocation.hpp> +#include <drafts/com/sun/star/script/framework/XScriptNameResolver.hpp> +#include <drafts/com/sun/star/script/framework/scripturi/XScriptURI.hpp> + +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 > +{ + // 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 ); + ~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); + + /** + * implements XScriptInvocation, invokes the script named in scriptURI + * (resolving it first, if necessary), with the args passed. + * + * @param scriptURI the URI, which may not be fully qualified, for the + * script to be invoked + * + /************************************************************* + 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 + + @param aParams all parameters; pure, out params are undefined in sequence, + i.e., the value has to be ignored by the callee + @param aOutParamIndex out indices + @param aOutParam out parameters + + @returns + the value returned from the function being invoked + + @throws IllegalArgumentException + if there is no matching script name + + @throws CannotConvertException + if args do not match or cannot be converted the those + of the invokee + + @throws InvocationTargetException + 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); + + /** + * implements XScriptNameResolver, attempts to resolve the script URI + * passed in + * + * @param scriptURI the URI to be resolved + * @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. + * @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); + +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); +}; +} // scripting_runtimemgr + +#endif //_COM_SUN_STAR_SCRIPTING_SCRIPTRUNTIMEMANAGER_HXX_ diff --git a/scripting/source/runtimemgr/StorageBridge.cxx b/scripting/source/runtimemgr/StorageBridge.cxx new file mode 100644 index 0000000000000..f03ff74a73791 --- /dev/null +++ b/scripting/source/runtimemgr/StorageBridge.cxx @@ -0,0 +1,152 @@ +/************************************************************************* + * + * $RCSfile: StorageBridge.cxx,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): _______________________________________ + * + * + ************************************************************************/ + + +#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> + +#include "StorageBridge.hxx" +#include <util/util.hxx> + +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +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 int STORAGEID = 0; +const int STORAGEPROXY = 0; + + +//************************************************************************* +// StorageBridge Constructor +StorageBridge::StorageBridge( const Reference< XComponentContext >& xContext, sal_Int16 sid ):m_xContext(xContext),m_sid(sid) +{ + try + { + initStorage(); + } + catch(RuntimeException& re) + { + throw RuntimeException(OUSTR("StorageBridge::StorageBridge(salIn32&): ") + re.Message, Reference< XInterface >()); + } +} + +//************************************************************************* +void +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< XInterface > temp; + + 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); + } + else + { + 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); + } + } + catch (Exception e) + { + throw RuntimeException(OUSTR("StorageBridge::StorageBridge: ") + e.Message, Reference< XInterface >()); + } +} +//************************************************************************* +Sequence < Reference< scripturi::XScriptURI > > +StorageBridge::getImplementations(const Reference< scripturi::XScriptURI >& queryURI ) +throw (lang::IllegalArgumentException, RuntimeException) +{ + OSL_TRACE("In StorageBridge getImplementations...\n"); + Sequence < Reference< scripturi::XScriptURI > > results; + try + { + results = m_xScriptImplAccess->getImplementations(queryURI); + } + catch (Exception e) + { + throw RuntimeException(OUSTR("StorageBridge::getImplementations: ") + e.Message, Reference< XInterface >()); + } + return results; +} +} diff --git a/scripting/source/runtimemgr/StorageBridge.hxx b/scripting/source/runtimemgr/StorageBridge.hxx new file mode 100644 index 0000000000000..1fe2835eaed3d --- /dev/null +++ b/scripting/source/runtimemgr/StorageBridge.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * $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): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGEBRIDGE_HXX_ +#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGEBRIDGE_HXX_ + +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <drafts/com/sun/star/script/framework/storage/XScriptImplAccess.hpp> +#include "StorageBridgeFactory.hxx" + +namespace scripting_runtimemgr +{ +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); +private: + StorageBridge(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext, sal_Int16 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; +}; +} + +#endif //_COM_SUN_STAR_SCRIPTING_STORAGEBRIDGE_HXX_ diff --git a/scripting/source/runtimemgr/StorageBridgeFactory.cxx b/scripting/source/runtimemgr/StorageBridgeFactory.cxx new file mode 100644 index 0000000000000..5a613570c1587 --- /dev/null +++ b/scripting/source/runtimemgr/StorageBridgeFactory.cxx @@ -0,0 +1,99 @@ +/************************************************************************* + * + * $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): _______________________________________ + * + * + ************************************************************************/ + + +#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) +{ +} + + + +//************************************************************************* +// 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. + + +Reference< storage::XScriptImplAccess > +StorageBridgeFactory::getStorageInstance(sal_Int16 sid) +{ + + Reference <storage::XScriptImplAccess> storage = new StorageBridge(m_xContext,sid) ; + return storage; +} +} //scripting_runtimemgr diff --git a/scripting/source/runtimemgr/StorageBridgeFactory.hxx b/scripting/source/runtimemgr/StorageBridgeFactory.hxx new file mode 100644 index 0000000000000..4846e1b9d998e --- /dev/null +++ b/scripting/source/runtimemgr/StorageBridgeFactory.hxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * $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): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGEBRIDGEFACTORY_HXX_ +#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGEBRIDGEFACTORY_HXX_ + +#include <rtl/ustring> + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/uno/Reference.hxx> + +#include <drafts/com/sun/star/script/framework/storage/XScriptImplAccess.hpp> + +namespace scripting_runtimemgr +{ +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; +private: + StorageBridgeFactory();// No definition for default ctor +}; +}// scripting_runtimemgr +#endif //_DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_NAMERESOLVER_HXX_ diff --git a/scripting/source/runtimemgr/exports.dxp b/scripting/source/runtimemgr/exports.dxp new file mode 100644 index 0000000000000..2513a15ad5d5f --- /dev/null +++ b/scripting/source/runtimemgr/exports.dxp @@ -0,0 +1,4 @@ +component_getDescriptionFunc +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/scripting/source/runtimemgr/makefile.mk b/scripting/source/runtimemgr/makefile.mk new file mode 100644 index 0000000000000..5106ae7db02e3 --- /dev/null +++ b/scripting/source/runtimemgr/makefile.mk @@ -0,0 +1,102 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: dfoster $ $Date: 2002-09-20 14:33:36 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME= scripting +TARGET= runtimemgr +USE_DEFFILE= TRUE +NO_BSYMBOLIC= TRUE +ENABLE_EXCEPTIONS=TRUE +COMP1TYPELIST=$(TARGET) + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# ------------------------------------------------------------------ + +.INCLUDE : ..$/cppumaker.mk + +SLOFILES=\ + $(SLO)$/ScriptNameResolverImpl.obj\ + $(SLO)$/ScriptRuntimeManager.obj\ + $(SLO)$/StorageBridge.obj\ + $(SLO)$/StorageBridgeFactory.obj\ + +SHL1TARGET= $(TARGET) + +SHL1STDLIBS= \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/scripting/source/runtimemgr/runtimemgr.xml b/scripting/source/runtimemgr/runtimemgr.xml new file mode 100755 index 0000000000000..7ad856e5a5830 --- /dev/null +++ b/scripting/source/runtimemgr/runtimemgr.xml @@ -0,0 +1,47 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name> ScriptRuntimeManager </module-name> + <component-description> + <author> Alexis Ledoux</author> + <name> drafts.com.sun.star.script.framework.ScriptRuntimeManager </name> + <description> + This component is part of the Scripting Framework +</description> + <loader-name> com.sun.star.loader.SharedLibrary </loader-name> + <language> c++ </language> + <status value="final"/> + <supported-service> drafts.com.sun.star.script.framework.ScriptRuntimeManager </supported-service> + <type> com.sun.star.lang.XSingleServiceFactory </type> + <type> com.sun.star.lang.XMultiComponentFactory </type> + <type> com.sun.star.lang.XSingleComponentFactory </type> + <type> com.sun.star.uno.XNamingService </type> + <type> com.sun.star.uno.XWeak </type> + <type> com.sun.star.lang.XMain </type> + <type> com.sun.star.uno.XAggregation </type> + <type> com.sun.star.lang.XMultiServiceFactory </type> + <type> com.sun.star.lang.XTypeProvider </type> + <type> com.sun.star.registry.XSimpleRegistry </type> + <type> com.sun.star.loader.XImplementationLoader </type> + <type> com.sun.star.registry.XImplementationRegistration </type> + <type> com.sun.star.lang.XComponent </type> + <type> com.sun.star.connection.XAcceptor </type> + <type> com.sun.star.connection.XConnector </type> + <type> com.sun.star.container.XHierarchicalNameAccess </type> + <type> com.sun.star.lang.XServiceInfo </type> + <type> com.sun.star.io.XOutputStream </type> + <type> drafts.com.sun.star.script.framework.storage.XScriptImplAccess </type> + <type> drafts.com.sun.star.script.framework.XScriptInvocation </type> + <type> drafts.com.sun.star.script.framework.XScriptNameResolver </type> + <type> drafts.com.sun.star.script.framework.scripturi.XScriptURI </type> + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + <runtime-module-dependency> cppuhelper$(UDK_MAJOR)$(COM) </runtime-module-dependency> + <runtime-module-dependency> salhelper$(UDK_MAJOR)$(COM) </runtime-module-dependency> + <runtime-module-dependency> cppu$(UDK_MAJOR) </runtime-module-dependency> + <runtime-module-dependency> reg$(UDK_MAJOR) </runtime-module-dependency> + <runtime-module-dependency> store$(UDK_MAJOR) </runtime-module-dependency> + <runtime-module-dependency> sal$(UDK_MAJOR) </runtime-module-dependency> +</module-description> diff --git a/scripting/source/storage/ScriptElement.cxx b/scripting/source/storage/ScriptElement.cxx new file mode 100644 index 0000000000000..06d4e86d2e1b8 --- /dev/null +++ b/scripting/source/storage/ScriptElement.cxx @@ -0,0 +1,159 @@ +/************************************************************************* + * + * $RCSfile: ScriptElement.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:48 $ + * + * 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 "ScriptElement.hxx" +#include <util/util.hxx> + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::drafts::com::sun::star::script::framework; + +namespace scripting_impl +{ + +//************************************************************************* +ScriptElement::ScriptElement(storage::ScriptImplInfo & sII) : + m_sII( sII ), + XMLElement(OUSTR("script")) +{ + OSL_TRACE("ScriptElement ctor called\n"); + + addAttribute(OUSTR("language"), sII.scriptLanguage); + addAttribute(OUSTR("deploymentdir"), sII.scriptRoot); + + { + XMLElement* xel = new XMLElement(OUSTR("logicalname")); + xel->addAttribute(OUSTR("value"), sII.logicalName); + Reference <xml::sax::XAttributeList> xal(xel); + addSubElement(xal); + } + + { + XMLElement* xel = new XMLElement(OUSTR("languagename")); + xel->addAttribute(OUSTR("value"), sII.functionName); + xel->addAttribute(OUSTR("location"), sII.scriptLocation); + Reference <xml::sax::XAttributeList> xal(xel); + addSubElement(xal); + } + + storage::ScriptDepFile *pArray = sII.scriptDependencies.getArray(); + sal_Int32 len = sII.scriptDependencies.getLength(); + + if (len > 0) + { + XMLElement* xel = new XMLElement(OUSTR("dependencies")); + + for(sal_Int32 i = 0; i < len; i++) + { + XMLElement* subxel = new XMLElement(OUSTR("dependfile")); + subxel->addAttribute(OUSTR("name"), pArray[i].fileName); + if(pArray[i].isDeliverable) + { + subxel->addAttribute(OUSTR("isdeliverable"), OUSTR("yes")); + } + else + { + subxel->addAttribute(OUSTR("isdeliverable"), OUSTR("no")); + } + Reference <xml::sax::XAttributeList> subxal(subxel); + xel->addSubElement(subxal); + } + + Reference <xml::sax::XAttributeList> xal(xel); + addSubElement(xal); + } + + if(sII.scriptDescription.getLength() > 0) + { + XMLElement* xel = new XMLElement(OUSTR("description"), + sII.scriptDescription); + Reference< xml::sax::XAttributeList > xal(xel); + addSubElement(xal); + } + + storage::ScriptDeliverFile *pt_Array = sII.parcelDelivers.getArray(); + sal_Int32 len_d = sII.parcelDelivers.getLength(); + + if(len_d > 0) + { + XMLElement* xel = new XMLElement(OUSTR("delivery")); + + for(sal_Int32 i = 0; i < len_d; i++) + { + XMLElement* subxel = new XMLElement(OUSTR("deliverfile")); + subxel->addAttribute(OUSTR("name"), pt_Array[i].fileName); + subxel->addAttribute(OUSTR("type"), pt_Array[i].fileType); + Reference < xml::sax::XAttributeList > subxal(subxel); + xel->addSubElement(subxal); + } + + Reference <xml::sax::XAttributeList> xal(xel); + addSubElement(xal); + } +} + +//************************************************************************* +ScriptElement::~ScriptElement() SAL_THROW(()) +{ +} + +} diff --git a/scripting/source/storage/ScriptElement.hxx b/scripting/source/storage/ScriptElement.hxx new file mode 100644 index 0000000000000..7777b8746806c --- /dev/null +++ b/scripting/source/storage/ScriptElement.hxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * $RCSfile: ScriptElement.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:48 $ + * + * 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 _SCRIPTING_STORAGE_METADATA_ELEMENT_HXX_ +#define _SCRIPTING_STORAGE_METADATA_ELEMENT_HXX_ + +#include <osl/mutex.hxx> + +#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp> + +#include "XMLElement.hxx" + +namespace scripting_impl +{ + +class ScriptElement : public ::scripting_impl::XMLElement +{ +private: + drafts::com::sun::star::script::framework::storage::ScriptImplInfo m_sII; + +public: + explicit ScriptElement(drafts::com::sun::star::script::framework::storage::ScriptImplInfo &); + ~ScriptElement() SAL_THROW (()); +}; + +} + +#endif diff --git a/scripting/source/storage/ScriptInfo.cxx b/scripting/source/storage/ScriptInfo.cxx new file mode 100644 index 0000000000000..3a2080306b4d8 --- /dev/null +++ b/scripting/source/storage/ScriptInfo.cxx @@ -0,0 +1,328 @@ +/************************************************************************* + * + * $RCSfile: ScriptInfo.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:49 $ + * + * 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 <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::uno; +using namespace com::sun::star::beans; +using namespace ::drafts::com::sun::star::script::framework; + +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) +{ + 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<storage::XScriptStorageManager> xSSM(xx,UNO_QUERY_THROW); + validateXRef(xSSM, "ScriptInfo::prepareForInvocation(): could not get XScriptStorageManager"); + xx = xSSM->getScriptStorage(m_storageID); + validateXRef(xx, "ScriptInfo::prepareForInvocation(): could not get XInterface"); + Reference <storage::XParcelInvocationPrep> xPIP(xx, UNO_QUERY_THROW); + 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; +} +} diff --git a/scripting/source/storage/ScriptInfo.hxx b/scripting/source/storage/ScriptInfo.hxx new file mode 100644 index 0000000000000..f5b8c845e1995 --- /dev/null +++ b/scripting/source/storage/ScriptInfo.hxx @@ -0,0 +1,123 @@ +/************************************************************************* + * + * $RCSfile: ScriptInfo.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:50 $ + * + * 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 __SCRIPTING_STORAGE_SCRIPTINFO_HXX_ +#define __SCRIPTING_STORAGE_SCRIPTINFO_HXX_ + +#include <cppuhelper/implbase4.hxx> // helper for component factory + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +#include <drafts/com/sun/star/script/framework/storage/XScriptInfo.hpp> +#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp> +#include <drafts/com/sun/star/script/framework/storage/XScriptInvocationPrep.hpp> + +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 > +{ + // 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 >& ); + virtual ~ScriptInfo(); + + 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 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); + + // XScriptInfo + virtual ::rtl::OUString SAL_CALL getLogicalName( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLogicalName( const ::rtl::OUString& name ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getDescription( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDescription( const ::rtl::OUString& desc ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getLanguage( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getScriptLocation( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLanguage( const ::rtl::OUString& language ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasSource( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getLanguageSpecificName( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setLanguageSpecificName( const ::rtl::OUString& langName ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getRoot( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getDependencies( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getLocation( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > SAL_CALL extraProperties( ) throw (::com::sun::star::uno::RuntimeException); + /** + * This function prepares the script for invocation and returns the full path + * to the prepared parcel folder + */ + virtual ::rtl::OUString SAL_CALL prepareForInvocation() throw (::com::sun::star::uno::RuntimeException); + +}; + +} +#endif // define __SCRIPTING_STORAGE... diff --git a/scripting/source/storage/ScriptMetadataImporter.cxx b/scripting/source/storage/ScriptMetadataImporter.cxx new file mode 100644 index 0000000000000..41b897a8eaa1e --- /dev/null +++ b/scripting/source/storage/ScriptMetadataImporter.cxx @@ -0,0 +1,562 @@ +/************************************************************************* + * + * $RCSfile: ScriptMetadataImporter.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:50 $ + * + * 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 "ScriptMetadataImporter.hxx" +#include <osl/mutex.hxx> +#include <com/sun/star/xml/sax/XParser.hpp> + +#include <stdio.h> +#include <util/util.hxx> +#include <rtl/string.h> + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::drafts::com::sun::star::script::framework; + +namespace scripting_impl +{ + +//************************************************************************* +ScriptMetadataImporter::ScriptMetadataImporter( const Reference< XComponentContext > & xContext ) : m_xContext( xContext ) +{ + OSL_TRACE( "< ScriptMetadataImporter ctor called >\n" ); +} + +//************************************************************************* +ScriptMetadataImporter::~ScriptMetadataImporter() SAL_THROW( () ) +{ + OSL_TRACE( "< ScriptMetadataImporter dtor called >\n" ); +} + + +//************************************************************************* +Impls_vec ScriptMetadataImporter::parseMetaData( + Reference< io::XInputStream > const & xInput, const ::rtl::OUString & parcelURI ) +throw ( xml::sax::SAXException, io::IOException, RuntimeException ) +{ + //Clear the vector of parsed information + ms_scriptInfos.clear(); + + //Set the placeholder for the parcel URI + ms_parcelURI = parcelURI; + + //Get the parser service + validateXRef(m_xContext, + "ScriptMetadataImporter::parseMetaData: No context available"); + + Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); + validateXRef(xMgr, + "ScriptMetadataImporter::parseMetaData: No service manager available"); + + Reference< XInterface > xx = xMgr->createInstanceWithContext( + OUString::createFromAscii("com.sun.star.xml.sax.Parser"), m_xContext ); + + validateXRef(xMgr, "ScriptMetadataImporter::parseMetaData: cannot get SAX Parser"); + Reference< xml::sax::XParser > xParser(xx,UNO_QUERY_THROW); + + // xxx todo: error handler, entity resolver omitted + // This class is the document handler for the parser + Reference< xml::sax::XDocumentHandler > t_smI( this ); + xParser->setDocumentHandler( t_smI ); + + //Set up the input for the parser, the XInputStream + xml::sax::InputSource source; + source.aInputStream = xInput; + source.sSystemId = OUSTR("virtual file"); + + OSL_TRACE("ScriptMetadataImporter: Start the parser\n"); + + try + { + xParser->parseStream( source ); + } + catch ( xml::sax::SAXException & saxe ) + { + throw xml::sax::SAXException( + OUString::createFromAscii( + "ScriptMetadataImporter::parseMetaData SAXException: ") +saxe.Message, + Reference< XInterface > (), saxe.WrappedException); + } + catch ( io::IOException & ioe ) + { + throw io::IOException( OUString::createFromAscii( + "ScriptMetadataImporter::parseMetaData IOException: ")+ioe.Message, + Reference< XInterface > ()); + } +#ifdef _DEBUG + catch ( ... ) + { + throw RuntimeException(OUString::createFromAscii( + "ScriptMetadataImporter::parseMetadata UnknownException: "), + Reference< XInterface > ()); + } +#endif + OSL_TRACE("ScriptMetadataImporter: Parser finished\n"); +#ifdef _DEBUG + + printf("ScriptMetadataImporter: vector size is %d\n", ms_scriptInfos.size()); +#endif + //return the vector of ScriptImplInfos + return ms_scriptInfos; +} + +//************************************************************************* +// XExtendedDocumentHandler impl +void ScriptMetadataImporter::startCDATA() +throw (xml::sax::SAXException, RuntimeException) +{ + OSL_TRACE("ScriptMetadataImporter: startCDATA()\n"); +} + +//************************************************************************* +void ScriptMetadataImporter::endCDATA() +throw (RuntimeException) +{ + OSL_TRACE("ScriptMetadataImporter: endDATA()\n"); +} + +//************************************************************************* +void ScriptMetadataImporter::comment( const ::rtl::OUString & sComment ) +throw (xml::sax::SAXException, RuntimeException) +{ + OSL_TRACE("ScriptMetadataImporter: comment()\n"); +} + +//************************************************************************* +void ScriptMetadataImporter::allowLineBreak() +throw (xml::sax::SAXException, RuntimeException) +{ + OSL_TRACE("ScriptMetadataImporter: allowLineBreak()\n"); +} + +//************************************************************************* +void ScriptMetadataImporter::unknown( const ::rtl::OUString & sString ) +throw (xml::sax::SAXException, RuntimeException) +{ + OSL_TRACE("ScriptMetadataImporter: unknown()\n"); +} + +//************************************************************************* +// XDocumentHandler impl +void ScriptMetadataImporter::startDocument() +throw (xml::sax::SAXException, RuntimeException) +{ + // Ignore for now + OSL_TRACE("ScriptMetadataImporter: startDocument()\n"); +} + +//************************************************************************* +void ScriptMetadataImporter::endDocument() +throw (xml::sax::SAXException, RuntimeException) +{ + // Ignore for now + OSL_TRACE("ScriptMetadataImporter: endDocument()\n"); +} + +//************************************************************************* +void ScriptMetadataImporter::startElement( + const ::rtl::OUString& tagName, + const Reference< xml::sax::XAttributeList >& xAttribs ) +throw (xml::sax::SAXException, RuntimeException) +{ +#ifdef _DEBUG + printf("ScriptMetadataImporter: startElement() %s\n", + ::rtl::OUStringToOString(tagName, + RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + ::osl::Guard< ::osl::Mutex > aGuard( m_mutex ); + + //Set the state of the state machine + setState(tagName); + + //Temporay variables + ::rtl::OUString t_delivered = ::rtl::OUString::createFromAscii("false"); + + //Processing the elements + switch(m_state) + { + case PARCEL: + break; + + + case LOGICALNAME: + //logical name + m_scriptImplInfo.logicalName = + xAttribs->getValueByName( + ::rtl::OUString::createFromAscii("value")); +#ifdef _DEBUG + + printf("ScriptMetadataImporter: Got logicalname: %s\n", + ::rtl::OUStringToOString(m_scriptImplInfo.logicalName, + RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + break; + + case LANGUAGENAME: + //language(function) name + m_scriptImplInfo.functionName = + xAttribs->getValueByName( + ::rtl::OUString::createFromAscii("value")); + m_scriptImplInfo.scriptLocation = + xAttribs->getValueByName( + ::rtl::OUString::createFromAscii("location")); +#ifdef _DEBUG + + printf("ScriptMetadataImporter: Got language: %s\n", + ::rtl::OUStringToOString(m_scriptImplInfo.functionName, + RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + break; + + case DELIVERFILE: + //Get Info about delivered files + mv_delivFile.push_back( xAttribs->getValueByName( + ::rtl::OUString::createFromAscii("name"))); + mv_deliverType.push_back( xAttribs->getValueByName( + ::rtl::OUString::createFromAscii("type"))); + + break; + + case DEPENDFILE: + //push the dependency into the the vector + mv_deps.push_back( xAttribs->getValueByName( + ::rtl::OUString::createFromAscii("name"))); + + t_delivered = xAttribs->getValueByName( + ::rtl::OUString::createFromAscii("isdeliverable")); + + if( t_delivered.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("yes")) ) + { + mv_depsDelivered.push_back( true ); + } + else + { + mv_depsDelivered.push_back( false ); + } + +#ifdef _DEBUG + printf("ScriptMetadataImporter: Got dependency: %s\n", + ::rtl::OUStringToOString( xAttribs->getValueByName( + ::rtl::OUString::createFromAscii("name")), + RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + break; + + //Needs to be here to circumvent bypassing of initialization of + //local(global) variables affecting other cases + case SCRIPT: + //Assign a new empty struct to the member struct to clear + //all values in the struct + storage::ScriptImplInfo t_implInfo; + m_scriptImplInfo = t_implInfo; + m_scriptImplInfo.parcelURI = ms_parcelURI; + if(xAttribs->getLength() == 2) + { + //Get the script tag attributes + OSL_TRACE("ScriptMetadataImporter: Get language and deployment dir\n"); + + //script language + m_scriptImplInfo.scriptLanguage = xAttribs->getValueByName( + ::rtl::OUString::createFromAscii("language")); + +#ifdef _DEBUG + + printf("ScriptMetadataImporter: Got language: %s\n", + ::rtl::OUStringToOString(m_scriptImplInfo.scriptLanguage, + RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + //script root directory + m_scriptImplInfo.scriptRoot = xAttribs->getValueByName( + ::rtl::OUString::createFromAscii( "deploymentdir" )); + +#ifdef _DEBUG + + printf("ScriptMetadataImporter: Got dir: %s\n", + ::rtl::OUStringToOString(m_scriptImplInfo.scriptRoot, + RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + } + break; + } +} + +//************************************************************************* +void ScriptMetadataImporter::endElement( const ::rtl::OUString & aName ) +throw (xml::sax::SAXException, RuntimeException) +{ + + //The end tag of an element +#ifdef _DEBUG + printf("ScriptMetadataImporter: endElement() %s\n", ::rtl::OUStringToOString(aName, + RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + ::osl::Guard< ::osl::Mutex > aGuard( m_mutex ); + + //Set the state + setState(aName); + + //Temporary variables + int t_delSize = 0; + + switch (m_state) + { + case PARCEL: + break; + case SCRIPT: +#ifdef _DEBUG + + OSL_TRACE("ScriptMetadataImporter: Got a scriptImplInfo\n"); + + printf("ScriptMetadataImporter: \t %s\n", ::rtl::OUStringToOString( + m_scriptImplInfo.scriptLanguage, RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + //Push the struct into the vector + ms_scriptInfos.push_back(m_scriptImplInfo); + break; + + case LOGICALNAME: + break; + + case LANGUAGENAME: + break; + + case DELIVERY: + t_delSize = mv_delivFile.size(); + if(t_delSize > 0) + { + Sequence< storage::ScriptDeliverFile > t_delivers(t_delSize); + Deps_vec::const_iterator it = mv_delivFile.begin(); + Deps_vec::const_iterator it_end = mv_delivFile.end(); + Deps_vec::const_iterator itType = mv_deliverType.begin(); + Deps_vec::const_iterator itType_end = mv_deliverType.end(); + for(int cnt = 0; (it!=it_end)&&(itType!=itType_end); ++it) + { + t_delivers[cnt].fileName = *it; + t_delivers[cnt].fileType = *itType; + cnt++; + ++itType; + } + m_scriptImplInfo.parcelDelivers = t_delivers; + mv_delivFile.clear(); + mv_deliverType.clear(); + } + break; + + case DEPENDENCIES: + //Iterator through the vector of dependencies + //and put them into a sequence + int t_depsSize = mv_deps.size(); + //Check if there is any dependencies, no need + //to bother doing anything + if(t_depsSize > 0) + { + Sequence< storage::ScriptDepFile > t_deps(t_depsSize); + Deps_vec::const_iterator it = mv_deps.begin(); + Bool_vec::const_iterator itDel = mv_depsDelivered.begin(); + Deps_vec::const_iterator it_end = mv_deps.end(); + Bool_vec::const_iterator itDel_end = mv_depsDelivered.end(); + for( int cnt = 0; (it!=it_end)&&(itDel!=itDel_end); ++it) + { + t_deps[cnt].fileName = *it; + t_deps[cnt].isDeliverable = *itDel; + cnt++; + ++itDel; + } + m_scriptImplInfo.scriptDependencies = t_deps; + //Clear the dependencies vector + mv_deps.clear(); + mv_depsDelivered.clear(); + } + break; + } +} + +//************************************************************************* +void ScriptMetadataImporter::characters( const ::rtl::OUString & aChars ) +throw (xml::sax::SAXException, RuntimeException) +{ + OSL_TRACE("ScriptMetadataImporter: characters()\n"); + + ::osl::Guard< ::osl::Mutex > aGuard( m_mutex ); + + switch (m_state) + { + case PARCEL: + break; + case SCRIPT: + break; + case LANGUAGENAME: + break; + case LOGICALNAME: + break; + case DEPENDENCIES: + break; + case DESCRIPTION: + //Put description into the struct + m_scriptImplInfo.scriptDescription = aChars; + break; + case DELIVERY: + break; + case DELIVERFILE: + break; + case DEPENDFILE: + break; + } +} + +//************************************************************************* +void ScriptMetadataImporter::ignorableWhitespace( + const ::rtl::OUString & aWhitespaces ) +throw (xml::sax::SAXException, RuntimeException) +{ + OSL_TRACE("ScriptMetadataImporter: ignorableWhiteSpace()\n"); +} + +//************************************************************************* +void ScriptMetadataImporter::processingInstruction( + const ::rtl::OUString & aTarget, const ::rtl::OUString & aData ) +throw (xml::sax::SAXException, RuntimeException) +{ + OSL_TRACE("ScriptMetadataImporter: processingInstruction()\n"); +} + +//************************************************************************* +void ScriptMetadataImporter::setDocumentLocator( + const Reference< xml::sax::XLocator >& xLocator ) +throw (xml::sax::SAXException, RuntimeException) +{ + OSL_TRACE("ScriptMetadataImporter: setDocumentLocator()\n"); +} + +//************************************************************************* +void ScriptMetadataImporter::setState(const ::rtl::OUString & tagName) +{ + //Set the state depending on the tag name of the current + //element the parser has arrived at + ::osl::Guard< ::osl::Mutex > aGuard( m_mutex ); + + if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("parcel") )) + { + //Parcel tag + m_state = PARCEL; + } + else if (tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("script") )) + { + //Script tag + m_state = SCRIPT; + } + else if (tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("logicalname") )) + { + //logicalname tag + m_state = LOGICALNAME; + } + else if (tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("languagename") )) + { + //languagename tag + m_state = LANGUAGENAME; + } + else if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dependencies") )) + { + //dependencies tag + m_state = DEPENDENCIES; + } + else if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("description") )) + { + //Description tag + m_state = DESCRIPTION; + } + else if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("delivery") )) + { + //delivery tag, nothing to be done here + m_state = DELIVERY; + } + else if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("deliverfile") )) + { + //deliverfile tag, nothing to be done here + m_state = DELIVERFILE; + } + else if(tagName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dependfile") )) + { + m_state = DEPENDFILE; + } + else + { + //If there is a tag we don't know about, throw a expcetion (woobler) :) + ::rtl::OUString str_sax = ::rtl::OUString::createFromAscii( "No Such Tag" ); + +#ifdef _DEBUG + + printf("ScriptMetadataImporter: No Such Tag: %s\n", ::rtl::OUStringToOString( + tagName, RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + throw xml::sax::SAXException( + str_sax, Reference< XInterface >(), Any() ); + } +} +} diff --git a/scripting/source/storage/ScriptMetadataImporter.hxx b/scripting/source/storage/ScriptMetadataImporter.hxx new file mode 100644 index 0000000000000..389274f7b4fdb --- /dev/null +++ b/scripting/source/storage/ScriptMetadataImporter.hxx @@ -0,0 +1,279 @@ +/************************************************************************* + * + * $RCSfile: ScriptMetadataImporter.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:50 $ + * + * 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 _SCRIPTING_STORAGE_SCRIPTMETADATAIMPORTER_HXX_ +#define _SCRIPTING_STORAGE_SCRIPTMETADATAIMPORTER_HXX_ + +#include <vector> + +#include <rtl/ustring.h> +#include <osl/mutex.hxx> +#include <cppuhelper/implbase1.hxx> // helper for component factory + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp> +#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> +#include <com/sun/star/io/XInputStream.hpp> + + +namespace scripting_impl +{ + +typedef ::std::vector< ::drafts::com::sun::star::script::framework::storage::ScriptImplInfo > Impls_vec; +typedef ::std::vector< ::rtl::OUString > Deps_vec; +typedef ::std::vector< bool > Bool_vec; + +/** + * Script Meta Data Importer + */ +class ScriptMetadataImporter + : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XExtendedDocumentHandler > +{ + // private member +private: + + /** Vector contains the ScriptImplInfo structs */ + Impls_vec ms_scriptInfos; + + /** @internal */ + Deps_vec mv_deps; + + /** @internal */ + Deps_vec mv_delivFile; + + /** @internal */ + Deps_vec mv_deliverType; + + /** @internal */ + Bool_vec mv_depsDelivered; + + /** @internal */ + osl::Mutex m_mutex; + + /** @internal */ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + + //Placeholder for the parcel URI + ::rtl::OUString ms_parcelURI; + + /** States for state machine during parsing */ + enum { PARCEL, SCRIPT, LANGUAGE_NAME, LOGICALNAME, LANGUAGENAME, + DEPENDENCIES, DESCRIPTION, DELIVERY, DELIVERFILE, DEPENDFILE } m_state; + + ::com::sun::star::uno::Sequence< ::rtl::OUString > ms_dependFiles; + + //Build up the struct during parsing the meta data + ::drafts::com::sun::star::script::framework::storage::ScriptImplInfo m_scriptImplInfo; + + //Helper function to set the state + void setState(const ::rtl::OUString & tagName); + + // public interface +public: + + /** + * This function will begin the parser and parse the meta data + * + * @param xInput The XInputStream for the parser which contains the XML + * @param parcelURI The parcel's URI in the document or the application + * + * @see ::com::sun::star::io::XInputStream + */ + Impls_vec parseMetaData( + ::com::sun::star::uno::Reference< + ::com::sun::star::io::XInputStream > + const & xInput, const ::rtl::OUString & parcelURI ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::io::IOException, + ::com::sun::star::uno::RuntimeException); + + explicit ScriptMetadataImporter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& ); + virtual ~ScriptMetadataImporter() SAL_THROW( () ); + + // XExtendedDocumentHandler impl + /** + * Function to handle the start of CDATA in XML + * + * @see com::sun::star::xml::sax::XExtendedDocumentHandler + */ + virtual void SAL_CALL startCDATA() + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle the end of CDATA in XML + * + * @see com::sun::star::xml::sax::XExtendedDocumentHandler + */ + virtual void SAL_CALL endCDATA() + throw ( ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle comments in XML + * + * @see com::sun::star::xml::sax::XExtendedDocumentHandler + */ + virtual void SAL_CALL comment( const ::rtl::OUString & sComment ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle line breaks in XML + * + * @see com::sun::star::xml::sax::XExtendedDocumentHandler + */ + virtual void SAL_CALL allowLineBreak() + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle unknowns in XML + * + * @see com::sun::star::xml::sax::XExtendedDocumentHandler + */ + virtual void SAL_CALL unknown( const ::rtl::OUString & sString ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle the start of XML document + * + * @see com::sun::star::xml::sax::XExtendedDocumentHandler + */ + // XDocumentHandler impl + virtual void SAL_CALL startDocument() + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle the end of the XML document + * + * @see com::sun::star::xml::sax::XDocumentHandler + */ + virtual void SAL_CALL endDocument() + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle the start of an element + * + * @see com::sun::star::xml::sax::XDocumentHandler + */ + virtual void SAL_CALL startElement( + const ::rtl::OUString& aName, + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttribs ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle the end of an element + * + * @see com::sun::star::xml::sax::XDocumentHandler + */ + virtual void SAL_CALL endElement( const ::rtl::OUString & aName ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle characters in elements + * + * @see com::sun::star::xml::sax::XDocumentHandler + */ + virtual void SAL_CALL characters( const ::rtl::OUString & aChars ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle whitespace + * + * @see com::sun::star::xml::sax::XDocumentHandler + */ + virtual void SAL_CALL ignorableWhitespace( + const ::rtl::OUString & aWhitespaces ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to handle XML processing instructions + * + * @see com::sun::star::xml::sax::XDocumentHandler + */ + virtual void SAL_CALL processingInstruction( + const ::rtl::OUString & aTarget, const ::rtl::OUString & aData ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); + + /** + * Function to set the document locator + * + * @see com::sun::star::xml::sax::XDocumentHandler + */ + virtual void SAL_CALL setDocumentLocator( + const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XLocator >& xLocator ) + throw ( ::com::sun::star::xml::sax::SAXException, + ::com::sun::star::uno::RuntimeException ); +} +; // class ScriptMetadataImporter + +} + +#endif diff --git a/scripting/source/storage/ScriptStorage.cxx b/scripting/source/storage/ScriptStorage.cxx new file mode 100644 index 0000000000000..4df664672ba04 --- /dev/null +++ b/scripting/source/storage/ScriptStorage.cxx @@ -0,0 +1,691 @@ +/************************************************************************* + * + * $RCSfile: ScriptStorage.cxx,v $ + * + * $Revision: 1.1 $ + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:51 $ + * + * 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 <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/ucb/CommandAbortedException.hpp> +#include <com/sun/star/io/XActiveDataSource.hpp> +#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> +#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp> + +#include <util/util.hxx> + +#include "ScriptInfo.hxx" +#include "ScriptStorage.hxx" +#include "ScriptMetadataImporter.hxx" +#include "ScriptElement.hxx" + +using namespace ::rtl; +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::drafts::com::sun::star::script::framework; + +namespace scripting_impl +{ + +const sal_Char* const SERVICE_NAME="drafts.com.sun.star.script.framework.storage.ScriptStorage"; +const sal_Char* const IMPL_NAME="drafts.com.sun.star.script.framework.storage.ScriptStorage"; + +static OUString ss_implName = OUString::createFromAscii(IMPL_NAME); +static OUString ss_serviceName = OUString::createFromAscii(SERVICE_NAME); +static Sequence< OUString > ss_serviceNames = Sequence< OUString >( &ss_serviceName, 1 ); + +extern ::rtl_StandardModuleCount s_moduleCount; + +//************************************************************************* +ScriptStorage::ScriptStorage( const Reference< + XComponentContext > & xContext ) + : m_xContext( xContext ) +{ + OSL_TRACE( "< ScriptStorage ctor called >\n" ); + s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt ); +} + +//************************************************************************* +ScriptStorage::~ScriptStorage() SAL_THROW( () ) +{ + OSL_TRACE( "< ScriptStorage dtor called >\n" ); + s_moduleCount.modCnt.release( &s_moduleCount.modCnt ); +} + +//************************************************************************* +void ScriptStorage::initialize( + const Sequence <Any> & args ) +throw (Exception) +{ + OSL_TRACE("Entering ScriptStorage::initialize\n"); + // work in progress. + // what might we expect to get? + // at the moment only consider 3 possibilities + // 1. an XInputStream - [deprecated!!] + // 2. an XSimpleFileAccess + // 3. an OUString containing a URI + + ::osl::Guard< osl::Mutex > aGuard( m_mutex ); + + Reference< io::XInputStream > xInput; + ::rtl::OUString xStringUri; + + // need to replace this with a proper call to getService... + ScriptMetadataImporter* SMI = new ScriptMetadataImporter(m_xContext); + Reference<xml::sax::XExtendedDocumentHandler> xSMI(SMI); + if (args.getLength()) + { + if((sal_False != (args[0] >>= m_xSimpleFileAccess)) && + (sal_False != (args[1]>>=m_scriptStorageID))) + { + if(args.getLength()>2 && (sal_False == (args[2] >>= xStringUri))) + { + xStringUri=::rtl::OUString::createFromAscii(""); + } + } + /* deprecated? + else if((sal_False != (args[1]>>=m_scriptStorageID)) && + (sal_False != (args[0] >>= xStringUri))) + { + //probably need some check for type of URI???? + validateXRef(m_xContext, "ScriptStorage::initialize: No context available"); + Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); + validateXRef(xMgr, "ScriptStorage::initialize: No service manager available"); + Reference< XInterface > xx = xMgr->createInstanceWithContext(OUString::createFromAscii("com.sun.star.ucb.SimpleFileAccess"), m_xContext ); + validateXRef(xMgr, "ScriptStorage::initialize: cannot get XSimpleFileAccess"); + m_xSimpleFileAccess.set(xx, UNO_QUERY_THROW); + } */ + else + { + OSL_TRACE("ScriptStorage::initialize: got some unknown type of arg\n"); + throw lang::IllegalArgumentException( + OUSTR("unexpected argument type provided!"), + static_cast< OWeakObject * >( this ), 0 ); + } + } + else //no args provided + { + OSL_TRACE("ScriptStorage::initialize: got no args\n"); + throw lang::IllegalArgumentException( + OUSTR("No arguments provided!"), + static_cast< OWeakObject * >( this ), 0 ); + } +#ifdef _DEBUG + fprintf(stderr,"uri: %s\n",::rtl::OUStringToOString(xStringUri,RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + try + { + xStringUri=xStringUri.concat(::rtl::OUString::createFromAscii("/Scripts")); + + // get the list of files/folders under the Scripts directory + Sequence< ::rtl::OUString > results=m_xSimpleFileAccess->getFolderContents(xStringUri,true); + for(int i=0;i<results.getLength();i++) + { +#ifdef _DEBUG + fprintf(stderr,"contains: %s\n",::rtl::OUStringToOString(results[i],RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + if(m_xSimpleFileAccess->isFolder(results[i])) + { + //get the list of files/folders for each folder + // under Scripts/ + Sequence< ::rtl::OUString > subresults=m_xSimpleFileAccess->getFolderContents(results[i],true); + for(int j=0;j<subresults.getLength();j++) + { +#ifdef _DEBUG + fprintf(stderr,"contains: %s\n",::rtl::OUStringToOString(subresults[j],RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + OUString parcelFile=subresults[j].concat(::rtl::OUString::createFromAscii("/parcel.xml")); + //if the subfolder Scripts/*/ has a file + //called parcel.xml + if(m_xSimpleFileAccess->isFolder(subresults[j]) && m_xSimpleFileAccess->exists(parcelFile) && !m_xSimpleFileAccess->isFolder(parcelFile)) + { +#ifdef _DEBUG + fprintf(stderr,"parcel file: %s\n",::rtl::OUStringToOString(parcelFile,RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + xInput = m_xSimpleFileAccess->openFileRead(parcelFile); + if (xInput.is()) + { + // should I aquire the stream?? + OSL_TRACE("Parse the metadata \n"); +#ifndef TEST_ONLY + + Impls_vec vSII = SMI->parseMetaData( xInput, subresults[j] ); + xInput->closeInput(); +#else + + Impls_vec vSII; + storage::ScriptImplInfo m,m2,m3; + m.scriptLanguage=rtl::OUString::createFromAscii("java"); + ; + m.functionName=rtl::OUString::createFromAscii("com.sun.star.foo"); + ; + m.logicalName=rtl::OUString::createFromAscii("my.foo"); + ; + m2.scriptLanguage=rtl::OUString::createFromAscii("java"); + ; + m2.functionName=rtl::OUString::createFromAscii("com.sun.star.foo2"); + ; + m2.logicalName=rtl::OUString::createFromAscii("my.foo"); + ; + m3.scriptLanguage=rtl::OUString::createFromAscii("java"); + ; + m3.functionName=rtl::OUString::createFromAscii("com.sun.star.bar"); + ; + m3.logicalName=rtl::OUString::createFromAscii("my.bar"); + ; + vSII.push_back(m); + vSII.push_back(m2); + vSII.push_back(m3); + +#endif + // should I now release the stream?? + updateMaps(vSII); + } + } + } + } + } + } + catch(xml::sax::SAXException saxe) + { + //From ScriptMetadata Importer + OSL_TRACE("caught com::sun::star::xml::sax::SAXException in ScriptStorage::initalize"); + throw RuntimeException(OUSTR("ScriptStorage::initalize SAXException: ")+saxe.Message, + Reference<XInterface> ()); + } + catch(io::IOException ioe) + { + //From ScriptMetadata Importer + OSL_TRACE("caught com::sun::star::io::IOException in ScriptStorage::initalize"); + throw RuntimeException(OUSTR("ScriptStorage::initalize IOException: ")+ioe.Message, + Reference<XInterface> ()); + + } + catch(ucb::CommandAbortedException cae) + { + OSL_TRACE("caught com::sun::star::ucb::CommandAbortedException in ScriptStorage::initialize"); + throw RuntimeException(OUSTR("ScriptStorage::initalize CommandAbortedException: ")+cae.Message, + Reference<XInterface> ()); + } + catch(Exception ue) + { + OSL_TRACE("caught com::sun::star::uno::Exception in ScriptStorage::initialize"); + throw RuntimeException(OUSTR("ScriptStorage::initalize Exception: ")+ue.Message, + Reference<XInterface> ()); + } + OSL_TRACE("Parsed the XML\n"); +} + +//************************************************************************* +// private method for updating hashmaps +void ScriptStorage::updateMaps(Impls_vec vScriptII) +{ + ::osl::Guard< osl::Mutex > aGuard( m_mutex ); + + Impls_vec::iterator it = vScriptII.begin(); + Impls_vec::iterator it_end = vScriptII.end(); + // step through the vector of ScripImplInfos returned from parse + for(sal_Int32 count=0;it!=it_end;++it) + { + //find the Impls_vec for this logical name + ScriptInfo_hash::iterator h_it = mh_implementations.find(it->logicalName); + + if(h_it==mh_implementations.end()) + { + //if it's null, need to create a new Impls_vec +#ifdef _DEBUG + fprintf(stderr,"updateMaps: new logical name: %s\n",rtl::OUStringToOString(it->logicalName,RTL_TEXTENCODING_ASCII_US).pData->buffer); + fprintf(stderr," language name: %s\n",rtl::OUStringToOString(it->functionName,RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + Impls_vec v; + v.push_back(*it); + mh_implementations[it->logicalName]=v; + } + else + { +#ifdef _DEBUG + fprintf(stderr,"updateMaps: existing logical name: %s\n",rtl::OUStringToOString(it->logicalName,RTL_TEXTENCODING_ASCII_US).pData->buffer); + fprintf(stderr," language name: %s\n",rtl::OUStringToOString(it->functionName,RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + h_it->second.push_back(*it); + } + } +} + +//************************************************************************* +// Not part of the interface yet, ie. not in the idl, and it should be!! +void ScriptStorage::save() +throw (RuntimeException) +{ + ::osl::Guard< osl::Mutex > aGuard( m_mutex ); + Reference< io::XActiveDataSource > xSource; + Reference<io::XOutputStream> xOS; + // xScriptInvocation = Reference<XScriptInvocation>(xx, UNO_QUERY_THROW); + Reference<xml::sax::XExtendedDocumentHandler> xHandler; + + OUString parcel_suffix = OUString::createFromAscii("/parcel.xml"); + + validateXRef(m_xContext, "ScriptStorage::save: No context available"); + Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); + validateXRef(xMgr, "ScriptStorage::save: No service manager available"); + + OUString ou_parcel = OUString( RTL_CONSTASCII_USTRINGPARAM("parcel")); + + ScriptInfo_hash::iterator it = mh_implementations.begin(); + ScriptInfo_hash::iterator it_end = mh_implementations.end(); + for(sal_Int32 count=0;it!=it_end;++it) + { + ::rtl::OUString logName=it->first; + Impls_vec::iterator it_impls_end =it->second.end(); + for( Impls_vec::iterator it_impls =it->second.begin(); it_impls!=it_impls_end;++it_impls) + { + ScriptOutput_hash::iterator it_parcels = mh_parcels.find(it_impls->parcelURI); + if(it_parcels==mh_parcels.end()) + { + //create new outputstream + OUString parcel_xml_path = it_impls->parcelURI.concat(parcel_suffix); + m_xSimpleFileAccess->kill(parcel_xml_path); + xOS=m_xSimpleFileAccess->openFileWrite(parcel_xml_path); +#ifdef _DEBUG + + fprintf(stderr,"saving: %s\n",rtl::OUStringToOString(it_impls->parcelURI.concat(OUString::createFromAscii("/parcel.xml")),RTL_TEXTENCODING_ASCII_US).pData->buffer); +#endif + + Reference< XInterface > xx = xMgr->createInstanceWithContext(OUString::createFromAscii("com.sun.star.xml.sax.Writer"), m_xContext ); + validateXRef(xMgr, "ScriptStorage::save: cannot get sax.Writer"); + xHandler = Reference<xml::sax::XExtendedDocumentHandler>(xx, UNO_QUERY_THROW); + xSource = Reference< io::XActiveDataSource >( xHandler, UNO_QUERY_THROW ); + xSource->setOutputStream( xOS ); + + writeMetadataHeader(xHandler); + + xHandler->startElement( ou_parcel, Reference< xml::sax::XAttributeList >() ); + + mh_parcels[it_impls->parcelURI]=xHandler; + } + else + { + xHandler=it_parcels->second; + } + + ScriptElement* pSE = new ScriptElement(*it_impls); + // this is to get pSE released correctly + Reference <xml::sax::XAttributeList> xal(pSE); + pSE->dump(xHandler); + } + } + + ScriptOutput_hash::const_iterator out_it_end = mh_parcels.end(); + + for(ScriptOutput_hash::const_iterator out_it = mh_parcels.begin(); + out_it != out_it_end; + ++out_it) + { + out_it->second->ignorableWhitespace( ::rtl::OUString() ); + out_it->second->endElement(ou_parcel); + out_it->second->endDocument(); + xSource.set( out_it->second, UNO_QUERY ); + Reference<io::XOutputStream> xOS = xSource->getOutputStream(); + xOS->closeOutput(); + + } +} + +//************************************************************************* +void ScriptStorage::writeMetadataHeader(Reference <xml::sax::XExtendedDocumentHandler> & xHandler) +{ + xHandler->startDocument(); + OUString aDocTypeStr( RTL_CONSTASCII_USTRINGPARAM( + "<!DOCTYPE dlg:window PUBLIC \"-//OpenOffice.org//DTD OfficeDocument 1.0//EN\"" + " \"parcel.dtd\">" ) ); + xHandler->unknown( aDocTypeStr ); + xHandler->ignorableWhitespace( OUString() ); +} + +//************************************************************************* +//Returns a sequence of XScriptInfo interfaces +//to give access to info on scripts +//Eh, method name is not initiutive, maybe it +//should be getScriptInfoInterfaces? (Need to change IDL) +Sequence < Reference< storage::XScriptInfo > > +ScriptStorage::getScriptInfoService(const OUString & name) +throw (RuntimeException) +{ + ::osl::Guard< osl::Mutex > aGuard( m_mutex ); + + //Get iterator over the hash_map + ScriptInfo_hash::const_iterator h_iter = mh_implementations.find(name); + Impls_vec::const_iterator it = + h_iter->second.begin(), end_iter = h_iter->second.end(); + + Sequence< Reference< storage::XScriptInfo > > sr_xScriptInfo( + h_iter->second.size() ); + + //Get array of XScriptInfos + Reference< storage::XScriptInfo >* pScriptInfo = sr_xScriptInfo.getArray(); + + validateXRef(m_xContext, "ScriptStorage::getScriptInfoService: No context available"); + Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); + validateXRef(xMgr, "ScriptStorage::getScriptInfoService: No service manager available"); + + for(sal_Int32 count = 0; it != end_iter; ++it) + { +#ifdef _DEBUG + fprintf(stderr,"in for cycle, count is %d\n", count); +#endif + + Any a( makeAny( *it ) ); + Reference< XInterface > xx = xMgr->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.storage.ScriptInfo"), Sequence< Any >( &a, 1 ), m_xContext ); + validateXRef(xMgr, "ScriptStorage::getScriptInfoService: cannot get drafts.com.sun.star.script.framework.storage.ScriptInfo"); + pScriptInfo[ count ] = Reference< storage::XScriptInfo >(xx, UNO_QUERY_THROW ); + sr_xScriptInfo[ count ] = Reference< storage::XScriptInfo >(xx, UNO_QUERY_THROW ); + count++; + } + + return sr_xScriptInfo; +} + +//XNamingAccess +/** +Reference<XInterface> ScriptStorage::getView( + const ::rtl::OUString& viewName ) + throw (storage::NoSuchView, + RuntimeException) +{ +} +*/ + +//************************************************************************* +Sequence< Reference< scripturi::XScriptURI > > +ScriptStorage::getImplementations( const Reference< + scripturi::XScriptURI >& queryURI ) +throw (lang::IllegalArgumentException, + RuntimeException) +{ + ::osl::Guard< osl::Mutex > aGuard( m_mutex ); + Sequence< Reference< scripturi::XScriptURI > > results; + try + { + //find the implementations for the given logical name + ScriptInfo_hash::iterator h_it = mh_implementations.find(queryURI->getLogicalName()); + if(h_it!=mh_implementations.end()) + { + Impls_vec::iterator it_impls =h_it->second.begin(); + Impls_vec::iterator it_impls_end =h_it->second.end(); + for(sal_Int32 count=0;it_impls!=it_impls_end;++it_impls) + { + //should we do any resolution here????? + // or leave it completely up to the resolver? + //construct new Reference<scripturi::ScriptURI> + Sequence<Any> aArgs(2); + aArgs[0]<<=*it_impls; + aArgs[1]<<=m_scriptStorageID; + + validateXRef(m_xContext, "ScriptStorage::getImplementations: No context available"); + Reference< lang::XMultiComponentFactory > xMgr = m_xContext->getServiceManager(); + validateXRef(xMgr, "ScriptStorage::getImplementations: No service manager available"); + Reference< XInterface > xx = xMgr->createInstanceWithArgumentsAndContext(OUString::createFromAscii("drafts.com.sun.star.script.framework.scripturi.ScriptURI"), aArgs, m_xContext ); + validateXRef(xMgr, "ScriptStorage::getImplementations: cannot get drafts.com.sun.star.script.framework.storage.ScriptInfo"); + Reference<scripturi::XScriptURI> uri(xx,UNO_QUERY_THROW); + //add to the sequence + //assuming that we'll usually only get 1 elt returned + //first realloc if we get 2 elts... + if(count>=results.getLength()) + { + results.realloc(results.getLength()+1); + } + results[count++]=uri; + } + } + } + catch(Exception e) + { + throw RuntimeException(OUSTR("ScriptStorage::getImplementations Exception: ")+e.Message, + Reference<XInterface> ()); + } + return results; +} + +//************************************************************************* +OUString SAL_CALL ScriptStorage::prepareForInvocation( const OUString& parcelURI ) throw (RuntimeException) +{ + try + { + validateXRef(m_xSimpleFileAccess, + "ScriptStorage::prepareForInvocation(): no SimpleFileAccess"); + + if ((m_xSimpleFileAccess->exists(parcelURI) != sal_True) || + (m_xSimpleFileAccess->isFolder(parcelURI) != sal_True)) + { + throw RuntimeException( + OUSTR("ScriptStorage::prepareForInvocation(): parcel URI is not valid"), + Reference<XInterface> ()); + } + + OUString dest = OUString::createFromAscii("file:///tmp"); + sal_Int32 idx = parcelURI.lastIndexOf('/'); + sal_Int32 len = parcelURI.getLength(); + if (idx == (len-1)) + { + // deal with the trailing separator + idx = parcelURI.lastIndexOf('/', len-2); + OUString parcel_base = parcelURI.copy(idx, len-idx-1); + dest = dest.concat(parcel_base); + } + else + { + dest = dest.concat(parcelURI.copy(idx)); + } + dest = dest.concat(OUString::valueOf((sal_Int32)m_scriptStorageID)); + + fprintf(stderr,"dest is: %s\n",rtl::OUStringToOString(dest, RTL_TEXTENCODING_ASCII_US).pData->buffer); + + copyFolder(parcelURI, dest); + + return dest; + } + catch(RuntimeException &e) + { + OUString temp = OUSTR( + "ScriptStorage::prepareForInvocation RuntimeException: "); + throw RuntimeException(temp.concat(e.Message), + Reference<XInterface> ()); + } +#ifdef _DEBUG + catch ( ... ) + { + throw RuntimeException(OUSTR( + "ScriptStorage::prepareForInvocation UnknownException: "), + Reference<XInterface> ()); + } +#endif +} + +//************************************************************************* +/** + * 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. + */ +void ScriptStorage::copyFolder(const OUString &src, const OUString &dest) throw (RuntimeException) +{ + try + { + OUString new_dest; + sal_Int32 idx; + + /* A mutex guard is needed to not write later into + * a folder that has been deleted by an incoming thread. + * Note that this calls into the SimpleFileAccess service + * with a locked mutex, but the implementation of this method + * will probably change soon. + */ + ::osl::Guard< osl::Mutex > aGuard( m_mutex ); + + if (m_xSimpleFileAccess->isFolder(dest) == sal_True) + { + m_xSimpleFileAccess->kill(dest); + } + m_xSimpleFileAccess->createFolder(dest); + + Sequence <OUString> seq = m_xSimpleFileAccess->getFolderContents( + src, sal_True); + sal_Int32 len = seq.getLength(); + for(int i = 0; i < len; i++) + { + new_dest = dest; + idx = seq[i].lastIndexOf('/'); + new_dest = new_dest.concat(seq[i].copy(idx)); + + if (m_xSimpleFileAccess->isFolder(seq[i]) == sal_True) + { + copyFolder(seq[i], new_dest); + } + else + { + m_xSimpleFileAccess->copy(seq[i], new_dest); + } + } + } + catch(ucb::CommandAbortedException &e) + { + OUString temp = OUSTR( + "ScriptStorage::copyFolder CommandAbortedException: "); + throw RuntimeException(temp.concat(e.Message), + Reference<XInterface> ()); + } + catch(RuntimeException &e) + { + OUString temp = OUSTR("ScriptStorage::copyFolder RuntimeException: "); + throw RuntimeException(temp.concat(e.Message), + Reference<XInterface> ()); + } + catch(Exception &e) + { + OUString temp = OUSTR("ScriptStorage::copyFolder Exception: "); + throw RuntimeException(temp.concat(e.Message), + Reference<XInterface> ()); + } +#ifdef _DEBUG + catch ( ... ) + { + throw RuntimeException(OUSTR( + "ScriptStorage::copyFolder UnknownException: "), + Reference<XInterface> ()); + } +#endif +} + + +//************************************************************************* +OUString SAL_CALL ScriptStorage::getImplementationName( ) +throw(RuntimeException) +{ + return ss_implName; +} + +//************************************************************************* +sal_Bool SAL_CALL ScriptStorage::supportsService( const OUString& serviceName ) +throw(RuntimeException) +{ + OUString const * pNames = ss_serviceNames.getConstArray(); + for ( sal_Int32 nPos = ss_serviceNames.getLength(); nPos--; ) + { + if (serviceName.equals( pNames[ nPos ] )) + { + return sal_True; + } + } + return sal_False; +} + +//************************************************************************* +Sequence<OUString> SAL_CALL ScriptStorage::getSupportedServiceNames( ) +throw(RuntimeException) +{ + return ss_serviceNames; +} +//************************************************************************* +Reference<XInterface> SAL_CALL ss_create( + const Reference< XComponentContext > & xCompC ) +{ + return ( cppu::OWeakObject * ) new ScriptStorage( xCompC ); +} + +//************************************************************************* +Sequence<OUString> ss_getSupportedServiceNames( ) +SAL_THROW( () ) +{ + return ss_serviceNames; +} + +//************************************************************************* +OUString ss_getImplementationName( ) +SAL_THROW( () ) +{ + return ss_implName; +} +} diff --git a/scripting/source/storage/ScriptStorage.hxx b/scripting/source/storage/ScriptStorage.hxx new file mode 100644 index 0000000000000..d1b50f83a52b8 --- /dev/null +++ b/scripting/source/storage/ScriptStorage.hxx @@ -0,0 +1,246 @@ +/************************************************************************* + * + * $RCSfile: ScriptStorage.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33: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): _______________________________________ + * + * + ************************************************************************/ +#ifndef __SCRIPTING_STORAGE_SCRIPTSTORAGE_HXX_ +#define __SCRIPTING_STORAGE_SCRIPTSTORAGE_HXX_ + +#include <vector> +#include <hash_map> + +#include <osl/mutex.hxx> +#include <cppuhelper/implbase6.hxx> // helper for component factory + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XInitialization.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> +#include <drafts/com/sun/star/script/framework/storage/ScriptImplInfo.hpp> +#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> +#include <drafts/com/sun/star/script/framework/storage/XParcelInvocationPrep.hpp> + +namespace scripting_impl +{ + +//Typedefs +//============================================================================= +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, +::com::sun::star::uno::Reference< +::com::sun::star::xml::sax::XExtendedDocumentHandler >, +::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > +ScriptOutput_hash; +//============================================================================= + +class ScriptStorage + : public ::cppu::WeakImplHelper6< + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::lang::XInitialization, + ::drafts::com::sun::star::script::framework::storage::XScriptImplAccess, + ::drafts::com::sun::star::script::framework::storage::XScriptStorageExport, + ::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 > & ); + void copyFolder(const ::rtl::OUString & src, const ::rtl::OUString & dest) throw (::com::sun::star::uno::RuntimeException); + +public: + //Constructors and Destructors + //========================================================================= + explicit ScriptStorage( const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& ); + //------------------------------------------------------------------------- + virtual ~ScriptStorage() SAL_THROW( () ); + //========================================================================= + + // XServiceInfo impl + //========================================================================= + 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); + //------------------------------------------------------------------------- + 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); + //========================================================================= + + // XScriptAccessManager impl + //========================================================================= + /** + * Gets the sequence of XScriptInfo interfaces for the corresponding + * logical name that is passed in + * + * @param name + * The logical name of the script + * + * @return Sequence< XScriptInfo > + * 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); + //========================================================================= + + //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); + //========================================================================= + + + //XNamingAccess + //========================================================================= + /** + * Get a certain type of view of the naming heirarchy + * + * @param viewName + * The view name + * + * @return XInterface + * 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, + ::com::sun::star::uno::RuntimeException); + //========================================================================= + + // XScriptStorageExport + void SAL_CALL save() + throw (::com::sun::star::uno::RuntimeException); + //========================================================================= + + //XParcelInvocationPrep + //========================================================================= + /** + * Prepare a pracel for invocation + * @param parcelURI + * URI to the parcel to be prepared + * + * @return ::rtl::OUString + * URI to the prepared parcel + */ + + ::rtl::OUString SAL_CALL prepareForInvocation( const ::rtl::OUString& parcelURI ) + throw (::com::sun::star::uno::RuntimeException); + //========================================================================= +} +; // class ScriptingStorage + +} + +#endif diff --git a/scripting/source/storage/ScriptStorageManager.cxx b/scripting/source/storage/ScriptStorageManager.cxx new file mode 100644 index 0000000000000..d79dc6046ee88 --- /dev/null +++ b/scripting/source/storage/ScriptStorageManager.cxx @@ -0,0 +1,354 @@ +/************************************************************************* + * + * $RCSfile: ScriptStorageManager.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33: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 <sal/config.h> +#include <util/util.hxx> + +#include <com/sun/star/ucb/XSimpleFileAccess.hpp> +#include <com/sun/star/util/XMacroExpander.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XMultiComponentFactory.hpp> + +#include "ScriptStorageManager.hxx" +#include <util/util.hxx> + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +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 Sequence< OUString > s_serviceNames = Sequence< OUString >( &s_serviceName, 1 ); + +::rtl_StandardModuleCount s_moduleCount = MODULE_COUNT_INIT; + +//************************************************************************* +// ScriptStorageManager Constructor +ScriptStorageManager::ScriptStorageManager(const Reference< XComponentContext > & xContext) + : m_xContext( xContext ) +{ + OSL_TRACE( "< ScriptStorageManager ctor called >\n" ); + s_moduleCount.modCnt.acquire( &s_moduleCount.modCnt ); + 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")); + Reference<util::XMacroExpander> xME; + OSL_ASSERT(sal_False!=(aAny>>=xME)); + OSL_ASSERT(xME.is()); + 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); + + // 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"))); +#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); +#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"); + // and place it in the hash_map. Increment the counter + m_ScriptStorageHash[count++]=xx; +#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); +#endif + + } + catch (Exception &e) + { + throw RuntimeException(OUSTR("ScriptStorageManager::ScriptStorageManager: ") + e.Message, Reference< XInterface >()); + } +} + +//************************************************************************* +// ScriptStorageManager Destructor +ScriptStorageManager::~ScriptStorageManager() +{ + OSL_TRACE( "< ScriptStorageManager dtor called >\n" ); + s_moduleCount.modCnt.release( &s_moduleCount.modCnt ); +} + +//************************************************************************* +// 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) +{ + 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 + + fprintf(stderr,"\tcreated with ID=%d\n",count-1); +#endif + + return count-1; +} + +//************************************************************************* +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 + + fprintf(stderr,"\tcreated with ID=%d\n",count-1); +#endif + + return count-1; +} + +//************************************************************************* +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; +} + +//************************************************************************* +OUString SAL_CALL ScriptStorageManager::getImplementationName( ) +throw(RuntimeException) +{ + return s_implName; +} + +//************************************************************************* +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 ] )) + { + return sal_True; + } + } + return sal_False; +} + +//************************************************************************* +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) +{ + OSL_TRACE("ScriptStorageManager::disposing started"); +} + +//************************************************************************* +static Reference<XInterface> SAL_CALL ssm_create( + const Reference< XComponentContext > & xCompC ) +{ + return (cppu::OWeakObject *)new ScriptStorageManager( xCompC ); +} + +//************************************************************************* +static Sequence<OUString> ssm_getSupportedServiceNames( ) +SAL_THROW( () ) +{ + return s_serviceNames; +} + +//************************************************************************* +static OUString ssm_getImplementationName( ) +SAL_THROW( () ) +{ + return s_implName; +} +//************************************************************************* +Reference<XInterface> SAL_CALL ss_create( const Reference< XComponentContext > & xCompC ); +//************************************************************************* +Sequence<OUString> ss_getSupportedServiceNames( ) SAL_THROW( () ); +//************************************************************************* +OUString ss_getImplementationName( ) SAL_THROW( () ); +//************************************************************************* +Reference<XInterface> SAL_CALL si_create( const Reference< XComponentContext > & xCompC ); +//************************************************************************* +Sequence<OUString> si_getSupportedServiceNames( ) SAL_THROW( () ); +//************************************************************************* +OUString si_getImplementationName( ) SAL_THROW( () ); +//************************************************************************* +static struct cppu::ImplementationEntry s_entries [] = + { + { + ssm_create, ssm_getImplementationName, + ssm_getSupportedServiceNames, cppu::createSingleComponentFactory, + &s_moduleCount.modCnt, 0 + }, + { + ss_create, ss_getImplementationName, + ss_getSupportedServiceNames, cppu::createSingleComponentFactory, + &s_moduleCount.modCnt, 0 + }, + { + si_create, si_getImplementationName, + si_getSupportedServiceNames, cppu::createSingleComponentFactory, + &s_moduleCount.modCnt, 0 + }, + { 0, 0, 0, 0, 0, 0 } + }; +} // Namespace + +//################################################################################################## +//#### EXPORTED #################################################################################### +//################################################################################################## + +/** + * Gives the environment this component belongs to. + */ +extern "C" +{ + void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv) + { + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; + } + + /** + * This function creates an implementation section in the registry and another subkey + * + * for each supported service. + * @param pServiceManager the service manager + * @param pRegistryKey the registry key + */ + sal_Bool SAL_CALL component_writeInfo(lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey) + { + return ::cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, ::scripting_impl::s_entries); + } + + /** + * This function is called to get service factories for an implementation. + * + * @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 + * @return a component factory + */ + 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); + } +} diff --git a/scripting/source/storage/ScriptStorageManager.hxx b/scripting/source/storage/ScriptStorageManager.hxx new file mode 100644 index 0000000000000..928ad025c8c46 --- /dev/null +++ b/scripting/source/storage/ScriptStorageManager.hxx @@ -0,0 +1,155 @@ +/************************************************************************* + * + * $RCSfile: ScriptStorageManager.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:54 $ + * + * 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_STORAGE_SCRIPTSTORAGEMANAGER_HXX_ +#define _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_STORAGE_SCRIPTSTORAGEMANAGER_HXX_ + +#include <osl/mutex.hxx> +#include <hash_map> + +#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> + +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; + +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(); + + + // 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); + //====================================================================== + + //XScriptStorageManager + //====================================================================== + /** + create a ScriptStorage using the XSimpleFileAccess passed as an + argument, and return a ID for getting the associated ScriptStorage + + @params xSFA + an implementation of XSimpleFileAccess that knows its own base URL + and can thus take URLs relative to that base. + + @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); + //---------------------------------------------------------------------- + /** + create a ScriptStorage using the XSimpleFileAccess, and a string URL + and return a ID for getting the associated ScriptStorage + + @params xSFA + a standard implementation of XSimpleFileAccess + + @params stringURI + a string URI to the head of the script storage + + @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); + //---------------------------------------------------------------------- + /** + get a ScriptStorage component using its scriptStorageID + + @params scriptStorageID + the usigned short returned by one of the methods above. ID=0 is + reserved for the application/share scripts, and ID=1 is reserved + for the application/user scripts + + @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); + //====================================================================== + + + //XEventListener + //====================================================================== + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); +}; +} // scripting_impl + +#endif //_COM_SUN_STAR_SCRIPTING_STORAGE_SCRIPTSTORAGEMANAGER_HXX_ diff --git a/scripting/source/storage/XMLElement.cxx b/scripting/source/storage/XMLElement.cxx new file mode 100644 index 0000000000000..72e4025913d51 --- /dev/null +++ b/scripting/source/storage/XMLElement.cxx @@ -0,0 +1,196 @@ +/************************************************************************* + * + * $RCSfile: XMLElement.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:54 $ + * + * 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 "XMLElement.hxx" +#include <osl/diagnose.h> + +using namespace rtl; +using namespace com::sun::star; +using namespace com::sun::star::uno; + +namespace scripting_impl +{ + +//************************************************************************* +void XMLElement::addAttribute( OUString const & rAttrName, OUString const & rValue ) +SAL_THROW( () ) +{ + OSL_TRACE("XMLElement::addAttribute\n"); + + _attrNames.push_back( rAttrName ); + _attrValues.push_back( rValue ); +} + +//************************************************************************* +void XMLElement::addSubElement( Reference< xml::sax::XAttributeList > const & xElem ) +SAL_THROW( () ) +{ + OSL_TRACE("XMLElement::addSubElement\n"); + + _subElems.push_back( xElem ); +} + +//************************************************************************* +Reference< xml::sax::XAttributeList > XMLElement::getSubElement( sal_Int32 nIndex ) +SAL_THROW( () ) +{ + OSL_TRACE("XMLElement::getSubElement\n"); + + return _subElems[ (size_t)nIndex ]; +} + +//************************************************************************* +void XMLElement::dumpSubElements( Reference< xml::sax::XExtendedDocumentHandler > const & xOut ) +{ + OSL_TRACE("+++++ XMLElement::dumpSubElement\n"); + + for ( size_t nPos = 0; nPos < _subElems.size(); ++nPos ) + { + XMLElement * pElem = static_cast< XMLElement * >( _subElems[ nPos ].get() ); + pElem->dump( xOut ); + } +} + +//************************************************************************* +void XMLElement::dump( Reference< xml::sax::XExtendedDocumentHandler > const & xOut ) +{ + OSL_TRACE("XMLElement::dump\n"); + + xOut->ignorableWhitespace( OUString() ); + xOut->startElement( _name, static_cast< xml::sax::XAttributeList * >( this ) ); + // Write out CDATA + if(_chars.getLength() > 0) + { + xOut->ignorableWhitespace( OUString() ); + xOut->characters( _chars ); + } + // write sub elements + dumpSubElements( xOut ); + xOut->ignorableWhitespace( OUString() ); + xOut->endElement( _name ); +} + +//************************************************************************* +// XAttributeList +sal_Int16 XMLElement::getLength() +throw (RuntimeException) +{ + OSL_TRACE("XMLElement::getLength\n"); + + return _attrNames.size(); +} + +//************************************************************************* +OUString XMLElement::getNameByIndex( sal_Int16 nPos ) +throw (RuntimeException) +{ + OSL_TRACE("XMLElement::getNameByIndex\n"); + OSL_ASSERT( (size_t)nPos < _attrNames.size() ); + + return _attrNames[ nPos ]; +} + +//************************************************************************* +OUString XMLElement::getTypeByIndex( sal_Int16 nPos ) +throw (RuntimeException) +{ + OSL_TRACE("XMLElement::getTypeByIndex\n"); + OSL_ASSERT( (size_t)nPos < _attrNames.size() ); + + // xxx todo + return OUString(); +} + +//************************************************************************* +OUString XMLElement::getTypeByName( OUString const & rName ) +throw (RuntimeException) +{ + OSL_TRACE("XMLElement::getTypeByName\n"); + // xxx todo + return OUString(); +} + +//************************************************************************* +OUString XMLElement::getValueByIndex( sal_Int16 nPos ) +throw (RuntimeException) +{ + OSL_TRACE("XMLElement::getValueByIndex\n"); + OSL_ASSERT( (size_t)nPos < _attrNames.size() ); + + return _attrValues[ nPos ]; +} + +//************************************************************************* +OUString XMLElement::getValueByName( OUString const & rName ) +throw (RuntimeException) +{ + OSL_TRACE("XMLElement::getValueByName\n"); + + for ( size_t nPos = 0; nPos < _attrNames.size(); ++nPos ) + { + if (_attrNames[ nPos ] == rName) + { + return _attrValues[ nPos ]; + } + } + return OUString(); +} + +} diff --git a/scripting/source/storage/XMLElement.hxx b/scripting/source/storage/XMLElement.hxx new file mode 100644 index 0000000000000..dbee95bd8a8c9 --- /dev/null +++ b/scripting/source/storage/XMLElement.hxx @@ -0,0 +1,170 @@ +/************************************************************************* + * + * $RCSfile: XMLElement.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dfoster $ $Date: 2002-09-20 14:33:55 $ + * + * 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 _SCRIPTING_XML_ELEMENT_HXX_ +#define _SCRIPTING_XML_ELEMENT_HXX_ + +#include <vector> + +#include <cppuhelper/implbase1.hxx> + +#include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> + +namespace scripting_impl +{ + +/*################################################################################################## + + EXPORTING + +##################################################################################################*/ + +//================================================================================================== +class XMLElement + : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XAttributeList > +{ +public: + inline XMLElement( ::rtl::OUString const & name, ::rtl::OUString const & chars ) + SAL_THROW( () ) + : _name( name ), _chars( chars ) + { + } + + inline XMLElement( ::rtl::OUString const & name ) + SAL_THROW( () ) + : _name( name ) + { + } + + /** Adds a sub element of element. + + @param xElem element reference + */ + void SAL_CALL addSubElement( + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > const & xElem ) + SAL_THROW( () ); + + /** Gets sub element of given index. The index follows order in which sub elements were added. + + @param nIndex index of sub element + */ + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > SAL_CALL getSubElement( sal_Int32 nIndex ) + SAL_THROW( () ); + + /** Adds an attribute to elements. + + @param rAttrName qname of attribute + @param rValue value string of element + */ + void SAL_CALL addAttribute( ::rtl::OUString const & rAttrName, ::rtl::OUString const & rValue ) + SAL_THROW( () ); + + /** Gets the tag name (qname) of element. + + @return + qname of element + */ + inline ::rtl::OUString SAL_CALL getName() SAL_THROW( () ) + { + return _name; + } + + /** Dumps out element (and all sub elements). + + @param xOut document handler to be written to + */ + void SAL_CALL dump( + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut ); + /** Dumps out sub elements (and all further sub elements). + + @param xOut document handler to be written to + */ + void SAL_CALL dumpSubElements( + ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XExtendedDocumentHandler > const & xOut ); + + // XAttributeList + virtual sal_Int16 SAL_CALL getLength() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getNameByIndex( sal_Int16 nPos ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTypeByIndex( sal_Int16 nPos ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTypeByName( ::rtl::OUString const & rName ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getValueByIndex( sal_Int16 nPos ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getValueByName( ::rtl::OUString const & rName ) + throw (::com::sun::star::uno::RuntimeException); + +protected: + ::rtl::OUString _name; + + ::rtl::OUString _chars; + + ::std::vector< ::rtl::OUString > _attrNames; + ::std::vector< ::rtl::OUString > _attrValues; + + ::std::vector< ::com::sun::star::uno::Reference< + ::com::sun::star::xml::sax::XAttributeList > > _subElems; +}; + +} + +#endif diff --git a/scripting/source/storage/exports.dxp b/scripting/source/storage/exports.dxp new file mode 100644 index 0000000000000..9630d7e067687 --- /dev/null +++ b/scripting/source/storage/exports.dxp @@ -0,0 +1,3 @@ +component_getImplementationEnvironment +component_writeInfo +component_getFactory diff --git a/scripting/source/storage/makefile.mk b/scripting/source/storage/makefile.mk new file mode 100644 index 0000000000000..d09232137efc4 --- /dev/null +++ b/scripting/source/storage/makefile.mk @@ -0,0 +1,105 @@ +#************************************************************************* +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.1 $ +# +# last change: $Author: dfoster $ $Date: 2002-09-20 14:33:56 $ +# +# 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): _______________________________________ +# +# +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME= scripting +TARGET= storage +USE_DEFFILE= TRUE +NO_BSYMBOLIC= TRUE +ENABLE_EXCEPTIONS=TRUE +COMP1TYPELIST=$(TARGET) + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# ------------------------------------------------------------------ + +.INCLUDE : ..$/cppumaker.mk + +SLOFILES=\ + $(SLO)$/ScriptStorage.obj\ + $(SLO)$/ScriptInfo.obj\ + $(SLO)$/ScriptMetadataImporter.obj\ + $(SLO)$/ScriptElement.obj\ + $(SLO)$/XMLElement.obj\ + $(SLO)$/ScriptStorageManager.obj\ + +SHL1TARGET= $(TARGET) + +SHL1STDLIBS= \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SALLIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB= i$(TARGET) +SHL1LIBS= $(SLB)$/$(TARGET).lib +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +DEF1NAME= $(SHL1TARGET) +DEF1EXPORTFILE= exports.dxp + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk diff --git a/scripting/source/storage/storage.xml b/scripting/source/storage/storage.xml new file mode 100644 index 0000000000000..1f818ffe158e4 --- /dev/null +++ b/scripting/source/storage/storage.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> +<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> + <module-name> storage </module-name> + <component-description> + <author> </author> + <name> drafts.com.sun.star.script.framework.storage.ScriptStorage </name> + <description> + </description> + <loader-name> com.sun.star.loader.SharedLibrary </loader-name> + <language> c++ </language> + <status value="draft"/> + <supported-service> drafts.com.sun.star.script.framework.storage.ScriptingStorage </supported-service> + <type> com.sun.star.beans.XPropertySet </type> + <type> com.sun.star.uno.Exception </type> + <type> com.sun.star.uno.XComponentContext </type> + <type> com.sun.star.io.IOException </type> + <type> com.sun.star.io.XStream </type> + <type> com.sun.star.io.XOutputStream </type> + <type> com.sun.star.registry.XRegistryKey </type> + <type> drafts.com.sun.star.script.framework.storage.XParcelStore </type> + <type> drafts.com.sun.star.script.framework.storage.NoSuchView </type> + <type> drafts.com.sun.star.script.framework.storage.ScriptInfoAccessException </type> + <type> drafts.com.sun.star.script.framework.storage.XBinding </type> + <type> drafts.com.sun.star.script.framework.storage.XBindingStore </type> + <type> drafts.com.sun.star.script.framework.storage.XScriptInfo </type> + <type> drafts.com.sun.star.script.framework.storage.XNameNode </type> + <type> drafts.com.sun.star.script.framework.storage.XNamingAccess </type> + <type> drafts.com.sun.star.script.framework.storage.XScriptAccessManager </type> + <type> drafts.com.sun.star.script.framework.storage.XScriptImplAccess </type> + <type> drafts.com.sun.star.script.framework.storage.XScriptStorageExport </type> + <type> drafts.com.sun.star.script.framework.storage.XScriptStore </type> + <type> drafts.com.sun.star.script.framework.storage.XParcel </type> + <type> com.sun.star.lang.XInitialization </type> + <type> drafts.com.sun.star.script.framework.storage.ScriptImplInfo </type> + <type> drafts.com.sun.star.script.framework.storage.XScriptInvocationPrep </type> + <type> drafts.com.sun.star.script.framework.storage.XParcelInvocationPrep </type> + <type> drafts.com.sun.star.script.framework.storage.XScriptStorageManager </type> + <type> com.sun.star.xml.sax.XExtendedDocumentHandler </type> + <type> com.sun.star.xml.sax.XParser </type> + <type> com.sun.star.io.XInputStream </type> + <type> com.sun.star.ucb.XSimpleFileAccess2 </type> + <type> com.sun.star.xml.sax.SAXException </type> + <type> com.sun.star.xml.sax.XAttributeList </type> + <type> com.sun.star.io.XActiveDataSource </type> + </component-description> + <project-build-dependency> cppuhelper </project-build-dependency> + <project-build-dependency> cppu </project-build-dependency> + <project-build-dependency> sal </project-build-dependency> + <runtime-module-dependency> cppuhelper2$(COM) </runtime-module-dependency> + <runtime-module-dependency> cppu2 </runtime-module-dependency> + <runtime-module-dependency> sal2 </runtime-module-dependency> + <runtime-module-dependency> ucb </runtime-module-dependency> +</module-description> |