summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorobo <obo@openoffice.org>2010-06-22 05:59:20 +0200
committerobo <obo@openoffice.org>2010-06-22 05:59:20 +0200
commit852bcc1999cd69a2e68ce8ad04f85acc3412f1d5 (patch)
tree0e579cc908f6f357eb83ca442bbe30076bcfdfc2 /basic
parentecd5c7ba7b94ea51f49e2a80113ae7cea08c7812 (diff)
parentb6c1b13bb24fe05a69bc4c07909a254825cdadb1 (diff)
CWS-TOOLING: integrate CWS mib16
Diffstat (limited to 'basic')
-rw-r--r--basic/inc/basic/sbmod.hxx10
-rw-r--r--basic/inc/basic/sbobjmod.hxx18
-rw-r--r--basic/inc/basic/sbx.hxx2
-rw-r--r--basic/inc/basic/sbxdef.hxx4
-rw-r--r--basic/inc/basic/sbxvar.hxx11
-rwxr-xr-xbasic/prj/build.lst2
-rw-r--r--basic/source/basmgr/basmgr.cxx2
-rw-r--r--basic/source/classes/disas.cxx3
-rwxr-xr-xbasic/source/classes/sb.cxx81
-rwxr-xr-x[-rw-r--r--]basic/source/classes/sbunoobj.cxx288
-rw-r--r--basic/source/classes/sbxmod.cxx64
-rw-r--r--basic/source/comp/dim.cxx75
-rw-r--r--basic/source/comp/exprgen.cxx6
-rw-r--r--basic/source/comp/exprnode.cxx14
-rw-r--r--basic/source/comp/exprtree.cxx72
-rw-r--r--basic/source/comp/io.cxx37
-rw-r--r--basic/source/comp/parser.cxx62
-rw-r--r--basic/source/comp/symtbl.cxx2
-rw-r--r--basic/source/comp/token.cxx58
-rw-r--r--basic/source/inc/codegen.hxx2
-rw-r--r--basic/source/inc/dlgcont.hxx9
-rw-r--r--basic/source/inc/expr.hxx20
-rw-r--r--basic/source/inc/namecont.hxx9
-rw-r--r--basic/source/inc/opcodes.hxx1
-rw-r--r--basic/source/inc/parser.hxx3
-rw-r--r--basic/source/inc/runtime.hxx5
-rw-r--r--basic/source/inc/sbintern.hxx3
-rw-r--r--basic/source/inc/scriptcont.hxx9
-rw-r--r--basic/source/inc/symtbl.hxx6
-rw-r--r--basic/source/inc/token.hxx20
-rw-r--r--basic/source/runtime/dllmgr.cxx1159
-rw-r--r--basic/source/runtime/dllmgr.hxx73
-rw-r--r--basic/source/runtime/makefile.mk21
-rw-r--r--basic/source/runtime/methods1.cxx15
-rw-r--r--basic/source/runtime/os2.asm103
-rw-r--r--basic/source/runtime/rtlproto.hxx1
-rwxr-xr-xbasic/source/runtime/runtime.cxx7
-rw-r--r--basic/source/runtime/stdobj.cxx7
-rw-r--r--basic/source/runtime/step0.cxx37
-rw-r--r--basic/source/runtime/step1.cxx9
-rw-r--r--basic/source/runtime/step2.cxx32
-rw-r--r--basic/source/runtime/win.asm80
-rw-r--r--basic/source/runtime/wnt-mingw.s98
-rw-r--r--basic/source/runtime/wnt.asm100
-rw-r--r--basic/source/sbx/sbxvar.cxx57
-rw-r--r--basic/source/uno/dlgcont.cxx11
-rw-r--r--basic/source/uno/namecont.cxx18
-rw-r--r--basic/source/uno/scriptcont.cxx142
-rw-r--r--basic/util/makefile.mk1
49 files changed, 1774 insertions, 1095 deletions
diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx
index 9681149936..7f401ef69f 100644
--- a/basic/inc/basic/sbmod.hxx
+++ b/basic/inc/basic/sbmod.hxx
@@ -40,6 +40,7 @@ class SbiBreakpoints;
class SbiImage;
class SbProcedureProperty;
class SbIfaceMapperMethod;
+class SbClassModuleObject;
struct SbClassData;
class SbModuleImpl;
@@ -125,11 +126,12 @@ public:
BOOL LoadBinaryData( SvStream& );
BOOL ExceedsLegacyModuleSize();
void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const;
- BOOL IsVBACompat();
- void SetVBACompat( BOOL bCompat );
- INT32 GetModuleType() { return mnType; }
- void SetModuleType( INT32 nType ) { mnType = nType; }
+ BOOL IsVBACompat() const;
+ void SetVBACompat( BOOL bCompat );
+ INT32 GetModuleType() { return mnType; }
+ void SetModuleType( INT32 nType ) { mnType = nType; }
bool GetIsProxyModule() { return bIsProxyModule; }
+ bool createCOMWrapperForIface( ::com::sun::star::uno::Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject );
};
#ifndef __SB_SBMODULEREF_HXX
diff --git a/basic/inc/basic/sbobjmod.hxx b/basic/inc/basic/sbobjmod.hxx
index ad804dcfab..3d638a475f 100644
--- a/basic/inc/basic/sbobjmod.hxx
+++ b/basic/inc/basic/sbobjmod.hxx
@@ -62,6 +62,7 @@ public:
class SbUserFormModule : public SbObjModule
{
+ com::sun::star::script::ModuleInfo m_mInfo;
css::uno::Reference<css::lang::XEventListener> m_DialogListener;
css::uno::Reference<css::awt::XDialog> m_xDialog;
css::uno::Reference<css::frame::XModel> m_xModel;
@@ -70,7 +71,7 @@ class SbUserFormModule : public SbObjModule
SbUserFormModule( const SbUserFormModule& );
SbUserFormModule();
-protected:
+//protected:
virtual void InitObject();
public:
TYPEINFO();
@@ -85,8 +86,23 @@ public:
void triggerDeActivateEvent();
void triggerInitializeEvent();
void triggerTerminateEvent();
+
+ class SbUserFormModuleInstance* CreateInstance();
};
+class SbUserFormModuleInstance : public SbUserFormModule
+{
+ SbUserFormModule* m_pParentModule;
+
+public:
+ SbUserFormModuleInstance( SbUserFormModule* pParentModule, const String& rName,
+ const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat );
+
+ virtual BOOL IsClass( const String& ) const;
+ virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
+};
+
+
#ifndef __SB_SBOBJMODULEREF_HXX
#define __SB_SBOBJMODULEREF_HXX
diff --git a/basic/inc/basic/sbx.hxx b/basic/inc/basic/sbx.hxx
index 3f5a49f522..647aeea7f7 100644
--- a/basic/inc/basic/sbx.hxx
+++ b/basic/inc/basic/sbx.hxx
@@ -171,8 +171,8 @@ class SbxArray : public SbxBase
{
// #100883 Method to set method directly to parameter array
friend class SbMethod;
- friend class SbTypeFactory;
friend class SbClassModuleObject;
+ friend SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj );
void PutDirect( SbxVariable* pVar, UINT32 nIdx );
SbxArrayImpl* mpSbxArrayImpl; // Impl data
diff --git a/basic/inc/basic/sbxdef.hxx b/basic/inc/basic/sbxdef.hxx
index cf45aa8d03..42117ce78b 100644
--- a/basic/inc/basic/sbxdef.hxx
+++ b/basic/inc/basic/sbxdef.hxx
@@ -105,6 +105,9 @@ enum SbxDataType {
SbxUSERn = 2047 // last user defined data type
};
+const UINT32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000;
+const UINT32 SBX_FIXED_LEN_STRING_FLAG = 0x10000; // same value as above as no conflict possible
+
#endif
#ifndef _SBX_OPERATOR
@@ -313,6 +316,7 @@ enum SbxError { // Ergebnis einer Rechenoperation/Konversion
#define SBX_NO_BROADCAST 0x2000 // No broadcast on Get/Put
#define SBX_REFERENCE 0x4000 // Parameter is Reference (DLL-call)
#define SBX_NO_MODIFY 0x8000 // SetModified is suppressed
+#define SBX_WITH_EVENTS 0x0080 // Same value as unused SBX_HIDDEN
// Broadcaster-IDs:
#define SBX_HINT_DYING SFX_HINT_DYING
diff --git a/basic/inc/basic/sbxvar.hxx b/basic/inc/basic/sbxvar.hxx
index 2f890a01b8..0e44b07079 100644
--- a/basic/inc/basic/sbxvar.hxx
+++ b/basic/inc/basic/sbxvar.hxx
@@ -230,8 +230,6 @@ class SbxValueImpl;
class SbxValue : public SbxBase
{
- friend class SbiDllMgr; // BASIC-Runtime must access aData
-
SbxValueImpl* mpSbxValueImplImpl; // Impl data
// #55226 Transport additional infos
@@ -289,6 +287,8 @@ public:
const SbxValues& GetValues_Impl() const { return aData; }
virtual BOOL Put( const SbxValues& );
+ inline SbxValues * data() { return &aData; }
+
SbxINT64 GetCurrency() const;
SbxINT64 GetLong64() const;
SbxUINT64 GetULong64() const;
@@ -447,6 +447,9 @@ class SbxVariable : public SbxValue
String maName; // Name, if available
SbxArrayRef mpPar; // Parameter-Array, if set
USHORT nHash; // Hash-ID for search
+
+ SbxVariableImpl* getImpl( void );
+
protected:
SbxInfoRef pInfo; // Probably called information
sal_uIntPtr nUserData; // User data for Call()
@@ -492,6 +495,10 @@ public:
inline SbxObject* GetParent() { return pParent; }
virtual void SetParent( SbxObject* );
+ const String& GetDeclareClassName( void );
+ void SetDeclareClassName( const String& );
+ void SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener );
+
static USHORT MakeHashCode( const String& rName );
};
diff --git a/basic/prj/build.lst b/basic/prj/build.lst
index 9453154edf..c00a3d8412 100755
--- a/basic/prj/build.lst
+++ b/basic/prj/build.lst
@@ -1,4 +1,4 @@
-sb basic : l10n offuh oovbaapi svtools xmlscript framework NULL
+sb basic : l10n offuh oovbaapi svtools xmlscript framework salhelper NULL
sb basic usr1 - all sb_mkout NULL
sb basic\inc nmake - all sb_inc NULL
sb basic\source\app nmake - all sb_app sb_class sb_inc NULL
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index a18b9bb081..247a833b3e 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -1789,7 +1789,7 @@ bool BasicManager::GetGlobalUNOConstant( const sal_Char* _pAsciiName, ::com::sun
{
bool bRes = false;
StarBASIC* pStandardLib = GetStdLib();
- OSL_PRECOND( pStandardLib, "BasicManager::SetGlobalUNOConstant: no lib to insert into!" );
+ OSL_PRECOND( pStandardLib, "BasicManager::GetGlobalUNOConstant: no lib to read from!" );
if ( pStandardLib )
bRes = pStandardLib->GetUNOConstant( _pAsciiName, aOut );
return bRes;
diff --git a/basic/source/classes/disas.cxx b/basic/source/classes/disas.cxx
index cdb9c78523..82f3c08d61 100644
--- a/basic/source/classes/disas.cxx
+++ b/basic/source/classes/disas.cxx
@@ -89,7 +89,8 @@ static const char* pOp1[] = {
"INITFOREACH",
"VBASET",
"ERASE_CLEAR",
- "ARRAYACCESS"
+ "ARRAYACCESS",
+ "BYVAL"
};
static const char* pOp2[] = {
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index a7d1c50987..9be441e011 100755
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -321,23 +321,52 @@ SbxObject* SbOLEFactory::CreateObject( const String& rClassName )
}
-// Factory class to create user defined objects (type command)
-class SbTypeFactory : public SbxFactory
-{
- SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj );
+//========================================================================
+// SbFormFactory, show user forms by: dim as new <user form name>
+class SbFormFactory : public SbxFactory
+{
public:
virtual SbxBase* Create( UINT16 nSbxId, UINT32 = SBXCR_SBX );
virtual SbxObject* CreateObject( const String& );
};
-SbxBase* SbTypeFactory::Create( UINT16, UINT32 )
+SbxBase* SbFormFactory::Create( UINT16, UINT32 )
{
// Not supported
return NULL;
}
-SbxObject* SbTypeFactory::cloneTypeObjectImpl( const SbxObject& rTypeObj )
+SbxObject* SbFormFactory::CreateObject( const String& rClassName )
+{
+ static String aLoadMethodName( RTL_CONSTASCII_USTRINGPARAM("load") );
+
+ SbxObject* pRet = NULL;
+ SbModule* pMod = pMOD;
+ if( pMod )
+ {
+ SbxVariable* pVar = pMod->Find( rClassName, SbxCLASS_OBJECT );
+ if( pVar )
+ {
+ SbxBase* pObj = pVar->GetObject();
+ SbUserFormModule* pFormModule = PTR_CAST( SbUserFormModule, pObj );
+
+ if( pFormModule != NULL )
+ {
+ pFormModule->load();
+ SbUserFormModuleInstance* pFormInstance = pFormModule->CreateInstance();
+ pRet = pFormInstance;
+ }
+ }
+ }
+ return pRet;
+}
+
+
+//========================================================================
+// SbTypeFactory
+
+SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj )
{
SbxObject* pRet = new SbxObject( rTypeObj );
pRet->PutObject( pRet );
@@ -352,7 +381,8 @@ SbxObject* SbTypeFactory::cloneTypeObjectImpl( const SbxObject& rTypeObj )
if( pProp )
{
SbxProperty* pNewProp = new SbxProperty( *pProp );
- if( pVar->GetType() & SbxARRAY )
+ SbxDataType eVarType = pVar->GetType();
+ if( eVarType & SbxARRAY )
{
SbxBase* pParObj = pVar->GetObject();
SbxDimArray* pSource = PTR_CAST(SbxDimArray,pParObj);
@@ -379,12 +409,35 @@ SbxObject* SbTypeFactory::cloneTypeObjectImpl( const SbxObject& rTypeObj )
pNewProp->PutObject( pDest );
pNewProp->SetFlags( nSavFlags );
}
+ if( eVarType == SbxOBJECT )
+ {
+ SbxBase* pObjBase = pVar->GetObject();
+ SbxObject* pSrcObj = PTR_CAST(SbxObject,pObjBase);
+ SbxObject* pDestObj = NULL;
+ if( pSrcObj != NULL )
+ pDestObj = cloneTypeObjectImpl( *pSrcObj );
+ pNewProp->PutObject( pDestObj );
+ }
pProps->PutDirect( pNewProp, i );
}
}
return pRet;
}
+// Factory class to create user defined objects (type command)
+class SbTypeFactory : public SbxFactory
+{
+public:
+ virtual SbxBase* Create( UINT16 nSbxId, UINT32 = SBXCR_SBX );
+ virtual SbxObject* CreateObject( const String& );
+};
+
+SbxBase* SbTypeFactory::Create( UINT16, UINT32 )
+{
+ // Not supported
+ return NULL;
+}
+
SbxObject* SbTypeFactory::CreateObject( const String& rClassName )
{
SbxObject* pRet = NULL;
@@ -728,6 +781,8 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic )
AddFactory( pCLASSFAC );
pOLEFAC = new SbOLEFactory;
AddFactory( pOLEFAC );
+ pFORMFAC = new SbFormFactory;
+ AddFactory( pFORMFAC );
}
pRtl = new SbiStdObject( String( RTL_CONSTASCII_USTRINGPARAM(RTLNAME) ), this );
// Search via StarBasic is always global
@@ -748,15 +803,17 @@ StarBASIC::~StarBASIC()
if( !--GetSbData()->nInst )
{
RemoveFactory( pSBFAC );
- pSBFAC = NULL;
+ delete pSBFAC; pSBFAC = NULL;
RemoveFactory( pUNOFAC );
- pUNOFAC = NULL;
+ delete pUNOFAC; pUNOFAC = NULL;
RemoveFactory( pTYPEFAC );
- pTYPEFAC = NULL;
+ delete pTYPEFAC; pTYPEFAC = NULL;
RemoveFactory( pCLASSFAC );
- pCLASSFAC = NULL;
+ delete pCLASSFAC; pCLASSFAC = NULL;
RemoveFactory( pOLEFAC );
- pOLEFAC = NULL;
+ delete pOLEFAC; pOLEFAC = NULL;
+ RemoveFactory( pFORMFAC );
+ delete pFORMFAC; pFORMFAC = NULL;
#ifdef DBG_UTIL
// There is no need to clean SbiData at program end,
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index f80e5e082c..291aaa4f7d 100644..100755
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -49,6 +49,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/uno/DeploymentException.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
@@ -1074,8 +1075,19 @@ Any sbxToUnoValueImpl( SbxVariable* pVar, bool bBlockConversionToSmallestType =
if( eBaseType == SbxOBJECT )
{
SbxBaseRef xObj = (SbxBase*)pVar->GetObject();
- if( xObj.Is() && xObj->ISA(SbUnoAnyObject) )
- return ((SbUnoAnyObject*)(SbxBase*)xObj)->getValue();
+ if( xObj.Is() )
+ {
+ if( xObj->ISA(SbUnoAnyObject) )
+ return ((SbUnoAnyObject*)(SbxBase*)xObj)->getValue();
+ if( xObj->ISA(SbClassModuleObject) )
+ {
+ Any aRetAny;
+ SbClassModuleObject* pClassModuleObj = (SbClassModuleObject*)(SbxBase*)xObj;
+ SbModule* pClassModule = pClassModuleObj->getClassModule();
+ if( pClassModule->createCOMWrapperForIface( aRetAny, pClassModuleObj ) )
+ return aRetAny;
+ }
+ }
}
Type aType = getUnoTypeForSbxValue( pVar );
@@ -1581,12 +1593,18 @@ String getBasicObjectTypeName( SbxObject* pObj )
bool checkUnoObjectType( SbUnoObject* pUnoObj,
const String& aClass )
{
- bool result = false;
Any aToInspectObj = pUnoObj->getUnoAny();
TypeClass eType = aToInspectObj.getValueType().getTypeClass();
if( eType != TypeClass_INTERFACE )
return false;
const Reference< XInterface > x = *(Reference< XInterface >*)aToInspectObj.getValue();
+
+ // Return true for XInvocation based objects as interface type names don't count then
+ Reference< XInvocation > xInvocation( x, UNO_QUERY );
+ if( xInvocation.is() )
+ return true;
+
+ bool result = false;
Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY );
if( xTypeProvider.is() )
{
@@ -4135,3 +4153,267 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
refVar->PutObject( xUnoAnyObject );
}
+//==========================================================================
+
+typedef WeakImplHelper1< XInvocation > ModuleInvocationProxyHelper;
+
+class ModuleInvocationProxy : public ModuleInvocationProxyHelper
+{
+ ::rtl::OUString m_aPrefix;
+ SbxObjectRef m_xScopeObj;
+ bool m_bProxyIsClassModuleObject;
+
+public:
+ ModuleInvocationProxy( const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj );
+ ~ModuleInvocationProxy()
+ {}
+
+ // XInvocation
+ virtual Reference< XIntrospectionAccess > SAL_CALL getIntrospection() throw();
+ virtual void SAL_CALL setValue( const ::rtl::OUString& rProperty, const Any& rValue )
+ throw( UnknownPropertyException );
+ virtual Any SAL_CALL getValue( const ::rtl::OUString& rProperty )
+ throw( UnknownPropertyException );
+ virtual sal_Bool SAL_CALL hasMethod( const ::rtl::OUString& rName ) throw();
+ virtual sal_Bool SAL_CALL hasProperty( const ::rtl::OUString& rProp ) throw();
+
+ virtual Any SAL_CALL invoke( const ::rtl::OUString& rFunction,
+ const Sequence< Any >& rParams,
+ Sequence< sal_Int16 >& rOutParamIndex,
+ Sequence< Any >& rOutParam )
+ throw( CannotConvertException, InvocationTargetException );
+};
+
+ModuleInvocationProxy::ModuleInvocationProxy( const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj )
+ : m_aPrefix( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_") ) )
+ , m_xScopeObj( xScopeObj )
+{
+ m_bProxyIsClassModuleObject = xScopeObj.Is() ? xScopeObj->ISA(SbClassModuleObject) : false;
+}
+
+Reference< XIntrospectionAccess > SAL_CALL ModuleInvocationProxy::getIntrospection() throw()
+{
+ return Reference< XIntrospectionAccess >();
+}
+
+void SAL_CALL ModuleInvocationProxy::setValue( const ::rtl::OUString& rProperty, const Any& rValue ) throw( UnknownPropertyException )
+{
+ if( !m_bProxyIsClassModuleObject )
+ throw UnknownPropertyException();
+
+ NAMESPACE_VOS(OGuard) guard( Application::GetSolarMutex() );
+
+ ::rtl::OUString aPropertyFunctionName( RTL_CONSTASCII_USTRINGPARAM( "Property Set ") );
+ aPropertyFunctionName += m_aPrefix;
+ aPropertyFunctionName += rProperty;
+
+ SbxVariable* p = m_xScopeObj->Find( aPropertyFunctionName, SbxCLASS_METHOD );
+ SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL;
+ if( pMeth == NULL )
+ {
+ // TODO: Check vba behavior concernig missing function
+ //StarBASIC::Error( SbERR_NO_METHOD, aFunctionName );
+ throw UnknownPropertyException();
+ }
+
+ // Setup parameter
+ SbxArrayRef xArray = new SbxArray;
+ SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
+ unoToSbxValue( (SbxVariable*)xVar, rValue );
+ xArray->Put( xVar, 1 );
+
+ // Call property method
+ SbxVariableRef xValue = new SbxVariable;
+ pMeth->SetParameters( xArray );
+ pMeth->Call( xValue );
+ //aRet = sbxToUnoValue( xValue );
+ pMeth->SetParameters( NULL );
+
+ // TODO: OutParameter?
+
+ // throw InvocationTargetException();
+
+ //return aRet;
+
+}
+
+Any SAL_CALL ModuleInvocationProxy::getValue( const ::rtl::OUString& rProperty ) throw( UnknownPropertyException )
+{
+ if( !m_bProxyIsClassModuleObject )
+ throw UnknownPropertyException();
+
+ NAMESPACE_VOS(OGuard) guard( Application::GetSolarMutex() );
+
+ ::rtl::OUString aPropertyFunctionName( RTL_CONSTASCII_USTRINGPARAM( "Property Get ") );
+ aPropertyFunctionName += m_aPrefix;
+ aPropertyFunctionName += rProperty;
+
+ SbxVariable* p = m_xScopeObj->Find( aPropertyFunctionName, SbxCLASS_METHOD );
+ SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL;
+ if( pMeth == NULL )
+ {
+ // TODO: Check vba behavior concernig missing function
+ //StarBASIC::Error( SbERR_NO_METHOD, aFunctionName );
+ throw UnknownPropertyException();
+ }
+
+ // Call method
+ SbxVariableRef xValue = new SbxVariable;
+ pMeth->Call( xValue );
+ Any aRet = sbxToUnoValue( xValue );
+ return aRet;
+}
+
+sal_Bool SAL_CALL ModuleInvocationProxy::hasMethod( const ::rtl::OUString& ) throw()
+{
+ return sal_False;
+}
+
+sal_Bool SAL_CALL ModuleInvocationProxy::hasProperty( const ::rtl::OUString& ) throw()
+{
+ return sal_False;
+}
+
+Any SAL_CALL ModuleInvocationProxy::invoke( const ::rtl::OUString& rFunction,
+ const Sequence< Any >& rParams,
+ Sequence< sal_Int16 >&,
+ Sequence< Any >& )
+ throw( CannotConvertException, InvocationTargetException )
+{
+ NAMESPACE_VOS(OGuard) guard( Application::GetSolarMutex() );
+
+ Any aRet;
+ if( !m_xScopeObj.Is() )
+ return aRet;
+
+ ::rtl::OUString aFunctionName = m_aPrefix;
+ aFunctionName += rFunction;
+
+ SbxVariable* p = m_xScopeObj->Find( aFunctionName, SbxCLASS_METHOD );
+ SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL;
+ if( pMeth == NULL )
+ {
+ // TODO: Check vba behavior concernig missing function
+ //StarBASIC::Error( SbERR_NO_METHOD, aFunctionName );
+ return aRet;
+ }
+
+ // Setup parameters
+ SbxArrayRef xArray;
+ sal_Int32 nParamCount = rParams.getLength();
+ if( nParamCount )
+ {
+ xArray = new SbxArray;
+ const Any *pArgs = rParams.getConstArray();
+ for( sal_Int32 i = 0 ; i < nParamCount ; i++ )
+ {
+ SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
+ unoToSbxValue( (SbxVariable*)xVar, pArgs[i] );
+ xArray->Put( xVar, sal::static_int_cast< USHORT >(i+1) );
+ }
+ }
+
+ // Call method
+ SbxVariableRef xValue = new SbxVariable;
+ if( xArray.Is() )
+ pMeth->SetParameters( xArray );
+ pMeth->Call( xValue );
+ aRet = sbxToUnoValue( xValue );
+ pMeth->SetParameters( NULL );
+
+ // TODO: OutParameter?
+
+ return aRet;
+}
+
+Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::OUString& aVBAType,
+ const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj )
+{
+ Reference< XInterface > xRet;
+
+ Reference< XComponentContext > xContext = getComponentContext_Impl();
+ Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
+
+ Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPrefix, xScopeObj );
+
+ Sequence<Any> args( 3 );
+ args[0] <<= aControlAny;
+ args[1] <<= aVBAType;
+ args[2] <<= xProxy;
+
+ try
+ {
+ xRet = xServiceMgr->createInstanceWithArgumentsAndContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.UnoComListener")),
+ args, xContext );
+ }
+ catch( const Exception& )
+ {
+ implHandleAnyException( ::cppu::getCaughtException() );
+ }
+
+ return xRet;
+}
+
+// Handle module implements mechanism for OLE types
+bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject )
+{
+ // For now: Take first interface that allows to instantiate COM wrapper
+ // TODO: Check if support for multiple interfaces is needed
+
+ Reference< XComponentContext > xContext = getComponentContext_Impl();
+ Reference< XMultiComponentFactory > xServiceMgr( xContext->getServiceManager() );
+ Reference< XSingleServiceFactory > xComImplementsFactory
+ (
+ xServiceMgr->createInstanceWithContext(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.custom.ComImplementsFactory")), xContext ),
+ UNO_QUERY
+ );
+ if( !xComImplementsFactory.is() )
+ return false;
+
+ bool bSuccess = false;
+
+ SbxArray* pModIfaces = pClassData->mxIfaces;
+ USHORT nCount = pModIfaces->Count();
+ for( USHORT i = 0 ; i < nCount ; ++i )
+ {
+ SbxVariable* pVar = pModIfaces->Get( i );
+ ::rtl::OUString aIfaceName = pVar->GetName();
+
+ if( aIfaceName.getLength() != 0 )
+ {
+ ::rtl::OUString aPureIfaceName = aIfaceName;
+ sal_Int32 indexLastDot = aIfaceName.lastIndexOf('.');
+ if ( indexLastDot > -1 )
+ aPureIfaceName = aIfaceName.copy( indexLastDot + 1 );
+
+ Reference< XInvocation > xProxy = new ModuleInvocationProxy( aPureIfaceName, pProxyClassModuleObject );
+
+ Sequence<Any> args( 2 );
+ args[0] <<= aIfaceName;
+ args[1] <<= xProxy;
+
+ Reference< XInterface > xRet;
+ bSuccess = false;
+ try
+ {
+ xRet = xComImplementsFactory->createInstanceWithArguments( args );
+ bSuccess = true;
+ }
+ catch( const Exception& )
+ {
+ implHandleAnyException( ::cppu::getCaughtException() );
+ }
+
+ if( bSuccess )
+ {
+ o_rRetAny <<= xRet;
+ break;
+ }
+ }
+ }
+
+ return bSuccess;
+}
+
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 8c3ef89017..79ab2071c3 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -190,6 +190,11 @@ SbModule::SbModule( const String& rName, BOOL bVBACompat )
SetName( rName );
SetFlag( SBX_EXTSEARCH | SBX_GBLSEARCH );
SetModuleType( script::ModuleType::NORMAL );
+
+ // #i92642: Set name property to intitial name
+ SbxVariable* pNameProp = pProps->Find( String( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_PROPERTY );
+ if( pNameProp != NULL )
+ pNameProp->PutString( GetName() );
}
SbModule::~SbModule()
@@ -366,7 +371,7 @@ SbxVariable* SbModule::Find( const XubString& rName, SbxClassType t )
{
// make sure a search in an uninstatiated class module will fail
SbxVariable* pRes = SbxObject::Find( rName, t );
- if ( bIsProxyModule )
+ if ( bIsProxyModule && !GetSbData()->bRunInit )
return NULL;
if( !pRes && pImage )
{
@@ -452,7 +457,19 @@ void SbModule::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
}
}
else
- SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
+ {
+ // #i92642: Special handling for name property to avoid
+ // side effects when using name as variable implicitely
+ bool bForwardToSbxObject = true;
+
+ ULONG nId = pHint->GetId();
+ if( (nId == SBX_HINT_DATAWANTED || nId == SBX_HINT_DATACHANGED) &&
+ pVar->GetName().EqualsIgnoreCaseAscii( "name" ) )
+ bForwardToSbxObject = false;
+
+ if( bForwardToSbxObject )
+ SbxObject::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
+ }
}
}
@@ -646,7 +663,7 @@ void ClearUnoObjectsInRTL_Impl( StarBASIC* pBasic )
if( ((StarBASIC*)p) != pBasic )
ClearUnoObjectsInRTL_Impl_Rek( (StarBASIC*)p );
}
-BOOL SbModule::IsVBACompat()
+BOOL SbModule::IsVBACompat() const
{
return mbVBACompat;
}
@@ -1710,18 +1727,20 @@ public:
};
SbUserFormModule::SbUserFormModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsCompat )
- :SbObjModule( rName, mInfo, bIsCompat ), mbInit( false )
+ : SbObjModule( rName, mInfo, bIsCompat )
+ , m_mInfo( mInfo )
+ , mbInit( false )
{
- m_xModel.set( mInfo.ModuleObject, uno::UNO_QUERY_THROW );
+ m_xModel.set( mInfo.ModuleObject, uno::UNO_QUERY_THROW );
}
void SbUserFormModule::ResetApiObj()
{
- if ( m_xDialog.is() ) // probably someone close the dialog window
+ if ( m_xDialog.is() ) // probably someone close the dialog window
{
- triggerTerminateEvent();
- }
- pDocObject = NULL;
+ triggerTerminateEvent();
+ }
+ pDocObject = NULL;
m_xDialog = NULL;
}
@@ -1807,6 +1826,33 @@ void SbUserFormModule::triggerTerminateEvent( void )
mbInit=false;
}
+SbUserFormModuleInstance* SbUserFormModule::CreateInstance()
+{
+ SbUserFormModuleInstance* pInstance = new SbUserFormModuleInstance( this, GetName(), m_mInfo, IsVBACompat() );
+ return pInstance;
+}
+
+SbUserFormModuleInstance::SbUserFormModuleInstance( SbUserFormModule* pParentModule,
+ const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat )
+ : SbUserFormModule( rName, mInfo, bIsVBACompat )
+ , m_pParentModule( pParentModule )
+{
+}
+
+BOOL SbUserFormModuleInstance::IsClass( const XubString& rName ) const
+{
+ BOOL bParentNameMatches = m_pParentModule->GetName().EqualsIgnoreCaseAscii( rName );
+ BOOL bRet = bParentNameMatches || SbxObject::IsClass( rName );
+ return bRet;
+}
+
+SbxVariable* SbUserFormModuleInstance::Find( const XubString& rName, SbxClassType t )
+{
+ SbxVariable* pVar = m_pParentModule->Find( rName, t );
+ return pVar;
+}
+
+
void SbUserFormModule::load()
{
OSL_TRACE("** load() ");
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index 36bbb8d551..b5131c99f1 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -1,4 +1,4 @@
- /*************************************************************************
+/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@@ -30,6 +30,8 @@
#include <basic/sbx.hxx>
#include "sbcomp.hxx"
+SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj );
+
// Deklaration einer Variablen
// Bei Fehlern wird bis zum Komma oder Newline geparst.
// Returnwert: eine neue Instanz, die eingefuegt und dann geloescht wird.
@@ -37,6 +39,12 @@
SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, BOOL bStatic, BOOL bConst )
{
+ bool bWithEvents = false;
+ if( Peek() == WITHEVENTS )
+ {
+ Next();
+ bWithEvents = true;
+ }
if( !TestSymbol() ) return NULL;
SbxDataType t = eScanType;
SbiSymDef* pDef = bConst ? new SbiConstDef( aSym ) : new SbiSymDef( aSym );
@@ -47,6 +55,8 @@ SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, BOOL bStatic, BOOL bConst )
pDef->SetType( t );
if( bStatic )
pDef->SetStatic();
+ if( bWithEvents )
+ pDef->SetWithEvents();
TypeDecl( *pDef );
if( !ppDim && pDim )
{
@@ -107,8 +117,10 @@ void SbiParser::TypeDecl( SbiSymDef& rDef, BOOL bAsNewAlreadyParsed )
Next();
SbiConstExpression aSize( this );
nSize = aSize.GetShortValue();
- if( nSize < 0 )
+ if( nSize < 0 || (bVBASupportOn && nSize <= 0) )
Error( SbERR_OUT_OF_RANGE );
+ else
+ rDef.SetFixedStringLength( nSize );
}
}
break;
@@ -209,7 +221,7 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic )
// #110004 It can also be a sub/function
if( !bConst && (eCurTok == SUB || eCurTok == FUNCTION || eCurTok == PROPERTY ||
- eCurTok == STATIC || eCurTok == ENUM || eCurTok == DECLARE) )
+ eCurTok == STATIC || eCurTok == ENUM || eCurTok == DECLARE || eCurTok == TYPE) )
{
// Next token is read here, because !bConst
bool bPrivate = ( eFirstTok == PRIVATE );
@@ -244,6 +256,13 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic )
DefDeclare( bPrivate );
return;
}
+ // #i109049
+ else if( eCurTok == TYPE )
+ {
+ Next();
+ DefType( bPrivate );
+ return;
+ }
}
#ifdef SHARED
@@ -349,9 +368,15 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic )
break;
default: eOp2 = _LOCAL;
}
- aGen.Gen(
- eOp2, pDef->GetId(),
- sal::static_int_cast< UINT16 >( pDef->GetType() ) );
+ UINT32 nOpnd2 = sal::static_int_cast< UINT16 >( pDef->GetType() );
+ if( pDef->IsWithEvents() )
+ nOpnd2 |= SBX_TYPE_WITH_EVENTS_FLAG;
+
+ short nFixedStringLength = pDef->GetFixedStringLength();
+ if( nFixedStringLength >= 0 )
+ nOpnd2 |= (SBX_FIXED_LEN_STRING_FLAG + (UINT32(nFixedStringLength) << 17)); // len = all bits above 0x10000
+
+ aGen.Gen( eOp2, pDef->GetId(), nOpnd2 );
}
// Initialisierung fuer selbstdefinierte Datentypen
@@ -473,7 +498,7 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic )
// d.h. pPool muss immer am Schleifen-Ende zurueckgesetzt werden.
// auch bei break
pPool = pOldPool;
- continue; // MyBreak überspingen
+ continue; // MyBreak überspingen
MyBreak:
pPool = pOldPool;
break;
@@ -506,18 +531,7 @@ void SbiParser::Erase()
{
while( !bAbort )
{
- if( !TestSymbol() ) return;
- String aName( aSym );
- SbxDataType eType = eScanType;
- SbiSymDef* pDef = pPool->Find( aName );
- if( !pDef )
- {
- if( bExplicit )
- Error( SbERR_UNDEF_VAR, aName );
- pDef = pPool->AddSym( aName );
- pDef->SetType( eType );
- }
- SbiExpression aExpr( this, *pDef );
+ SbiExpression aExpr( this, SbLVALUE );
aExpr.Gen();
aGen.Gen( _ERASE );
if( !TestComma() ) break;
@@ -576,12 +590,14 @@ void SbiParser::DefType( BOOL bPrivate )
}
if( pElem )
{
- SbxArray *pTypeMembers = pType -> GetProperties();
- if (pTypeMembers -> Find (pElem->GetName(),SbxCLASS_DONTCARE))
+ SbxArray *pTypeMembers = pType->GetProperties();
+ String aElemName = pElem->GetName();
+ if( pTypeMembers->Find( aElemName, SbxCLASS_DONTCARE) )
Error (SbERR_VAR_DEFINED);
else
{
- SbxProperty *pTypeElem = new SbxProperty (pElem->GetName(),pElem->GetType());
+ SbxDataType eElemType = pElem->GetType();
+ SbxProperty *pTypeElem = new SbxProperty( aElemName, eElemType );
if( pDim )
{
SbxDimArray* pArray = new SbxDimArray( pElem->GetType() );
@@ -618,6 +634,21 @@ void SbiParser::DefType( BOOL bPrivate )
pTypeElem->PutObject( pArray );
pTypeElem->SetFlags( nSavFlags );
}
+ // Nested user type?
+ if( eElemType == SbxOBJECT )
+ {
+ USHORT nElemTypeId = pElem->GetTypeId();
+ if( nElemTypeId != 0 )
+ {
+ String aTypeName( aGblStrings.Find( nElemTypeId ) );
+ SbxObject* pTypeObj = static_cast< SbxObject* >( rTypeArray->Find( aTypeName, SbxCLASS_OBJECT ) );
+ if( pTypeObj != NULL )
+ {
+ SbxObject* pCloneObj = cloneTypeObjectImpl( *pTypeObj );
+ pTypeElem->PutObject( pCloneObj );
+ }
+ }
+ }
delete pDim;
pTypeMembers->Insert( pTypeElem, pTypeMembers->Count() );
}
diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx
index 5e28d95ac0..82b2d39dcf 100644
--- a/basic/source/comp/exprgen.cxx
+++ b/basic/source/comp/exprgen.cxx
@@ -148,6 +148,10 @@ void SbiExprNode::Gen( RecursiveMode eRecMode )
pLeft->Gen();
pGen->Gen( _TESTCLASS, nTypeStrId );
}
+ else if( IsNew() )
+ {
+ pGen->Gen( _CREATE, 0, nTypeStrId );
+ }
else
{
pLeft->Gen();
@@ -285,6 +289,8 @@ void SbiExpression::Gen( RecursiveMode eRecMode )
// AB: 17.12.1995, Spezialbehandlung fuer WITH
// Wenn pExpr == .-Ausdruck in With, zunaechst Gen fuer Basis-Objekt
pExpr->Gen( eRecMode );
+ if( bByVal )
+ pParser->aGen.Gen( _BYVAL );
if( bBased )
{
USHORT uBase = pParser->nBase;
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index 2ae9903fec..bf891bc5a2 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -100,6 +100,15 @@ SbiExprNode::SbiExprNode( SbiParser* p, SbiExprNode* l, USHORT nId )
nTypeStrId = nId;
}
+// new <type>
+SbiExprNode::SbiExprNode( SbiParser* p, USHORT nId )
+{
+ BaseInit( p );
+
+ eType = SbxOBJECT;
+ eNodeType = SbxNEW;
+ nTypeStrId = nId;
+}
// AB: 17.12.95, Hilfsfunktion fuer Ctor fuer einheitliche Initialisierung
void SbiExprNode::BaseInit( SbiParser* p )
@@ -253,7 +262,8 @@ void SbiExprNode::CollectBits()
void SbiExprNode::FoldConstants()
{
if( IsOperand() || eTok == LIKE ) return;
- pLeft->FoldConstants();
+ if( pLeft )
+ pLeft->FoldConstants();
if( pRight )
{
pRight->FoldConstants();
@@ -431,7 +441,7 @@ void SbiExprNode::FoldConstants()
}
}
}
- else if( pLeft->IsNumber() )
+ else if( pLeft && pLeft->IsNumber() )
{
nVal = pLeft->nVal;
delete pLeft;
diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index eafe38dcdb..604ac61745 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -38,7 +38,8 @@
|*
***************************************************************************/
-SbiExpression::SbiExpression( SbiParser* p, SbiExprType t, SbiExprMode eMode )
+SbiExpression::SbiExpression( SbiParser* p, SbiExprType t,
+ SbiExprMode eMode, const KeywordSymbolInfo* pKeywordSymbolInfo )
{
pParser = p;
bError = bByVal = bBased = bBracket = FALSE;
@@ -46,7 +47,7 @@ SbiExpression::SbiExpression( SbiParser* p, SbiExprType t, SbiExprMode eMode )
eCurExpr = t;
m_eMode = eMode;
pNext = NULL;
- pExpr = (t != SbSTDEXPR ) ? Term() : Boolean();
+ pExpr = (t != SbSTDEXPR ) ? Term( pKeywordSymbolInfo ) : Boolean();
if( t != SbSYMBOL )
pExpr->Optimize();
if( t == SbLVALUE && !pExpr->IsLvalue() )
@@ -114,7 +115,7 @@ static BOOL DoParametersFollow( SbiParser* p, SbiExprType eCurExpr, SbiToken eTo
if( !p->WhiteSpace() || eCurExpr != SbSYMBOL )
return FALSE;
if ( eTok == NUMBER || eTok == MINUS || eTok == FIXSTRING
- || eTok == SYMBOL || eTok == COMMA || eTok == DOT || eTok == NOT )
+ || eTok == SYMBOL || eTok == COMMA || eTok == DOT || eTok == NOT || eTok == BYVAL )
{
return TRUE;
}
@@ -177,7 +178,7 @@ static SbiSymDef* AddSym
// Zur Zeit sind sogar Keywords zugelassen (wg. gleichnamiger Dflt-Properties)
-SbiExprNode* SbiExpression::Term( void )
+SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo )
{
if( pParser->Peek() == DOT )
{
@@ -204,11 +205,11 @@ SbiExprNode* SbiExpression::Term( void )
return pNd;
}
- SbiToken eTok = pParser->Next();
+ SbiToken eTok = (pKeywordSymbolInfo == NULL) ? pParser->Next() : pKeywordSymbolInfo->m_eTok;
// Anfang des Parsings merken
pParser->LockColumn();
- String aSym( pParser->GetSym() );
- SbxDataType eType = pParser->GetType();
+ String aSym( (pKeywordSymbolInfo == NULL) ? pParser->GetSym() : pKeywordSymbolInfo->m_aKeywordSymbol );
+ SbxDataType eType = (pKeywordSymbolInfo == NULL) ? pParser->GetType() : pKeywordSymbolInfo->m_eSbxDataType;
SbiParameters* pPar = NULL;
SbiExprListVector* pvMoreParLcl = NULL;
// Folgen Parameter?
@@ -280,6 +281,12 @@ SbiExprNode* SbiExpression::Term( void )
// AB 31.3.1996: In Parser-Methode ausgelagert
// (wird auch in SbiParser::DefVar() in DIM.CXX benoetigt)
pDef = pParser->CheckRTLForSym( aSym, eType );
+
+ // #i109184: Check if symbol is or later will be defined inside module
+ SbModule& rMod = pParser->aGen.GetModule();
+ SbxArray* pModMethods = rMod.GetMethods();
+ if( pModMethods->Find( aSym, SbxCLASS_DONTCARE ) )
+ pDef = NULL;
}
if( !pDef )
{
@@ -417,13 +424,27 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj )
String aSym( pParser->GetSym() );
SbxDataType eType = pParser->GetType();
SbiParameters* pPar = NULL;
+ SbiExprListVector* pvMoreParLcl = NULL;
eTok = pParser->Peek();
// Parameter?
if( DoParametersFollow( pParser, eCurExpr, eTok ) )
{
- pPar = new SbiParameters( pParser );
+ bool bStandaloneExpression = false;
+ pPar = new SbiParameters( pParser, bStandaloneExpression );
bError |= !pPar->IsValid();
eTok = pParser->Peek();
+
+ // i109624 check for additional sets of parameters
+ while( eTok == LPAREN )
+ {
+ if( pvMoreParLcl == NULL )
+ pvMoreParLcl = new SbiExprListVector();
+ SbiParameters* pAddPar = new SbiParameters( pParser );
+ pvMoreParLcl->push_back( pAddPar );
+ bError |= !pPar->IsValid();
+ eTok = pParser->Peek();
+ }
+
}
BOOL bObj = BOOL( ( eTok == DOT || eTok == EXCLAM ) && !pParser->WhiteSpace() );
if( bObj )
@@ -450,6 +471,7 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj )
SbiExprNode* pNd = new SbiExprNode( pParser, *pDef, eType );
pNd->aVar.pPar = pPar;
+ pNd->aVar.pvMorePar = pvMoreParLcl;
if( bObj )
{
// Falls wir etwas mit Punkt einscannen, muss der
@@ -483,7 +505,7 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj )
// Funktionen
// geklammerte Ausdruecke
-SbiExprNode* SbiExpression::Operand()
+SbiExprNode* SbiExpression::Operand( bool bUsedForTypeOf )
{
SbiExprNode *pRes;
SbiToken eTok;
@@ -494,7 +516,7 @@ SbiExprNode* SbiExpression::Operand()
case SYMBOL:
pRes = Term();
// process something like "IF Not r Is Nothing Then .."
- if( pParser->IsVBASupportOn() && pParser->Peek() == IS )
+ if( !bUsedForTypeOf && pParser->IsVBASupportOn() && pParser->Peek() == IS )
{
eTok = pParser->Next();
pRes = new SbiExprNode( pParser, pRes, eTok, Like() );
@@ -576,7 +598,8 @@ SbiExprNode* SbiExpression::Unary()
case TYPEOF:
{
pParser->Next();
- SbiExprNode* pObjNode = Operand();
+ bool bUsedForTypeOf = true;
+ SbiExprNode* pObjNode = Operand( bUsedForTypeOf );
pParser->TestToken( IS );
String aDummy;
SbiSymDef* pTypeDef = new SbiSymDef( aDummy );
@@ -584,6 +607,15 @@ SbiExprNode* SbiExpression::Unary()
pNd = new SbiExprNode( pParser, pObjNode, pTypeDef->GetTypeId() );
break;
}
+ case NEW:
+ {
+ pParser->Next();
+ String aStr;
+ SbiSymDef* pTypeDef = new SbiSymDef( aStr );
+ pParser->TypeDecl( *pTypeDef, TRUE );
+ pNd = new SbiExprNode( pParser, pTypeDef->GetTypeId() );
+ break;
+ }
default:
pNd = Operand();
}
@@ -938,6 +970,14 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa
// Benannte Argumente: entweder .name= oder name:=
else
{
+ bool bByVal = false;
+ if( eTok == BYVAL )
+ {
+ bByVal = true;
+ pParser->Next();
+ eTok = pParser->Peek();
+ }
+
if( bAssumeExprLParenMode )
{
pExpr = new SbiExpression( pParser, SbSTDEXPR, EXPRMODE_LPAREN_PENDING );
@@ -961,12 +1001,22 @@ SbiParameters::SbiParameters( SbiParser* p, BOOL bStandaloneExpression, BOOL bPa
{
bBracket = TRUE;
delete pExpr;
+ if( bByVal )
+ pParser->Error( SbERR_LVALUE_EXPECTED );
return;
}
}
else
pExpr = new SbiExpression( pParser );
+ if( bByVal )
+ {
+ if( !pExpr->IsLvalue() )
+ pParser->Error( SbERR_LVALUE_EXPECTED );
+ else
+ pExpr->SetByVal();
+ }
+
//pExpr = bConst ? new SbiConstExpression( pParser )
// : new SbiExpression( pParser );
if( !bAssumeArrayMode )
diff --git a/basic/source/comp/io.cxx b/basic/source/comp/io.cxx
index 7575381c24..c7ed83c677 100644
--- a/basic/source/comp/io.cxx
+++ b/basic/source/comp/io.cxx
@@ -115,6 +115,30 @@ void SbiParser::Write()
aGen.Gen( _CHAN0 );
}
+
+// #i92642 Handle LINE keyword outside ::Next()
+void SbiParser::Line()
+{
+ // #i92642: Special handling to allow name as symbol
+ if( Peek() == INPUT )
+ {
+ Next();
+ LineInput();
+ }
+ else
+ {
+ aGen.Statement();
+
+ KeywordSymbolInfo aInfo;
+ aInfo.m_aKeywordSymbol = String( RTL_CONSTASCII_USTRINGPARAM( "line" ) );
+ aInfo.m_eSbxDataType = GetType();
+ aInfo.m_eTok = SYMBOL;
+
+ Symbol( &aInfo );
+ }
+}
+
+
// LINE INPUT [prompt], var$
void SbiParser::LineInput()
@@ -288,6 +312,19 @@ void SbiParser::Open()
void SbiParser::Name()
{
+ // #i92642: Special handling to allow name as symbol
+ if( Peek() == EQ )
+ {
+ aGen.Statement();
+
+ KeywordSymbolInfo aInfo;
+ aInfo.m_aKeywordSymbol = String( RTL_CONSTASCII_USTRINGPARAM( "name" ) );
+ aInfo.m_eSbxDataType = GetType();
+ aInfo.m_eTok = SYMBOL;
+
+ Symbol( &aInfo );
+ return;
+ }
SbiExpression aExpr1( this );
TestToken( AS );
SbiExpression aExpr2( this );
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index eecc2291e3..83e7bbd604 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -83,6 +83,7 @@ static SbiStatement StmntTable [] = {
{ IMPLEMENTS, &SbiParser::Implements, Y, N, }, // IMPLEMENTS
{ INPUT, &SbiParser::Input, N, Y, }, // INPUT
{ LET, &SbiParser::Assign, N, Y, }, // LET
+{ LINE, &SbiParser::Line, N, Y, }, // LINE, -> LINE INPUT (#i92642)
{ LINEINPUT,&SbiParser::LineInput, N, Y, }, // LINE INPUT
{ LOOP, &SbiParser::BadBlock, N, Y, }, // LOOP
{ LSET, &SbiParser::LSet, N, Y, }, // LSET
@@ -237,7 +238,9 @@ void SbiParser::Exit()
SbiToken eTok = Next();
for( SbiParseStack* p = pStack; p; p = p->pNext )
{
- if( eTok == p->eExitTok )
+ SbiToken eExitTok = p->eExitTok;
+ if( eTok == eExitTok ||
+ (eTok == PROPERTY && (eExitTok == GET || eExitTok == LET) ) ) // #i109051
{
p->nChain = aGen.Gen( _JUMP, p->nChain );
return;
@@ -367,7 +370,10 @@ BOOL SbiParser::Parse()
}
// Ende des Parsings?
- if( eCurTok == eEndTok )
+ if( eCurTok == eEndTok ||
+ ( bVBASupportOn && // #i109075
+ (eCurTok == ENDFUNC || eCurTok == ENDPROPERTY || eCurTok == ENDSUB) &&
+ (eEndTok == ENDFUNC || eEndTok == ENDPROPERTY || eEndTok == ENDSUB) ) )
{
Next();
if( eCurTok != NIL )
@@ -477,10 +483,10 @@ SbiExprNode* SbiParser::GetWithVar()
// Zuweisung oder Subroutine Call
-void SbiParser::Symbol()
+void SbiParser::Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo )
{
SbiExprMode eMode = bVBASupportOn ? EXPRMODE_STANDALONE : EXPRMODE_STANDARD;
- SbiExpression aVar( this, SbSYMBOL, eMode );
+ SbiExpression aVar( this, SbSYMBOL, eMode, pKeywordSymbolInfo );
bool bEQ = ( Peek() == EQ );
if( !bEQ && bVBASupportOn && aVar.IsBracket() )
@@ -704,11 +710,37 @@ void SbiParser::Implements()
return;
}
- if( TestSymbol() )
+ Peek();
+ if( eCurTok != SYMBOL )
+ {
+ Error( SbERR_SYMBOL_EXPECTED );
+ return;
+ }
+
+ String aImplementedIface = aSym;
+ Next();
+ if( Peek() == DOT )
{
- String aImplementedIface = GetSym();
- aIfaceVector.push_back( aImplementedIface );
+ String aDotStr( '.' );
+ while( Peek() == DOT )
+ {
+ aImplementedIface += aDotStr;
+ Next();
+ SbiToken ePeekTok = Peek();
+ if( ePeekTok == SYMBOL || IsKwd( ePeekTok ) )
+ {
+ Next();
+ aImplementedIface += aSym;
+ }
+ else
+ {
+ Next();
+ Error( SbERR_SYMBOL_EXPECTED );
+ break;
+ }
+ }
}
+ aIfaceVector.push_back( aImplementedIface );
}
void SbiParser::EnableCompatibility()
@@ -745,12 +777,16 @@ void SbiParser::Option()
break;
}
case COMPARE:
- switch( Next() )
- {
- case TEXT: bText = TRUE; return;
- case BINARY: bText = FALSE; return;
- default:;
- } // Fall thru!
+ {
+ SbiToken eTok = Next();
+ if( eTok == BINARY )
+ bText = FALSE;
+ else if( eTok == SYMBOL && GetSym().EqualsIgnoreCaseAscii("text") )
+ bText = TRUE;
+ else
+ Error( SbERR_EXPECTED, "Text/Binary" );
+ break;
+ }
case COMPATIBLE:
EnableCompatibility();
break;
diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index 08703e7036..a09cc4490b 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -300,12 +300,14 @@ SbiSymDef::SbiSymDef( const String& rName ) : aName( rName )
bStatic =
bOpt =
bParamArray =
+ bWithEvents =
bByVal =
bChained =
bGlobal = FALSE;
pIn =
pPool = NULL;
nDefaultId = 0;
+ nFixedStringLength = -1;
}
SbiSymDef::~SbiSymDef()
diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx
index a41944c852..00690796a7 100644
--- a/basic/source/comp/token.cxx
+++ b/basic/source/comp/token.cxx
@@ -185,6 +185,7 @@ static TokenTable aTokTable_Basic [] = { // Token-Tabelle:
{ WEND, "Wend" },
{ WHILE, "While" },
{ WITH, "With" },
+ { WITHEVENTS, "WithEvents" },
{ WRITE, "Write" }, // auch WRITE #
{ XOR, "Xor" },
{ NIL, "" }
@@ -353,6 +354,29 @@ TokenTable aTokTable_Java [] = { // Token-Tabelle:
};
*/
+// #i109076
+TokenLabelInfo::TokenLabelInfo( void )
+{
+ m_pTokenCanBeLabelTab = new bool[VBASUPPORT+1];
+ for( int i = 0 ; i <= VBASUPPORT ; ++i )
+ m_pTokenCanBeLabelTab[i] = false;
+
+ // Token accepted as label by VBA
+ SbiToken eLabelToken[] = { ACCESS, ALIAS, APPEND, BASE, BINARY, CLASSMODULE,
+ COMPARE, COMPATIBLE, DEFERR, _ERROR_, EXPLICIT, LIB, LINE, LPRINT, NAME,
+ TOBJECT, OUTPUT, PROPERTY, RANDOM, READ, STEP, STOP, TEXT, VBASUPPORT, NIL };
+ SbiToken* pTok = eLabelToken;
+ SbiToken eTok;
+ for( pTok = eLabelToken ; (eTok = *pTok) != NIL ; ++pTok )
+ m_pTokenCanBeLabelTab[eTok] = true;
+}
+
+TokenLabelInfo::~TokenLabelInfo()
+{
+ delete[] m_pTokenCanBeLabelTab;
+}
+
+
// Der Konstruktor ermittelt die Laenge der Token-Tabelle.
SbiTokenizer::SbiTokenizer( const ::rtl::OUString& rSrc, StarBASIC* pb )
@@ -371,7 +395,8 @@ SbiTokenizer::SbiTokenizer( const ::rtl::OUString& rSrc, StarBASIC* pb )
}
SbiTokenizer::~SbiTokenizer()
-{}
+{
+}
// Wiederablage (Pushback) eines Tokens. (Bis zu 2 Tokens)
@@ -513,7 +538,8 @@ SbiToken SbiTokenizer::Next()
tp = &pTokTable[ lb + delta ];
StringCompare res = aSym.CompareIgnoreCaseToAscii( tp->s );
// Gefunden?
- if( res == COMPARE_EQUAL ) goto special;
+ if( res == COMPARE_EQUAL )
+ goto special;
// Groesser? Dann untere Haelfte
if( res == COMPARE_LESS )
{
@@ -534,24 +560,14 @@ SbiToken SbiTokenizer::Next()
return eCurTok = SYMBOL;
}
special:
- // LINE INPUT
- if( tp->t == LINE )
- {
- short nC1 = nCol1;
- String aOldSym = aSym;
- eCurTok = Peek();
- if( eCurTok == INPUT )
- {
- Next();
- nCol1 = nC1;
- return eCurTok = LINEINPUT;
- }
- else
- {
- aSym = aOldSym;
- return eCurTok = LINE;
- }
- }
+ // #i92642
+ if( eCurTok != NIL && eCurTok != REM && eCurTok != EOLN && (tp->t == NAME || tp->t == LINE) )
+ return eCurTok = SYMBOL;
+ else if( tp->t == TEXT )
+ return eCurTok = SYMBOL;
+
+ // #i92642: Special LINE token handling -> SbiParser::Line()
+
// END IF, CASE, SUB, DEF, FUNCTION, TYPE, CLASS, WITH
if( tp->t == END )
{
@@ -639,7 +655,7 @@ special:
BOOL SbiTokenizer::MayBeLabel( BOOL bNeedsColon )
{
- if( eCurTok == SYMBOL )
+ if( eCurTok == SYMBOL || m_aTokenLabelInfo.canTokenBeLabel( eCurTok ) )
return bNeedsColon ? DoesColonFollow() : TRUE;
else
return BOOL( eCurTok == NUMBER
diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx
index 362e9e2947..c9dd546d43 100644
--- a/basic/source/inc/codegen.hxx
+++ b/basic/source/inc/codegen.hxx
@@ -44,6 +44,7 @@ class SbiCodeGen { // Code-Erzeugung:
public:
SbiCodeGen( SbModule&, SbiParser*, short );
SbiParser* GetParser() { return pParser; }
+ SbModule& GetModule() { return rMod; }
UINT32 Gen( SbiOpcode );
UINT32 Gen( SbiOpcode, UINT32 );
UINT32 Gen( SbiOpcode, UINT32, UINT32 );
@@ -53,7 +54,6 @@ public:
void GenStmnt(); // evtl. Statement-Opcode erzeugen
UINT32 GetPC();
UINT32 GetOffset() { return GetPC() + 1; }
- SbModule& GetModule() { return rMod; }
void Save();
// #29955 for-Schleifen-Ebene pflegen
diff --git a/basic/source/inc/dlgcont.hxx b/basic/source/inc/dlgcont.hxx
index b5387ce483..7d22f4d64c 100644
--- a/basic/source/inc/dlgcont.hxx
+++ b/basic/source/inc/dlgcont.hxx
@@ -54,14 +54,17 @@ class SfxDialogLibraryContainer : public SfxLibraryContainer
virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const;
virtual void SAL_CALL writeLibraryElement
(
- ::com::sun::star::uno::Any aElement,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
const ::rtl::OUString& aElementName,
- ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xOutput
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput
)
throw(::com::sun::star::uno::Exception);
virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement
- ( const ::rtl::OUString& aFile,
+ (
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
+ const ::rtl::OUString& aElementName,
+ const ::rtl::OUString& aFile,
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream );
virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile );
diff --git a/basic/source/inc/expr.hxx b/basic/source/inc/expr.hxx
index 712ae8b606..af7302d1e1 100644
--- a/basic/source/inc/expr.hxx
+++ b/basic/source/inc/expr.hxx
@@ -52,6 +52,13 @@ struct SbVar { // Variablen-Element:
SbiExprListVector* pvMorePar; // Array of arrays foo(pPar)(avMorePar[0])(avMorePar[1])...
};
+struct KeywordSymbolInfo
+{
+ String m_aKeywordSymbol;
+ SbxDataType m_eSbxDataType;
+ SbiToken m_eTok;
+};
+
enum SbiExprType { // Expression-Typen:
SbSTDEXPR, // normaler Ausdruck
SbLVALUE, // beliebiger lValue
@@ -76,6 +83,7 @@ enum SbiNodeType {
SbxVARVAL, // aVar = Wert
SbxTYPEOF, // TypeOf ObjExpr Is Type
SbxNODE, // Node
+ SbxNEW, // new <type> expression
SbxDUMMY
};
@@ -107,9 +115,11 @@ class SbiExprNode { // Operatoren (und Operanden)
void FoldConstants(); // Constant Folding durchfuehren
void CollectBits(); // Umwandeln von Zahlen in Strings
BOOL IsOperand() // TRUE, wenn Operand
- { return BOOL( eNodeType != SbxNODE && eNodeType != SbxTYPEOF ); }
+ { return BOOL( eNodeType != SbxNODE && eNodeType != SbxTYPEOF && eNodeType != SbxNEW ); }
BOOL IsTypeOf()
{ return BOOL( eNodeType == SbxTYPEOF ); }
+ BOOL IsNew()
+ { return BOOL( eNodeType == SbxNEW ); }
BOOL IsNumber(); // TRUE bei Zahlen
BOOL IsString(); // TRUE bei Strings
BOOL IsLvalue(); // TRUE, falls als Lvalue verwendbar
@@ -122,6 +132,7 @@ public:
SbiExprNode( SbiParser*, const SbiSymDef&, SbxDataType, SbiExprList* = NULL );
SbiExprNode( SbiParser*, SbiExprNode*, SbiToken, SbiExprNode* );
SbiExprNode( SbiParser*, SbiExprNode*, USHORT ); // #120061 TypeOf
+ SbiExprNode( SbiParser*, USHORT ); // new <type>
virtual ~SbiExprNode();
BOOL IsValid() { return BOOL( !bError ); }
@@ -166,9 +177,9 @@ protected:
BOOL bByVal; // TRUE: ByVal-Parameter
BOOL bBracket; // TRUE: Parameter list with brackets
USHORT nParenLevel;
- SbiExprNode* Term();
+ SbiExprNode* Term( const KeywordSymbolInfo* pKeywordSymbolInfo = NULL );
SbiExprNode* ObjTerm( SbiSymDef& );
- SbiExprNode* Operand();
+ SbiExprNode* Operand( bool bUsedForTypeOf = false );
SbiExprNode* Unary();
SbiExprNode* Exp();
SbiExprNode* MulDiv();
@@ -180,7 +191,8 @@ protected:
SbiExprNode* Comp();
SbiExprNode* Boolean();
public:
- SbiExpression( SbiParser*, SbiExprType = SbSTDEXPR, SbiExprMode eMode = EXPRMODE_STANDARD ); // Parsender Ctor
+ SbiExpression( SbiParser*, SbiExprType = SbSTDEXPR,
+ SbiExprMode eMode = EXPRMODE_STANDARD, const KeywordSymbolInfo* pKeywordSymbolInfo = NULL ); // Parsender Ctor
SbiExpression( SbiParser*, const String& );
SbiExpression( SbiParser*, double, SbxDataType = SbxDOUBLE );
SbiExpression( SbiParser*, const SbiSymDef&, SbiExprList* = NULL );
diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx
index 7bbe89671e..2d53a1f442 100644
--- a/basic/source/inc/namecont.hxx
+++ b/basic/source/inc/namecont.hxx
@@ -284,14 +284,17 @@ protected:
virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const = 0;
virtual void SAL_CALL writeLibraryElement
(
- ::com::sun::star::uno::Any aElement,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
const ::rtl::OUString& aElementName,
- ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xOutput
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput
)
throw(::com::sun::star::uno::Exception) = 0;
virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement
- ( const ::rtl::OUString& aFile,
+ (
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
+ const ::rtl::OUString& aElementName,
+ const ::rtl::OUString& aFile,
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream ) = 0;
virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile ) = 0;
diff --git a/basic/source/inc/opcodes.hxx b/basic/source/inc/opcodes.hxx
index f82c8854ba..9eb1a27c8f 100644
--- a/basic/source/inc/opcodes.hxx
+++ b/basic/source/inc/opcodes.hxx
@@ -93,6 +93,7 @@ enum SbiOpcode {
_VBASET, // VBA-like Set
_ERASE_CLEAR, // Erase array and clear variable
_ARRAYACCESS, // Assign parameters to TOS and get value, used for array of arrays
+ _BYVAL, // byref -> byval for lvalue parameter passed in call
SbOP0_END,
// Alle Opcodes mit einem Operanden
diff --git a/basic/source/inc/parser.hxx b/basic/source/inc/parser.hxx
index 04c0269388..4fb7b1886c 100644
--- a/basic/source/inc/parser.hxx
+++ b/basic/source/inc/parser.hxx
@@ -99,7 +99,7 @@ public:
BOOL TestComma(); // Komma oder EOLN?
void TestEoln(); // EOLN?
- void Symbol(); // Let oder Call
+ void Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo = NULL ); // Let oder Call
void ErrorStmnt(); // ERROR n
void NotImp(); // nicht implementiert
void BadBlock(); // LOOP/WEND/NEXT
@@ -119,6 +119,7 @@ public:
void If(); // IF
void Implements(); // IMPLEMENTS
void Input(); // INPUT, INPUT #
+ void Line(); // LINE -> LINE INPUT [#] (#i92642)
void LineInput(); // LINE INPUT, LINE INPUT #
void LSet(); // LSET
void Name(); // NAME .. AS ..
diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx
index 64ecac24a5..96de7e5ce6 100644
--- a/basic/source/inc/runtime.hxx
+++ b/basic/source/inc/runtime.hxx
@@ -407,7 +407,7 @@ class SbiRuntime
void StepPRINTF(), StepWRITE(), StepRENAME(), StepPROMPT();
void StepRESTART(), StepEMPTY(), StepLEAVE();
void StepLSET(), StepRSET(), StepREDIMP_ERASE(), StepERASE_CLEAR();
- void StepARRAYACCESS();
+ void StepARRAYACCESS(), StepBYVAL();
// Alle Opcodes mit einem Operanden
void StepLOADNC( UINT32 ), StepLOADSC( UINT32 ), StepLOADI( UINT32 );
void StepARGN( UINT32 ), StepBASED( UINT32 ), StepPAD( UINT32 );
@@ -416,7 +416,7 @@ class SbiRuntime
void StepGOSUB( UINT32 ), StepRETURN( UINT32 );
void StepTESTFOR( UINT32 ), StepCASETO( UINT32 ), StepERRHDL( UINT32 );
void StepRESUME( UINT32 ), StepSETCLASS( UINT32 ), StepVBASETCLASS( UINT32 ), StepTESTCLASS( UINT32 ), StepLIB( UINT32 );
- bool checkClass_Impl( const SbxVariableRef& refVal, const String& aClass, bool bRaiseErrors );
+ bool checkClass_Impl( const SbxVariableRef& refVal, const String& aClass, bool bRaiseErrors, bool bDefault = true );
void StepCLOSE( UINT32 ), StepPRCHAR( UINT32 ), StepARGTYP( UINT32 );
// Alle Opcodes mit zwei Operanden
void StepRTL( UINT32, UINT32 ), StepPUBLIC( UINT32, UINT32 ), StepPUBLIC_P( UINT32, UINT32 );
@@ -434,6 +434,7 @@ class SbiRuntime
void StepDCREATE_REDIMP(UINT32,UINT32), StepDCREATE_IMPL(UINT32,UINT32);
void StepFIND_CM( UINT32, UINT32 );
void StepFIND_STATIC( UINT32, UINT32 );
+ void implCreateFixedString( SbxVariable* pStrVar, UINT32 nOp2 );
public:
void SetVBAEnabled( bool bEnabled );
USHORT GetImageFlag( USHORT n ) const;
diff --git a/basic/source/inc/sbintern.hxx b/basic/source/inc/sbintern.hxx
index 3423f99a84..938315aa12 100644
--- a/basic/source/inc/sbintern.hxx
+++ b/basic/source/inc/sbintern.hxx
@@ -39,6 +39,7 @@ namespace utl
class SbUnoFactory;
class SbTypeFactory;
class SbOLEFactory;
+class SbFormFactory;
class SbiInstance;
class SbModule;
@@ -101,6 +102,7 @@ struct SbiGlobals
SbTypeFactory* pTypeFac; // Factory for user defined types
SbClassFactory* pClassFac; // Factory for user defined classes (based on class modules)
SbOLEFactory* pOLEFac; // Factory for OLE types
+ SbFormFactory* pFormFac; // Factory for user forms
SbModule* pMod; // aktuell aktives Modul
SbModule* pCompMod; // aktuell compiliertes Modul
short nInst; // Anzahl BASICs
@@ -136,6 +138,7 @@ SbiGlobals* GetSbData();
#define pTYPEFAC GetSbData()->pTypeFac
#define pCLASSFAC GetSbData()->pClassFac
#define pOLEFAC GetSbData()->pOLEFac
+#define pFORMFAC GetSbData()->pFormFac
#endif
diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx
index b1abdcd9ee..2c71183918 100644
--- a/basic/source/inc/scriptcont.hxx
+++ b/basic/source/inc/scriptcont.hxx
@@ -53,14 +53,17 @@ class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPas
virtual bool SAL_CALL isLibraryElementValid( ::com::sun::star::uno::Any aElement ) const;
virtual void SAL_CALL writeLibraryElement
(
- ::com::sun::star::uno::Any aElement,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
const ::rtl::OUString& aElementName,
- ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xOutput
+ const ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >& xOutput
)
throw(::com::sun::star::uno::Exception);
virtual ::com::sun::star::uno::Any SAL_CALL importLibraryElement
- ( const ::rtl::OUString& aFile,
+ (
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& xLibrary,
+ const ::rtl::OUString& aElementName,
+ const ::rtl::OUString& aFile,
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xElementStream );
virtual void SAL_CALL importFromOldStorage( const ::rtl::OUString& aFile );
diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx
index cb1301bf83..a2a5896943 100644
--- a/basic/source/inc/symtbl.hxx
+++ b/basic/source/inc/symtbl.hxx
@@ -132,7 +132,9 @@ protected:
BOOL bAs : 1; // TRUE: Datentyp per AS XXX definiert
BOOL bGlobal : 1; // TRUE: Global-Variable
BOOL bParamArray : 1; // TRUE: ParamArray parameter
+ BOOL bWithEvents : 1; // TRUE: Declared WithEvents
USHORT nDefaultId; // Symbol number of default value
+ short nFixedStringLength; // String length in: Dim foo As String*Length
public:
SbiSymDef( const String& );
virtual ~SbiSymDef();
@@ -156,6 +158,7 @@ public:
BOOL IsDefined() const{ return bChained; }
void SetOptional() { bOpt = TRUE; }
void SetParamArray() { bParamArray = TRUE; }
+ void SetWithEvents() { bWithEvents = TRUE; }
void SetByVal() { bByVal = TRUE; }
void SetStatic( BOOL bAsStatic = TRUE ) { bStatic = bAsStatic; }
void SetNew() { bNew = TRUE; }
@@ -165,11 +168,14 @@ public:
USHORT GetDefaultId( void ) { return nDefaultId; }
BOOL IsOptional() const{ return bOpt; }
BOOL IsParamArray() const{ return bParamArray; }
+ BOOL IsWithEvents() const{ return bWithEvents; }
BOOL IsByVal() const { return bByVal; }
BOOL IsStatic() const { return bStatic; }
BOOL IsNew() const { return bNew; }
BOOL IsDefinedAs() const { return bAs; }
BOOL IsGlobal() const { return bGlobal; }
+ short GetFixedStringLength( void ) const { return nFixedStringLength; }
+ void SetFixedStringLength( short n ) { nFixedStringLength = n; }
SbiSymPool& GetPool();
UINT32 Define(); // Symbol in Code definieren
diff --git a/basic/source/inc/token.hxx b/basic/source/inc/token.hxx
index 737075a797..7c3ff75332 100644
--- a/basic/source/inc/token.hxx
+++ b/basic/source/inc/token.hxx
@@ -95,7 +95,7 @@ enum SbiToken {
NUMBER=FIRSTEXTRA, FIXSTRING, SYMBOL, _CDECL_, BYVAL, BYREF,
OUTPUT, RANDOM, APPEND, BINARY, ACCESS,
LOCK, READ, PRESERVE, BASE, ANY, LIB, _OPTIONAL_,
- EXPLICIT, COMPATIBLE, CLASSMODULE, PARAMARRAY,
+ EXPLICIT, COMPATIBLE, CLASSMODULE, PARAMARRAY, WITHEVENTS,
// Ab hier kommen JavaScript-Tokens (gleiches enum, damit gleicher Typ)
FIRSTJAVA,
@@ -120,7 +120,25 @@ enum SbiToken {
#undef SbiTokenSHAREDTMPUNDEF
#endif
+// #i109076
+class TokenLabelInfo
+{
+ bool* m_pTokenCanBeLabelTab;
+
+public:
+ TokenLabelInfo( void );
+ TokenLabelInfo( const TokenLabelInfo& rInfo )
+ : m_pTokenCanBeLabelTab( NULL )
+ { (void)rInfo; }
+ ~TokenLabelInfo();
+
+ bool canTokenBeLabel( SbiToken eTok )
+ { return m_pTokenCanBeLabelTab[eTok]; }
+};
+
class SbiTokenizer : public SbiScanner {
+ TokenLabelInfo m_aTokenLabelInfo;
+
protected:
SbiToken eCurTok; // aktuelles Token
SbiToken ePush; // Pushback-Token
diff --git a/basic/source/runtime/dllmgr.cxx b/basic/source/runtime/dllmgr.cxx
index 092548b36f..bc08a8cb64 100644
--- a/basic/source/runtime/dllmgr.cxx
+++ b/basic/source/runtime/dllmgr.cxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -25,647 +25,714 @@
*
************************************************************************/
-// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_basic.hxx"
+#include "sal/config.h"
-#include <stdlib.h>
-#ifdef OS2
-#define INCL_DOSMODULEMGR
-#include <svpm.h>
-#endif
-
-#if defined( WIN ) || defined( WNT )
-#ifndef _SVWIN_H
-#undef WB_LEFT
-#undef WB_RIGHT
-#include <tools/svwin.h>
-#endif
-#endif
-#include <tools/debug.hxx>
-#include <tools/string.hxx>
-#include <tools/errcode.hxx>
-#include <basic/sbxvar.hxx>
-#include <basic/sbx.hxx>
-
-#if defined(WIN)
-typedef HINSTANCE SbiDllHandle;
-typedef FARPROC SbiDllProc;
-#elif defined(WNT)
-typedef HMODULE SbiDllHandle;
-typedef int(*SbiDllProc)();
-#elif defined(OS2)
-typedef HMODULE SbiDllHandle;
-typedef PFN SbiDllProc;
-#else
-typedef void* SbiDllHandle;
-typedef void* SbiDllProc;
-#endif
+#include <algorithm>
+#include <cstddef>
+#include <list>
+#include <map>
+#include <vector>
-#define _DLLMGR_CXX
-#include "dllmgr.hxx"
-#include <basic/sberrors.hxx>
+#include "basic/sbx.hxx"
+#include "basic/sbxvar.hxx"
+#include "osl/thread.h"
+#include "rtl/ref.hxx"
+#include "rtl/string.hxx"
+#include "rtl/ustring.hxx"
+#include "salhelper/simplereferenceobject.hxx"
+#include "tools/svwin.h"
-#ifndef WINAPI
-#ifdef WNT
-#define WINAPI __far __pascal
-#endif
-#endif
+#undef max
-extern "C" {
-#if defined(INTEL) && (defined(WIN) || defined(WNT))
+#include "dllmgr.hxx"
-extern INT16 WINAPI CallINT( SbiDllProc, char *stack, short nstack);
-extern INT32 WINAPI CallLNG( SbiDllProc, char *stack, short nstack);
-#ifndef WNT
-extern float WINAPI CallSNG( SbiDllProc, char *stack, short nstack);
-#endif
-extern double WINAPI CallDBL( SbiDllProc, char *stack, short nstack);
-extern char* WINAPI CallSTR( SbiDllProc, char *stack, short nstack);
-// extern CallFIX( SbiDllProc, char *stack, short nstack);
+/* Open issues:
-#else
+ Only 32-bit Windows for now.
-INT16 CallINT( SbiDllProc, char *, short ) { return 0; }
-INT32 CallLNG( SbiDllProc, char *, short ) { return 0; }
-float CallSNG( SbiDllProc, char *, short ) { return 0; }
-double CallDBL( SbiDllProc, char *, short) { return 0; }
-char* CallSTR( SbiDllProc, char *, short ) { return 0; }
-#endif
-}
+ Missing support for functions returning structs (see TODO in call()).
-SV_IMPL_OP_PTRARR_SORT(ImplDllArr,ByteStringPtr)
+ Missing support for additional data types (64 bit integers, Any, ...; would
+ trigger OSL_ASSERT(false) in various switches).
-/* mit Optimierung An stuerzt unter Win95 folgendes Makro ab:
-declare Sub MessageBeep Lib "user32" (ByVal long)
-sub main
- MessageBeep( 1 )
-end sub
+ It is assumed that the variables passed into SbiDllMgr::Call to represent
+ the arguments and return value have types that exactly match the Declare
+ statement; it would be better if this code had access to the function
+ signature from the Declare statement, so that it could convert the passed
+ variables accordingly.
*/
-#if defined (WNT) && defined (MSC)
-//#pragma optimize ("", off)
-#endif
-
-//
-// ***********************************************************************
-//
-class ImplSbiProc : public ByteString
-{
- SbiDllProc pProc;
- ImplSbiProc();
- ImplSbiProc( const ImplSbiProc& );
+#if defined WNT // only 32-bit Windows, actually
-public:
- ImplSbiProc( const ByteString& rName, SbiDllProc pFunc )
- : ByteString( rName ) { pProc = pFunc; }
- SbiDllProc GetProc() const { return pProc; }
-};
+extern "C" {
-//
-// ***********************************************************************
-//
+int __stdcall DllMgr_call32(FARPROC, void const * stack, std::size_t size);
+double __stdcall DllMgr_callFp(FARPROC, void const * stack, std::size_t size);
-class ImplSbiDll : public ByteString
-{
- ImplDllArr aProcArr;
- SbiDllHandle hDLL;
+}
- ImplSbiDll( const ImplSbiDll& );
-public:
- ImplSbiDll( const ByteString& rName, SbiDllHandle hHandle )
- : ByteString( rName ) { hDLL = hHandle; }
- ~ImplSbiDll();
- SbiDllHandle GetHandle() const { return hDLL; }
- SbiDllProc GetProc( const ByteString& rName ) const;
- void InsertProc( const ByteString& rName, SbiDllProc pProc );
-};
+namespace {
-ImplSbiDll::~ImplSbiDll()
-{
- USHORT nCount = aProcArr.Count();
- for( USHORT nCur = 0; nCur < nCount; nCur++ )
- {
- ImplSbiProc* pProc = (ImplSbiProc*)aProcArr.GetObject( nCur );
- delete pProc;
- }
+char * address(std::vector< char > & blob) {
+ return blob.empty() ? 0 : &blob[0];
}
-SbiDllProc ImplSbiDll::GetProc( const ByteString& rName ) const
-{
- USHORT nPos;
- BOOL bRet = aProcArr.Seek_Entry( (ByteStringPtr)&rName, &nPos );
- if( bRet )
- {
- ImplSbiProc* pImplProc = (ImplSbiProc*)aProcArr.GetObject(nPos);
- return pImplProc->GetProc();
- }
- return (SbiDllProc)0;
+SbError convert(rtl::OUString const & source, rtl::OString * target) {
+ return
+ source.convertToString(
+ target, osl_getThreadTextEncoding(),
+ (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))
+ ? ERRCODE_NONE : ERRCODE_BASIC_BAD_ARGUMENT;
+ //TODO: more specific errcode?
}
-void ImplSbiDll::InsertProc( const ByteString& rName, SbiDllProc pProc )
-{
- DBG_ASSERT(aProcArr.Seek_Entry((ByteStringPtr)&rName,0)==0,"InsertProc: Already in table");
- ImplSbiProc* pImplProc = new ImplSbiProc( rName, pProc );
- aProcArr.Insert( (ByteStringPtr)pImplProc );
+SbError convert(char const * source, sal_Int32 length, rtl::OUString * target) {
+ return
+ rtl_convertStringToUString(
+ &target->pData, source, length, osl_getThreadTextEncoding(),
+ (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
+ RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))
+ ? ERRCODE_NONE : ERRCODE_BASIC_BAD_ARGUMENT;
+ //TODO: more specific errcode?
}
+struct UnmarshalData {
+ UnmarshalData(SbxVariable * theVariable, void * theBuffer):
+ variable(theVariable), buffer(theBuffer) {}
-//
-// ***********************************************************************
-//
+ SbxVariable * variable;
+ void * buffer;
+};
-SbiDllMgr::SbiDllMgr( const SbiDllMgr& )
-{
-}
+struct StringData: public UnmarshalData {
+ StringData(SbxVariable * theVariable, void * theBuffer, bool theSpecial):
+ UnmarshalData(theVariable, theBuffer), special(theSpecial) {}
-SbiDllMgr::SbiDllMgr()
-{
-}
+ bool special;
+};
-SbiDllMgr::~SbiDllMgr()
-{
- USHORT nCount = aDllArr.Count();
- for( USHORT nCur = 0; nCur < nCount; nCur++ )
- {
- ImplSbiDll* pDll = (ImplSbiDll*)aDllArr.GetObject( nCur );
- FreeDllHandle( pDll->GetHandle() );
- delete pDll;
+class MarshalData: private boost::noncopyable {
+public:
+ std::vector< char > * newBlob() {
+ blobs_.push_front(std::vector< char >());
+ return &blobs_.front();
}
-}
-void SbiDllMgr::FreeDll( const ByteString& rDllName )
-{
- USHORT nPos;
- BOOL bRet = aDllArr.Seek_Entry( (ByteStringPtr)&rDllName, &nPos );
- if( bRet )
- {
- ImplSbiDll* pDll = (ImplSbiDll*)aDllArr.GetObject(nPos);
- FreeDllHandle( pDll->GetHandle() );
- delete pDll;
- aDllArr.Remove( nPos, 1 );
- }
-}
+ std::vector< UnmarshalData > unmarshal;
+ std::vector< StringData > unmarshalStrings;
-ImplSbiDll* SbiDllMgr::GetDll( const ByteString& rDllName )
-{
- USHORT nPos;
- ImplSbiDll* pDll = 0;
- BOOL bRet = aDllArr.Seek_Entry( (ByteStringPtr)&rDllName, &nPos );
- if( bRet )
- pDll = (ImplSbiDll*)aDllArr.GetObject(nPos);
- else
- {
- SbiDllHandle hDll = CreateDllHandle( rDllName );
- if( hDll )
- {
- pDll = new ImplSbiDll( rDllName, hDll );
- aDllArr.Insert( (ByteStringPtr)pDll );
- }
- }
- return pDll;
+private:
+ std::list< std::vector< char > > blobs_;
+};
+
+std::size_t align(std::size_t address, std::size_t alignment) {
+ // alignment = 2^k for some k >= 0
+ return (address + (alignment - 1)) & ~(alignment - 1);
}
-SbiDllProc SbiDllMgr::GetProc( ImplSbiDll* pDll, const ByteString& rProcName )
+char * align(
+ std::vector< char > & blob, std::size_t alignment, std::size_t offset,
+ std::size_t add)
{
- DBG_ASSERT(pDll,"GetProc: No dll-ptr");
- SbiDllProc pProc;
- pProc = pDll->GetProc( rProcName );
- if( !pProc )
- {
- pProc = GetProcAddr( pDll->GetHandle(), rProcName );
- if( pProc )
- pDll->InsertProc( rProcName, pProc );
- }
- return pProc;
+ std::vector< char >::size_type n = blob.size();
+ n = align(n - offset, alignment) + offset; //TODO: overflow in align()
+ blob.resize(n + add); //TODO: overflow
+ return address(blob) + n;
}
-
-SbError SbiDllMgr::Call( const char* pProcName, const char* pDllName,
- SbxArray* pArgs, SbxVariable& rResult, BOOL bCDecl )
+template< typename T > void add(
+ std::vector< char > & blob, T const & data, std::size_t alignment,
+ std::size_t offset)
{
- DBG_ASSERT(pProcName&&pDllName,"Call: Bad parms");
- SbError nSbErr = 0;
- ByteString aDllName( pDllName );
- CheckDllName( aDllName );
- ImplSbiDll* pDll = GetDll( aDllName );
- if( pDll )
- {
- SbiDllProc pProc = GetProc( pDll, pProcName );
- if( pProc )
- {
- if( bCDecl )
- nSbErr = CallProcC( pProc, pArgs, rResult );
- else
- nSbErr = CallProc( pProc, pArgs, rResult );
+ *reinterpret_cast< T * >(align(blob, alignment, offset, sizeof (T))) = data;
+}
+
+std::size_t alignment(SbxVariable * variable) {
+ OSL_ASSERT(variable != 0);
+ if ((variable->GetType() & SbxARRAY) == 0) {
+ switch (variable->GetType()) {
+ case SbxINTEGER:
+ return 2;
+ case SbxLONG:
+ case SbxSINGLE:
+ case SbxSTRING:
+ return 4;
+ case SbxDOUBLE:
+ return 8;
+ case SbxOBJECT:
+ {
+ std::size_t n = 1;
+ SbxArray * props = PTR_CAST(SbxObject, variable->GetObject())->
+ GetProperties();
+ for (USHORT i = 0; i < props->Count(); ++i) {
+ n = std::max(n, alignment(props->Get(i)));
+ }
+ return n;
+ }
+ case SbxBOOL:
+ case SbxBYTE:
+ return 1;
+ default:
+ OSL_ASSERT(false);
+ return 1;
}
- else
- nSbErr = SbERR_PROC_UNDEFINED;
+ } else {
+ SbxDimArray * arr = PTR_CAST(SbxDimArray, variable->GetObject());
+ int dims = arr->GetDims();
+ std::vector< INT32 > low(dims);
+ for (int i = 0; i < dims; ++i) {
+ INT32 up;
+ arr->GetDim32(i + 1, low[i], up);
+ }
+ return alignment(arr->Get32(&low[0]));
}
- else
- nSbErr = SbERR_BAD_DLL_LOAD;
- return nSbErr;
}
-// ***********************************************************************
-// ******************* abhaengige Implementationen ***********************
-// ***********************************************************************
+SbError marshal(
+ bool outer, SbxVariable * variable, bool special,
+ std::vector< char > & blob, std::size_t offset, MarshalData & data);
-void SbiDllMgr::CheckDllName( ByteString& rDllName )
+SbError marshalString(
+ SbxVariable * variable, bool special, MarshalData & data, void ** buffer)
{
-#if defined(WIN) || defined(WNT) || defined(OS2)
- if( rDllName.Search('.') == STRING_NOTFOUND )
- rDllName += ".DLL";
-#else
- (void)rDllName;
-#endif
+ OSL_ASSERT(variable != 0 && buffer != 0);
+ rtl::OString str;
+ SbError e = convert(variable->GetString(), &str);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ std::vector< char > * blob = data.newBlob();
+ blob->insert(blob->begin(), str.getStr(), str.getStr() + str.getLength());
+ *buffer = address(*blob);
+ data.unmarshalStrings.push_back(StringData(variable, *buffer, special));
+ return ERRCODE_NONE;
}
-
-SbiDllHandle SbiDllMgr::CreateDllHandle( const ByteString& rDllName )
+SbError marshalStruct(
+ SbxVariable * variable, std::vector< char > & blob, std::size_t offset,
+ MarshalData & data)
{
- (void)rDllName;
-
-#if defined(UNX)
- SbiDllHandle hLib=0;
-#else
- SbiDllHandle hLib;
-#endif
-
-#if defined(WIN)
- hLib = LoadLibrary( (const char*)rDllName );
- if( (ULONG)hLib < 32 )
- hLib = 0;
-
-#elif defined(WNT)
- hLib = LoadLibrary( rDllName.GetBuffer() );
- if( !(ULONG)hLib )
- {
-#ifdef DBG_UTIL
- ULONG nLastErr;
- nLastErr = GetLastError();
-#endif
- hLib = 0;
+ OSL_ASSERT(variable != 0);
+ SbxArray * props = PTR_CAST(SbxObject, variable->GetObject())->
+ GetProperties();
+ for (USHORT i = 0; i < props->Count(); ++i) {
+ SbError e = marshal(false, props->Get(i), false, blob, offset, data);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
}
-
-#elif defined(OS2)
- char cErr[ 100 ];
- if( DosLoadModule( (PSZ) cErr, 100, (const char*)rDllName.GetBuffer(), &hLib ) )
- hLib = 0;
-#endif
- return hLib;
+ return ERRCODE_NONE;
}
-void SbiDllMgr::FreeDllHandle( SbiDllHandle hLib )
+SbError marshalArray(
+ SbxVariable * variable, std::vector< char > & blob, std::size_t offset,
+ MarshalData & data)
{
-#if defined(WIN) || defined(WNT)
- if( hLib )
- FreeLibrary ((HINSTANCE) hLib);
-#elif defined(OS2)
- if( hLib )
- DosFreeModule( (HMODULE) hLib );
-#else
- (void)hLib;
-#endif
+ OSL_ASSERT(variable != 0);
+ SbxDimArray * arr = PTR_CAST(SbxDimArray, variable->GetObject());
+ int dims = arr->GetDims();
+ std::vector< INT32 > low(dims);
+ std::vector< INT32 > up(dims);
+ for (int i = 0; i < dims; ++i) {
+ arr->GetDim32(i + 1, low[i], up[i]);
+ }
+ for (std::vector< INT32 > idx = low;;) {
+ SbError e = marshal(
+ false, arr->Get32(&idx[0]), false, blob, offset, data);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ int i = dims - 1;
+ while (idx[i] == up[i]) {
+ idx[i] = low[i];
+ if (i == 0) {
+ return ERRCODE_NONE;
+ }
+ --i;
+ }
+ ++idx[i];
+ }
}
-SbiDllProc SbiDllMgr::GetProcAddr(SbiDllHandle hLib, const ByteString& rProcName)
+// 8-aligned structs are only 4-aligned on stack, so alignment of members in
+// such structs must take that into account via "offset"
+SbError marshal(
+ bool outer, SbxVariable * variable, bool special,
+ std::vector< char > & blob, std::size_t offset, MarshalData & data)
{
- char buf1 [128] = "";
- char buf2 [128] = "";
-
- SbiDllProc pProc = 0;
- int nOrd = 0;
-
- // Ordinal?
- if( rProcName.GetBuffer()[0] == '@' )
- nOrd = atoi( rProcName.GetBuffer()+1 );
-
- // Moegliche Parameter weg:
- DBG_ASSERT( sizeof(buf1) > rProcName.Len(),
- "SbiDllMgr::GetProcAddr: buffer to small!" );
- strncpy( buf1, rProcName.GetBuffer(), sizeof(buf1)-1 );
- char *p = strchr( buf1, '#' );
- if( p )
- *p = 0;
-
- DBG_ASSERT( sizeof(buf2) > strlen(buf1) + 1,
- "SbiDllMgr::GetProcAddr: buffer to small!" );
- strncpy( buf2, "_", sizeof(buf2)-1 );
- strncat( buf2, buf1, sizeof(buf2)-1-strlen(buf2) );
-
-#if defined(WIN) || defined(WNT)
- if( nOrd > 0 )
- pProc = (SbiDllProc)GetProcAddress( hLib, (char*)(long) nOrd );
- else
- {
- // 2. mit Parametern:
- pProc = (SbiDllProc)GetProcAddress ( hLib, rProcName.GetBuffer() );
- // 3. nur der Name:
- if (!pProc)
- pProc = (SbiDllProc)GetProcAddress( hLib, buf1 );
- // 4. der Name mit Underline vorweg:
- if( !pProc )
- pProc = (SbiDllProc)GetProcAddress( hLib, buf2 );
+ OSL_ASSERT(variable != 0);
+ if ((variable->GetFlags() & SBX_REFERENCE) == 0) {
+ if ((variable->GetType() & SbxARRAY) == 0) {
+ switch (variable->GetType()) {
+ case SbxINTEGER:
+ add(blob, variable->GetInteger(), outer ? 4 : 2, offset);
+ break;
+ case SbxLONG:
+ add(blob, variable->GetLong(), 4, offset);
+ break;
+ case SbxSINGLE:
+ add(blob, variable->GetSingle(), 4, offset);
+ break;
+ case SbxDOUBLE:
+ add(blob, variable->GetDouble(), outer ? 4 : 8, offset);
+ break;
+ case SbxSTRING:
+ {
+ void * p;
+ SbError e = marshalString(variable, special, data, &p);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ add(blob, p, 4, offset);
+ break;
+ }
+ case SbxOBJECT:
+ {
+ align(blob, outer ? 4 : alignment(variable), offset, 0);
+ SbError e = marshalStruct(variable, blob, offset, data);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ break;
+ }
+ case SbxBOOL:
+ add(blob, variable->GetBool(), outer ? 4 : 1, offset);
+ break;
+ case SbxBYTE:
+ add(blob, variable->GetByte(), outer ? 4 : 1, offset);
+ break;
+ default:
+ OSL_ASSERT(false);
+ break;
+ }
+ } else {
+ SbError e = marshalArray(variable, blob, offset, data);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ }
+ } else {
+ if ((variable->GetType() & SbxARRAY) == 0) {
+ switch (variable->GetType()) {
+ case SbxINTEGER:
+ case SbxLONG:
+ case SbxSINGLE:
+ case SbxDOUBLE:
+ case SbxBOOL:
+ case SbxBYTE:
+ add(blob, variable->data(), 4, offset);
+ break;
+ case SbxSTRING:
+ {
+ std::vector< char > * blob2 = data.newBlob();
+ void * p;
+ SbError e = marshalString(variable, special, data, &p);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ add(*blob2, p, 4, 0);
+ add(blob, address(*blob2), 4, offset);
+ break;
+ }
+ case SbxOBJECT:
+ {
+ std::vector< char > * blob2 = data.newBlob();
+ SbError e = marshalStruct(variable, *blob2, 0, data);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ void * p = address(*blob2);
+ if (outer) {
+ data.unmarshal.push_back(UnmarshalData(variable, p));
+ }
+ add(blob, p, 4, offset);
+ break;
+ }
+ default:
+ OSL_ASSERT(false);
+ break;
+ }
+ } else {
+ std::vector< char > * blob2 = data.newBlob();
+ SbError e = marshalArray(variable, *blob2, 0, data);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ void * p = address(*blob2);
+ if (outer) {
+ data.unmarshal.push_back(UnmarshalData(variable, p));
+ }
+ add(blob, p, 4, offset);
+ }
}
+ return ERRCODE_NONE;
+}
-#elif defined(OS2)
- PSZ pp;
- APIRET rc;
- // 1. Ordinal oder mit Parametern:
- rc = DosQueryProcAddr( hLib, nOrd, pp = (char*)rProcName.GetBuffer(), &pProc );
- // 2. nur der Name:
- if( rc )
- rc = DosQueryProcAddr( hLib, 0, pp = (PSZ)buf1, &pProc );
- // 3. der Name mit Underline vorweg:
- if( rc )
- rc = DosQueryProcAddr( hLib, 0, pp = (PSZ)buf2, &pProc );
- if( rc )
- pProc = NULL;
- else
- {
- // 16-bit oder 32-bit?
- ULONG nInfo = 0;
- if( DosQueryProcType( hLib, nOrd, pp, &nInfo ) )
- nInfo = 0;;
- }
-#else
- (void)hLib;
-#endif
- return pProc;
+template< typename T > T read(void const ** pointer) {
+ T const * p = static_cast< T const * >(*pointer);
+ *pointer = static_cast< void const * >(p + 1);
+ return *p;
}
-SbError SbiDllMgr::CallProc( SbiDllProc pProc, SbxArray* pArgs,
- SbxVariable& rResult )
-{
-// ByteString aStr("Calling DLL at ");
-// aStr += (ULONG)pProc;
-// InfoBox( 0, aStr ).Execute();
- INT16 nInt16; int nInt; INT32 nInt32; double nDouble;
- char* pStr;
-
- USHORT nSize;
- char* pStack = (char*)CreateStack( pArgs, nSize );
- switch( rResult.GetType() )
- {
+void const * unmarshal(SbxVariable * variable, void const * data) {
+ OSL_ASSERT(variable != 0);
+ if ((variable->GetType() & SbxARRAY) == 0) {
+ switch (variable->GetType()) {
case SbxINTEGER:
- nInt16 = CallINT(pProc, pStack, (short)nSize );
- rResult.PutInteger( nInt16 );
- break;
-
- case SbxUINT:
- case SbxUSHORT:
- nInt16 = (INT16)CallINT(pProc, pStack, (short)nSize );
- rResult.PutUShort( (USHORT)nInt16 );
- break;
-
- case SbxERROR:
- nInt16 = (INT16)CallINT(pProc, pStack, (short)nSize );
- rResult.PutErr( (USHORT)nInt16 );
- break;
-
- case SbxINT:
- nInt = CallINT(pProc, pStack, (short)nSize );
- rResult.PutInt( nInt );
+ variable->PutInteger(read< sal_Int16 >(&data));
break;
-
case SbxLONG:
- nInt32 = CallLNG(pProc, pStack, (short)nSize );
- rResult.PutLong( nInt32 );
+ variable->PutLong(read< sal_Int32 >(&data));
break;
-
- case SbxULONG:
- nInt32 = CallINT(pProc, pStack, (short)nSize );
- rResult.PutULong( (ULONG)nInt32 );
- break;
-
-#ifndef WNT
case SbxSINGLE:
- {
- float nSingle = CallSNG(pProc, pStack, (short)nSize );
- rResult.PutSingle( nSingle );
+ variable->PutSingle(read< float >(&data));
break;
- }
-#endif
-
case SbxDOUBLE:
-#ifdef WNT
- case SbxSINGLE:
-#endif
- nDouble = CallDBL(pProc, pStack, (short)nSize );
- rResult.PutDouble( nDouble );
+ variable->PutDouble(read< double >(&data));
break;
-
- case SbxDATE:
- nDouble = CallDBL(pProc, pStack, (short)nSize );
- rResult.PutDate( nDouble );
+ case SbxSTRING:
+ read< char * >(&data); // handled by unmarshalString
break;
-
- case SbxCHAR:
- case SbxBYTE:
+ case SbxOBJECT:
+ {
+ data = reinterpret_cast< void const * >(
+ align(
+ reinterpret_cast< sal_uIntPtr >(data),
+ alignment(variable)));
+ SbxArray * props = PTR_CAST(SbxObject, variable->GetObject())->
+ GetProperties();
+ for (USHORT i = 0; i < props->Count(); ++i) {
+ data = unmarshal(props->Get(i), data);
+ }
+ break;
+ }
case SbxBOOL:
- nInt16 = CallINT(pProc, pStack, (short)nSize );
- rResult.PutByte( (BYTE)nInt16 );
- break;
-
- case SbxSTRING:
- case SbxLPSTR:
- pStr = CallSTR(pProc, pStack, (short)nSize );
- rResult.PutString( String::CreateFromAscii( pStr ) );
+ variable->PutBool(read< sal_Bool >(&data));
break;
-
- case SbxNULL:
- case SbxEMPTY:
- nInt16 = CallINT(pProc, pStack, (short)nSize );
- // Rueckgabe nur zulaessig, wenn variant!
- if( !rResult.IsFixed() )
- rResult.PutInteger( nInt16 );
+ case SbxBYTE:
+ variable->PutByte(read< sal_uInt8 >(&data));
break;
-
- case SbxCURRENCY:
- case SbxOBJECT:
- case SbxDATAOBJECT:
default:
- CallINT(pProc, pStack, (short)nSize );
+ OSL_ASSERT(false);
break;
- }
- delete [] pStack;
-
- if( pArgs )
- {
- // die Laengen aller uebergebenen Strings anpassen
- USHORT nCount = pArgs->Count();
- for( USHORT nCur = 1; nCur < nCount; nCur++ )
- {
- SbxVariable* pVar = pArgs->Get( nCur );
- BOOL bIsString = ( pVar->GetType() == SbxSTRING ) ||
- ( pVar->GetType() == SbxLPSTR );
-
- if( pVar->GetFlags() & SBX_REFERENCE )
- {
- pVar->ResetFlag( SBX_REFERENCE ); // Sbx moechte es so
- if( bIsString )
- {
- ByteString aByteStr( (char*)pVar->GetUserData() );
- String aStr( aByteStr, gsl_getSystemTextEncoding() );
- pVar->PutString( aStr );
+ }
+ } else {
+ SbxDimArray * arr = PTR_CAST(SbxDimArray, variable->GetObject());
+ int dims = arr->GetDims();
+ std::vector< INT32 > low(dims);
+ std::vector< INT32 > up(dims);
+ for (int i = 0; i < dims; ++i) {
+ arr->GetDim32(i + 1, low[i], up[i]);
+ }
+ for (std::vector< INT32 > idx = low;;) {
+ data = unmarshal(arr->Get32(&idx[0]), data);
+ int i = dims - 1;
+ while (idx[i] == up[i]) {
+ idx[i] = low[i];
+ if (i == 0) {
+ goto done;
}
+ --i;
}
- if( bIsString )
- {
- delete (char*)(pVar->GetUserData());
- pVar->SetUserData( 0 );
- }
+ ++idx[i];
}
+ done:;
}
- return 0;
+ return data;
}
-SbError SbiDllMgr::CallProcC( SbiDllProc pProc, SbxArray* pArgs,
- SbxVariable& rResult )
-{
- (void)pProc;
- (void)pArgs;
- (void)rResult;
-
- DBG_ERROR("C calling convention not supported");
- return SbERR_BAD_ARGUMENT;
+SbError unmarshalString(StringData const & data, SbxVariable & result) {
+ rtl::OUString str;
+ if (data.buffer != 0) {
+ char const * p = static_cast< char const * >(data.buffer);
+ sal_Int32 len;
+ if (data.special) {
+ len = static_cast< sal_Int32 >(result.GetULong());
+ if (len < 0) { // i.e., DWORD result >= 2^31
+ return ERRCODE_BASIC_BAD_ARGUMENT;
+ //TODO: more specific errcode?
+ }
+ } else {
+ len = rtl_str_getLength(p);
+ }
+ SbError e = convert(p, len, &str);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ }
+ data.variable->PutString(String(str));
+ return ERRCODE_NONE;
}
-void* SbiDllMgr::CreateStack( SbxArray* pArgs, USHORT& rSize )
+struct ProcData {
+ rtl::OString name;
+ FARPROC proc;
+};
+
+SbError call(
+ rtl::OUString const & dll, ProcData const & proc, SbxArray * arguments,
+ SbxVariable & result)
{
- if( !pArgs )
+ std::vector< char > stack;
+ MarshalData data;
+ // For DWORD GetLogicalDriveStringsA(DWORD nBufferLength, LPSTR lpBuffer)
+ // from kernel32, upon return, filled lpBuffer length is result DWORD, which
+ // requires special handling in unmarshalString; other functions might
+ // require similar treatment, too:
+ bool special =
+ dll.equalsIgnoreAsciiCaseAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("KERNEL32.DLL")) &&
+ (proc.name ==
+ rtl::OString(RTL_CONSTASCII_STRINGPARAM("GetLogicalDriveStringsA")));
+ for (USHORT i = 1; i < (arguments == 0 ? 0 : arguments->Count()); ++i) {
+ SbError e = marshal(
+ true, arguments->Get(i), special && i == 2, stack, stack.size(),
+ data);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ align(stack, 4, 0, 0);
+ }
+ switch (result.GetType()) {
+ case SbxEMPTY:
+ DllMgr_call32(proc.proc, address(stack), stack.size());
+ break;
+ case SbxINTEGER:
+ result.PutInteger(
+ static_cast< sal_Int16 >(
+ DllMgr_call32(proc.proc, address(stack), stack.size())));
+ break;
+ case SbxLONG:
+ result.PutLong(
+ static_cast< sal_Int32 >(
+ DllMgr_call32(proc.proc, address(stack), stack.size())));
+ break;
+ case SbxSINGLE:
+ result.PutSingle(
+ static_cast< float >(
+ DllMgr_callFp(proc.proc, address(stack), stack.size())));
+ break;
+ case SbxDOUBLE:
+ result.PutDouble(
+ DllMgr_callFp(proc.proc, address(stack), stack.size()));
+ break;
+ case SbxSTRING:
+ {
+ char const * s1 = reinterpret_cast< char const * >(
+ DllMgr_call32(proc.proc, address(stack), stack.size()));
+ rtl::OUString s2;
+ SbError e = convert(s1, rtl_str_getLength(s1), &s2);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ result.PutString(String(s2));
+ break;
+ }
+ case SbxOBJECT:
+ //TODO
+ DllMgr_call32(proc.proc, address(stack), stack.size());
+ break;
+ case SbxBOOL:
+ result.PutBool(
+ static_cast< sal_Bool >(
+ DllMgr_call32(proc.proc, address(stack), stack.size())));
+ break;
+ case SbxBYTE:
+ result.PutByte(
+ static_cast< sal_uInt8 >(
+ DllMgr_call32(proc.proc, address(stack), stack.size())));
+ break;
+ default:
+ OSL_ASSERT(false);
+ break;
+ }
+ for (USHORT i = 1; i < (arguments == 0 ? 0 : arguments->Count()); ++i) {
+ arguments->Get(i)->ResetFlag(SBX_REFERENCE);
+ //TODO: skipped for errors?!?
+ }
+ for (std::vector< UnmarshalData >::iterator i(data.unmarshal.begin());
+ i != data.unmarshal.end(); ++i)
{
- rSize = 0;
- return 0;
+ unmarshal(i->variable, i->buffer);
}
- char* pStack = new char[ 2048 ];
- char* pTop = pStack;
- USHORT nCount = pArgs->Count();
- // erstes Element ueberspringen
-#ifndef WIN
- for( USHORT nCur = 1; nCur < nCount; nCur++ )
-#else
- // unter 16-Bit Windows anders rum (OS/2 ?????)
- for( USHORT nCur = nCount-1; nCur >= 1; nCur-- )
-#endif
+ for (std::vector< StringData >::iterator i(data.unmarshalStrings.begin());
+ i != data.unmarshalStrings.end(); ++i)
{
- SbxVariable* pVar = pArgs->Get( nCur );
- // AB 22.1.1996, Referenz
- if( pVar->GetFlags() & SBX_REFERENCE ) // Es ist eine Referenz
- {
- switch( pVar->GetType() )
- {
- case SbxINTEGER:
- case SbxUINT:
- case SbxINT:
- case SbxUSHORT:
- case SbxLONG:
- case SbxULONG:
- case SbxSINGLE:
- case SbxDOUBLE:
- case SbxCHAR:
- case SbxBYTE:
- case SbxBOOL:
- *((void**)pTop) = (void*)&(pVar->aData);
- pTop += sizeof( void* );
- break;
-
- case SbxSTRING:
- case SbxLPSTR:
- {
- USHORT nLen = 256;
- ByteString rStr( pVar->GetString(), gsl_getSystemTextEncoding() );
- if( rStr.Len() > 255 )
- nLen = rStr.Len() + 1;
-
- char* pStr = new char[ nLen ];
- strcpy( pStr, rStr.GetBuffer() ); // #100211# - checked
- // ist nicht so sauber, aber wir sparen ein Pointerarray
- DBG_ASSERT(sizeof(UINT32)>=sizeof(char*),"Gleich krachts im Basic");
- pVar->SetUserData( (sal_uIntPtr)pStr );
- *((const char**)pTop) = pStr;
- pTop += sizeof( char* );
- }
- break;
+ SbError e = unmarshalString(*i, result);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ }
+ return ERRCODE_NONE;
+}
- case SbxNULL:
- case SbxEMPTY:
- case SbxERROR:
- case SbxDATE:
- case SbxCURRENCY:
- case SbxOBJECT:
- case SbxDATAOBJECT:
- default:
- break;
+SbError getProcData(HMODULE handle, rtl::OUString const & name, ProcData * proc)
+{
+ OSL_ASSERT(proc != 0);
+ if (name.getLength() != 0 && name[0] == '@') { //TODO: "@" vs. "#"???
+ sal_Int32 n = name.copy(1).toInt32(); //TODO: handle bad input
+ if (n <= 0 || n > 0xFFFF) {
+ return ERRCODE_BASIC_BAD_ARGUMENT; //TODO: more specific errcode?
+ }
+ FARPROC p = GetProcAddress(handle, reinterpret_cast< LPCSTR >(n));
+ if (p != 0) {
+ proc->name = rtl::OString(RTL_CONSTASCII_STRINGPARAM("#")) +
+ rtl::OString::valueOf(n);
+ proc->proc = p;
+ return ERRCODE_NONE;
+ }
+ } else {
+ rtl::OString name8;
+ SbError e = convert(name, &name8);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ FARPROC p = GetProcAddress(handle, name8.getStr());
+ if (p != 0) {
+ proc->name = name8;
+ proc->proc = p;
+ return ERRCODE_NONE;
+ }
+ sal_Int32 i = name8.indexOf('#');
+ if (i != -1) {
+ name8 = name8.copy(0, i);
+ p = GetProcAddress(handle, name8.getStr());
+ if (p != 0) {
+ proc->name = name8;
+ proc->proc = p;
+ return ERRCODE_NONE;
}
}
- else
- {
- // ByVal
- switch( pVar->GetType() )
- {
- case SbxINTEGER:
- case SbxUINT:
- case SbxINT:
- case SbxUSHORT:
- *((INT16*)pTop) = pVar->GetInteger();
- pTop += sizeof( INT16 );
- break;
+ rtl::OString real(
+ rtl::OString(RTL_CONSTASCII_STRINGPARAM("_")) + name8);
+ p = GetProcAddress(handle, real.getStr());
+ if (p != 0) {
+ proc->name = real;
+ proc->proc = p;
+ return ERRCODE_NONE;
+ }
+ real = name8 + rtl::OString(RTL_CONSTASCII_STRINGPARAM("A"));
+ p = GetProcAddress(handle, real.getStr());
+ if (p != 0) {
+ proc->name = real;
+ proc->proc = p;
+ return ERRCODE_NONE;
+ }
+ }
+ return ERRCODE_BASIC_PROC_UNDEFINED;
+}
- case SbxLONG:
- case SbxULONG:
- *((INT32*)pTop) = pVar->GetLong();
- pTop += sizeof( INT32 );
- break;
+struct Dll: public salhelper::SimpleReferenceObject {
+private:
+ typedef std::map< rtl::OUString, ProcData > Procs;
- case SbxSINGLE:
- *((float*)pTop) = pVar->GetSingle();
- pTop += sizeof( float );
- break;
+ virtual ~Dll();
- case SbxDOUBLE:
- *((double*)pTop) = pVar->GetDouble();
- pTop += sizeof( double );
- break;
+public:
+ Dll(): handle(0) {}
- case SbxSTRING:
- case SbxLPSTR:
- {
- char* pStr = new char[ pVar->GetString().Len() + 1 ];
- ByteString aByteStr( pVar->GetString(), gsl_getSystemTextEncoding() );
- strcpy( pStr, aByteStr.GetBuffer() ); // #100211# - checked
- // ist nicht so sauber, aber wir sparen ein Pointerarray
- DBG_ASSERT(sizeof(UINT32)>=sizeof(char*),"Gleich krachts im Basic");
- pVar->SetUserData( (sal_uIntPtr)pStr );
- *((const char**)pTop) = pStr;
- pTop += sizeof( char* );
- }
- break;
+ SbError getProc(rtl::OUString const & name, ProcData * proc);
- case SbxCHAR:
- case SbxBYTE:
- case SbxBOOL:
- *((BYTE*)pTop) = pVar->GetByte();
- pTop += sizeof( BYTE );
- break;
+ HMODULE handle;
+ Procs procs;
+};
- case SbxNULL:
- case SbxEMPTY:
- case SbxERROR:
- case SbxDATE:
- case SbxCURRENCY:
- case SbxOBJECT:
- case SbxDATAOBJECT:
- default:
- break;
- }
+Dll::~Dll() {
+ if (handle != 0 && !FreeLibrary(handle)) {
+ OSL_TRACE("FreeLibrary(%p) failed with %u", handle, GetLastError());
+ }
+}
+
+SbError Dll::getProc(rtl::OUString const & name, ProcData * proc) {
+ Procs::iterator i(procs.find(name));
+ if (i != procs.end()) {
+ *proc = i->second;
+ return ERRCODE_NONE;
+ }
+ SbError e = getProcData(handle, name, proc);
+ if (e == ERRCODE_NONE) {
+ procs.insert(Procs::value_type(name, *proc));
+ }
+ return e;
+}
+
+rtl::OUString fullDllName(rtl::OUString const & name) {
+ rtl::OUString full(name);
+ if (full.indexOf('.') == -1) {
+ full += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".DLL"));
+ }
+ return full;
+}
+
+}
+
+struct SbiDllMgr::Impl: private boost::noncopyable {
+private:
+ typedef std::map< rtl::OUString, rtl::Reference< Dll > > Dlls;
+
+public:
+ Dll * getDll(rtl::OUString const & name);
+
+ Dlls dlls;
+};
+
+Dll * SbiDllMgr::Impl::getDll(rtl::OUString const & name) {
+ Dlls::iterator i(dlls.find(name));
+ if (i == dlls.end()) {
+ i = dlls.insert(Dlls::value_type(name, new Dll)).first;
+ HMODULE h = LoadLibraryW(name);
+ if (h == 0) {
+ dlls.erase(i);
+ return 0;
}
+ i->second->handle = h;
}
- rSize = (USHORT)((ULONG)pTop - (ULONG)pStack);
- return pStack;
+ return i->second.get();
}
+SbError SbiDllMgr::Call(
+ rtl::OUString const & function, rtl::OUString const & library,
+ SbxArray * arguments, SbxVariable & result, bool cdeclConvention)
+{
+ if (cdeclConvention) {
+ return ERRCODE_BASIC_NOT_IMPLEMENTED;
+ }
+ rtl::OUString dllName(fullDllName(library));
+ Dll * dll = impl_->getDll(dllName);
+ if (dll == 0) {
+ return ERRCODE_BASIC_BAD_DLL_LOAD;
+ }
+ ProcData proc;
+ SbError e = dll->getProc(function, &proc);
+ if (e != ERRCODE_NONE) {
+ return e;
+ }
+ return call(dllName, proc, arguments, result);
+}
+
+void SbiDllMgr::FreeDll(rtl::OUString const & library) {
+ impl_->dlls.erase(library);
+}
+#else
+
+struct SbiDllMgr::Impl {};
+
+SbError SbiDllMgr::Call(
+ rtl::OUString const &, rtl::OUString const &, SbxArray *, SbxVariable &,
+ bool)
+{
+ return ERRCODE_BASIC_NOT_IMPLEMENTED;
+}
+
+void SbiDllMgr::FreeDll(rtl::OUString const &) {}
+
+#endif
+SbiDllMgr::SbiDllMgr(): impl_(new Impl) {}
+SbiDllMgr::~SbiDllMgr() {}
diff --git a/basic/source/runtime/dllmgr.hxx b/basic/source/runtime/dllmgr.hxx
index c57e05e3fc..fdff8c2849 100644
--- a/basic/source/runtime/dllmgr.hxx
+++ b/basic/source/runtime/dllmgr.hxx
@@ -1,7 +1,7 @@
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
+ *
* Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
@@ -25,71 +25,36 @@
*
************************************************************************/
-#ifndef _DLLMGR_HXX
-#define _DLLMGR_HXX
+#ifndef INCLUDED_BASIC_SOURCE_RUNTIME_DLLMGR_HXX
+#define INCLUDED_BASIC_SOURCE_RUNTIME_DLLMGR_HXX
-#define _SVSTDARR_BYTESTRINGSSORT
-#include <svl/svarray.hxx>
-#ifndef _SVSTDARR_HXX //autogen
-#include <svl/svstdarr.hxx>
-#endif
+#include "sal/config.h"
-// !!! nur zum debuggen fuer infoboxes !!!
-//#ifndef _SV_HXX
-//#include <sv.hxx>
-//#endif
+#include <memory>
-//#ifndef _TOOLS_HXX
-//#include <tools.hxx>
-//#endif
-#define _SVSTDARR_STRINGS
-//#ifndef _SVSTDARR_HXX
-//#include <svstdarr.hxx>
-//#endif
-#ifndef _SBERRORS_HXX
-#include <basic/sberrors.hxx>
-#endif
+#include "basic/sberrors.hxx"
+#include "boost/noncopyable.hpp"
+namespace rtl { class OUString; }
class SbxArray;
class SbxVariable;
-class ImplSbiDll;
-class ImplSbiProc;
-
-SV_DECL_PTRARR_SORT(ImplDllArr,ByteStringPtr,5,5)
-
-class SbiDllMgr
-{
- ImplDllArr aDllArr;
-
- SbiDllMgr( const SbiDllMgr& );
+class SbiDllMgr: private boost::noncopyable {
+public:
+ SbiDllMgr();
-#ifdef _DLLMGR_CXX
- ImplSbiDll* GetDll( const ByteString& rDllName );
- SbiDllProc GetProc( ImplSbiDll*, const ByteString& rProcName );
+ ~SbiDllMgr();
- SbiDllHandle CreateDllHandle( const ByteString& rDllName );
- void FreeDllHandle( SbiDllHandle );
- SbiDllProc GetProcAddr( SbiDllHandle, const ByteString& pProcName );
- SbError CallProc( SbiDllProc pProc, SbxArray* pArgs,
- SbxVariable& rResult );
- SbError CallProcC( SbiDllProc pProc, SbxArray* pArgs,
- SbxVariable& rResult );
- void* CreateStack( SbxArray* pArgs, USHORT& rSize );
- void CheckDllName( ByteString& rName );
-#endif
+ SbError Call(
+ rtl::OUString const & function, rtl::OUString const & library,
+ SbxArray * arguments, SbxVariable & result, bool cdeclConvention);
-public:
- SbiDllMgr();
- ~SbiDllMgr();
+ void FreeDll(rtl::OUString const & library);
- SbError Call( const char* pFunc, const char* pDll,
- SbxArray* pArgs, SbxVariable& rResult,
- BOOL bCDecl );
+private:
+ struct Impl;
- void FreeDll( const ByteString& rDllName );
+ std::auto_ptr< Impl > impl_;
};
-
-
#endif
diff --git a/basic/source/runtime/makefile.mk b/basic/source/runtime/makefile.mk
index 9bd197975e..f2ed11196b 100644
--- a/basic/source/runtime/makefile.mk
+++ b/basic/source/runtime/makefile.mk
@@ -30,6 +30,8 @@ PRJ=..$/..
PRJNAME=basic
TARGET=runtime
+ENABLE_EXCEPTIONS = TRUE
+
# --- Settings -----------------------------------------------------------
.INCLUDE : settings.mk
@@ -53,29 +55,12 @@ SLOFILES= \
$(SLO)$/ddectrl.obj \
$(SLO)$/dllmgr.obj
-.IF "$(GUI)$(CPU)" == "WINI"
-SLOFILES+= $(SLO)$/win.obj
-.ENDIF
-
.IF "$(GUI)$(COM)$(CPU)" == "WNTMSCI"
SLOFILES+= $(SLO)$/wnt.obj
-.ENDIF
-
-.IF "$(GUI)$(COM)$(CPU)" == "WNTGCCI"
+.ELIF "$(GUI)$(COM)$(CPU)" == "WNTGCCI"
SLOFILES+= $(SLO)$/wnt-mingw.obj
.ENDIF
-.IF "$(GUI)$(CPU)" == "OS2I"
-#FIXME SLOFILES+= $(SLO)$/os2.obj
-.ENDIF
-
-EXCEPTIONSFILES=$(SLO)$/step0.obj \
- $(SLO)$/step2.obj \
- $(SLO)$/methods.obj \
- $(SLO)$/methods1.obj \
- $(SLO)$/iosys.obj \
- $(SLO)$/runtime.obj
-
# --- Targets -------------------------------------------------------------
.INCLUDE : target.mk
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index 69c6713122..f22a52c51a 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -523,6 +523,18 @@ RTLFUNC(WaitUntil)
Wait_Impl( true, rPar );
}
+RTLFUNC(DoEvents)
+{
+ (void)pBasic;
+ (void)bWrite;
+ (void)rPar;
+ Timer aTimer;
+ aTimer.SetTimeout( 1 );
+ aTimer.Start();
+ while ( aTimer.IsActive() )
+ Application::Yield();
+}
+
RTLFUNC(GetGUIVersion)
{
(void)pBasic;
@@ -622,8 +634,7 @@ RTLFUNC(FreeLibrary)
if ( rPar.Count() != 2 )
StarBASIC::Error( SbERR_BAD_ARGUMENT );
- ByteString aByteDLLName( rPar.Get(1)->GetString(), gsl_getSystemTextEncoding() );
- pINST->GetDllMgr()->FreeDll( aByteDLLName );
+ pINST->GetDllMgr()->FreeDll( rPar.Get(1)->GetString() );
}
bool IsBaseIndexOne()
{
diff --git a/basic/source/runtime/os2.asm b/basic/source/runtime/os2.asm
deleted file mode 100644
index a56f0b74b8..0000000000
--- a/basic/source/runtime/os2.asm
+++ /dev/null
@@ -1,103 +0,0 @@
-;*************************************************************************
-;
-; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-;
-; Copyright 2000, 2010 Oracle and/or its affiliates.
-;
-; OpenOffice.org - a multi-platform office productivity suite
-;
-; This file is part of OpenOffice.org.
-;
-; OpenOffice.org is free software: you can redistribute it and/or modify
-; it under the terms of the GNU Lesser General Public License version 3
-; only, as published by the Free Software Foundation.
-;
-; OpenOffice.org 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 version 3 for more details
-; (a copy is included in the LICENSE file that accompanied this code).
-;
-; You should have received a copy of the GNU Lesser General Public License
-; version 3 along with OpenOffice.org. If not, see
-; <http://www.openoffice.org/license.html>
-; for a copy of the LGPLv3 License.
-;
-;*************************************************************************
-
-; Anmerkungen
-; Direktaufruf von C- und PASCAL-Routinen, OS/2
-;
-; Inhalt:
-; type = CallXXX (far *proc, char *stack, short nstack)
-;
-; Kopie des Basic-Stacks (nstack Bytes) auf den C-Stack
-; und Aufruf der Prozedur.
-
- .386
- .MODEL FLAT
-
- .CODE
-
- PUBLIC CallINT
- PUBLIC CallLNG
- PUBLIC CallSNG
- PUBLIC CallDBL
- PUBLIC CallSTR
- PUBLIC CallFIX
-
- PUBLIC _CallINT
- PUBLIC _CallLNG
- PUBLIC _CallSNG
- PUBLIC _CallDBL
- PUBLIC _CallSTR
- PUBLIC _CallFIX
-
-_CallINT LABEL byte
-_CallLNG LABEL byte
-_CallSNG LABEL byte
-_CallDBL LABEL byte
-_CallSTR LABEL byte
-_CallFIX LABEL byte
-
-CallINT LABEL byte
-CallLNG LABEL byte
-CallSNG LABEL byte
-CallDBL LABEL byte
-CallSTR LABEL byte
-CallFIX PROC
-
-p EQU [EBP+8]
-stk EQU [EBP+12]
-n EQU [EBP+16]
-
- PUSH EBP
- MOV EBP,ESP
- PUSH ESI
- PUSH EDI
- MOV DX,DS
- MOVZX ECX,word ptr [n]
- SUB ESP,ECX
- MOV EDI,ESP
- MOV AX,SS
- MOV ES,AX
- MOV ESI,[stk]
- SHR ECX,1
- CLD
- JCXZ $1
- REP MOVSW ; Stack uebernehmen
-$1: MOV DS,DX
- CALL LARGE [p] ; 32-bit
- MOV ECX,EBP
- SUB ECX,8 ; wegen gepushter Register
- MOV ESP,ECX
- POP EDI
- POP ESI
- POP EBP
-; Bei Borland C++ Calling Convention:
-; RET 12
-; CSet System-Calling Convention
- RET
-CallFIX ENDP
-
- END
diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx
index 485abe4794..13485d7bb2 100644
--- a/basic/source/runtime/rtlproto.hxx
+++ b/basic/source/runtime/rtlproto.hxx
@@ -166,6 +166,7 @@ extern RTLFUNC(RmDir); // JSM
extern RTLFUNC(SendKeys); // JSM
extern RTLFUNC(DimArray);
extern RTLFUNC(Dir);
+extern RTLFUNC(DoEvents);
extern RTLFUNC(Exp);
extern RTLFUNC(FileLen);
extern RTLFUNC(Fix);
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index c7d2d4ed4b..b27495099a 100755
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -155,6 +155,7 @@ SbiRuntime::pStep0 SbiRuntime::aStep0[] = { // Alle Opcodes ohne Operanden
&SbiRuntime::StepVBASET,// vba-like set statement
&SbiRuntime::StepERASE_CLEAR,// vba-like set statement
&SbiRuntime::StepARRAYACCESS,// access TOS as array
+ &SbiRuntime::StepBYVAL, // access TOS as array
};
SbiRuntime::pStep1 SbiRuntime::aStep1[] = { // Alle Opcodes mit einem Operanden
@@ -906,7 +907,7 @@ sal_Int32 SbiRuntime::translateErrorToVba( SbError nError, String& rMsg )
{
// TEST, has to be vb here always
#ifdef DBG_UTIL
- SbError nTmp = StarBASIC::GetSfxFromVBError( USHORT( nError ) );
+ SbError nTmp = StarBASIC::GetSfxFromVBError( (USHORT)nError );
DBG_ASSERT( nTmp, "No VB error!" );
#endif
@@ -1231,9 +1232,7 @@ void SbiRuntime::DllCall
SbxVariable* pRes = new SbxVariable( eResType );
SbiDllMgr* pDllMgr = pInst->GetDllMgr();
- ByteString aByteFuncName( aFuncName, gsl_getSystemTextEncoding() );
- ByteString aByteDLLName( aDLLName, gsl_getSystemTextEncoding() );
- SbError nErr = pDllMgr->Call( aByteFuncName.GetBuffer(), aByteDLLName.GetBuffer(), pArgs, *pRes, bCDecl );
+ SbError nErr = pDllMgr->Call( aFuncName, aDLLName, pArgs, *pRes, bCDecl );
if( nErr )
Error( nErr );
PushVar( pRes );
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index c9baf952ed..a4a7f7f68b 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -216,6 +216,7 @@ static Methods aMethods[] = {
{ "Dir", SbxSTRING, 2 | _FUNCTION, RTLNAME(Dir),0 },
{ "FileSpec", SbxSTRING, _OPT, NULL,0 },
{ "attrmask", SbxINTEGER, _OPT, NULL,0 },
+{ "DoEvents", SbxEMPTY, _FUNCTION, RTLNAME(DoEvents),0 },
{ "DumpAllObjects", SbxEMPTY, 2 | _SUB, RTLNAME(DumpAllObjects),0 },
{ "FileSpec", SbxSTRING, 0,NULL,0 },
{ "DumpAll", SbxINTEGER, _OPT, NULL,0 },
@@ -361,6 +362,8 @@ static Methods aMethods[] = {
{ "Count", SbxLONG, 0,NULL,0 },
{ "Len", SbxLONG, 1 | _FUNCTION, RTLNAME(Len),0 },
{ "StringOrVariant", SbxVARIANT, 0,NULL,0 },
+{ "LenB", SbxLONG, 1 | _FUNCTION, RTLNAME(Len),0 },
+ { "StringOrVariant", SbxVARIANT, 0,NULL,0 },
{ "Load", SbxNULL, 1 | _FUNCTION, RTLNAME(Load),0 },
{ "object", SbxOBJECT, 0,NULL,0 },
{ "LoadPicture", SbxOBJECT, 1 | _FUNCTION, RTLNAME(LoadPicture),0 },
@@ -628,6 +631,10 @@ SbiStdObject::SbiStdObject( const String& r, StarBASIC* pb ) : SbxObject( r )
p += ( p->nArgs & _ARGSMASK ) + 1;
}
+ // #i92642: Remove default properties
+ Remove( XubString( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_DONTCARE );
+ Remove( XubString( RTL_CONSTASCII_USTRINGPARAM("Parent") ), SbxCLASS_DONTCARE );
+
SetParent( pb );
pStdFactory = new SbStdFactory;
diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx
index 96a3e80a84..2c576e07f6 100644
--- a/basic/source/runtime/step0.cxx
+++ b/basic/source/runtime/step0.cxx
@@ -43,6 +43,9 @@
#include <vcl/svapp.hxx>
#include <unotools/textsearch.hxx>
+Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::OUString& aVBAType,
+ const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj );
+
#include <algorithm>
SbxVariable* getDefaultProp( SbxVariable* pRef );
@@ -515,8 +518,29 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
}
}
+ // Handle withevents
+ BOOL bWithEvents = refVar->IsSet( SBX_WITH_EVENTS );
+ Reference< XInterface > xComListener;
+ if( bWithEvents )
+ {
+ SbxBase* pObj = refVal->GetObject();
+ SbUnoObject* pUnoObj = (pObj != NULL) ? PTR_CAST(SbUnoObject,pObj) : NULL;
+ if( pUnoObj != NULL )
+ {
+ Any aControlAny = pUnoObj->getUnoAny();
+ String aDeclareClassName = refVar->GetDeclareClassName();
+ ::rtl::OUString aVBAType = aDeclareClassName;
+ ::rtl::OUString aPrefix = refVar->GetName();
+ SbxObjectRef xScopeObj = refVar->GetParent();
+ xComListener = createComListener( aControlAny, aVBAType, aPrefix, xScopeObj );
+ }
+ }
+
*refVar = *refVal;
+ if( bWithEvents )
+ refVar->SetComListener( xComListener ); // Hold reference
+
// lhs is a property who's value is currently (Empty e.g. no broadcast yet)
// in this case if there is a default prop involved the value of the
// default property may infact be void so the type will also be SbxEMPTY
@@ -908,6 +932,19 @@ void SbiRuntime::StepARRAYACCESS()
PushVar( CheckArray( refVar ) );
}
+void SbiRuntime::StepBYVAL()
+{
+ // Copy variable on stack to break call by reference
+ SbxVariableRef pVar = PopVar();
+ SbxDataType t = pVar->GetType();
+
+ SbxVariable* pCopyVar = new SbxVariable( t );
+ pCopyVar->SetFlag( SBX_READWRITE );
+ *pCopyVar = *pVar;
+
+ PushVar( pCopyVar );
+}
+
// Einrichten eines Argvs
// nOp1 bleibt so -> 1. Element ist Returnwert
diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx
index cfbea24405..f448f7900b 100644
--- a/basic/source/runtime/step1.cxx
+++ b/basic/source/runtime/step1.cxx
@@ -453,9 +453,9 @@ bool SbiRuntime::implIsClass( SbxObject* pObj, const String& aClass )
}
bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal,
- const String& aClass, bool bRaiseErrors )
+ const String& aClass, bool bRaiseErrors, bool bDefault )
{
- bool bOk = true;
+ bool bOk = bDefault;
SbxDataType t = refVal->GetType();
if( t == SbxOBJECT )
@@ -489,6 +489,8 @@ bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal,
}
else
{
+ bOk = true;
+
SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pObj);
if( pClassModuleObject != NULL )
pClassModuleObject->triggerInitializeEvent();
@@ -532,7 +534,8 @@ void SbiRuntime::StepTESTCLASS( UINT32 nOp1 )
{
SbxVariableRef xObjVal = PopVar();
String aClass( pImg->GetString( static_cast<short>( nOp1 ) ) );
- bool bOk = checkClass_Impl( xObjVal, aClass, false );
+ bool bDefault = !bVBAEnabled;
+ bool bOk = checkClass_Impl( xObjVal, aClass, false, bDefault );
SbxVariable* pRet = new SbxVariable;
pRet->PutBool( bOk );
diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx
index fb79d2f863..48a0a0da99 100644
--- a/basic/source/runtime/step2.cxx
+++ b/basic/source/runtime/step2.cxx
@@ -1068,9 +1068,17 @@ void SbiRuntime::StepTCREATE( UINT32 nOp1, UINT32 nOp2 )
pCopyObj->SetName( aName );
SbxVariable* pNew = new SbxVariable;
pNew->PutObject( pCopyObj );
+ pNew->SetDeclareClassName( aClass );
PushVar( pNew );
}
+void SbiRuntime::implCreateFixedString( SbxVariable* pStrVar, UINT32 nOp2 )
+{
+ USHORT nCount = static_cast<USHORT>( nOp2 >> 17 ); // len = all bits above 0x10000
+ String aStr;
+ aStr.Fill( nCount, 0 );
+ pStrVar->PutString( aStr );
+}
// Einrichten einer lokalen Variablen (+StringID+Typ)
@@ -1081,9 +1089,15 @@ void SbiRuntime::StepLOCAL( UINT32 nOp1, UINT32 nOp2 )
String aName( pImg->GetString( static_cast<short>( nOp1 ) ) );
if( refLocals->Find( aName, SbxCLASS_DONTCARE ) == NULL )
{
- SbxDataType t = (SbxDataType) nOp2;
+ SbxDataType t = (SbxDataType)(nOp2 & 0xffff);
SbxVariable* p = new SbxVariable( t );
p->SetName( aName );
+ bool bWithEvents = ((t & 0xff) == SbxOBJECT && (nOp2 & SBX_TYPE_WITH_EVENTS_FLAG) != 0);
+ if( bWithEvents )
+ p->SetFlag( SBX_WITH_EVENTS );
+ bool bFixedString = ((t & 0xff) == SbxSTRING && (nOp2 & SBX_FIXED_LEN_STRING_FLAG) != 0);
+ if( bFixedString )
+ implCreateFixedString( p, nOp2 );
refLocals->Put( p, refLocals->Count() );
}
}
@@ -1093,7 +1107,7 @@ void SbiRuntime::StepLOCAL( UINT32 nOp1, UINT32 nOp2 )
void SbiRuntime::StepPUBLIC_Impl( UINT32 nOp1, UINT32 nOp2, bool bUsedForClassModule )
{
String aName( pImg->GetString( static_cast<short>( nOp1 ) ) );
- SbxDataType t = (SbxDataType) nOp2;
+ SbxDataType t = (SbxDataType)(SbxDataType)(nOp2 & 0xffff);;
BOOL bFlag = pMod->IsSet( SBX_NO_MODIFY );
pMod->SetFlag( SBX_NO_MODIFY );
SbxVariableRef p = pMod->Find( aName, SbxCLASS_PROPERTY );
@@ -1109,6 +1123,13 @@ void SbiRuntime::StepPUBLIC_Impl( UINT32 nOp1, UINT32 nOp2, bool bUsedForClassMo
pProp->SetFlag( SBX_DONTSTORE );
// AB: 2.7.1996: HACK wegen 'Referenz kann nicht gesichert werden'
pProp->SetFlag( SBX_NO_MODIFY);
+
+ bool bWithEvents = ((t & 0xff) == SbxOBJECT && (nOp2 & SBX_TYPE_WITH_EVENTS_FLAG) != 0);
+ if( bWithEvents )
+ pProp->SetFlag( SBX_WITH_EVENTS );
+ bool bFixedString = ((t & 0xff) == SbxSTRING && (nOp2 & SBX_FIXED_LEN_STRING_FLAG) != 0);
+ if( bFixedString )
+ implCreateFixedString( p, nOp2 );
}
}
@@ -1122,7 +1143,10 @@ void SbiRuntime::StepPUBLIC_P( UINT32 nOp1, UINT32 nOp2 )
// Creates module variable that isn't reinitialised when
// between invocations ( for VBASupport & document basic only )
if( pMod->pImage->bFirstInit )
- StepPUBLIC( nOp1, nOp2 );
+ {
+ bool bUsedForClassModule = pImg->GetFlag( SBIMG_CLASSMODULE );
+ StepPUBLIC_Impl( nOp1, nOp2, bUsedForClassModule );
+ }
}
// Einrichten einer globalen Variablen (+StringID+Typ)
@@ -1133,7 +1157,7 @@ void SbiRuntime::StepGLOBAL( UINT32 nOp1, UINT32 nOp2 )
StepPUBLIC_Impl( nOp1, nOp2, true );
String aName( pImg->GetString( static_cast<short>( nOp1 ) ) );
- SbxDataType t = (SbxDataType) nOp2;
+ SbxDataType t = (SbxDataType)(SbxDataType)(nOp2 & 0xffff);;
BOOL bFlag = rBasic.IsSet( SBX_NO_MODIFY );
rBasic.SetFlag( SBX_NO_MODIFY );
SbxVariableRef p = rBasic.Find( aName, SbxCLASS_PROPERTY );
diff --git a/basic/source/runtime/win.asm b/basic/source/runtime/win.asm
deleted file mode 100644
index dea597a4ce..0000000000
--- a/basic/source/runtime/win.asm
+++ /dev/null
@@ -1,80 +0,0 @@
-;*************************************************************************
-;
-; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-;
-; Copyright 2000, 2010 Oracle and/or its affiliates.
-;
-; OpenOffice.org - a multi-platform office productivity suite
-;
-; This file is part of OpenOffice.org.
-;
-; OpenOffice.org is free software: you can redistribute it and/or modify
-; it under the terms of the GNU Lesser General Public License version 3
-; only, as published by the Free Software Foundation.
-;
-; OpenOffice.org 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 version 3 for more details
-; (a copy is included in the LICENSE file that accompanied this code).
-;
-; You should have received a copy of the GNU Lesser General Public License
-; version 3 along with OpenOffice.org. If not, see
-; <http://www.openoffice.org/license.html>
-; for a copy of the LGPLv3 License.
-;
-;*************************************************************************
-
-; Anmerkungen
-; Direktaufruf von C- und PASCAL-Routinen, Windows und OS/2
-;
-; Inhalt:
-; type = CallXXX (far *proc, char *stack, short nstack)
-;
-; Kopie des Basic-Stacks (nstack Bytes) auf den C-Stack
-; und Aufruf der Prozedur.
-
- .MODEL LARGE,C
-
- .CODE
-
- PUBLIC CallINT
- PUBLIC CallLNG
- PUBLIC CallSNG
- PUBLIC CallDBL
- PUBLIC CallSTR
- PUBLIC CallFIX
-
-CallINT LABEL byte
-CallLNG LABEL byte
-CallSNG LABEL byte
-CallDBL LABEL byte
-CallSTR LABEL byte
-CallFIX PROC p:PTR,stk:PTR,n:WORD
-
- PUSH SI
- PUSH DI
- MOV DX,DS
- SUB SP,[n]
- MOV DI,SP
- MOV AX,SS
- MOV ES,AX
- LDS SI,[stk]
- MOV CX,[n]
- SHR CX,1
- CLD
- JCXZ $1
- REP MOVSW ; Stack uebernehmen
-$1: MOV DS,DX
- CALL [p] ; Aufruf der Prozedur
- CLI
- MOV SP,BP
- SUB SP,4 ; wegen gepushter Register
- STI
- POP DI
- POP SI
- RET
-
-CallFIX ENDP
-
- END
diff --git a/basic/source/runtime/wnt-mingw.s b/basic/source/runtime/wnt-mingw.s
index 1168804102..7868ddd386 100644
--- a/basic/source/runtime/wnt-mingw.s
+++ b/basic/source/runtime/wnt-mingw.s
@@ -1,7 +1,7 @@
#*************************************************************************
#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
+#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
@@ -23,71 +23,31 @@
# <http://www.openoffice.org/license.html>
# for a copy of the LGPLv3 License.
#
-#*************************************************************************
-
-# Anmerkungen
-# Direktaufruf von C- und PASCAL-Routinen, Windows und OS/2
-#
-# Inhalt:
-# type = CallXXX (far *pProc, char *pStack, short nStack)
-#
-# Kopie des Basic-Stacks (nStack Bytes) auf den C-Stack
-# und Aufruf der Prozedur.
-
- .intel_syntax
- #.386
-
-#_TEXT SEGMENT DWORD PUBLIC 'CODE' USE32
-
- #ASSUME CS:_TEXT
-
-.globl _CallINT
-.globl _CallLNG
-.globl _CallDBL
-.globl _CallSTR
-.globl _CallFIX
-
-_CallINT:
-_CallLNG:
-_CallDBL:
-_CallSTR:
-
-_CallFIX: PUSH EBP
- MOV EBP,ESP
- PUSH ESI
- PUSH EDI
-
- PUSH ECX
- PUSH EDX
-
- MOV DX,DS
- MOVZX EAX,WORD PTR [EBP+16] # EAX == nStack
- SUB ESP,EAX # Stack um nStack Bytes vergroessern
- MOV EDI,ESP
- MOV AX,SS
- MOV ES,AX # ES:EDI = Startadresse des fuer
- # Parameter reservierten Stackbereichs
- MOV ESI,[EBP+12] # DS:ESI == pStack
-
- MOVZX ECX,WORD PTR [EBP+16] # ECX == nStack
- SHR ECX,1
- CLD
- JCXZ $1
- REP MOVSW # Stack uebernehmen
-$1: MOV DS,DX
- CALL DWORD PTR [EBP+8] # Aufruf der Prozedur
- # CLI # unter NT nicht erlaubt (privileged instruction)
- MOV ESP,EBP
- SUB ESP,16 # wegen gepushter Register
- # (ESI, EDI)
- # STI
- POP EDX
- POP ECX
- POP EDI
- POP ESI
- POP EBP
- RET 12
-
-#_TEXT ENDS
-
- #END
+#***********************************************************************/
+
+.intel_syntax
+
+.globl _DllMgr_call32
+.globl _DllMgr_callFp
+
+_DllMgr_call32:
+_DllMgr_callFp:
+ push ebp
+ mov ebp, esp
+ push esi
+ push edi
+ mov ecx, [ebp+16]
+ jecxz $1
+ sub esp, ecx
+ mov edi, esp
+ mov esi, [ebp+12]
+ shr ecx, 2
+ rep movsd
+$1: call DWORD PTR [ebp+8]
+ ; for extra safety, do not trust esp after call (in case the Basic Declare
+ ; signature is wrong):
+ mov edi, [ebp-8]
+ mov esi, [ebp-4]
+ mov esp, ebp
+ pop ebp
+ ret 12
diff --git a/basic/source/runtime/wnt.asm b/basic/source/runtime/wnt.asm
index 3824daae96..2a8710e342 100644
--- a/basic/source/runtime/wnt.asm
+++ b/basic/source/runtime/wnt.asm
@@ -1,7 +1,7 @@
;*************************************************************************
;
; DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-;
+;
; Copyright 2000, 2010 Oracle and/or its affiliates.
;
; OpenOffice.org - a multi-platform office productivity suite
@@ -23,70 +23,34 @@
; <http://www.openoffice.org/license.html>
; for a copy of the LGPLv3 License.
;
-;*************************************************************************
-
-; Anmerkungen
-; Direktaufruf von C- und PASCAL-Routinen, Windows und OS/2
-;
-; Inhalt:
-; type = CallXXX (far *pProc, char *pStack, short nStack)
-;
-; Kopie des Basic-Stacks (nStack Bytes) auf den C-Stack
-; und Aufruf der Prozedur.
-
- .386
-
-_TEXT SEGMENT DWORD PUBLIC 'CODE' USE32
-
- ASSUME CS:_TEXT
-
- PUBLIC _CallINT@12
- PUBLIC _CallLNG@12
- PUBLIC _CallDBL@12
- PUBLIC _CallSTR@12
- PUBLIC _CallFIX@12
-
-_CallINT@12 LABEL byte
-_CallLNG@12 LABEL byte
-_CallDBL@12 LABEL byte
-_CallSTR@12 LABEL byte
-
-_CallFIX@12: PUSH EBP
- MOV EBP,ESP
- PUSH ESI
- PUSH EDI
-
- PUSH ECX
- PUSH EDX
-
- MOV DX,DS
- MOVZX EAX,WORD PTR [EBP+16] ; EAX == nStack
- SUB ESP,EAX ; Stack um nStack Bytes vergroessern
- MOV EDI,ESP
- MOV AX,SS
- MOV ES,AX ; ES:EDI = Startadresse des fuer
- ; Parameter reservierten Stackbereichs
- MOV ESI,[EBP+12] ; DS:ESI == pStack
-
- MOVZX ECX,WORD PTR [EBP+16] ; ECX == nStack
- SHR ECX,1
- CLD
- JCXZ $1
- REP MOVSW ; Stack uebernehmen
-$1: MOV DS,DX
- CALL DWORD PTR [EBP+8] ; Aufruf der Prozedur
- ; CLI ; unter NT nicht erlaubt (privileged instruction)
- MOV ESP,EBP
- SUB ESP,16 ; wegen gepushter Register
- ; (ESI, EDI)
- ; STI
- POP EDX
- POP ECX
- POP EDI
- POP ESI
- POP EBP
- RET 12
-
-_TEXT ENDS
-
- END
+;***********************************************************************/
+
+.386
+
+PUBLIC _DllMgr_call32@12
+PUBLIC _DllMgr_callFp@12
+
+_TEXT SEGMENT
+_DllMgr_call32@12:
+_DllMgr_callFp@12:
+ push ebp
+ mov ebp, esp
+ push esi
+ push edi
+ mov ecx, [ebp+16]
+ jecxz $1
+ sub esp, ecx
+ mov edi, esp
+ mov esi, [ebp+12]
+ shr ecx, 2
+ rep movsd
+$1: call DWORD PTR [ebp+8]
+ ; for extra safety, do not trust esp after call (in case the Basic Declare
+ ; signature is wrong):
+ mov edi, [ebp-8]
+ mov esi, [ebp-4]
+ mov esp, ebp
+ pop ebp
+ ret 12
+_TEXT ENDS
+END
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index fe9734c84e..69ae79cad5 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -39,6 +39,9 @@
#include <math.h>
#include <ctype.h>
+#include "com/sun/star/uno/XInterface.hpp"
+using namespace com::sun::star::uno;
+
///////////////////////////// SbxVariable //////////////////////////////
TYPEINIT1(SbxVariable,SbxValue)
@@ -49,10 +52,28 @@ extern UINT32 nVarCreator; // in SBXBASE.CXX, fuer LoadData()
static ULONG nVar = 0;
#endif
+///////////////////////////// SbxVariableImpl ////////////////////////////
+
+class SbxVariableImpl
+{
+ friend class SbxVariable;
+ String m_aDeclareClassName;
+ Reference< XInterface > m_xComListener;
+
+ SbxVariableImpl( void )
+ {}
+ SbxVariableImpl( const SbxVariableImpl& r )
+ : m_aDeclareClassName( r.m_aDeclareClassName )
+ , m_xComListener( r.m_xComListener )
+ {}
+};
+
+
///////////////////////////// Konstruktoren //////////////////////////////
SbxVariable::SbxVariable() : SbxValue()
{
+ mpSbxVariableImpl = NULL;
pCst = NULL;
pParent = NULL;
nUserData = 0;
@@ -66,6 +87,9 @@ SbxVariable::SbxVariable() : SbxValue()
SbxVariable::SbxVariable( const SbxVariable& r )
: SvRefBase( r ), SbxValue( r ), mpPar( r.mpPar ), pInfo( r.pInfo )
{
+ mpSbxVariableImpl = NULL;
+ if( r.mpSbxVariableImpl != NULL )
+ mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl );
pCst = NULL;
if( r.CanRead() )
{
@@ -91,6 +115,7 @@ SbxVariable::SbxVariable( const SbxVariable& r )
SbxVariable::SbxVariable( SbxDataType t, void* p ) : SbxValue( t, p )
{
+ mpSbxVariableImpl = NULL;
pCst = NULL;
pParent = NULL;
nUserData = 0;
@@ -111,6 +136,7 @@ SbxVariable::~SbxVariable()
maName.AssignAscii( aCellsStr, sizeof( aCellsStr )-1 );
GetSbxData_Impl()->aVars.Remove( this );
#endif
+ delete mpSbxVariableImpl;
delete pCst;
}
@@ -287,6 +313,11 @@ USHORT SbxVariable::MakeHashCode( const XubString& rName )
SbxVariable& SbxVariable::operator=( const SbxVariable& r )
{
SbxValue::operator=( r );
+ delete mpSbxVariableImpl;
+ if( r.mpSbxVariableImpl != NULL )
+ mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl );
+ else
+ mpSbxVariableImpl = NULL;
return *this;
}
@@ -346,6 +377,32 @@ void SbxVariable::SetParent( SbxObject* p )
pParent = p;
}
+SbxVariableImpl* SbxVariable::getImpl( void )
+{
+ if( mpSbxVariableImpl == NULL )
+ mpSbxVariableImpl = new SbxVariableImpl();
+ return mpSbxVariableImpl;
+}
+
+const String& SbxVariable::GetDeclareClassName( void )
+{
+ SbxVariableImpl* pImpl = getImpl();
+ return pImpl->m_aDeclareClassName;
+}
+
+void SbxVariable::SetDeclareClassName( const String& rDeclareClassName )
+{
+ SbxVariableImpl* pImpl = getImpl();
+ pImpl->m_aDeclareClassName = rDeclareClassName;
+}
+
+void SbxVariable::SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener )
+{
+ SbxVariableImpl* pImpl = getImpl();
+ pImpl->m_xComListener = xComListener;
+}
+
+
////////////////////////////// Laden/Speichern /////////////////////////////
BOOL SbxVariable::LoadData( SvStream& rStrm, USHORT nVer )
diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx
index 4bbcb31359..aee3d18392 100644
--- a/basic/source/uno/dlgcont.cxx
+++ b/basic/source/uno/dlgcont.cxx
@@ -187,12 +187,13 @@ bool writeOasis2OOoLibraryElement(
void SAL_CALL SfxDialogLibraryContainer::writeLibraryElement
(
- Any aElement,
- const OUString& /*aElementName*/,
- Reference< XOutputStream > xOutput
+ const Reference < XNameContainer >& xLib,
+ const OUString& aElementName,
+ const Reference< XOutputStream >& xOutput
)
throw(Exception)
{
+ Any aElement = xLib->getByName( aElementName );
Reference< XInputStreamProvider > xISP;
aElement >>= xISP;
if( !xISP.is() )
@@ -256,7 +257,9 @@ void SfxDialogLibraryContainer::storeLibrariesToStorage( const uno::Reference< e
Any SAL_CALL SfxDialogLibraryContainer::importLibraryElement
- ( const OUString& aFile, const uno::Reference< io::XInputStream >& xElementStream )
+ ( const Reference < XNameContainer >& /*xLib*/,
+ const OUString& /*aElementName */, const OUString& aFile,
+ const uno::Reference< io::XInputStream >& xElementStream )
{
Any aRetAny;
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 06f4ecf22d..288b06a8f9 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -1369,8 +1369,8 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
OUString aStreamName = aElementName;
aStreamName += String( RTL_CONSTASCII_USTRINGPARAM(".xml") );
- Any aElement = pLib->getByName( aElementName );
- if( !isLibraryElementValid( aElement ) )
+ /*Any aElement = pLib->getByName( aElementName );*/
+ if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
{
#if OSL_DEBUG_LEVEL > 0
::rtl::OStringBuffer aMessage;
@@ -1406,7 +1406,8 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
xProps->setPropertyValue( aPropName, uno::makeAny( sal_True ) );
Reference< XOutputStream > xOutput = xElementStream->getOutputStream();
- writeLibraryElement( aElement, aElementName, xOutput );
+ Reference< XNameContainer > xLib( pLib );
+ writeLibraryElement( xLib, aElementName, xOutput );
// writeLibraryElement closes the stream
// xOutput->closeOutput();
}
@@ -1458,8 +1459,8 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
aElementInetObj.setExtension( maLibElementFileExtension );
String aElementPath( aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ) );
- Any aElement = pLib->getByName( aElementName );
- if( !isLibraryElementValid( aElement ) )
+ /*Any aElement = pLib->getByName( aElementName );*/
+ if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
{
#if OSL_DEBUG_LEVEL > 0
::rtl::OStringBuffer aMessage;
@@ -1477,7 +1478,8 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib,
if( xSFI->exists( aElementPath ) )
xSFI->kill( aElementPath );
Reference< XOutputStream > xOutput = xSFI->openFileWrite( aElementPath );
- writeLibraryElement( aElement, aElementName, xOutput );
+ Reference< XNameContainer > xLib( pLib );
+ writeLibraryElement( xLib, aElementName, xOutput );
xOutput->closeOutput();
}
catch( Exception& )
@@ -2380,7 +2382,9 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name )
aFile = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE );
}
- Any aAny = importLibraryElement( aFile, xInStream );
+ Reference< XNameContainer > xLib( pImplLib );
+ Any aAny = importLibraryElement( xLib, aElementName,
+ aFile, xInStream );
if( pImplLib->hasByName( aElementName ) )
{
if( aAny.hasValue() )
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index c490571855..2bc4787a65 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -41,6 +41,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/embed/XTransactedObject.hpp>
#include <com/sun/star/task/ErrorCodeIOException.hpp>
+#include <com/sun/star/script/ModuleType.hpp>
#include <comphelper/processfactory.hxx>
#ifndef _COMPHELPER_STORAGEHELPER_HXX_
#include <comphelper/storagehelper.hxx>
@@ -60,6 +61,7 @@
#include <svtools/ehdl.hxx>
#include <basic/basmgr.hxx>
#include <basic/sbmod.hxx>
+#include <basic/basicmanagerrepository.hxx>
#include "modsizeexceeded.hxx"
#include <xmlscript/xmlmod_imexp.hxx>
#include <cppuhelper/factory.hxx>
@@ -184,9 +186,9 @@ bool SAL_CALL SfxScriptLibraryContainer::isLibraryElementValid( Any aElement ) c
void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement
(
- Any aElement,
+ const Reference < XNameContainer >& xLib,
const OUString& aElementName,
- Reference< XOutputStream > xOutput
+ const Reference< XOutputStream >& xOutput
)
throw(Exception)
{
@@ -211,13 +213,42 @@ void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement
xmlscript::ModuleDescriptor aMod;
aMod.aName = aElementName;
aMod.aLanguage = maScriptLanguage;
+ Any aElement = xLib->getByName( aElementName );
aElement >>= aMod.aCode;
+
+ Reference < script::XVBAModuleInfo > xModInfo( xLib, UNO_QUERY );
+
+ if( xModInfo.is() && xModInfo->hasModuleInfo( aElementName ) )
+ {
+ script::ModuleInfo aModInfo = xModInfo->getModuleInfo( aElementName );
+ switch( aModInfo.ModuleType )
+ {
+ case ModuleType::NORMAL:
+ aMod.aModuleType = OUString( RTL_CONSTASCII_USTRINGPARAM("normal") );
+ break;
+ case ModuleType::CLASS:
+ aMod.aModuleType = OUString( RTL_CONSTASCII_USTRINGPARAM("class") );
+ break;
+ case ModuleType::FORM:
+ aMod.aModuleType = OUString( RTL_CONSTASCII_USTRINGPARAM("form") );
+ break;
+ case ModuleType::DOCUMENT:
+ aMod.aModuleType = OUString( RTL_CONSTASCII_USTRINGPARAM("document") );
+ break;
+ case ModuleType::UNKNOWN:
+ // nothing
+ break;
+ }
+ }
+
xmlscript::exportScriptModule( xHandler, aMod );
}
Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement
- ( const OUString& aFile, const uno::Reference< io::XInputStream >& xInStream )
+ ( const Reference < XNameContainer >& xLib,
+ const OUString& aElementName, const OUString& aFile,
+ const uno::Reference< io::XInputStream >& xInStream )
{
Any aRetAny;
@@ -279,6 +310,86 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement
// TODO: Check language
// aMod.aLanguage
// aMod.aName ignored
+ if( aMod.aModuleType.getLength() > 0 )
+ {
+ if( !getVBACompatModeOn() )
+ {
+ setVBACompatModeOn( sal_True );
+
+ Any aGlobs;
+ Sequence< Any > aArgs(1);
+ Reference<frame::XModel > xModel( mxOwnerDocument );
+ aArgs[ 0 ] <<= xModel;
+
+ BasicManager* pBasicMgr = getBasicManager();
+ if( pBasicMgr )
+ {
+ aGlobs <<= ::comphelper::getProcessServiceFactory()->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Globals" ) ), aArgs );
+ pBasicMgr->SetGlobalUNOConstant( "VBAGlobals", aGlobs );
+ }
+ pBasicMgr = BasicManagerRepository::getApplicationBasicManager( sal_False );
+ if( pBasicMgr )
+ pBasicMgr->SetGlobalUNOConstant( "ThisExcelDoc", aArgs[0] );
+ }
+
+ script::ModuleInfo aModInfo;
+ aModInfo.ModuleType = ModuleType::UNKNOWN;
+ if( aMod.aModuleType.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("normal") ))
+ {
+ aModInfo.ModuleType = ModuleType::NORMAL;
+ }
+ else if( aMod.aModuleType.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("class") ))
+ {
+ aModInfo.ModuleType = ModuleType::CLASS;
+ }
+ else if( aMod.aModuleType.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("form") ))
+ {
+ aModInfo.ModuleType = ModuleType::FORM;
+ aModInfo.ModuleObject = mxOwnerDocument;
+ }
+ else if( aMod.aModuleType.equalsAsciiL(
+ RTL_CONSTASCII_STRINGPARAM("document") ))
+ {
+ aModInfo.ModuleType = ModuleType::DOCUMENT;
+ Reference<frame::XModel > xModel( mxOwnerDocument );
+ Reference< XMultiServiceFactory> xSF( xModel, UNO_QUERY);
+ Reference< container::XNameAccess > xVBACodeNameAccess;
+ if( xSF.is() )
+ {
+ try
+ {
+ xVBACodeNameAccess.set( xSF->createInstance(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
+ "ooo.vba.VBAObjectModuleObjectProvider"))),
+ UNO_QUERY );
+ }
+ catch(uno::Exception&) {}
+ }
+ if( xVBACodeNameAccess.is() )
+ {
+ try
+ {
+ aModInfo.ModuleObject.set( xVBACodeNameAccess->getByName( aElementName), uno::UNO_QUERY );
+ }
+ catch(uno::Exception&)
+ {
+ OSL_TRACE("Failed to get documument object for %s", rtl::OUStringToOString( aElementName, RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
+ }
+ }
+
+ Reference< script::XVBAModuleInfo > xVBAModuleInfo( xLib,
+ UNO_QUERY );
+ if( xVBAModuleInfo.is() )
+ {
+ if( xVBAModuleInfo->hasModuleInfo( aElementName ) )
+ xVBAModuleInfo->removeModuleInfo( aElementName );
+ xVBAModuleInfo->insertModuleInfo( aElementName, aModInfo );
+ }
+ }
return aRetAny;
}
@@ -574,8 +685,8 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
if( pLib->mbPasswordVerified || pLib->mbDoc50Password )
{
- Any aElement = pLib->getByName( aElementName );
- if( !isLibraryElementValid( aElement ) )
+ /*Any aElement = pLib->getByName( aElementName );*/
+ if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
{
#if OSL_DEBUG_LEVEL > 0
::rtl::OStringBuffer aMessage;
@@ -606,7 +717,8 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
setStreamKey( xSourceStream, pLib->maPassword );
Reference< XOutputStream > xOutput = xSourceStream->getOutputStream();
- writeLibraryElement( aElement, aElementName, xOutput );
+ Reference< XNameContainer > xLib( pLib );
+ writeLibraryElement( xLib, aElementName, xOutput );
// writeLibraryElement should have the stream already closed
// xOutput->closeOutput();
}
@@ -659,8 +771,8 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
aElementInetObj.setExtension( OUString( RTL_CONSTASCII_USTRINGPARAM("pba") ) );
String aElementPath = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE );
- Any aElement = pLib->getByName( aElementName );
- if( !isLibraryElementValid( aElement ) )
+ /*Any aElement = pLib->getByName( aElementName );*/
+ if( !isLibraryElementValid( pLib->getByName( aElementName ) ) )
{
#if OSL_DEBUG_LEVEL > 0
::rtl::OStringBuffer aMessage;
@@ -741,7 +853,8 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib,
xProps->setPropertyValue( aPropName, uno::makeAny( aMime ) );
Reference< XOutputStream > xOut = xSourceStream->getOutputStream();
- writeLibraryElement( aElement, aElementName, xOut );
+ Reference< XNameContainer > xLib( pLib );
+ writeLibraryElement( xLib, aElementName, xOut );
// i50568: sax writer already closes stream
// xOut->closeOutput();
@@ -903,7 +1016,10 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
if ( !xInStream.is() )
throw io::IOException(); // read access denied, seems to be impossible
- Any aAny = importLibraryElement( aSourceStreamName, xInStream );
+ Reference< XNameContainer > xLib( pLib );
+ Any aAny = importLibraryElement( xLib,
+ aElementName, aSourceStreamName,
+ xInStream );
if( pLib->hasByName( aElementName ) )
{
if( aAny.hasValue() )
@@ -1006,7 +1122,11 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary
if ( !xInStream.is() )
throw io::IOException(); // read access denied, seems to be impossible
- Any aAny = importLibraryElement( aSourceStreamName, xInStream );
+ Reference< XNameContainer > xLib( pLib );
+ Any aAny = importLibraryElement( xLib,
+ aElementName,
+ aSourceStreamName,
+ xInStream );
if( pLib->hasByName( aElementName ) )
{
if( aAny.hasValue() )
diff --git a/basic/util/makefile.mk b/basic/util/makefile.mk
index 645c9b6a3c..629586f044 100644
--- a/basic/util/makefile.mk
+++ b/basic/util/makefile.mk
@@ -59,6 +59,7 @@ SHL1STDLIBS= \
$(VCLLIB) \
$(VOSLIB) \
$(SALLIB) \
+ $(SALHELPERLIB) \
$(COMPHELPERLIB) \
$(UNOTOOLSLIB) \
$(SOTLIB) \