summaryrefslogtreecommitdiff
path: root/scripting/source/basprov
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2010-10-13 10:51:50 +0100
committerNoel Power <noel.power@novell.com>2010-10-13 10:51:50 +0100
commit6db6a43ddc5a66f41f109b7995fd83adb5d35411 (patch)
treebe01c36438a39fdebd43608355671d2e6d120108 /scripting/source/basprov
parent20658054d8bd6380b4b175b552ccc1480c49d01c (diff)
parentd1a9ad8f4dc25817cea279262286cdfb421fe891 (diff)
Merge branch 'vba' fix conflics, trailing ws & tab issues
also removed some old headers ( which I need to add new ones for ) Conflicts: basic/source/classes/sbunoobj.cxx basic/source/classes/sbxmod.cxx xmloff/inc/xmlnmspe.hxx xmloff/inc/xmloff/xmltoken.hxx xmlscript/inc/xmlscript/xmldlg_imexp.hxx
Diffstat (limited to 'scripting/source/basprov')
-rw-r--r--scripting/source/basprov/basprov.cxx37
-rw-r--r--scripting/source/basprov/basscript.cxx72
-rw-r--r--scripting/source/basprov/basscript.hxx29
3 files changed, 121 insertions, 17 deletions
diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx
index 73f6abd1c87d..87e3c79181bf 100644
--- a/scripting/source/basprov/basprov.cxx
+++ b/scripting/source/basprov/basprov.cxx
@@ -369,7 +369,33 @@ namespace basprov
::rtl::OUString::createFromAscii( "location" ) );
sal_Int32 nIndex = 0;
- ::rtl::OUString aLibrary = aDescription.getToken( 0, (sal_Unicode)'.', nIndex );
+ // In some strange circumstances the Library name can have an
+ // apparantly illegal '.' in it ( in imported VBA )
+
+ BasicManager* pBasicMgr = NULL;
+ if ( aLocation.equals( ::rtl::OUString::createFromAscii("document") ) )
+ {
+ pBasicMgr = m_pDocBasicManager;
+ }
+ else if ( aLocation.equals( ::rtl::OUString::createFromAscii("application") ) )
+ {
+ pBasicMgr = m_pAppBasicManager;
+ }
+ rtl::OUString sProjectName;
+ if ( pBasicMgr )
+ sProjectName = pBasicMgr->GetName();
+
+ ::rtl::OUString aLibrary;
+ if ( sProjectName.getLength() && aDescription.match( sProjectName ) )
+ {
+ OSL_TRACE("LibraryName %s is part of the url %s",
+ rtl::OUStringToOString( sProjectName, RTL_TEXTENCODING_UTF8 ).getStr(),
+ rtl::OUStringToOString( aDescription, RTL_TEXTENCODING_UTF8 ).getStr() );
+ aLibrary = sProjectName;
+ nIndex = sProjectName.getLength() + 1;
+ }
+ else
+ aLibrary = aDescription.getToken( 0, (sal_Unicode)'.', nIndex );
::rtl::OUString aModule;
if ( nIndex != -1 )
aModule = aDescription.getToken( 0, (sal_Unicode)'.', nIndex );
@@ -379,15 +405,6 @@ namespace basprov
if ( aLibrary.getLength() != 0 && aModule.getLength() != 0 && aMethod.getLength() != 0 && aLocation.getLength() != 0 )
{
- BasicManager* pBasicMgr = NULL;
- if ( aLocation.equals( ::rtl::OUString::createFromAscii("document") ) )
- {
- pBasicMgr = m_pDocBasicManager;
- }
- else if ( aLocation.equals( ::rtl::OUString::createFromAscii("application") ) )
- {
- pBasicMgr = m_pAppBasicManager;
- }
if ( pBasicMgr )
{
diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx
index c6de155e3ed0..ca0b22d6c2c1 100644
--- a/scripting/source/basprov/basscript.cxx
+++ b/scripting/source/basprov/basscript.cxx
@@ -36,7 +36,10 @@
#include <basic/sbmeth.hxx>
#include <basic/basmgr.hxx>
#include <com/sun/star/script/provider/ScriptFrameworkErrorType.hpp>
-
+#include "bcholder.hxx"
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <map>
@@ -45,6 +48,7 @@ using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::script;
using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::beans;
extern ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar );
extern void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue );
@@ -54,6 +58,10 @@ extern void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any&
namespace basprov
{
//.........................................................................
+#define BASSCRIPT_PROPERTY_ID_CALLER 1
+#define BASSCRIPT_PROPERTY_CALLER ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Caller" ) )
+
+#define BASSCRIPT_DEFAULT_ATTRIBS() PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT
typedef ::std::map< sal_Int16, Any, ::std::less< sal_Int16 > > OutParamMap;
@@ -64,22 +72,28 @@ namespace basprov
// -----------------------------------------------------------------------------
BasicScriptImpl::BasicScriptImpl( const ::rtl::OUString& funcName, SbMethodRef xMethod )
- :m_xMethod( xMethod )
+ : ::scripting_helper::OBroadcastHelperHolder( m_aMutex )
+ ,OPropertyContainer( GetBroadcastHelper() )
+ ,m_xMethod( xMethod )
,m_funcName( funcName )
,m_documentBasicManager( NULL )
,m_xDocumentScriptContext()
{
+ registerProperty( BASSCRIPT_PROPERTY_CALLER, BASSCRIPT_PROPERTY_ID_CALLER, BASSCRIPT_DEFAULT_ATTRIBS(), &m_caller, ::getCppuType( &m_caller ) );
}
// -----------------------------------------------------------------------------
BasicScriptImpl::BasicScriptImpl( const ::rtl::OUString& funcName, SbMethodRef xMethod,
- BasicManager& documentBasicManager, const Reference< XScriptInvocationContext >& documentScriptContext )
- :m_xMethod( xMethod )
+ BasicManager& documentBasicManager, const Reference< XScriptInvocationContext >& documentScriptContext ) : ::scripting_helper::OBroadcastHelperHolder( m_aMutex )
+ ,OPropertyContainer( GetBroadcastHelper() )
+ ,m_xMethod( xMethod )
,m_funcName( funcName )
,m_documentBasicManager( &documentBasicManager )
,m_xDocumentScriptContext( documentScriptContext )
{
+ //
+ registerProperty( BASSCRIPT_PROPERTY_CALLER, BASSCRIPT_PROPERTY_ID_CALLER, BASSCRIPT_DEFAULT_ATTRIBS(), &m_caller, ::getCppuType( &m_caller ) );
}
// -----------------------------------------------------------------------------
@@ -88,6 +102,48 @@ namespace basprov
}
// -----------------------------------------------------------------------------
+ // XInterface
+ // -----------------------------------------------------------------------------
+
+ IMPLEMENT_FORWARD_XINTERFACE2( BasicScriptImpl, BasicScriptImpl_BASE, OPropertyContainer )
+
+ // -----------------------------------------------------------------------------
+ // XTypeProvider
+ // -----------------------------------------------------------------------------
+
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( BasicScriptImpl, BasicScriptImpl_BASE, OPropertyContainer )
+
+ // -----------------------------------------------------------------------------
+ // OPropertySetHelper
+ // -----------------------------------------------------------------------------
+
+ ::cppu::IPropertyArrayHelper& BasicScriptImpl::getInfoHelper( )
+ {
+ return *getArrayHelper();
+ }
+
+ // -----------------------------------------------------------------------------
+ // OPropertyArrayUsageHelper
+ // -----------------------------------------------------------------------------
+
+ ::cppu::IPropertyArrayHelper* BasicScriptImpl::createArrayHelper( ) const
+ {
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+ }
+
+ // -----------------------------------------------------------------------------
+ // XPropertySet
+ // -----------------------------------------------------------------------------
+
+ Reference< XPropertySetInfo > BasicScriptImpl::getPropertySetInfo( ) throw (RuntimeException)
+ {
+ Reference< XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
+ return xInfo;
+ }
+
+ // -----------------------------------------------------------------------------
// XScript
// -----------------------------------------------------------------------------
@@ -166,8 +222,14 @@ namespace basprov
if ( m_documentBasicManager && m_xDocumentScriptContext.is() )
aOldThisComponent = m_documentBasicManager->SetGlobalUNOConstant( "ThisComponent", makeAny( m_xDocumentScriptContext ) );
+ if ( m_caller.getLength() && m_caller[ 0 ].hasValue() )
+ {
+ SbxVariableRef xCallerVar = new SbxVariable( SbxVARIANT );
+ unoToSbxValue( static_cast< SbxVariable* >( xCallerVar ), m_caller[ 0 ] );
+ nErr = m_xMethod->Call( xReturn, xCallerVar );
+ }
+ else
nErr = m_xMethod->Call( xReturn );
-
if ( m_documentBasicManager && m_xDocumentScriptContext.is() )
m_documentBasicManager->SetGlobalUNOConstant( "ThisComponent", aOldThisComponent );
}
diff --git a/scripting/source/basprov/basscript.hxx b/scripting/source/basprov/basscript.hxx
index 4a3d6f1ab61d..177ceeacdea8 100644
--- a/scripting/source/basprov/basscript.hxx
+++ b/scripting/source/basprov/basscript.hxx
@@ -28,12 +28,14 @@
#ifndef SCRIPTING_BASSCRIPT_HXX
#define SCRIPTING_BASSCRIPT_HXX
+#include "bcholder.hxx"
#include <com/sun/star/script/provider/XScript.hpp>
#include <com/sun/star/document/XScriptInvocationContext.hpp>
#include <cppuhelper/implbase1.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
#include <basic/sbmeth.hxx>
-
class BasicManager;
//.........................................................................
@@ -49,7 +51,11 @@ namespace basprov
::com::sun::star::script::provider::XScript > BasicScriptImpl_BASE;
- class BasicScriptImpl : public BasicScriptImpl_BASE
+ class BasicScriptImpl : public BasicScriptImpl_BASE,
+ public ::scripting_helper::OMutexHolder,
+ public ::scripting_helper::OBroadcastHelperHolder,
+ public ::comphelper::OPropertyContainer,
+ public ::comphelper::OPropertyArrayUsageHelper< BasicScriptImpl >
{
private:
SbMethodRef m_xMethod;
@@ -57,6 +63,16 @@ namespace basprov
BasicManager* m_documentBasicManager;
::com::sun::star::uno::Reference< ::com::sun::star::document::XScriptInvocationContext >
m_xDocumentScriptContext;
+ // hack, OPropertyContainer doesn't allow you to define a property of unknown
+ // type ( I guess because an Any can't contain an Any... I've always wondered why?
+ // as its not unusual to do that in corba )
+ ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > m_caller;
+ protected:
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper( );
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
public:
BasicScriptImpl(
@@ -71,6 +87,12 @@ namespace basprov
);
virtual ~BasicScriptImpl();
+ // XInterface
+ DECLARE_XINTERFACE()
+
+ // XTypeProvider
+ DECLARE_XTYPEPROVIDER()
+
// XScript
virtual ::com::sun::star::uno::Any SAL_CALL invoke(
const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aParams,
@@ -80,6 +102,9 @@ namespace basprov
::com::sun::star::script::provider::ScriptFrameworkErrorException,
::com::sun::star::reflection::InvocationTargetException,
::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);
};
//.........................................................................