Kaydet (Commit) f8ee32b7 authored tarafından Thomas Benisch's avatar Thomas Benisch

#i18767# integration of Starbasic runtime to ScriptingFramework provider

üst 5990f47b
tc scripting : bridges rdbmaker vcl NULL
tc scripting : bridges rdbmaker vcl basic sfx2 NULL
tc scripting usr1 - all tc_mkout NULL
tc scripting\source\storage nmake - all tc_scriptingstorage NULL
tc scripting\source\provider nmake - all tc_scriptingprovider tc_scriptingstorage NULL
tc scripting\source\basprov nmake - all tc_scriptingbasprov NULL
tc scripting\source\protocolhandler nmake - all tc_scriptingprotocolhandler tc_scriptingstorage tc_scriptingprovider NULL
tc scripting\java nmake - all tc_scriptingjava tc_scriptingstorage tc_scriptingprovider tc_scriptingprotocolhandler NULL
tc scripting\examples\java nmake - all tc_scriptingexamplesjava tc_scriptingjava NULL
......
This diff is collapsed.
/*************************************************************************
*
* $RCSfile: basprov.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: tbe $ $Date: 2003-09-16 15:21:18 $
*
* 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_BASPROV_HXX
#define SCRIPTING_BASPROV_HXX
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.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 _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_PROVIDER_XSCRIPTPROVIDER_HPP_
#include <drafts/com/sun/star/script/framework/provider/XScriptProvider.hpp>
#endif
#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
#include <com/sun/star/uno/XComponentContext.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE3_HXX_
#include <cppuhelper/implbase3.hxx>
#endif
class BasicManager;
//.........................................................................
namespace basprov
{
//.........................................................................
// ----------------------------------------------------
// class BasicProviderImpl
// ----------------------------------------------------
typedef ::cppu::WeakImplHelper3<
::com::sun::star::lang::XServiceInfo,
::com::sun::star::lang::XInitialization,
::drafts::com::sun::star::script::framework::provider::XScriptProvider > BasicProviderImpl_BASE;
class BasicProviderImpl : public BasicProviderImpl_BASE
{
private:
BasicManager* m_pBasicManager;
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xScriptingContext;
public:
BasicProviderImpl(
const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext );
virtual ~BasicProviderImpl();
// XServiceInfo
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);
// XInitialization
virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
// XScriptProvider
virtual ::com::sun::star::uno::Reference < ::drafts::com::sun::star::script::framework::provider::XScript > SAL_CALL getScript(
const ::rtl::OUString& scriptURI )
throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
};
//.........................................................................
} // namespace basprov
//.........................................................................
#endif // SCRIPTING_BASPROV_HXX
OOO_1.1 {
global:
component_getDescriptionFunc;
component_getImplementationEnvironment;
component_getFactory;
component_writeInfo;
local:
*;
};
<?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>basprov</module-name>
<component-description>
<author>Thomas Benisch</author>
<name>com.sun.star.comp.scripting.ScriptProviderForBasic</name>
<description>script provider for Basic</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.ScriptProviderForBasic</supported-service>
<type>com.sun.star.beans.XPropertySet</type>
<type>com.sun.star.frame.XModel</type>
<type>com.sun.star.lang.IllegalArgumentException</type>
<type>com.sun.star.lang.XInitialization</type>
<type>com.sun.star.lang.XServiceInfo</type>
<type>com.sun.star.reflection.InvocationTargetException</type>
<type>com.sun.star.script.CannotConvertException</type>
<type>com.sun.star.uno.Exception</type>
<type>com.sun.star.uno.RuntimeException</type>
<type>com.sun.star.uno.XComponentContext</type>
<type>drafts.com.sun.star.script.framework.provider.XScript</type>
<type>drafts.com.sun.star.script.framework.provider.XScriptProvider</type>
</component-description>
<project-build-dependency>sfx2</project-build-dependency>
<project-build-dependency>basic</project-build-dependency>
<project-build-dependency>svtools</project-build-dependency>
<project-build-dependency>tools</project-build-dependency>
<project-build-dependency>cppuhelper</project-build-dependency>
<project-build-dependency>cppu</project-build-dependency>
<project-build-dependency>sal</project-build-dependency>
<runtime-module-dependency>sfx2</runtime-module-dependency>
<runtime-module-dependency>sb</runtime-module-dependency>
<runtime-module-dependency>svt</runtime-module-dependency>
<runtime-module-dependency>tl</runtime-module-dependency>
<runtime-module-dependency>cppuhelper3$(COM)</runtime-module-dependency>
<runtime-module-dependency>cppu3</runtime-module-dependency>
<runtime-module-dependency>sal3</runtime-module-dependency>
</module-description>
/*************************************************************************
*
* $RCSfile: basscript.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: tbe $ $Date: 2003-09-16 15:23: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): _______________________________________
*
*
************************************************************************/
#ifndef SCRIPTING_BASSCRIPT_HXX
#include "basscript.hxx"
#endif
#ifndef _SBXCLASS_HXX
#include <svtools/sbx.hxx>
#endif
#ifndef _SB_SBSTAR_HXX
#include <basic/sbstar.hxx>
#endif
#ifndef _SB_SBMOD_HXX
#include <basic/sbmod.hxx>
#endif
#ifndef _SB_SBMETH_HXX
#include <basic/sbmeth.hxx>
#endif
#include <map>
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::drafts::com::sun::star::script::framework;
extern ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar );
extern void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue );
//.........................................................................
namespace basprov
{
//.........................................................................
typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap;
// =============================================================================
// BasicScriptImpl
// =============================================================================
BasicScriptImpl::BasicScriptImpl( SbMethod* pMethod )
:m_pMethod( pMethod )
{
}
// -----------------------------------------------------------------------------
BasicScriptImpl::~BasicScriptImpl()
{
}
// -----------------------------------------------------------------------------
// XScript
// -----------------------------------------------------------------------------
Any BasicScriptImpl::invoke( const Sequence< Any >& aParams, Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam )
throw (IllegalArgumentException, script::CannotConvertException, reflection::InvocationTargetException, uno::RuntimeException)
{
// TODO: throw CannotConvertException
// TODO: check length of aOutParamIndex, aOutParam
::osl::MutexGuard aGuard( StarBASIC::GetGlobalMutex() );
Any aReturn;
if ( m_pMethod )
{
// check if compiled
SbModule* pModule = (SbModule*)m_pMethod->GetParent();
if ( pModule && !pModule->IsCompiled() )
pModule->Compile();
// check number of parameters
sal_Int32 nParamsCount = aParams.getLength();
SbxInfo* pInfo = m_pMethod->GetInfo();
if ( pInfo )
{
sal_Int32 nSbxOptional = 0;
USHORT n = 1;
for ( const SbxParamInfo* pParamInfo = pInfo->GetParam( n ); pParamInfo; pParamInfo = pInfo->GetParam( ++n ) )
{
if ( ( pParamInfo->nFlags & SBX_OPTIONAL ) != 0 )
++nSbxOptional;
else
nSbxOptional = 0;
}
sal_Int32 nSbxCount = n - 1;
if ( ( nParamsCount < nSbxCount - nSbxOptional ) || ( nParamsCount > nSbxCount ) )
{
throw IllegalArgumentException(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicScriptImpl::invoke: wrong number of paramters!" ) ),
Reference< XInterface >(), 1 );
}
}
// set parameters
SbxArrayRef xSbxParams;
if ( nParamsCount > 0 )
{
xSbxParams = new SbxArray;
const Any* pParams = aParams.getConstArray();
for ( sal_Int32 i = 0; i < nParamsCount; ++i )
{
SbxVariableRef xSbxVar = new SbxVariable( SbxVARIANT );
unoToSbxValue( (SbxVariable*)xSbxVar, pParams[i] );
xSbxParams->Put( xSbxVar, (USHORT)i + 1 );
}
}
if ( xSbxParams.Is() )
m_pMethod->SetParameters( xSbxParams );
// call method
SbxVariableRef xReturn = new SbxVariable;
ErrCode nErr = m_pMethod->Call( xReturn );
if ( nErr != SbxERR_OK )
{
// TODO: throw InvocationTargetException ?
}
// get output parameters
if ( xSbxParams.Is() )
{
SbxInfo* pInfo = m_pMethod->GetInfo();
if ( pInfo )
{
OutParamMap aOutParamMap;
for ( USHORT n = 1, nCount = xSbxParams->Count(); n < nCount; ++n )
{
const SbxParamInfo* pParamInfo = pInfo->GetParam( n );
if ( pParamInfo && ( pParamInfo->eType & SbxBYREF ) != 0 )
{
SbxVariable* pVar = xSbxParams->Get( n );
if ( pVar )
{
SbxVariableRef xVar = pVar;
aOutParamMap.insert( OutParamMap::value_type( n - 1, sbxToUnoValue( xVar ) ) );
}
}
}
sal_Int32 nOutParamCount = aOutParamMap.size();
aOutParamIndex.realloc( nOutParamCount );
aOutParam.realloc( nOutParamCount );
sal_Int16* pOutParamIndex = aOutParamIndex.getArray();
Any* pOutParam = aOutParam.getArray();
for ( OutParamMap::iterator aIt = aOutParamMap.begin(); aIt != aOutParamMap.end(); ++aIt, ++pOutParamIndex, ++pOutParam )
{
*pOutParamIndex = aIt->first;
*pOutParam = aIt->second;
}
}
}
// get return value
aReturn = sbxToUnoValue( xReturn );
// reset parameters
m_pMethod->SetParameters( NULL );
}
return aReturn;
}
// -----------------------------------------------------------------------------
//.........................................................................
} // namespace basprov
//.........................................................................
/*************************************************************************
*
* $RCSfile: basscript.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: tbe $ $Date: 2003-09-16 15:22:58 $
*
* 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_BASSCRIPT_HXX
#define SCRIPTING_BASSCRIPT_HXX
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_FRAMEWORK_PROVIDER_XSCRIPT_HPP_
#include <drafts/com/sun/star/script/framework/provider/XScript.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
class SbMethod;
//.........................................................................
namespace basprov
{
//.........................................................................
// ----------------------------------------------------
// class BasicScriptImpl
// ----------------------------------------------------
typedef ::cppu::WeakImplHelper1<
::drafts::com::sun::star::script::framework::provider::XScript > BasicScriptImpl_BASE;
class BasicScriptImpl : public BasicScriptImpl_BASE
{
private:
SbMethod* m_pMethod;
public:
BasicScriptImpl( SbMethod* pMethod );
virtual ~BasicScriptImpl();
// XScript
virtual ::com::sun::star::uno::Any SAL_CALL invoke(
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams,
::com::sun::star::uno::Sequence< sal_Int16 >& aOutParamIndex,
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aOutParam )
throw ( ::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::script::CannotConvertException,
::com::sun::star::reflection::InvocationTargetException,
::com::sun::star::uno::RuntimeException );
};
//.........................................................................
} // namespace basprov
//.........................................................................
#endif // SCRIPTING_BASSCRIPT_HXX
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: tbe $ $Date: 2003-09-16 15:23: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): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJNAME=scripting
TARGET=basprov
NO_BSYMBOLIC= TRUE
ENABLE_EXCEPTIONS=TRUE
COMP1TYPELIST=$(TARGET)
COMPRDB=$(SOLARBINDIR)$/types.rdb
# --- Settings -----------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
DLLPRE =
# ------------------------------------------------------------------
.INCLUDE : ..$/cppumaker.mk
SLOFILES= \
$(SLO)$/basprov.obj \
$(SLO)$/basscript.obj
SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX).uno
SHL1IMPLIB= i$(TARGET)
SHL1VERSIONMAP=$(TARGET).map
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
DEF1NAME=$(SHL1TARGET)
SHL1STDLIBS= \
$(SFX2LIB) \
$(BASICLIB) \
$(SVTOOLLIB) \
$(TOOLSLIB) \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(SALLIB)
SHL1DEPN=
SHL1LIBS=$(SLB)$/$(TARGET).lib
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment