summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
authorThomas Benisch <tbe@openoffice.org>2003-11-07 12:51:16 +0000
committerThomas Benisch <tbe@openoffice.org>2003-11-07 12:51:16 +0000
commitb9506c12d309dc7196147fb24a0ab3b9f0f0c0df (patch)
tree05f64f9aeb12e3af46c711f9992a76effdf90fad /scripting
parent2b6897ce289596f88549a6a2708fed74dc808fa3 (diff)
#i21560# editing a basic macro using script selector
Diffstat (limited to 'scripting')
-rw-r--r--scripting/source/basprov/baslibnode.cxx16
-rw-r--r--scripting/source/basprov/baslibnode.hxx17
-rw-r--r--scripting/source/basprov/basmethnode.cxx348
-rw-r--r--scripting/source/basprov/basmethnode.hxx129
-rw-r--r--scripting/source/basprov/basmodnode.cxx14
-rw-r--r--scripting/source/basprov/basmodnode.hxx17
-rw-r--r--scripting/source/basprov/basprov.cxx10
-rw-r--r--scripting/source/basprov/makefile.mk5
-rw-r--r--scripting/source/inc/bcholder.hxx98
9 files changed, 473 insertions, 181 deletions
diff --git a/scripting/source/basprov/baslibnode.cxx b/scripting/source/basprov/baslibnode.cxx
index a9594f159d0f..0e3738998584 100644
--- a/scripting/source/basprov/baslibnode.cxx
+++ b/scripting/source/basprov/baslibnode.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: baslibnode.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: toconnor $ $Date: 2003-10-29 15:00:42 $
+ * last change: $Author: tbe $ $Date: 2003-11-07 13:48:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,11 +94,15 @@ namespace basprov
// BasicLibraryNodeImpl
// =============================================================================
- BasicLibraryNodeImpl::BasicLibraryNodeImpl( BasicManager* pBasicManager,
+ BasicLibraryNodeImpl::BasicLibraryNodeImpl( const Reference< XComponentContext >& rxContext,
+ const Reference< beans::XPropertySet >& rxScriptingContext, BasicManager* pBasicManager,
const Reference< script::XLibraryContainer >& xLibContainer, const ::rtl::OUString& sLibName, bool isAppScript )
- :m_pBasicManager( pBasicManager )
+ :m_xContext( rxContext )
+ ,m_xScriptingContext( rxScriptingContext )
+ ,m_pBasicManager( pBasicManager )
,m_xLibContainer( xLibContainer )
- ,m_sLibName( sLibName ),m_bIsAppScript( isAppScript )
+ ,m_sLibName( sLibName )
+ ,m_bIsAppScript( isAppScript )
{
if ( m_xLibContainer.is() )
{
@@ -150,7 +154,7 @@ namespace basprov
{
SbModule* pModule = pBasic->FindModule( pNames[i] );
if ( pModule )
- pChildNodes[i] = static_cast< browse::XBrowseNode* >( new BasicModuleNodeImpl( pModule, m_bIsAppScript ) );
+ pChildNodes[i] = static_cast< browse::XBrowseNode* >( new BasicModuleNodeImpl( m_xContext, m_xScriptingContext, pModule, m_bIsAppScript ) );
}
}
}
diff --git a/scripting/source/basprov/baslibnode.hxx b/scripting/source/basprov/baslibnode.hxx
index edee5006998a..bbf42b96b17b 100644
--- a/scripting/source/basprov/baslibnode.hxx
+++ b/scripting/source/basprov/baslibnode.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: baslibnode.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: toconnor $ $Date: 2003-10-29 15:00:43 $
+ * last change: $Author: tbe $ $Date: 2003-11-07 13:46:26 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,12 +62,18 @@
#ifndef SCRIPTING_BASLIBNODE_HXX
#define SCRIPTING_BASLIBNODE_HXX
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
#ifndef _COM_SUN_STAR_SCRIPT_XLIBRARYCONTAINER_HPP_
#include <com/sun/star/script/XLibraryContainer.hpp>
#endif
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_BROWSE_XBROWSENODE_HPP_
#include <drafts/com/sun/star/script/browse/XBrowseNode.hpp>
#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
@@ -92,13 +98,18 @@ namespace basprov
class BasicLibraryNodeImpl : public BasicLibraryNodeImpl_BASE
{
private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xScriptingContext;
BasicManager* m_pBasicManager;
::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer > m_xLibContainer;
::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > m_xLibrary;
::rtl::OUString m_sLibName;
bool m_bIsAppScript;
+
public:
- BasicLibraryNodeImpl( BasicManager* pBasicManager,
+ BasicLibraryNodeImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rxScriptingContext,
+ BasicManager* pBasicManager,
const ::com::sun::star::uno::Reference< ::com::sun::star::script::XLibraryContainer >& xLibContainer,
const ::rtl::OUString& sLibName, bool isAppScript=true );
virtual ~BasicLibraryNodeImpl();
diff --git a/scripting/source/basprov/basmethnode.cxx b/scripting/source/basprov/basmethnode.cxx
index b5fc65ee2b09..815b995e15b9 100644
--- a/scripting/source/basprov/basmethnode.cxx
+++ b/scripting/source/basprov/basmethnode.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basmethnode.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: toconnor $ $Date: 2003-10-29 15:00:44 $
+ * last change: $Author: tbe $ $Date: 2003-11-07 13:51:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,6 +63,21 @@
#include "basmethnode.hxx"
#endif
+#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDESKTOP_HPP_
+#include <com/sun/star/frame/XDesktop.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCHHELPER_HPP_
+#include <com/sun/star/frame/XDispatchHelper.hpp>
+#endif
+#ifndef _COM_SUN_STAR_FRAME_XDISPATCHPROVIDER_HPP_
+#include <com/sun/star/frame/XDispatchProvider.hpp>
+#endif
+#ifndef _COM_SUN_STAR_LANG_XMULTICOMPONENTFACTORY_HPP_
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#endif
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_BROWSE_BROWSENODETYPES_HPP_
#include <drafts/com/sun/star/script/browse/BrowseNodeTypes.hpp>
#endif
@@ -80,9 +95,20 @@
using namespace ::com::sun::star;
using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::comphelper;
using namespace ::drafts::com::sun::star::script;
+#define BASPROV_PROPERTY_ID_URI 1
+#define BASPROV_PROPERTY_ID_EDITABLE 2
+
+#define BASPROV_PROPERTY_URI ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URI" ) )
+#define BASPROV_PROPERTY_EDITABLE ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Editable" ) )
+
+#define BASPROV_DEFAULT_ATTRIBS() PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT | PropertyAttribute::READONLY
+
+
//.........................................................................
namespace basprov
{
@@ -92,39 +118,41 @@ namespace basprov
// BasicMethodNodeImpl
// =============================================================================
- BasicMethodNodeImpl::BasicMethodNodeImpl( SbMethod* pMethod, bool isAppScript )
- :m_pMethod( pMethod ), m_bIsAppScript( isAppScript )
+ BasicMethodNodeImpl::BasicMethodNodeImpl( const Reference< XComponentContext >& rxContext,
+ const Reference< XPropertySet >& rxScriptingContext, SbMethod* pMethod, bool isAppScript )
+ : ::scripting_helper::OBroadcastHelperHolder( StarBASIC::GetGlobalMutex() )
+ ,OPropertyContainer( GetBroadcastHelper() )
+ ,m_xContext( rxContext )
+ ,m_xScriptingContext( rxScriptingContext )
+ ,m_pMethod( pMethod )
+ ,m_bIsAppScript( isAppScript )
+ ,m_bEditable( sal_True )
{
- String sModName = m_pMethod->GetModule()->GetName();
- String sLibName = m_pMethod->GetModule()->GetParent()->GetName();
- String sMethName = m_pMethod->GetName();
- String sTmp = String::CreateFromAscii("vnd.sun.star.script://");
- sTmp += sLibName;
- sTmp += '.';
- sTmp += sModName;
- sTmp += '.';
- sTmp += sMethName;
- sTmp += String::CreateFromAscii("?language=Basic&location=");
- if ( m_bIsAppScript )
- {
- sTmp += String::CreateFromAscii("application");
- }
- else
- {
- sTmp += String::CreateFromAscii("document");
- }
- rtl::OUString sUrl( sTmp );
- try
- {
- Any aURIVal;
- aURIVal <<= sUrl;
- setPropertyValue( ::rtl::OUString::createFromAscii("URI"), aURIVal);
- }
- catch ( RuntimeException& re )
+ if ( m_pMethod )
{
- OSL_TRACE("caught exception trying to set property %s",
- ::rtl::OUStringToOString( re.Message, RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+ SbModule* pModule = m_pMethod->GetModule();
+ if ( pModule )
+ {
+ StarBASIC* pBasic = static_cast< StarBASIC* >( pModule->GetParent() );
+ if ( pBasic )
+ {
+ m_sURI = ::rtl::OUString::createFromAscii( "vnd.sun.star.script://" );
+ m_sURI += pBasic->GetName();
+ m_sURI += ::rtl::OUString::createFromAscii( "." );
+ m_sURI += pModule->GetName();
+ m_sURI += ::rtl::OUString::createFromAscii( "." );
+ m_sURI += m_pMethod->GetName();
+ m_sURI += ::rtl::OUString::createFromAscii( "?language=Basic&location=" );
+ if ( m_bIsAppScript )
+ m_sURI += ::rtl::OUString::createFromAscii( "application" );
+ else
+ m_sURI += ::rtl::OUString::createFromAscii( "document" );
+ }
+ }
}
+
+ registerProperty( BASPROV_PROPERTY_URI, BASPROV_PROPERTY_ID_URI, BASPROV_DEFAULT_ATTRIBS(), &m_sURI, ::getCppuType( &m_sURI ) );
+ registerProperty( BASPROV_PROPERTY_EDITABLE, BASPROV_PROPERTY_ID_EDITABLE, BASPROV_DEFAULT_ATTRIBS(), &m_bEditable, ::getCppuType( &m_bEditable ) );
}
// -----------------------------------------------------------------------------
@@ -134,6 +162,18 @@ namespace basprov
}
// -----------------------------------------------------------------------------
+ // XInterface
+ // -----------------------------------------------------------------------------
+
+ IMPLEMENT_FORWARD_XINTERFACE2( BasicMethodNodeImpl, BasicMethodNodeImpl_BASE, OPropertyContainer )
+
+ // -----------------------------------------------------------------------------
+ // XTypeProvider
+ // -----------------------------------------------------------------------------
+
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( BasicMethodNodeImpl, BasicMethodNodeImpl_BASE, OPropertyContainer )
+
+ // -----------------------------------------------------------------------------
// XBrowseNode
// -----------------------------------------------------------------------------
@@ -176,85 +216,183 @@ namespace basprov
}
// -----------------------------------------------------------------------------
+ // OPropertySetHelper
+ // -----------------------------------------------------------------------------
+ ::cppu::IPropertyArrayHelper& BasicMethodNodeImpl::getInfoHelper( )
+ {
+ return *getArrayHelper();
+ }
-//*************************************************************************
-// XPropertySet implementation
-//*************************************************************************
-Reference< beans::XPropertySetInfo > SAL_CALL BasicMethodNodeImpl::getPropertySetInfo( )
- throw ( RuntimeException )
-{
- return Reference< beans::XPropertySetInfo > (); // Not supported
-}
-
-//*************************************************************************
-void SAL_CALL BasicMethodNodeImpl::setPropertyValue( const ::rtl::OUString& aPropertyName,
- const Any& aValue )
- throw ( beans::UnknownPropertyException, beans::PropertyVetoException,
- lang::IllegalArgumentException, lang::WrappedTargetException,
- RuntimeException )
-{
- m_hProps[ aPropertyName ] = aValue;
-}
+ // -----------------------------------------------------------------------------
+ // OPropertyArrayUsageHelper
+ // -----------------------------------------------------------------------------
-//*************************************************************************
-Any SAL_CALL BasicMethodNodeImpl::getPropertyValue( const ::rtl::OUString& PropertyName )
- throw ( beans::UnknownPropertyException,
- lang::WrappedTargetException, RuntimeException )
-{
- Any returnValue = m_hProps[ PropertyName ];
+ ::cppu::IPropertyArrayHelper* BasicMethodNodeImpl::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+ }
- return returnValue;
-}
+ // -----------------------------------------------------------------------------
+ // XPropertySet
+ // -----------------------------------------------------------------------------
-//*************************************************************************
-void SAL_CALL BasicMethodNodeImpl::addPropertyChangeListener(
- const ::rtl::OUString& aPropertyName,
- const Reference< beans::XPropertyChangeListener >& xListener )
- throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
- RuntimeException )
-{
- throw RuntimeException(
- ::rtl::OUString::createFromAscii( "BasicMethodNodeImpl::addPropertyChangeListener: method not supported" ),
- Reference< XInterface >() );
-}
-
-//*************************************************************************
-void SAL_CALL BasicMethodNodeImpl::removePropertyChangeListener(
- const ::rtl::OUString& aPropertyName,
- const Reference< beans::XPropertyChangeListener >& aListener )
- throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
- RuntimeException )
-{
- throw RuntimeException(
- ::rtl::OUString::createFromAscii( "BasicMethodNodeImpl::removePropertyChangeListener: method not supported" ),
- Reference< XInterface >() );
-}
-
-//*************************************************************************
-void SAL_CALL BasicMethodNodeImpl::addVetoableChangeListener(
- const ::rtl::OUString& PropertyName,
- const Reference< beans::XVetoableChangeListener >& aListener )
- throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
- RuntimeException )
-{
- throw RuntimeException(
- ::rtl::OUString::createFromAscii( "BasicMethodNodeImpl::addVetoableChangeListener: method not supported" ),
- Reference< XInterface >() );
-}
-
-//*************************************************************************
-void SAL_CALL BasicMethodNodeImpl::removeVetoableChangeListener(
- const ::rtl::OUString& PropertyName,
- const Reference< beans::XVetoableChangeListener >& aListener )
- throw ( beans::UnknownPropertyException, lang::WrappedTargetException,
- RuntimeException )
-{
- throw RuntimeException(
- ::rtl::OUString::createFromAscii( "BasicMethodNodeImpl::removeVetoableChangeListener: method not supported" ),
- Reference< XInterface >() );
-}
+ Reference< XPropertySetInfo > BasicMethodNodeImpl::getPropertySetInfo( ) throw (RuntimeException)
+ {
+ Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ // -----------------------------------------------------------------------------
+ // XInvocation
+ // -----------------------------------------------------------------------------
+
+ Reference< XIntrospectionAccess > BasicMethodNodeImpl::getIntrospection( ) throw (RuntimeException)
+ {
+ return Reference< XIntrospectionAccess >();
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Any BasicMethodNodeImpl::invoke( const ::rtl::OUString& aFunctionName, const Sequence< Any >& aParams,
+ Sequence< sal_Int16 >& aOutParamIndex, Sequence< Any >& aOutParam )
+ throw (IllegalArgumentException, script::CannotConvertException,
+ reflection::InvocationTargetException, RuntimeException)
+ {
+ if ( aFunctionName == BASPROV_PROPERTY_EDITABLE )
+ {
+ ::rtl::OUString sDocURL, sLibName, sModName;
+ USHORT nLine1, nLine2;
+
+ if ( !m_bIsAppScript && m_xScriptingContext.is() )
+ {
+ Reference< frame::XModel > xModel;
+ // TODO: use ScriptingContantsPool for SCRIPTING_DOC_REF
+ m_xScriptingContext->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SCRIPTING_DOC_REF" ) ) ) >>= xModel;
+
+ if ( xModel.is() )
+ {
+ sDocURL = xModel->getURL();
+ if ( sDocURL.getLength() == 0 )
+ {
+ Sequence < PropertyValue > aProps = xModel->getArgs();
+ sal_Int32 nProps = aProps.getLength();
+ const PropertyValue* pProps = aProps.getConstArray();
+ for ( sal_Int32 i = 0; i < nProps; ++i )
+ {
+ // TODO: according to MBA the property 'Title' may change in future
+ if ( pProps[i].Name == ::rtl::OUString::createFromAscii( "Title" ) )
+ {
+ pProps[i].Value >>= sDocURL;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if ( m_pMethod )
+ {
+ m_pMethod->GetLineRange( nLine1, nLine2 );
+ SbModule* pModule = m_pMethod->GetModule();
+ if ( pModule )
+ {
+ sModName = pModule->GetName();
+ StarBASIC* pBasic = static_cast< StarBASIC* >( pModule->GetParent() );
+ if ( pBasic )
+ sLibName = pBasic->GetName();
+ }
+ }
+
+ if ( m_xContext.is() )
+ {
+ Reference< XMultiComponentFactory > xSMgr( m_xContext->getServiceManager() );
+
+ if ( xSMgr.is() )
+ {
+ Reference< frame::XDesktop > xDesktop( xSMgr->createInstanceWithContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ), m_xContext ), UNO_QUERY );
+
+ if ( xDesktop.is() )
+ {
+ Reference < frame::XDispatchProvider > xProv( xDesktop->getCurrentFrame(), UNO_QUERY );
+
+ if ( xProv.is() )
+ {
+ Reference< frame::XDispatchHelper > xHelper( xSMgr->createInstanceWithContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.DispatchHelper" ) ), m_xContext ), UNO_QUERY );
+
+ if ( xHelper.is() )
+ {
+ Sequence < PropertyValue > aArgs(7);
+ aArgs[0].Name = ::rtl::OUString::createFromAscii( "Document" );
+ aArgs[0].Value <<= sDocURL;
+ aArgs[1].Name = ::rtl::OUString::createFromAscii( "LibName" );
+ aArgs[1].Value <<= sLibName;
+ aArgs[2].Name = ::rtl::OUString::createFromAscii( "Name" );
+ aArgs[2].Value <<= sModName;
+ aArgs[3].Name = ::rtl::OUString::createFromAscii( "Type" );
+ aArgs[3].Value <<= ::rtl::OUString::createFromAscii( "Module" );
+ aArgs[4].Name = ::rtl::OUString::createFromAscii( "Line" );
+ aArgs[4].Value <<= static_cast< sal_uInt32 >( nLine1 );
+ xHelper->executeDispatch( xProv, ::rtl::OUString::createFromAscii( ".uno:BasicIDEAppear" ), ::rtl::OUString(), 0, aArgs );
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ throw IllegalArgumentException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicMethodNodeImpl::invoke: function name not supported!" ) ),
+ Reference< XInterface >(), 1 );
+ }
+
+ return Any();
+ }
+
+ // -----------------------------------------------------------------------------
+ void BasicMethodNodeImpl::setValue( const ::rtl::OUString& aPropertyName, const Any& aValue )
+ throw (UnknownPropertyException, script::CannotConvertException,
+ reflection::InvocationTargetException, RuntimeException)
+ {
+ throw UnknownPropertyException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicMethodNodeImpl::setValue: property name is unknown!" ) ),
+ Reference< XInterface >() );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ Any BasicMethodNodeImpl::getValue( const ::rtl::OUString& aPropertyName ) throw (UnknownPropertyException, RuntimeException)
+ {
+ throw UnknownPropertyException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicMethodNodeImpl::getValue: property name is unknown!" ) ),
+ Reference< XInterface >() );
+ }
+
+ // -----------------------------------------------------------------------------
+
+ sal_Bool BasicMethodNodeImpl::hasMethod( const ::rtl::OUString& aName ) throw (RuntimeException)
+ {
+ sal_Bool bReturn = sal_False;
+ if ( aName == BASPROV_PROPERTY_EDITABLE )
+ bReturn = sal_True;
+
+ return bReturn;
+ }
+
+ // -----------------------------------------------------------------------------
+
+ sal_Bool BasicMethodNodeImpl::hasProperty( const ::rtl::OUString& aName ) throw (RuntimeException)
+ {
+ return sal_False;
+ }
+
+ // -----------------------------------------------------------------------------
//.........................................................................
} // namespace basprov
diff --git a/scripting/source/basprov/basmethnode.hxx b/scripting/source/basprov/basmethnode.hxx
index b4b327dc6ce7..2323471891bc 100644
--- a/scripting/source/basprov/basmethnode.hxx
+++ b/scripting/source/basprov/basmethnode.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basmethnode.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: toconnor $ $Date: 2003-10-29 15:00:45 $
+ * last change: $Author: tbe $ $Date: 2003-11-07 13:51:16 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,17 +62,36 @@
#ifndef SCRIPTING_BASMETHNODE_HXX
#define SCRIPTING_BASMETHNODE_HXX
+#ifndef SCRIPTING_BCHOLDER_HXX
+#include "bcholder.hxx"
+#endif
+
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
+#ifndef _COM_SUN_STAR_SCRIPT_XINVOCATION_HPP_
+#include <com/sun/star/script/XInvocation.hpp>
+#endif
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_BROWSE_XBROWSENODE_HPP_
#include <drafts/com/sun/star/script/browse/XBrowseNode.hpp>
#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
-#ifndef _CPPUHELPER_IMPLBASE1_HXX_
-#include <cppuhelper/implbase1.hxx>
+#ifndef _COMPHELPER_PROPERTY_ARRAY_HELPER_HXX_
+#include <comphelper/proparrhlp.hxx>
#endif
+#ifndef _COMPHELPER_PROPERTYCONTAINER_HXX_
+#include <comphelper/propertycontainer.hxx>
+#endif
+#ifndef _COMPHELPER_UNO3_HXX_
+#include <comphelper/uno3.hxx>
+#endif
+#ifndef _CPPUHELPER_IMPLBASE2_HXX_
#include <cppuhelper/implbase2.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
-#include <hash_map>
class SbMethod;
@@ -88,21 +107,42 @@ namespace basprov
typedef ::cppu::WeakImplHelper2<
::drafts::com::sun::star::script::browse::XBrowseNode,
- com::sun::star::beans::XPropertySet > BasicMethodNodeImpl_BASE;
-
- typedef ::std::hash_map < ::rtl::OUString, com::sun::star::uno::Any, ::rtl::OUStringHash,
- ::std::equal_to< ::rtl::OUString > > Props_hash;
+ ::com::sun::star::script::XInvocation > BasicMethodNodeImpl_BASE;
- class BasicMethodNodeImpl : public BasicMethodNodeImpl_BASE
+ class BasicMethodNodeImpl : public BasicMethodNodeImpl_BASE,
+ public ::scripting_helper::OBroadcastHelperHolder,
+ public ::comphelper::OPropertyContainer,
+ public ::comphelper::OPropertyArrayUsageHelper< BasicMethodNodeImpl >
{
private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xScriptingContext;
SbMethod* m_pMethod;
- Props_hash m_hProps;
- bool m_bIsAppScript;
+ bool m_bIsAppScript;
+
+ // properties
+ ::rtl::OUString m_sURI;
+ sal_Bool m_bEditable;
+
+ protected:
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper( );
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
public:
- BasicMethodNodeImpl( SbMethod* pMethod, bool isAppScript = true );
+ BasicMethodNodeImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rxScriptingContext,
+ SbMethod* pMethod, bool isAppScript = true );
virtual ~BasicMethodNodeImpl();
+ // XInterface
+ DECLARE_XINTERFACE()
+
+ // XTypeProvider
+ DECLARE_XTYPEPROVIDER()
+
// XBrowseNode
virtual ::rtl::OUString SAL_CALL getName( )
throw (::com::sun::star::uno::RuntimeException);
@@ -112,45 +152,30 @@ namespace basprov
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Int16 SAL_CALL getType( )
throw (::com::sun::star::uno::RuntimeException);
- // 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 );
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( )
+ throw (::com::sun::star::uno::RuntimeException);
+
+ // XInvocation
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XIntrospectionAccess > SAL_CALL getIntrospection( )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL invoke(
+ const ::rtl::OUString& aFunctionName,
+ 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);
+ virtual void SAL_CALL setValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue )
+ throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::script::CannotConvertException,
+ ::com::sun::star::reflection::InvocationTargetException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getValue( const ::rtl::OUString& aPropertyName )
+ throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& aName )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& aName )
+ throw (::com::sun::star::uno::RuntimeException);
};
//.........................................................................
diff --git a/scripting/source/basprov/basmodnode.cxx b/scripting/source/basprov/basmodnode.cxx
index 71fb301eaa20..2ae38157357d 100644
--- a/scripting/source/basprov/basmodnode.cxx
+++ b/scripting/source/basprov/basmodnode.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basmodnode.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: toconnor $ $Date: 2003-10-29 15:00:45 $
+ * last change: $Author: tbe $ $Date: 2003-11-07 13:49:39 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -100,8 +100,12 @@ namespace basprov
// BasicModuleNodeImpl
// =============================================================================
- BasicModuleNodeImpl::BasicModuleNodeImpl( SbModule* pModule, bool isAppScript )
- :m_pModule( pModule ), m_bIsAppScript( isAppScript )
+ BasicModuleNodeImpl::BasicModuleNodeImpl( const Reference< XComponentContext >& rxContext,
+ const Reference< beans::XPropertySet >& rxScriptingContext, SbModule* pModule, bool isAppScript )
+ :m_xContext( rxContext )
+ ,m_xScriptingContext( rxScriptingContext )
+ ,m_pModule( pModule )
+ ,m_bIsAppScript( isAppScript )
{
}
@@ -147,7 +151,7 @@ namespace basprov
{
SbMethod* pMethod = static_cast< SbMethod* >( pMethods->Get( static_cast< USHORT >( i ) ) );
if ( pMethod )
- pChildNodes[i] = static_cast< browse::XBrowseNode* >( new BasicMethodNodeImpl( pMethod, m_bIsAppScript ) );
+ pChildNodes[i] = static_cast< browse::XBrowseNode* >( new BasicMethodNodeImpl( m_xContext, m_xScriptingContext, pMethod, m_bIsAppScript ) );
}
}
}
diff --git a/scripting/source/basprov/basmodnode.hxx b/scripting/source/basprov/basmodnode.hxx
index 1a2b878dc948..31f9f594a180 100644
--- a/scripting/source/basprov/basmodnode.hxx
+++ b/scripting/source/basprov/basmodnode.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basmodnode.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: toconnor $ $Date: 2003-10-29 15:00:46 $
+ * last change: $Author: tbe $ $Date: 2003-11-07 13:49:38 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -62,9 +62,15 @@
#ifndef SCRIPTING_BASMODNODE_HXX
#define SCRIPTING_BASMODNODE_HXX
+#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
+#include <com/sun/star/beans/XPropertySet.hpp>
+#endif
#ifndef _DRAFTS_COM_SUN_STAR_SCRIPT_BROWSE_XBROWSENODE_HPP_
#include <drafts/com/sun/star/script/browse/XBrowseNode.hpp>
#endif
+#ifndef _COM_SUN_STAR_UNO_XCOMPONENTCONTEXT_HPP_
+#include <com/sun/star/uno/XComponentContext.hpp>
+#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
@@ -89,10 +95,15 @@ namespace basprov
class BasicModuleNodeImpl : public BasicModuleNodeImpl_BASE
{
private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xScriptingContext;
SbModule* m_pModule;
bool m_bIsAppScript;
+
public:
- BasicModuleNodeImpl( SbModule* pModule, bool isAppScript = true );
+ BasicModuleNodeImpl( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rxScriptingContext,
+ SbModule* pModule, bool isAppScript = true );
virtual ~BasicModuleNodeImpl();
// XBrowseNode
diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx
index 4c890832ae4c..edaf81fc0487 100644
--- a/scripting/source/basprov/basprov.cxx
+++ b/scripting/source/basprov/basprov.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: basprov.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: toconnor $ $Date: 2003-10-29 15:00:46 $
+ * last change: $Author: tbe $ $Date: 2003-11-07 13:45:18 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -479,18 +479,18 @@ namespace basprov
if ( m_bIsUserCtx && ( isLibLink == sal_False ) )
{
- pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) );
+ pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( m_xContext, m_xScriptingContext, pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) );
continue;
}
if ( !m_bIsUserCtx && ( isLibLink == sal_True ) )
{
- pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) );
+ pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( m_xContext, m_xScriptingContext, pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) );
continue;
}
}
else
{
- pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) );
+ pChildNodes[childsFound++] = static_cast< browse::XBrowseNode* >( new BasicLibraryNodeImpl( m_xContext, m_xScriptingContext, pBasicManager, xLibContainer, pLibNames[i],m_bIsAppScriptCtx ) );
}
}
if ( i != childsFound )
diff --git a/scripting/source/basprov/makefile.mk b/scripting/source/basprov/makefile.mk
index 6233768078a6..13140346b5af 100644
--- a/scripting/source/basprov/makefile.mk
+++ b/scripting/source/basprov/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: tbe $ $Date: 2003-09-23 10:02:53 $
+# last change: $Author: tbe $ $Date: 2003-11-07 13:44:27 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -99,6 +99,7 @@ SHL1STDLIBS= \
$(BASICLIB) \
$(SVTOOLLIB) \
$(TOOLSLIB) \
+ $(COMPHELPERLIB) \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(SALLIB)
diff --git a/scripting/source/inc/bcholder.hxx b/scripting/source/inc/bcholder.hxx
new file mode 100644
index 000000000000..7177da90c5cb
--- /dev/null
+++ b/scripting/source/inc/bcholder.hxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * $RCSfile: bcholder.hxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: tbe $ $Date: 2003-11-07 13:42:04 $
+ *
+ * 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_BCHOLDER_HXX
+#define SCRIPTING_BCHOLDER_HXX
+
+#ifndef _OSL_MUTEX_HXX_
+#include <osl/mutex.hxx>
+#endif
+#ifndef _CPPUHELPER_INTERFACECONTAINER_H_
+#include <cppuhelper/interfacecontainer.h>
+#endif
+
+
+//.........................................................................
+namespace scripting_helper
+{
+//.........................................................................
+
+ // ----------------------------------------------------
+ // class OBroadcastHelperHolder
+ // ----------------------------------------------------
+
+ class OBroadcastHelperHolder
+ {
+ protected:
+ ::cppu::OBroadcastHelper m_aBHelper;
+
+ public:
+ OBroadcastHelperHolder( ::osl::Mutex& rMutex ) : m_aBHelper( rMutex ) { }
+
+ ::cppu::OBroadcastHelper& GetBroadcastHelper() { return m_aBHelper; }
+ const ::cppu::OBroadcastHelper& GetBroadcastHelper() const { return m_aBHelper; }
+ };
+
+//.........................................................................
+} // namespace scripting_helper
+//.........................................................................
+
+#endif // SCRIPTING_BCHOLDER_HXX