summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Joachim Lankenau <hjs@openoffice.org>2010-12-17 13:36:59 +0100
committerHans-Joachim Lankenau <hjs@openoffice.org>2010-12-17 13:36:59 +0100
commit61e07dabe6b05ed341ad455724603390d102c4dd (patch)
tree8d469fd346579ed95046d3b7599d65b1fb9c3148
parentb80e3ed60399655cc665273e8f272dbea1721487 (diff)
parente632b638fe91d39f9c8f133e858f815b12b65e6d (diff)
CWS-TOOLING: integrate CWS mib19
-rw-r--r--basic/inc/basic/sbmod.hxx7
-rw-r--r--basic/inc/basic/sbobjmod.hxx15
-rw-r--r--basic/inc/basic/sbstar.hxx6
-rw-r--r--basic/inc/basic/sbxdef.hxx3
-rw-r--r--basic/inc/basic/sbxvar.hxx5
-rw-r--r--basic/source/basmgr/basicmanagerrepository.cxx56
-rw-r--r--basic/source/classes/eventatt.cxx50
-rw-r--r--basic/source/classes/sb.cxx236
-rwxr-xr-xbasic/source/classes/sbunoobj.cxx379
-rwxr-xr-x[-rw-r--r--]basic/source/classes/sbxmod.cxx231
-rw-r--r--basic/source/comp/dim.cxx3
-rw-r--r--basic/source/comp/exprtree.cxx31
-rwxr-xr-xbasic/source/comp/sbcomp.cxx249
-rw-r--r--basic/source/comp/scanner.cxx24
-rw-r--r--basic/source/comp/symtbl.cxx5
-rw-r--r--basic/source/inc/expr.hxx1
-rw-r--r--basic/source/inc/runtime.hxx4
-rwxr-xr-xbasic/source/inc/sbtrace.hxx4
-rw-r--r--basic/source/inc/sbunoobj.hxx18
-rw-r--r--basic/source/inc/scriptcont.hxx1
-rw-r--r--basic/source/runtime/comenumwrapper.cxx81
-rw-r--r--basic/source/runtime/comenumwrapper.hxx54
-rw-r--r--basic/source/runtime/makefile.mk1
-rwxr-xr-x[-rw-r--r--]basic/source/runtime/methods1.cxx127
-rw-r--r--basic/source/runtime/rtlproto.hxx6
-rw-r--r--basic/source/runtime/runtime.cxx23
-rw-r--r--basic/source/runtime/stdobj.cxx8
-rw-r--r--basic/source/runtime/step0.cxx115
-rwxr-xr-xbasic/source/runtime/step2.cxx92
-rw-r--r--basic/source/sbx/sbxobj.cxx3
-rwxr-xr-x[-rw-r--r--]basic/source/sbx/sbxvalue.cxx10
-rw-r--r--basic/source/sbx/sbxvar.cxx31
-rw-r--r--basic/source/uno/namecont.cxx34
-rw-r--r--basic/source/uno/scriptcont.cxx58
-rw-r--r--framework/source/fwi/helper/mischelper.cxx13
-rwxr-xr-xframework/source/layoutmanager/layoutmanager.cxx2
-rw-r--r--framework/source/services/pathsettings.cxx29
-rw-r--r--framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx5
-rw-r--r--framework/source/uiconfiguration/windowstateconfiguration.cxx27
-rw-r--r--framework/source/uielement/uicommanddescription.cxx27
-rw-r--r--oovbaapi/ooo/vba/XApplicationBase.idl6
-rwxr-xr-xoovbaapi/ooo/vba/XVBAAppService.idl72
-rwxr-xr-xoovbaapi/ooo/vba/XVBADocService.idl72
-rw-r--r--[-rwxr-xr-x]oovbaapi/ooo/vba/excel/SheetObject.idl2
-rw-r--r--[-rwxr-xr-x]oovbaapi/ooo/vba/excel/SheetObjects.idl6
-rw-r--r--oovbaapi/ooo/vba/excel/XApplication.idl10
-rw-r--r--oovbaapi/ooo/vba/excel/XFormat.idl2
-rw-r--r--oovbaapi/ooo/vba/excel/XGlobals.idl14
-rw-r--r--[-rwxr-xr-x]oovbaapi/ooo/vba/excel/XHyperlinks.idl10
-rw-r--r--oovbaapi/ooo/vba/excel/XRange.idl6
-rw-r--r--oovbaapi/ooo/vba/excel/XWindow.idl2
-rw-r--r--oovbaapi/ooo/vba/excel/XWorkbook.idl10
-rw-r--r--oovbaapi/ooo/vba/excel/XWorkbooks.idl2
-rw-r--r--oovbaapi/ooo/vba/excel/XWorksheet.idl32
-rw-r--r--oovbaapi/ooo/vba/word/XApplication.idl8
-rw-r--r--oovbaapi/ooo/vba/word/XDocument.idl20
-rw-r--r--oovbaapi/ooo/vba/word/XGlobals.idl8
-rw-r--r--oovbaapi/ooo/vba/word/XSelection.idl4
-rw-r--r--oovbaapi/ooo/vba/word/XTable.idl2
-rw-r--r--oovbaapi/ooo/vba/word/XTemplate.idl2
-rw-r--r--oovbaapi/ooo/vba/word/XWindow.idl2
-rw-r--r--sfx2/source/doc/objxtor.cxx26
-rw-r--r--svx/source/form/fmview.cxx4
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx18
-rw-r--r--vbahelper/inc/vbahelper/vbadocumentsbase.hxx8
-rwxr-xr-xvbahelper/inc/vbahelper/vbaeventshelperbase.hxx26
-rw-r--r--vbahelper/inc/vbahelper/vbahelper.hxx7
-rw-r--r--vbahelper/source/msforms/vbacontrol.cxx1
-rw-r--r--vbahelper/source/msforms/vbauserform.cxx36
-rw-r--r--vbahelper/source/vbahelper/vbaapplicationbase.cxx57
-rw-r--r--vbahelper/source/vbahelper/vbacommandbarcontrol.cxx40
-rw-r--r--vbahelper/source/vbahelper/vbadocumentbase.cxx95
-rw-r--r--vbahelper/source/vbahelper/vbadocumentsbase.cxx23
-rwxr-xr-xvbahelper/source/vbahelper/vbaeventshelperbase.cxx29
-rw-r--r--vbahelper/source/vbahelper/vbahelper.cxx286
75 files changed, 2074 insertions, 948 deletions
diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx
index d3813ad696..047f16bf38 100644
--- a/basic/inc/basic/sbmod.hxx
+++ b/basic/inc/basic/sbmod.hxx
@@ -46,6 +46,7 @@ class SbProcedureProperty;
class SbIfaceMapperMethod;
class SbClassModuleObject;
+class ModuleInitDependencyMap;
struct ClassModuleRunInitItem;
struct SbClassData;
class SbModuleImpl;
@@ -62,6 +63,8 @@ class SbModule : public SbxObject
SbModuleImpl* mpSbModuleImpl; // Impl data
std::vector< String > mModuleVariableNames;
+ void implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic );
+
protected:
com::sun::star::uno::Reference< com::sun::star::script::XInvocation > mxWrapper;
::rtl::OUString aOUSource;
@@ -74,7 +77,7 @@ protected:
SbxObjectRef pDocObject; // an impl object ( used by Document Modules )
bool bIsProxyModule;
- static void implProcessModuleRunInit( ClassModuleRunInitItem& rItem );
+ static void implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem );
void StartDefinitions();
SbMethod* GetMethod( const String&, SbxDataType );
SbProperty* GetProperty( const String&, SbxDataType );
@@ -84,6 +87,7 @@ protected:
USHORT Run( SbMethod* );
void RunInit();
void ClearPrivateVars();
+ void ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic );
void GlobalRunInit( BOOL bBasicStart ); // for all modules
void GlobalRunDeInit( void );
const BYTE* FindNextStmnt( const BYTE*, USHORT&, USHORT& ) const;
@@ -94,6 +98,7 @@ protected:
virtual BOOL LoadCompleted();
virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
const SfxHint& rHint, const TypeId& rHintType );
+ void handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint );
virtual ~SbModule();
public:
SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_BASICMOD,2);
diff --git a/basic/inc/basic/sbobjmod.hxx b/basic/inc/basic/sbobjmod.hxx
index 9ff46d1931..49fefb7930 100644
--- a/basic/inc/basic/sbobjmod.hxx
+++ b/basic/inc/basic/sbobjmod.hxx
@@ -52,10 +52,18 @@ class SbObjModule : public SbModule
{
SbObjModule( const SbObjModule& );
SbObjModule();
+
+protected:
+ virtual ~SbObjModule();
+
public:
TYPEINFO();
SbObjModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVbaCompatible );
virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
+
+ virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
+ const SfxHint& rHint, const TypeId& rHintType );
+
using SbxValue::GetObject;
SbxVariable* GetObject();
void SetUnoObject( const com::sun::star::uno::Any& aObj )throw ( com::sun::star::uno::RuntimeException ) ;
@@ -81,7 +89,7 @@ public:
SbUserFormModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVBACompat );
virtual ~SbUserFormModule();
virtual SbxVariable* Find( const XubString& rName, SbxClassType t );
- void ResetApiObj();
+ void ResetApiObj( bool bTriggerTerminateEvent = true );
void Unload();
void Load();
void triggerMethod( const String& );
@@ -93,6 +101,11 @@ public:
void triggerLayoutEvent();
void triggerResizeEvent();
+ bool getInitState( void )
+ { return mbInit; }
+ void setInitState( bool bInit )
+ { mbInit = bInit; }
+
class SbUserFormModuleInstance* CreateInstance();
};
diff --git a/basic/inc/basic/sbstar.hxx b/basic/inc/basic/sbstar.hxx
index 9ad0294c30..858c818b45 100644
--- a/basic/inc/basic/sbstar.hxx
+++ b/basic/inc/basic/sbstar.hxx
@@ -38,6 +38,7 @@
#include <basic/sbdef.hxx>
#include <basic/sberrors.hxx>
#include <com/sun/star/script/ModuleInfo.hpp>
+#include <com/sun/star/frame/XModel.hpp>
class SbModule; // completed module
class SbiInstance; // runtime instance
@@ -77,6 +78,8 @@ class StarBASIC : public SbxObject
SbxObjectRef pVBAGlobals;
SbxObject* getVBAGlobals( );
+ void implClearDependingVarsOnDelete( StarBASIC* pDeletedBasic );
+
protected:
BOOL CError( SbError, const String&, xub_StrLen, xub_StrLen, xub_StrLen );
private:
@@ -206,6 +209,9 @@ public:
bool GetUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut );
void QuitAndExitApplication();
BOOL IsQuitApplication() { return bQuit; };
+
+ static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
+ GetModelFromBasic( SbxObject* pBasic );
};
#ifndef __SB_SBSTARBASICREF_HXX
diff --git a/basic/inc/basic/sbxdef.hxx b/basic/inc/basic/sbxdef.hxx
index 42117ce78b..393a3773e7 100644
--- a/basic/inc/basic/sbxdef.hxx
+++ b/basic/inc/basic/sbxdef.hxx
@@ -106,6 +106,7 @@ enum SbxDataType {
};
const UINT32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000;
+const UINT32 SBX_TYPE_DIM_AS_NEW_FLAG = 0x20000;
const UINT32 SBX_FIXED_LEN_STRING_FLAG = 0x10000; // same value as above as no conflict possible
#endif
@@ -317,6 +318,8 @@ enum SbxError { // Ergebnis einer Rechenoperation/Konversion
#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
+#define SBX_DIM_AS_NEW 0x0800 // Same value as SBX_GBLSEARCH, cannot conflict as one
+ // is used for objects, the other for variables only
// Broadcaster-IDs:
#define SBX_HINT_DYING SFX_HINT_DYING
diff --git a/basic/inc/basic/sbxvar.hxx b/basic/inc/basic/sbxvar.hxx
index 7988c95399..72615f8c66 100644
--- a/basic/inc/basic/sbxvar.hxx
+++ b/basic/inc/basic/sbxvar.hxx
@@ -439,6 +439,7 @@ SV_DECL_REF(SbxInfo)
class SfxBroadcaster;
class SbxVariableImpl;
+class StarBASIC;
class SbxVariable : public SbxValue
{
@@ -499,7 +500,9 @@ public:
const String& GetDeclareClassName( void );
void SetDeclareClassName( const String& );
- void SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener );
+ void SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener,
+ StarBASIC* pParentBasic );
+ void ClearComListener( void );
static USHORT MakeHashCode( const String& rName );
};
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx
index 4ecaec7302..454b8875a9 100644
--- a/basic/source/basmgr/basicmanagerrepository.cxx
+++ b/basic/source/basmgr/basicmanagerrepository.cxx
@@ -139,9 +139,17 @@ namespace basic
impl_getLocationForModel( const Reference< XModel >& _rxDocumentModel );
/** creates a new BasicManager instance for the given model
+
+ @param _out_rpBasicManager
+ reference to the pointer variable that will hold the new
+ BasicManager.
+
+ @param _rxDocumentModel
+ the model whose BasicManager will be created. Must not be <NULL/>.
*/
- BasicManagerPointer
- impl_createManagerForModel( const Reference< XModel >& _rxDocumentModel );
+ void impl_createManagerForModel(
+ BasicManagerPointer& _out_rpBasicManager,
+ const Reference< XModel >& _rxDocumentModel );
/** creates the application-wide BasicManager
*/
@@ -244,9 +252,17 @@ namespace basic
{
::osl::MutexGuard aGuard( m_aMutex );
+ /* #163556# (DR) - This function may be called recursively while
+ constructing the Basic manager and loading the Basic storage. By
+ passing the map entry received from impl_getLocationForModel() to
+ the function impl_createManagerForModel(), the new Basic manager
+ will be put immediately into the map of existing Basic managers,
+ thus a recursive call of this function will find and return it
+ without creating another instance.
+ */
BasicManagerPointer& pBasicManager = impl_getLocationForModel( _rxDocumentModel );
if ( pBasicManager == NULL )
- pBasicManager = impl_createManagerForModel( _rxDocumentModel );
+ impl_createManagerForModel( pBasicManager, _rxDocumentModel );
return pBasicManager;
}
@@ -408,21 +424,21 @@ namespace basic
}
//--------------------------------------------------------------------
- BasicManagerPointer ImplRepository::impl_createManagerForModel( const Reference< XModel >& _rxDocumentModel )
+ void ImplRepository::impl_createManagerForModel( BasicManagerPointer& _out_rpBasicManager, const Reference< XModel >& _rxDocumentModel )
{
StarBASIC* pAppBasic = impl_getDefaultAppBasicLibrary();
- BasicManager* pBasicManager( NULL );
+ _out_rpBasicManager = 0;
Reference< XStorage > xStorage;
if ( !impl_getDocumentStorage_nothrow( _rxDocumentModel, xStorage ) )
// the document is not able to provide the storage it is based on.
- return pBasicManager;
+ return;
Reference< XPersistentLibraryContainer > xBasicLibs;
Reference< XPersistentLibraryContainer > xDialogLibs;
if ( !impl_getDocumentLibraryContainers_nothrow( _rxDocumentModel, xBasicLibs, xDialogLibs ) )
// the document does not have BasicLibraries and DialogLibraries
- return pBasicManager;
+ return;
if ( xStorage.is() )
{
@@ -433,24 +449,24 @@ namespace basic
// Storage and BaseURL are only needed by binary documents!
SotStorageRef xDummyStor = new SotStorage( ::rtl::OUString() );
- pBasicManager = new BasicManager( *xDummyStor, String() /* TODO/LATER: xStorage */,
+ _out_rpBasicManager = new BasicManager( *xDummyStor, String() /* TODO/LATER: xStorage */,
pAppBasic,
&aAppBasicDir, TRUE );
- if ( pBasicManager->HasErrors() )
+ if ( _out_rpBasicManager->HasErrors() )
{
// handle errors
- BasicError* pErr = pBasicManager->GetFirstError();
+ BasicError* pErr = _out_rpBasicManager->GetFirstError();
while ( pErr )
{
// show message to user
if ( ERRCODE_BUTTON_CANCEL == ErrorHandler::HandleError( pErr->GetErrorId() ) )
{
// user wants to break loading of BASIC-manager
- BasicManagerCleaner::deleteBasicManager( pBasicManager );
+ BasicManagerCleaner::deleteBasicManager( _out_rpBasicManager );
xStorage.clear();
break;
}
- pErr = pBasicManager->GetNextError();
+ pErr = _out_rpBasicManager->GetNextError();
}
}
}
@@ -461,14 +477,14 @@ namespace basic
// create new BASIC-manager
StarBASIC* pBasic = new StarBASIC( pAppBasic );
pBasic->SetFlag( SBX_EXTSEARCH );
- pBasicManager = new BasicManager( pBasic, NULL, TRUE );
+ _out_rpBasicManager = new BasicManager( pBasic, NULL, TRUE );
}
// knit the containers with the BasicManager
LibraryContainerInfo aInfo( xBasicLibs, xDialogLibs, dynamic_cast< OldBasicPassword* >( xBasicLibs.get() ) );
OSL_ENSURE( aInfo.mpOldBasicPassword, "ImplRepository::impl_createManagerForModel: wrong BasicLibraries implementation!" );
- pBasicManager->SetLibraryContainerInfo( aInfo );
- //pBasicCont->setBasicManager( pBasicManager );
+ _out_rpBasicManager->SetLibraryContainerInfo( aInfo );
+ //pBasicCont->setBasicManager( _out_rpBasicManager );
// that's not needed anymore today. The containers will retrieve their associated
// BasicManager from the BasicManagerRepository, when needed.
@@ -476,13 +492,13 @@ namespace basic
impl_initDocLibraryContainers_nothrow( xBasicLibs, xDialogLibs );
// damit auch Dialoge etc. 'qualifiziert' angesprochen werden k"onnen
- pBasicManager->GetLib(0)->SetParent( pAppBasic );
+ _out_rpBasicManager->GetLib(0)->SetParent( pAppBasic );
// global properties in the document's Basic
- pBasicManager->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxDocumentModel ) );
+ _out_rpBasicManager->SetGlobalUNOConstant( "ThisComponent", makeAny( _rxDocumentModel ) );
// notify
- impl_notifyCreationListeners( _rxDocumentModel, *pBasicManager );
+ impl_notifyCreationListeners( _rxDocumentModel, *_out_rpBasicManager );
// register as listener for this model being disposed/closed
Reference< XComponent > xDocumentComponent( _rxDocumentModel, UNO_QUERY );
@@ -490,9 +506,7 @@ namespace basic
startComponentListening( xDocumentComponent );
// register as listener for the BasicManager being destroyed
- StartListening( *pBasicManager );
-
- return pBasicManager;
+ StartListening( *_out_rpBasicManager );
}
//--------------------------------------------------------------------
diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx
index 16d05a6661..f6858bad55 100644
--- a/basic/source/classes/eventatt.cxx
+++ b/basic/source/classes/eventatt.cxx
@@ -88,54 +88,6 @@ using namespace ::cppu;
using namespace ::osl;
-
-Reference< frame::XModel > getModelFromBasic( SbxObject* pBasic )
-{
- OSL_PRECOND( pBasic != NULL, "getModelFromBasic: illegal call!" );
- if ( !pBasic )
- return NULL;
-
- // look for the ThisComponent variable, first in the parent (which
- // might be the document's Basic), then in the parent's parent (which might be
- // the application Basic)
- const ::rtl::OUString sThisComponent( RTL_CONSTASCII_USTRINGPARAM( "ThisComponent" ) );
- SbxVariable* pThisComponent = NULL;
-
- SbxObject* pLookup = pBasic->GetParent();
- while ( pLookup && !pThisComponent )
- {
- pThisComponent = pLookup->Find( sThisComponent, SbxCLASS_OBJECT );
- pLookup = pLookup->GetParent();
- }
- if ( !pThisComponent )
- {
- OSL_TRACE("Failed to get ThisComponent");
- // the application Basic, at the latest, should have this variable
- return NULL;
- }
-
- Any aThisComponent( sbxToUnoValue( pThisComponent ) );
- Reference< frame::XModel > xModel( aThisComponent, UNO_QUERY );
- if ( !xModel.is() )
- {
- // it's no XModel. Okay, ThisComponent nowadays is allowed to be a controller.
- Reference< frame::XController > xController( aThisComponent, UNO_QUERY );
- if ( xController.is() )
- xModel = xController->getModel();
- }
-
- if ( !xModel.is() )
- return NULL;
-
-#if OSL_DEBUG_LEVEL > 0
- OSL_TRACE("Have model ThisComponent points to url %s",
- ::rtl::OUStringToOString( xModel->getURL(),
- RTL_TEXTENCODING_ASCII_US ).pData->buffer );
-#endif
-
- return xModel;
-}
-
void SFURL_firing_impl( const ScriptEvent& aScriptEvent, Any* pRet, const Reference< frame::XModel >& xModel )
{
OSL_TRACE("SFURL_firing_impl() processing script url %s",
@@ -569,7 +521,7 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
bool bDocDialog = false;
StarBASIC* pFoundBasic = NULL;
OSL_TRACE("About to try get a hold of ThisComponent");
- Reference< frame::XModel > xModel = getModelFromBasic( pINST->GetBasic() ) ;
+ Reference< frame::XModel > xModel = StarBASIC::GetModelFromBasic( pINST->GetBasic() ) ;
aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pINST->GetBasic(), pFoundBasic );
// If we found the dialog then it belongs to the Search basic
if ( !pFoundBasic )
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index f8aef3d6d2..e0269f2052 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -71,6 +71,7 @@ TYPEINIT1(StarBASIC,SbxObject)
#define RTLNAME "@SBRTL"
// i#i68894#
+using namespace ::com::sun::star;
using com::sun::star::uno::Reference;
using com::sun::star::uno::Any;
using com::sun::star::uno::UNO_QUERY;
@@ -346,7 +347,18 @@ SbxObject* SbFormFactory::CreateObject( const String& rClassName )
{
if( SbUserFormModule* pFormModule = PTR_CAST( SbUserFormModule, pVar->GetObject() ) )
{
- pFormModule->Load();
+ bool bInitState = pFormModule->getInitState();
+ if( bInitState )
+ {
+ // Not the first instantiate, reset
+ bool bTriggerTerminateEvent = false;
+ pFormModule->ResetApiObj( bTriggerTerminateEvent );
+ pFormModule->setInitState( false );
+ }
+ else
+ {
+ pFormModule->Load();
+ }
return pFormModule->CreateInstance();
}
}
@@ -564,7 +576,6 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule )
if( pObj != NULL )
{
String aObjClass = pObj->GetClassName();
- (void)aObjClass;
SbClassModuleObject* pClassModuleObj = PTR_CAST(SbClassModuleObject,pObjBase);
if( pClassModuleObj != NULL )
@@ -611,93 +622,7 @@ SbClassModuleObject::~SbClassModuleObject()
void SbClassModuleObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
const SfxHint& rHint, const TypeId& rHintType )
{
- bool bDone = false;
-
- const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
- if( pHint )
- {
- SbxVariable* pVar = pHint->GetVar();
- SbProcedureProperty* pProcProperty = PTR_CAST( SbProcedureProperty, pVar );
- if( pProcProperty )
- {
- bDone = true;
-
- if( pHint->GetId() == SBX_HINT_DATAWANTED )
- {
- String aProcName;
- aProcName.AppendAscii( "Property Get " );
- aProcName += pProcProperty->GetName();
-
- SbxVariable* pMeth = Find( aProcName, SbxCLASS_METHOD );
- if( pMeth )
- {
- SbxValues aVals;
- aVals.eType = SbxVARIANT;
-
- SbxArray* pArg = pVar->GetParameters();
- USHORT nVarParCount = (pArg != NULL) ? pArg->Count() : 0;
- if( nVarParCount > 1 )
- {
- SbxArrayRef xMethParameters = new SbxArray;
- xMethParameters->Put( pMeth, 0 ); // Method as parameter 0
- for( USHORT i = 1 ; i < nVarParCount ; ++i )
- {
- SbxVariable* pPar = pArg->Get( i );
- xMethParameters->Put( pPar, i );
- }
-
- pMeth->SetParameters( xMethParameters );
- pMeth->Get( aVals );
- pMeth->SetParameters( NULL );
- }
- else
- {
- pMeth->Get( aVals );
- }
-
- pVar->Put( aVals );
- }
- }
- else if( pHint->GetId() == SBX_HINT_DATACHANGED )
- {
- SbxVariable* pMeth = NULL;
-
- bool bSet = pProcProperty->isSet();
- if( bSet )
- {
- pProcProperty->setSet( false );
-
- String aProcName;
- aProcName.AppendAscii( "Property Set " );
- aProcName += pProcProperty->GetName();
- pMeth = Find( aProcName, SbxCLASS_METHOD );
- }
- if( !pMeth ) // Let
- {
- String aProcName;
- aProcName.AppendAscii( "Property Let " );
- aProcName += pProcProperty->GetName();
- pMeth = Find( aProcName, SbxCLASS_METHOD );
- }
-
- if( pMeth )
- {
- // Setup parameters
- SbxArrayRef xArray = new SbxArray;
- xArray->Put( pMeth, 0 ); // Method as parameter 0
- xArray->Put( pVar, 1 );
- pMeth->SetParameters( xArray );
-
- SbxValues aVals;
- pMeth->Get( aVals );
- pMeth->SetParameters( NULL );
- }
- }
- }
- }
-
- if( !bDone )
- SbModule::SFX_NOTIFY( rBC, rBCType, rHint, rHintType );
+ handleProcedureProperties( rBC, rHint );
}
SbxVariable* SbClassModuleObject::Find( const XubString& rName, SbxClassType t )
@@ -809,6 +734,9 @@ SbModule* SbClassFactory::FindClass( const String& rClassName )
return pMod;
}
+typedef std::vector< StarBASIC* > DocBasicVector;
+static DocBasicVector GaDocBasics;
+
StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic )
: SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("StarBASIC") ) ), bDocBasic( bIsDocBasic )
{
@@ -822,8 +750,6 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic )
{
pSBFAC = new SbiFactory;
AddFactory( pSBFAC );
- pUNOFAC = new SbUnoFactory;
- AddFactory( pUNOFAC );
pTYPEFAC = new SbTypeFactory;
AddFactory( pTYPEFAC );
pCLASSFAC = new SbClassFactory;
@@ -832,12 +758,17 @@ StarBASIC::StarBASIC( StarBASIC* p, BOOL bIsDocBasic )
AddFactory( pOLEFAC );
pFORMFAC = new SbFormFactory;
AddFactory( pFORMFAC );
+ pUNOFAC = new SbUnoFactory;
+ AddFactory( pUNOFAC );
}
pRtl = new SbiStdObject( String( RTL_CONSTASCII_USTRINGPARAM(RTLNAME) ), this );
// Search via StarBasic is always global
SetFlag( SBX_GBLSEARCH );
pVBAGlobals = NULL;
bQuit = FALSE;
+
+ if( bDocBasic )
+ GaDocBasics.push_back( this );
}
// #51727 Override SetModified so that the modified state
@@ -877,6 +808,29 @@ StarBASIC::~StarBASIC()
}
#endif
}
+ else if( bDocBasic )
+ {
+ SbxError eOld = SbxBase::GetError();
+
+ DocBasicVector::iterator it;
+ for( it = GaDocBasics.begin() ; it != GaDocBasics.end() ; ++it )
+ {
+ if( *it == this )
+ {
+ GaDocBasics.erase( it );
+ break;
+ }
+ }
+ for( it = GaDocBasics.begin() ; it != GaDocBasics.end() ; ++it )
+ {
+ StarBASIC* pBasic = *it;
+ pBasic->implClearDependingVarsOnDelete( this );
+ }
+
+ SbxBase::ResetError();
+ if( eOld != SbxERR_OK )
+ SbxBase::SetError( eOld );
+ }
// #100326 Set Parent NULL in registered listeners
if( xUnoListeners.Is() )
@@ -889,6 +843,9 @@ StarBASIC::~StarBASIC()
}
xUnoListeners = NULL;
}
+
+ clearUnoMethodsForBasic( this );
+ disposeComVariablesForBasic( this );
}
// Override new() operator, so that everyone can create a new instance
@@ -907,6 +864,27 @@ void StarBASIC::operator delete( void* p )
::operator delete( p );
}
+void StarBASIC::implClearDependingVarsOnDelete( StarBASIC* pDeletedBasic )
+{
+ if( this != pDeletedBasic )
+ {
+ for( USHORT i = 0; i < pModules->Count(); i++ )
+ {
+ SbModule* p = (SbModule*)pModules->Get( i );
+ p->ClearVarsDependingOnDeletedBasic( pDeletedBasic );
+ }
+ }
+
+ for( USHORT nObj = 0; nObj < pObjs->Count(); nObj++ )
+ {
+ SbxVariable* pVar = pObjs->Get( nObj );
+ StarBASIC* pBasic = PTR_CAST(StarBASIC,pVar);
+ if( pBasic && pBasic != pDeletedBasic )
+ pBasic->implClearDependingVarsOnDelete( pDeletedBasic );
+ }
+}
+
+
/**************************************************************************
*
* Creation/Managment of modules
@@ -1036,15 +1014,15 @@ struct ClassModuleRunInitItem
{}
};
-typedef std::hash_map< ::rtl::OUString, ClassModuleRunInitItem,
- ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleInitDependencyMap;
-
-static ModuleInitDependencyMap* GpMIDMap = NULL;
+// Derive from has_map type instead of typedef
+// to allow forward declaration in sbmod.hxx
+class ModuleInitDependencyMap : public
+ std::hash_map< ::rtl::OUString, ClassModuleRunInitItem,
+ ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > >
+{};
-void SbModule::implProcessModuleRunInit( ClassModuleRunInitItem& rItem )
+void SbModule::implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem )
{
- ModuleInitDependencyMap& rMIDMap = *GpMIDMap;
-
rItem.m_bProcessing = true;
//bool bAnyDependencies = true;
@@ -1059,8 +1037,8 @@ void SbModule::implProcessModuleRunInit( ClassModuleRunInitItem& rItem )
String& rStr = *it;
// Is required type a class module?
- ModuleInitDependencyMap::iterator itFind = rMIDMap.find( rStr );
- if( itFind != rMIDMap.end() )
+ ModuleInitDependencyMap::iterator itFind = rMap.find( rStr );
+ if( itFind != rMap.end() )
{
ClassModuleRunInitItem& rParentItem = itFind->second;
if( rParentItem.m_bProcessing )
@@ -1071,7 +1049,7 @@ void SbModule::implProcessModuleRunInit( ClassModuleRunInitItem& rItem )
}
if( !rParentItem.m_bRunInitDone )
- implProcessModuleRunInit( rParentItem );
+ implProcessModuleRunInit( rMap, rParentItem );
}
}
}
@@ -1085,6 +1063,8 @@ void SbModule::implProcessModuleRunInit( ClassModuleRunInitItem& rItem )
// Run Init-Code of all modules (including inserted libraries)
void StarBASIC::InitAllModules( StarBASIC* pBasicNotToInit )
{
+ NAMESPACE_VOS(OGuard) guard( Application::GetSolarMutex() );
+
// Init own modules
for ( USHORT nMod = 0; nMod < pModules->Count(); nMod++ )
{
@@ -1099,7 +1079,6 @@ void StarBASIC::InitAllModules( StarBASIC* pBasicNotToInit )
// Consider required types to init in right order. Class modules
// that are required by other modules have to be initialized first.
ModuleInitDependencyMap aMIDMap;
- GpMIDMap = &aMIDMap;
for ( USHORT nMod = 0; nMod < pModules->Count(); nMod++ )
{
SbModule* pModule = (SbModule*)pModules->Get( nMod );
@@ -1112,9 +1091,8 @@ void StarBASIC::InitAllModules( StarBASIC* pBasicNotToInit )
for( it = aMIDMap.begin() ; it != aMIDMap.end(); ++it )
{
ClassModuleRunInitItem& rItem = it->second;
- SbModule::implProcessModuleRunInit( rItem );
+ SbModule::implProcessModuleRunInit( aMIDMap, rItem );
}
- GpMIDMap = NULL;
// Call RunInit on standard modules
for ( USHORT nMod = 0; nMod < pModules->Count(); nMod++ )
@@ -1143,7 +1121,7 @@ void StarBASIC::DeInitAllModules( void )
for ( USHORT nMod = 0; nMod < pModules->Count(); nMod++ )
{
SbModule* pModule = (SbModule*)pModules->Get( nMod );
- if( pModule->pImage )
+ if( pModule->pImage && !pModule->isProxyModule() && !pModule->ISA(SbObjModule) )
pModule->pImage->bInit = false;
}
@@ -1849,6 +1827,54 @@ bool StarBASIC::GetUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::u
return bRes;
}
+Reference< frame::XModel > StarBASIC::GetModelFromBasic( SbxObject* pBasic )
+{
+ OSL_PRECOND( pBasic != NULL, "getModelFromBasic: illegal call!" );
+ if ( !pBasic )
+ return NULL;
+
+ // look for the ThisComponent variable, first in the parent (which
+ // might be the document's Basic), then in the parent's parent (which might be
+ // the application Basic)
+ const ::rtl::OUString sThisComponent( RTL_CONSTASCII_USTRINGPARAM( "ThisComponent" ) );
+ SbxVariable* pThisComponent = NULL;
+
+ SbxObject* pLookup = pBasic->GetParent();
+ while ( pLookup && !pThisComponent )
+ {
+ pThisComponent = pLookup->Find( sThisComponent, SbxCLASS_OBJECT );
+ pLookup = pLookup->GetParent();
+ }
+ if ( !pThisComponent )
+ {
+ OSL_TRACE("Failed to get ThisComponent");
+ // the application Basic, at the latest, should have this variable
+ return NULL;
+ }
+
+ Any aThisComponentAny( sbxToUnoValue( pThisComponent ) );
+ Reference< frame::XModel > xModel( aThisComponentAny, UNO_QUERY );
+ if ( !xModel.is() )
+ {
+ // it's no XModel. Okay, ThisComponent nowadays is allowed to be a controller.
+ Reference< frame::XController > xController( aThisComponentAny, UNO_QUERY );
+ if ( xController.is() )
+ xModel = xController->getModel();
+ }
+
+ if ( !xModel.is() )
+ return NULL;
+
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("Have model ThisComponent points to url %s",
+ ::rtl::OUStringToOString( xModel->getURL(),
+ RTL_TEXTENCODING_ASCII_US ).pData->buffer );
+#endif
+
+ return xModel;
+}
+
+
//========================================================================
// #118116 Implementation Collection object
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index c0735bb1b3..b398583dd7 100755
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -36,15 +36,18 @@
#include <svl/hint.hxx>
#include <cppuhelper/implbase1.hxx>
+#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/typeprovider.hxx>
#include <cppuhelper/extract.hxx>
+#include <cppuhelper/interfacecontainer.hxx>
#include <comphelper/processfactory.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx>
#include <com/sun/star/script/ArrayWrapper.hpp>
+#include <com/sun/star/script/NativeObjectWrapper.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/uno/DeploymentException.hpp>
@@ -61,6 +64,7 @@
#include <com/sun/star/script/XInvocationAdapterFactory.hpp>
#include <com/sun/star/script/XTypeConverter.hpp>
#include <com/sun/star/script/XDefaultProperty.hpp>
+#include <com/sun/star/script/XDirectInvocation.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/container/XHierarchicalNameAccess.hpp>
#include <com/sun/star/reflection/XIdlArray.hpp>
@@ -512,6 +516,44 @@ static void implHandleAnyException( const Any& _rCaughtException )
}
}
+
+// NativeObjectWrapper handling
+struct ObjectItem
+{
+ SbxObjectRef m_xNativeObj;
+
+ ObjectItem( void )
+ {}
+ ObjectItem( SbxObject* pNativeObj )
+ : m_xNativeObj( pNativeObj )
+ {}
+};
+static std::vector< ObjectItem > GaNativeObjectWrapperVector;
+
+void clearNativeObjectWrapperVector( void )
+{
+ GaNativeObjectWrapperVector.clear();
+}
+
+sal_uInt32 lcl_registerNativeObjectWrapper( SbxObject* pNativeObj )
+{
+ sal_uInt32 nIndex = GaNativeObjectWrapperVector.size();
+ GaNativeObjectWrapperVector.push_back( ObjectItem( pNativeObj ) );
+ return nIndex;
+}
+
+SbxObject* lcl_getNativeObject( sal_uInt32 nIndex )
+{
+ SbxObjectRef xRetObj;
+ if( nIndex < GaNativeObjectWrapperVector.size() )
+ {
+ ObjectItem& rItem = GaNativeObjectWrapperVector[ nIndex ];
+ xRetObj = rItem.m_xNativeObj;
+ }
+ return xRetObj;
+}
+
+
// Von Uno nach Sbx wandeln
SbxDataType unoToSbxType( TypeClass eType )
{
@@ -698,6 +740,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
if( eTypeClass == TypeClass_STRUCT )
{
ArrayWrapper aWrap;
+ NativeObjectWrapper aNativeObjectWrapper;
if ( (aValue >>= aWrap) )
{
SbxDimArray* pArray = NULL;
@@ -717,6 +760,18 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
pVar->PutEmpty();
break;
}
+ else if ( (aValue >>= aNativeObjectWrapper) )
+ {
+ sal_uInt32 nIndex = 0;
+ if( (aNativeObjectWrapper.ObjectId >>= nIndex) )
+ {
+ SbxObject* pObj = lcl_getNativeObject( nIndex );
+ pVar->PutObject( pObj );
+ }
+ else
+ pVar->PutEmpty();
+ break;
+ }
else
{
SbiInstance* pInst = pINST;
@@ -1093,6 +1148,20 @@ Any sbxToUnoValueImpl( SbxVariable* pVar, bool bBlockConversionToSmallestType =
if( pClassModule->createCOMWrapperForIface( aRetAny, pClassModuleObj ) )
return aRetAny;
}
+ if( !xObj->ISA(SbUnoObject) )
+ {
+ // Create NativeObjectWrapper to identify object in case of callbacks
+ SbxObject* pObj = PTR_CAST(SbxObject,pVar->GetObject());
+ if( pObj != NULL )
+ {
+ NativeObjectWrapper aNativeObjectWrapper;
+ sal_uInt32 nIndex = lcl_registerNativeObjectWrapper( pObj );
+ aNativeObjectWrapper.ObjectId <<= nIndex;
+ Any aRetAny;
+ aRetAny <<= aNativeObjectWrapper;
+ return aRetAny;
+ }
+ }
}
}
@@ -2223,26 +2292,36 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
}
else if( bInvocation && mxInvocation.is() )
{
- Sequence< INT16 > OutParamIndex;
- Sequence< Any > OutParam;
- Any aRetAny = mxInvocation->invoke( pMeth->GetName(), args, OutParamIndex, OutParam );
-
- // Wert von Uno nach Sbx uebernehmen
- unoToSbxValue( pVar, aRetAny );
-
- const INT16* pIndices = OutParamIndex.getConstArray();
- UINT32 nLen = OutParamIndex.getLength();
- if( nLen )
+ Reference< XDirectInvocation > xDirectInvoke;
+ if ( pMeth->needsDirectInvocation() )
+ xDirectInvoke.set( mxInvocation, UNO_QUERY );
+
+ Any aRetAny;
+ if ( xDirectInvoke.is() )
+ aRetAny = xDirectInvoke->directInvoke( pMeth->GetName(), args );
+ else
{
- const Any* pNewValues = OutParam.getConstArray();
- for( UINT32 j = 0 ; j < nLen ; j++ )
+ Sequence< INT16 > OutParamIndex;
+ Sequence< Any > OutParam;
+ aRetAny = mxInvocation->invoke( pMeth->GetName(), args, OutParamIndex, OutParam );
+
+ const INT16* pIndices = OutParamIndex.getConstArray();
+ UINT32 nLen = OutParamIndex.getLength();
+ if( nLen )
{
- INT16 iTarget = pIndices[ j ];
- if( iTarget >= (INT16)nParamCount )
- break;
- unoToSbxValue( (SbxVariable*)pParams->Get( (USHORT)(j+1) ), pNewValues[ j ] );
+ const Any* pNewValues = OutParam.getConstArray();
+ for( UINT32 j = 0 ; j < nLen ; j++ )
+ {
+ INT16 iTarget = pIndices[ j ];
+ if( iTarget >= (INT16)nParamCount )
+ break;
+ unoToSbxValue( (SbxVariable*)pParams->Get( (USHORT)(j+1) ), pNewValues[ j ] );
+ }
}
}
+
+ // Wert von Uno nach Sbx uebernehmen
+ unoToSbxValue( pVar, aRetAny );
}
// #55460, Parameter hier weghauen, da das in unoToSbxValue()
@@ -2271,7 +2350,7 @@ Reference< XInvocation > createDynamicInvocationFor( const Any& aAny );
SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ )
: SbxObject( aName_ )
, bNeedIntrospection( TRUE )
- , bIgnoreNativeCOMObjectMembers( FALSE )
+ , bNativeCOMObject( FALSE )
{
static Reference< XIntrospection > xIntrospection;
@@ -2322,7 +2401,7 @@ SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ )
// hiding of equally named COM symbols, e.g. XInvocation::getValue
Reference< oleautomation::XAutomationObject > xAutomationObject( aUnoObj_, UNO_QUERY );
if( xAutomationObject.is() )
- bIgnoreNativeCOMObjectMembers = TRUE;
+ bNativeCOMObject = TRUE;
}
maTmpUnoObj = aUnoObj_;
@@ -2446,6 +2525,47 @@ void SbUnoObject::doIntrospection( void )
// #67781 Start einer Liste aller SbUnoMethod-Instanzen
static SbUnoMethod* pFirst = NULL;
+void clearUnoMethodsForBasic( StarBASIC* pBasic )
+{
+ SbUnoMethod* pMeth = pFirst;
+ while( pMeth )
+ {
+ SbxObject* pObject = dynamic_cast< SbxObject* >( pMeth->GetParent() );
+ if ( pObject )
+ {
+ StarBASIC* pModBasic = dynamic_cast< StarBASIC* >( pObject->GetParent() );
+ if ( pModBasic == pBasic )
+ {
+ // for now the solution is to remove the method from the list and to clear it,
+ // but in case the element should be correctly transfered to another StarBASIC,
+ // we should either set module parent to NULL without clearing it, or even
+ // set the new StarBASIC as the parent of the module
+ // pObject->SetParent( NULL );
+
+ if( pMeth == pFirst )
+ pFirst = pMeth->pNext;
+ else if( pMeth->pPrev )
+ pMeth->pPrev->pNext = pMeth->pNext;
+ if( pMeth->pNext )
+ pMeth->pNext->pPrev = pMeth->pPrev;
+
+ pMeth->pPrev = NULL;
+ pMeth->pNext = NULL;
+
+ pMeth->SbxValue::Clear();
+ pObject->SbxValue::Clear();
+
+ // start from the beginning after object clearing, the cycle will end since the method is removed each time
+ pMeth = pFirst;
+ }
+ else
+ pMeth = pMeth->pNext;
+ }
+ else
+ pMeth = pMeth->pNext;
+ }
+}
+
void clearUnoMethods( void )
{
SbUnoMethod* pMeth = pFirst;
@@ -2462,10 +2582,12 @@ SbUnoMethod::SbUnoMethod
const String& aName_,
SbxDataType eSbxType,
Reference< XIdlMethod > xUnoMethod_,
- bool bInvocation
+ bool bInvocation,
+ bool bDirect
)
: SbxMethod( aName_, eSbxType )
, mbInvocation( bInvocation )
+ , mbDirectInvocation( bDirect )
{
m_xUnoMethod = xUnoMethod_;
pParamInfoSeq = NULL;
@@ -2566,7 +2688,7 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t )
if( !pRes )
{
::rtl::OUString aUName( rName );
- if( mxUnoAccess.is() && !bIgnoreNativeCOMObjectMembers )
+ if( mxUnoAccess.is() && !bNativeCOMObject )
{
if( mxExactName.is() )
{
@@ -2667,6 +2789,17 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t )
QuickInsert( (SbxVariable*)xMethRef );
pRes = xMethRef;
}
+ else
+ {
+ Reference< XDirectInvocation > xDirectInvoke( mxInvocation, UNO_QUERY );
+ if ( xDirectInvoke.is() && xDirectInvoke->hasMember( aUName ) )
+ {
+ SbxVariableRef xMethRef = new SbUnoMethod( aUName, SbxVARIANT, xDummyMethod, true, true );
+ QuickInsert( (SbxVariable*)xMethRef );
+ pRes = xMethRef;
+ }
+
+ }
}
catch( RuntimeException& e )
{
@@ -2726,11 +2859,11 @@ void SbUnoObject::implCreateAll( void )
// Instrospection besorgen
Reference< XIntrospectionAccess > xAccess = mxUnoAccess;
- if( !xAccess.is() || bIgnoreNativeCOMObjectMembers )
+ if( !xAccess.is() || bNativeCOMObject )
{
if( mxInvocation.is() )
xAccess = mxInvocation->getIntrospection();
- else if( bIgnoreNativeCOMObjectMembers )
+ else if( bNativeCOMObject )
return;
}
if( !xAccess.is() )
@@ -4170,14 +4303,26 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
//==========================================================================
-typedef WeakImplHelper1< XInvocation > ModuleInvocationProxyHelper;
+namespace {
+class OMutexBasis
+{
+protected:
+ // this mutex is necessary for OInterfaceContainerHelper
+ ::osl::Mutex m_aMutex;
+};
+} // namespace
+
+typedef WeakImplHelper2< XInvocation, XComponent > ModuleInvocationProxyHelper;
-class ModuleInvocationProxy : public ModuleInvocationProxyHelper
+class ModuleInvocationProxy : public OMutexBasis,
+ public ModuleInvocationProxyHelper
{
::rtl::OUString m_aPrefix;
SbxObjectRef m_xScopeObj;
bool m_bProxyIsClassModuleObject;
+ ::cppu::OInterfaceContainerHelper m_aListeners;
+
public:
ModuleInvocationProxy( const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj );
~ModuleInvocationProxy()
@@ -4197,11 +4342,17 @@ public:
Sequence< sal_Int16 >& rOutParamIndex,
Sequence< Any >& rOutParam )
throw( CannotConvertException, InvocationTargetException );
+
+ // XComponent
+ virtual void SAL_CALL dispose() throw(RuntimeException);
+ virtual void SAL_CALL addEventListener( const Reference< XEventListener >& xListener ) throw (RuntimeException);
+ virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& aListener ) throw (RuntimeException);
};
ModuleInvocationProxy::ModuleInvocationProxy( const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj )
: m_aPrefix( aPrefix + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_") ) )
, m_xScopeObj( xScopeObj )
+ , m_aListeners( m_aMutex )
{
m_bProxyIsClassModuleObject = xScopeObj.Is() ? xScopeObj->ISA(SbClassModuleObject) : false;
}
@@ -4298,13 +4449,27 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const ::rtl::OUString& rFunction,
vos::OGuard guard( Application::GetSolarMutex() );
Any aRet;
- if( !m_xScopeObj.Is() )
+ SbxObjectRef xScopeObj = m_xScopeObj;
+ if( !xScopeObj.Is() )
return aRet;
::rtl::OUString aFunctionName = m_aPrefix;
aFunctionName += rFunction;
- SbxVariable* p = m_xScopeObj->Find( aFunctionName, SbxCLASS_METHOD );
+ sal_Bool bSetRescheduleBack = sal_False;
+ sal_Bool bOldReschedule = sal_True;
+ SbiInstance* pInst = pINST;
+ if( pInst && pInst->IsCompatibility() )
+ {
+ bOldReschedule = pInst->IsReschedule();
+ if ( bOldReschedule )
+ {
+ pInst->EnableReschedule( sal_False );
+ bSetRescheduleBack = sal_True;
+ }
+ }
+
+ SbxVariable* p = xScopeObj->Find( aFunctionName, SbxCLASS_METHOD );
SbMethod* pMeth = p != NULL ? PTR_CAST(SbMethod,p) : NULL;
if( pMeth == NULL )
{
@@ -4336,11 +4501,38 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const ::rtl::OUString& rFunction,
aRet = sbxToUnoValue( xValue );
pMeth->SetParameters( NULL );
+ if( bSetRescheduleBack )
+ pInst->EnableReschedule( bOldReschedule );
+
// TODO: OutParameter?
return aRet;
}
+void SAL_CALL ModuleInvocationProxy::dispose()
+ throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ EventObject aEvent( (XComponent*)this );
+ m_aListeners.disposeAndClear( aEvent );
+
+ m_xScopeObj = NULL;
+}
+
+void SAL_CALL ModuleInvocationProxy::addEventListener( const Reference< XEventListener >& xListener )
+ throw (RuntimeException)
+{
+ m_aListeners.addInterface( xListener );
+}
+
+void SAL_CALL ModuleInvocationProxy::removeEventListener( const Reference< XEventListener >& xListener )
+ throw (RuntimeException)
+{
+ m_aListeners.removeInterface( xListener );
+}
+
+
Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::OUString& aVBAType,
const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj )
{
@@ -4370,6 +4562,97 @@ Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::
return xRet;
}
+typedef std::vector< WeakReference< XComponent > > ComponentRefVector;
+
+struct StarBasicDisposeItem
+{
+ StarBASIC* m_pBasic;
+ SbxArrayRef m_pRegisteredVariables;
+ ComponentRefVector m_vComImplementsObjects;
+
+ StarBasicDisposeItem( StarBASIC* pBasic )
+ : m_pBasic( pBasic )
+ {
+ m_pRegisteredVariables = new SbxArray();
+ }
+};
+
+typedef std::vector< StarBasicDisposeItem* > DisposeItemVector;
+
+static DisposeItemVector GaDisposeItemVector;
+
+DisposeItemVector::iterator lcl_findItemForBasic( StarBASIC* pBasic )
+{
+ DisposeItemVector::iterator it;
+ for( it = GaDisposeItemVector.begin() ; it != GaDisposeItemVector.end() ; ++it )
+ {
+ StarBasicDisposeItem* pItem = *it;
+ if( pItem->m_pBasic == pBasic )
+ return it;
+ }
+ return GaDisposeItemVector.end();
+}
+
+StarBasicDisposeItem* lcl_getOrCreateItemForBasic( StarBASIC* pBasic )
+{
+ DisposeItemVector::iterator it = lcl_findItemForBasic( pBasic );
+ StarBasicDisposeItem* pItem = (it != GaDisposeItemVector.end()) ? *it : NULL;
+ if( pItem == NULL )
+ {
+ pItem = new StarBasicDisposeItem( pBasic );
+ GaDisposeItemVector.push_back( pItem );
+ }
+ return pItem;
+}
+
+void registerComponentToBeDisposedForBasic
+ ( Reference< XComponent > xComponent, StarBASIC* pBasic )
+{
+ StarBasicDisposeItem* pItem = lcl_getOrCreateItemForBasic( pBasic );
+ pItem->m_vComImplementsObjects.push_back( xComponent );
+}
+
+void registerComListenerVariableForBasic( SbxVariable* pVar, StarBASIC* pBasic )
+{
+ StarBasicDisposeItem* pItem = lcl_getOrCreateItemForBasic( pBasic );
+ SbxArray* pArray = pItem->m_pRegisteredVariables;
+ pArray->Put( pVar, pArray->Count() );
+}
+
+void disposeComVariablesForBasic( StarBASIC* pBasic )
+{
+ DisposeItemVector::iterator it = lcl_findItemForBasic( pBasic );
+ if( it != GaDisposeItemVector.end() )
+ {
+ StarBasicDisposeItem* pItem = *it;
+
+ SbxArray* pArray = pItem->m_pRegisteredVariables;
+ USHORT nCount = pArray->Count();
+ for( USHORT i = 0 ; i < nCount ; ++i )
+ {
+ SbxVariable* pVar = pArray->Get( i );
+ pVar->ClearComListener();
+ }
+
+ ComponentRefVector& rv = pItem->m_vComImplementsObjects;
+ ComponentRefVector::iterator itCRV;
+ for( itCRV = rv.begin() ; itCRV != rv.end() ; ++itCRV )
+ {
+ try
+ {
+ Reference< XComponent > xComponent( (*itCRV).get(), UNO_QUERY_THROW );
+ xComponent->dispose();
+ }
+ catch( Exception& )
+ {}
+ }
+
+ delete pItem;
+ GaDisposeItemVector.erase( it );
+ }
+}
+
+
// Handle module implements mechanism for OLE types
bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pProxyClassModuleObject )
{
@@ -4423,6 +4706,23 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP
if( bSuccess )
{
+ Reference< XComponent > xComponent( xProxy, UNO_QUERY );
+ if( xComponent.is() )
+ {
+ StarBASIC* pParentBasic = NULL;
+ SbxObject* pCurObject = this;
+ do
+ {
+ SbxObject* pObjParent = pCurObject->GetParent();
+ pParentBasic = PTR_CAST( StarBASIC, pObjParent );
+ pCurObject = pObjParent;
+ }
+ while( pParentBasic == NULL && pCurObject != NULL );
+
+ OSL_ASSERT( pParentBasic != NULL );
+ registerComponentToBeDisposedForBasic( xComponent, pParentBasic );
+ }
+
o_rRetAny <<= xRet;
break;
}
@@ -4432,3 +4732,30 @@ bool SbModule::createCOMWrapperForIface( Any& o_rRetAny, SbClassModuleObject* pP
return bSuccess;
}
+
+// Due to an incorrect behavior IE returns an object instead of a string
+// in some scenarios. Calling toString at the object may correct this.
+// Helper function used in sbxvalue.cxx
+bool handleToStringForCOMObjects( SbxObject* pObj, SbxValue* pVal )
+{
+ bool bSuccess = false;
+
+ SbUnoObject* pUnoObj = NULL;
+ if( pObj != NULL && (pUnoObj = PTR_CAST(SbUnoObject,(SbxObject*)pObj)) != NULL )
+ {
+ // Only for native COM objects
+ if( pUnoObj->isNativeCOMObject() )
+ {
+ SbxVariableRef pMeth = pObj->Find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "toString" ) ), SbxCLASS_METHOD );
+ if ( pMeth.Is() )
+ {
+ SbxValues aRes;
+ pMeth->Get( aRes );
+ pVal->Put( aRes );
+ bSuccess = true;
+ }
+ }
+ }
+ return bSuccess;
+}
+
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index b3fbd26caa..6f800054b8 100644..100755
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -496,33 +496,26 @@ IMPL_LINK( AsyncQuitHandler, OnAsyncQuit, void*, /*pNull*/ )
return 0L;
}
-#if 0
-bool UnlockControllerHack( StarBASIC* pBasic )
+bool VBAUnlockControllers( StarBASIC* pBasic )
{
bool bRes = false;
if ( pBasic && pBasic->IsDocBasic() )
{
- uno::Any aUnoVar;
- ::rtl::OUString sVarName( ::rtl::OUString::createFromAscii( "ThisComponent" ) );
- SbUnoObject* pGlobs = dynamic_cast<SbUnoObject*>( pBasic->Find( sVarName, SbxCLASS_DONTCARE ) );
- if ( pGlobs )
- aUnoVar = pGlobs->getUnoAny();
- uno::Reference< frame::XModel > xModel( aUnoVar, uno::UNO_QUERY);
- if ( xModel.is() )
+ SbUnoObject* pGlobs = dynamic_cast< SbUnoObject* >( pBasic->Find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThisComponent" ) ), SbxCLASS_DONTCARE ) );
+ if ( pGlobs ) try
{
- try
- {
+ uno::Reference< frame::XModel > xModel( pGlobs->getUnoAny(), uno::UNO_QUERY_THROW );
+ if ( xModel->hasControllersLocked() )
xModel->unlockControllers();
- bRes = true;
- }
- catch( uno::Exception& )
- {
- }
+ bRes = true;
+ }
+ catch( uno::Exception& )
+ {
}
}
return bRes;
}
-#endif
+
/////////////////////////////////////////////////////////////////////////////
// Ein BASIC-Modul hat EXTSEARCH gesetzt, damit die im Modul enthaltenen
@@ -1176,6 +1169,8 @@ USHORT SbModule::Run( SbMethod* pMeth )
// beim Programm-Ende freigeben, damit nichts gehalten wird.
ClearUnoObjectsInRTL_Impl( xBasic );
+ clearNativeObjectWrapperVector();
+
DBG_ASSERT(pINST->nCallLvl==0,"BASIC-Call-Level > 0");
delete pINST, pINST = NULL, bDelInst = FALSE;
@@ -1184,6 +1179,14 @@ USHORT SbModule::Run( SbMethod* pMeth )
SendHint( GetParent(), SBX_HINT_BASICSTOP, pMeth );
GlobalRunDeInit();
+
+ // VBA always ensures screenupdating is enabled after completing
+ if ( mbVBACompat )
+ VBAUnlockControllers( PTR_CAST( StarBASIC, GetParent() ) );
+
+#ifdef DBG_TRACE_BASIC
+ dbg_DeInitTrace();
+#endif
}
}
else
@@ -1195,12 +1198,7 @@ USHORT SbModule::Run( SbMethod* pMeth )
StarBASIC::FatalError( SbERR_STACK_OVERFLOW );
}
- // VBA always ensure screenupdating is enabled after completing
StarBASIC* pBasic = PTR_CAST(StarBASIC,GetParent());
-#if 0
- if ( pBasic && pBasic->IsDocBasic() && !pINST )
- UnlockControllerHack( pBasic );
-#endif
if( bDelInst )
{
// #57841 Uno-Objekte, die in RTL-Funktionen gehalten werden,
@@ -1332,6 +1330,61 @@ void SbModule::ClearPrivateVars()
}
}
+void SbModule::implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic )
+{
+ if( pVar->SbxValue::GetType() != SbxOBJECT || pVar->ISA( SbProcedureProperty ) )
+ return;
+
+ SbxObject* pObj = PTR_CAST(SbxObject,pVar->GetObject());
+ if( pObj != NULL )
+ {
+ SbxObject* p = pObj;
+
+ SbModule* pMod = PTR_CAST( SbModule, p );
+ if( pMod != NULL )
+ pMod->ClearVarsDependingOnDeletedBasic( pDeletedBasic );
+
+ while( (p = p->GetParent()) != NULL )
+ {
+ StarBASIC* pBasic = PTR_CAST( StarBASIC, p );
+ if( pBasic != NULL && pBasic == pDeletedBasic )
+ {
+ pVar->SbxValue::Clear();
+ break;
+ }
+ }
+ }
+}
+
+void SbModule::ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic )
+{
+ (void)pDeletedBasic;
+
+ for( USHORT i = 0 ; i < pProps->Count() ; i++ )
+ {
+ SbProperty* p = PTR_CAST(SbProperty,pProps->Get( i ) );
+ if( p )
+ {
+ if( p->GetType() & SbxARRAY )
+ {
+ SbxArray* pArray = PTR_CAST(SbxArray,p->GetObject());
+ if( pArray )
+ {
+ for( USHORT j = 0 ; j < pArray->Count() ; j++ )
+ {
+ SbxVariable* pVar = PTR_CAST(SbxVariable,pArray->Get( j ));
+ implClearIfVarDependsOnDeletedBasic( pVar, pDeletedBasic );
+ }
+ }
+ }
+ else
+ {
+ implClearIfVarDependsOnDeletedBasic( p, pDeletedBasic );
+ }
+ }
+ }
+}
+
// Zunaechst in dieses Modul, um 358-faehig zu bleiben
// (Branch in sb.cxx vermeiden)
void StarBASIC::ClearAllModuleVars( void )
@@ -1341,7 +1394,7 @@ void StarBASIC::ClearAllModuleVars( void )
{
SbModule* pModule = (SbModule*)pModules->Get( nMod );
// Nur initialisieren, wenn der Startcode schon ausgefuehrt wurde
- if( pModule->pImage && pModule->pImage->bInit )
+ if( pModule->pImage && pModule->pImage->bInit && !pModule->isProxyModule() && !pModule->ISA(SbObjModule) )
pModule->ClearPrivateVars();
}
@@ -1739,6 +1792,98 @@ BOOL SbModule::LoadCompleted()
return TRUE;
}
+void SbModule::handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ bool bDone = false;
+
+ const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
+ if( pHint )
+ {
+ SbxVariable* pVar = pHint->GetVar();
+ SbProcedureProperty* pProcProperty = PTR_CAST( SbProcedureProperty, pVar );
+ if( pProcProperty )
+ {
+ bDone = true;
+
+ if( pHint->GetId() == SBX_HINT_DATAWANTED )
+ {
+ String aProcName;
+ aProcName.AppendAscii( "Property Get " );
+ aProcName += pProcProperty->GetName();
+
+ SbxVariable* pMeth = Find( aProcName, SbxCLASS_METHOD );
+ if( pMeth )
+ {
+ SbxValues aVals;
+ aVals.eType = SbxVARIANT;
+
+ SbxArray* pArg = pVar->GetParameters();
+ USHORT nVarParCount = (pArg != NULL) ? pArg->Count() : 0;
+ if( nVarParCount > 1 )
+ {
+ SbxArrayRef xMethParameters = new SbxArray;
+ xMethParameters->Put( pMeth, 0 ); // Method as parameter 0
+ for( USHORT i = 1 ; i < nVarParCount ; ++i )
+ {
+ SbxVariable* pPar = pArg->Get( i );
+ xMethParameters->Put( pPar, i );
+ }
+
+ pMeth->SetParameters( xMethParameters );
+ pMeth->Get( aVals );
+ pMeth->SetParameters( NULL );
+ }
+ else
+ {
+ pMeth->Get( aVals );
+ }
+
+ pVar->Put( aVals );
+ }
+ }
+ else if( pHint->GetId() == SBX_HINT_DATACHANGED )
+ {
+ SbxVariable* pMeth = NULL;
+
+ bool bSet = pProcProperty->isSet();
+ if( bSet )
+ {
+ pProcProperty->setSet( false );
+
+ String aProcName;
+ aProcName.AppendAscii( "Property Set " );
+ aProcName += pProcProperty->GetName();
+ pMeth = Find( aProcName, SbxCLASS_METHOD );
+ }
+ if( !pMeth ) // Let
+ {
+ String aProcName;
+ aProcName.AppendAscii( "Property Let " );
+ aProcName += pProcProperty->GetName();
+ pMeth = Find( aProcName, SbxCLASS_METHOD );
+ }
+
+ if( pMeth )
+ {
+ // Setup parameters
+ SbxArrayRef xArray = new SbxArray;
+ xArray->Put( pMeth, 0 ); // Method as parameter 0
+ xArray->Put( pVar, 1 );
+ pMeth->SetParameters( xArray );
+
+ SbxValues aVals;
+ pMeth->Get( aVals );
+ pMeth->SetParameters( NULL );
+ }
+ }
+ }
+ }
+
+ if( !bDone )
+ SbModule::Notify( rBC, rHint );
+}
+
+
/////////////////////////////////////////////////////////////////////////
// Implementation SbJScriptModule (Basic-Modul fuer JavaScript-Sourcen)
SbJScriptModule::SbJScriptModule( const String& rName )
@@ -1969,6 +2114,11 @@ SbObjModule::SbObjModule( const String& rName, const com::sun::star::script::Mod
else if ( mInfo.ModuleObject.is() )
SetUnoObject( uno::makeAny( mInfo.ModuleObject ) );
}
+
+SbObjModule::~SbObjModule()
+{
+}
+
void
SbObjModule::SetUnoObject( const uno::Any& aObj ) throw ( uno::RuntimeException )
{
@@ -2005,6 +2155,13 @@ SbObjModule::Find( const XubString& rName, SbxClassType t )
return pVar;
}
+void SbObjModule::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
+ const SfxHint& rHint, const TypeId& rHintType )
+{
+ SbModule::handleProcedureProperties( rBC, rHint );
+}
+
+
typedef ::cppu::WeakImplHelper2< awt::XTopWindowListener, awt::XWindowListener > FormObjEventListener_BASE;
class FormObjEventListenerImpl : public FormObjEventListener_BASE
@@ -2108,7 +2265,7 @@ public:
}
}
}
-
+
mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ) );
#endif
}
@@ -2192,9 +2349,9 @@ SbUserFormModule::~SbUserFormModule()
{
}
-void SbUserFormModule::ResetApiObj()
+void SbUserFormModule::ResetApiObj( bool bTriggerTerminateEvent )
{
- if ( m_xDialog.is() ) // probably someone close the dialog window
+ if ( bTriggerTerminateEvent && m_xDialog.is() ) // probably someone close the dialog window
{
triggerTerminateEvent();
}
@@ -2379,11 +2536,12 @@ void SbUserFormModule::Unload()
}
//liuchen
+void registerComponentToBeDisposedForBasic( Reference< XComponent > xComponent, StarBASIC* pBasic );
+
void SbUserFormModule::InitObject()
{
try
{
-
String aHook( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobals" ) );
SbUnoObject* pGlobs = (SbUnoObject*)GetParent()->Find( aHook, SbxCLASS_DONTCARE );
if ( m_xModel.is() && pGlobs )
@@ -2410,6 +2568,25 @@ void SbUserFormModule::InitObject()
aArgs[ 3 ] <<= rtl::OUString( GetParent()->GetName() );
pDocObject = new SbUnoObject( GetName(), uno::makeAny( xVBAFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.UserForm")), aArgs ) ) );
uno::Reference< lang::XComponent > xComponent( aArgs[ 1 ], uno::UNO_QUERY_THROW );
+
+ // the dialog must be disposed at the end!
+ if( xComponent.is() )
+ {
+ StarBASIC* pParentBasic = NULL;
+ SbxObject* pCurObject = this;
+ do
+ {
+ SbxObject* pObjParent = pCurObject->GetParent();
+ pParentBasic = PTR_CAST( StarBASIC, pObjParent );
+ pCurObject = pObjParent;
+ }
+ while( pParentBasic == NULL && pCurObject != NULL );
+
+ OSL_ASSERT( pParentBasic != NULL );
+ registerComponentToBeDisposedForBasic( xComponent, pParentBasic );
+ }
+
+
// remove old listener if it exists
if ( m_DialogListener.get() )
m_DialogListener->removeListener();
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index 367be2a3e3..61cf215949 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -375,6 +375,9 @@ void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic )
if( pDef->IsWithEvents() )
nOpnd2 |= SBX_TYPE_WITH_EVENTS_FLAG;
+ if( bCompatible && pDef->IsNew() )
+ nOpnd2 |= SBX_TYPE_DIM_AS_NEW_FLAG;
+
short nFixedStringLength = pDef->GetFixedStringLength();
if( nFixedStringLength >= 0 )
nOpnd2 |= (SBX_FIXED_LEN_STRING_FLAG + (UINT32(nFixedStringLength) << 17)); // len = all bits above 0x10000
diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx
index f858c428af..ec86ae075f 100644
--- a/basic/source/comp/exprtree.cxx
+++ b/basic/source/comp/exprtree.cxx
@@ -578,10 +578,20 @@ SbiExprNode* SbiExpression::Unary()
{
case MINUS:
eTok = NEG;
- case NOT:
pParser->Next();
pNd = new SbiExprNode( pParser, Unary(), eTok, NULL );
break;
+ case NOT:
+ if( pParser->IsVBASupportOn() )
+ {
+ pNd = Operand();
+ }
+ else
+ {
+ pParser->Next();
+ pNd = new SbiExprNode( pParser, Unary(), eTok, NULL );
+ }
+ break;
case PLUS:
pParser->Next();
pNd = Unary();
@@ -725,9 +735,26 @@ SbiExprNode* SbiExpression::Comp()
return pNd;
}
+SbiExprNode* SbiExpression::VBA_Not()
+{
+ SbiExprNode* pNd = NULL;
+
+ SbiToken eTok = pParser->Peek();
+ if( eTok == NOT )
+ {
+ pParser->Next();
+ pNd = new SbiExprNode( pParser, VBA_Not(), eTok, NULL );
+ }
+ else
+ {
+ pNd = Comp();
+ }
+ return pNd;
+}
+
SbiExprNode* SbiExpression::Like()
{
- SbiExprNode* pNd = Comp();
+ SbiExprNode* pNd = pParser->IsVBASupportOn() ? VBA_Not() : Comp();
if( m_eMode != EXPRMODE_EMPTY_PAREN )
{
short nCount = 0;
diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx
index f9cd852efc..512fc6f694 100755
--- a/basic/source/comp/sbcomp.cxx
+++ b/basic/source/comp/sbcomp.cxx
@@ -32,6 +32,7 @@
#include "sbcomp.hxx"
#include "image.hxx"
#include "sbtrace.hxx"
+#include <basic/sbobjmod.hxx>
//==========================================================================
@@ -42,11 +43,145 @@
#include <hash_map>
-// Trace Settings
-static const char* GpTraceFileName = "d:\\zBasic.Asm\\BasicTrace.txt";
-static const bool GbIncludePCodes = false;
-static const int GnIndentPerCallLevel = 4;
-static const int GnIndentForPCode = 2;
+// Trace ini file (set NULL to ignore)
+static char GpTraceIniFile[] = "d:\\zBasic.Asm\\BasicTrace.ini";
+//static char* GpTraceIniFile = NULL;
+
+
+// Trace Settings, used if no ini file / not found in ini file
+static char GpTraceFileNameDefault[] = "d:\\zBasic.Asm\\BasicTrace.txt";
+static char* GpTraceFileName = GpTraceFileNameDefault;
+
+// GbTraceOn:
+// true = tracing is active, false = tracing is disabled, default = true
+// Set to false initially if you want to activate tracing on demand with
+// TraceCommand( "TraceOn" ), see below
+static bool GbTraceOn = true;
+
+// GbIncludePCodes:
+// true = PCodes are written to trace, default = false, correspondents
+// with TraceCommand( "PCodeOn" / "PCodeOff" ), see below
+static bool GbIncludePCodes = false;
+
+static int GnIndentPerCallLevel = 4;
+static int GnIndentForPCode = 2;
+
+/*
+ With trace enabled the runtime function TraceCommand
+ can be used to influence the trace functionality
+ from within the running Basic macro.
+
+ Format: TraceCommand( command as String [, param as Variant] )
+
+ Supported commands (command is NOT case sensitive):
+ TraceCommand "TraceOn" sets GbTraceOn = true
+ TraceCommand "TraceOff" sets GbTraceOn = false
+
+ TraceCommand "PCodeOn" sets GbIncludePCodes = true
+ TraceCommand "PCodeOff" sets GbIncludePCodes = false
+
+ TraceCommand "Print", aVal writes aVal into the trace file as
+ long as it can be converted to string
+*/
+
+static void lcl_skipWhites( char*& rpc )
+{
+ while( *rpc == ' ' || *rpc == '\t' )
+ ++rpc;
+}
+
+inline void lcl_findNextLine( char*& rpc, char* pe )
+{
+ // Find line end
+ while( rpc < pe && *rpc != 13 && *rpc != 10 )
+ ++rpc;
+
+ // Read all
+ while( rpc < pe && (*rpc == 13 || *rpc == 10) )
+ ++rpc;
+}
+
+inline bool lcl_isAlpha( char c )
+{
+ bool bRet = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
+ return bRet;
+}
+
+static void lcl_ReadIniFile( const char* pIniFileName )
+{
+ const int BUF_SIZE = 1000;
+ static sal_Char TraceFileNameBuffer[BUF_SIZE];
+ sal_Char Buffer[BUF_SIZE];
+ sal_Char VarNameBuffer[BUF_SIZE];
+ sal_Char ValBuffer[BUF_SIZE];
+
+ FILE* pFile = fopen( pIniFileName ,"rb" );
+ if( pFile == NULL )
+ return;
+
+ size_t nRead = fread( Buffer, 1, BUF_SIZE, pFile );
+
+ // Scan
+ char* pc = Buffer;
+ char* pe = Buffer + nRead;
+ while( pc < pe )
+ {
+ lcl_skipWhites( pc ); if( pc == pe ) break;
+
+ // Read variable
+ char* pVarStart = pc;
+ while( pc < pe && lcl_isAlpha( *pc ) )
+ ++pc;
+ int nVarLen = pc - pVarStart;
+ if( nVarLen == 0 )
+ {
+ lcl_findNextLine( pc, pe );
+ continue;
+ }
+ strncpy( VarNameBuffer, pVarStart, nVarLen );
+ VarNameBuffer[nVarLen] = '\0';
+
+ // Check =
+ lcl_skipWhites( pc ); if( pc == pe ) break;
+ if( *pc != '=' )
+ continue;
+ ++pc;
+ lcl_skipWhites( pc ); if( pc == pe ) break;
+
+ // Read value
+ char* pValStart = pc;
+ while( pc < pe && *pc != 13 && *pc != 10 )
+ ++pc;
+ int nValLen = pc - pValStart;
+ if( nValLen == 0 )
+ {
+ lcl_findNextLine( pc, pe );
+ continue;
+ }
+ strncpy( ValBuffer, pValStart, nValLen );
+ ValBuffer[nValLen] = '\0';
+
+ // Match variables
+ if( strcmp( VarNameBuffer, "GpTraceFileName") == 0 )
+ {
+ strcpy( TraceFileNameBuffer, ValBuffer );
+ GpTraceFileName = TraceFileNameBuffer;
+ }
+ else
+ if( strcmp( VarNameBuffer, "GbTraceOn") == 0 )
+ GbTraceOn = (strcmp( ValBuffer, "true" ) == 0);
+ else
+ if( strcmp( VarNameBuffer, "GbIncludePCodes") == 0 )
+ GbIncludePCodes = (strcmp( ValBuffer, "true" ) == 0);
+ else
+ if( strcmp( VarNameBuffer, "GnIndentPerCallLevel") == 0 )
+ GnIndentPerCallLevel = strtol( ValBuffer, NULL, 10 );
+ else
+ if( strcmp( VarNameBuffer, "GnIndentForPCode") == 0 )
+ GnIndentForPCode = strtol( ValBuffer, NULL, 10 );
+ }
+ fclose( pFile );
+}
struct TraceTextData
{
@@ -122,7 +257,7 @@ static rtl::OString lcl_toOStringSkipLeadingWhites( const String& aStr )
return aORetStr;
}
-String dumpMethodParameters( SbMethod* pMethod )
+String lcl_dumpMethodParameters( SbMethod* pMethod )
{
String aStr;
if( pMethod == NULL )
@@ -149,9 +284,10 @@ String dumpMethodParameters( SbMethod* pMethod )
aStr += pParam->aName;
}
aStr += '=';
- if( pVar->GetType() & SbxARRAY )
+ SbxDataType eType = pVar->GetType();
+ if( eType & SbxARRAY )
aStr += String( RTL_CONSTASCII_USTRINGPARAM( "..." ) );
- else
+ else if( eType != SbxOBJECT )
aStr += pVar->GetString();
if ( nParam < ( pParams->Count() - 1 ) )
aStr += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
@@ -164,18 +300,38 @@ String dumpMethodParameters( SbMethod* pMethod )
SbxBase::SetError( eOld );
return aStr;
-}
+}
+
// Public functions
+
+static bool GbSavTraceOn = false;
void dbg_InitTrace( void )
{
+ if( GpTraceIniFile != NULL )
+ lcl_ReadIniFile( GpTraceIniFile );
+
FILE* pFile = fopen( GpTraceFileName, "w" );
if( pFile != NULL )
fclose( pFile );
+ GbSavTraceOn = GbTraceOn;
+ if( !GbTraceOn )
+ lcl_lineOut( GpTraceFileName, "### Program started with trace off ###" );
+}
+
+void dbg_DeInitTrace( void )
+{
+ GbTraceOn = GbSavTraceOn;
}
+static INT32 GnLastCallLvl = 0;
+
void dbg_traceStep( SbModule* pModule, UINT32 nPC, INT32 nCallLvl )
{
+ if( !GbTraceOn )
+ return;
+ GnLastCallLvl = nCallLvl;
+
SbModule* pTraceMod = pModule;
if( pTraceMod->ISA(SbClassModuleObject) )
{
@@ -206,14 +362,11 @@ void dbg_traceStep( SbModule* pModule, UINT32 nPC, INT32 nCallLvl )
{
const char* pModuleNameStr = OUStringToOString( rtl::OUString( aModuleName ), RTL_TEXTENCODING_ASCII_US ).getStr();
char Buffer[200];
- sprintf( Buffer, "TRACE ERROR: No info for PC = %d in module \"%s\"", nPC, pModuleNameStr );
+ sprintf( Buffer, "TRACE ERROR: No info for PC = %d in module \"%s\"", (int)nPC, pModuleNameStr );
lcl_lineOut( GpTraceFileName, Buffer );
return;
}
- //nCallLvl--;
- //if( nCallLvl < 0 )
- // nCallLvl = 0;
int nIndent = nCallLvl * GnIndentPerCallLevel;
const TraceTextData& rTraceTextData = itInner->second;
@@ -234,6 +387,10 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, INT32 nCallLvl,
{
static const char* pSeparator = "' ================================================================================";
+ if( !GbTraceOn )
+ return;
+ GnLastCallLvl = nCallLvl;
+
SbModule* pTraceMod = pModule;
SbClassModuleObject* pClassModuleObj = NULL;
if( pTraceMod->ISA(SbClassModuleObject) )
@@ -281,7 +438,7 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, INT32 nCallLvl,
aStr.AppendAscii( "]" );
}
if( !bLeave )
- aStr += dumpMethodParameters( pMethod );
+ aStr += lcl_dumpMethodParameters( pMethod );
lcl_lineOut( GpTraceFileName, OUStringToOString( rtl::OUString( aStr ), RTL_TEXTENCODING_ASCII_US ).getStr(), lcl_getSpaces( nIndent ) );
if( !bLeave )
@@ -293,6 +450,10 @@ void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, INT32 nCallLvl,
void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, INT32 nCallLvl )
{
+ if( !GbTraceOn )
+ return;
+ GnLastCallLvl = nCallLvl;
+
rtl::OString aOTraceErrMsg = OUStringToOString( rtl::OUString( aTraceErrMsg ), RTL_TEXTENCODING_ASCII_US );
char Buffer[200];
@@ -329,6 +490,63 @@ void dbg_RegisterTraceTextForPC( SbModule* pModule, UINT32 nPC,
(*pInnerMap)[nPC] = aData;
}
+void RTL_Impl_TraceCommand( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
+{
+ (void)pBasic;
+ (void)bWrite;
+
+ if ( rPar.Count() < 2 )
+ {
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ return;
+ }
+
+ String aCommand = rPar.Get(1)->GetString();
+
+ if( aCommand.EqualsIgnoreCaseAscii( "TraceOn" ) )
+ GbTraceOn = true;
+ else
+ if( aCommand.EqualsIgnoreCaseAscii( "TraceOff" ) )
+ GbTraceOn = false;
+ else
+ if( aCommand.EqualsIgnoreCaseAscii( "PCodeOn" ) )
+ GbIncludePCodes = true;
+ else
+ if( aCommand.EqualsIgnoreCaseAscii( "PCodeOff" ) )
+ GbIncludePCodes = false;
+ else
+ if( aCommand.EqualsIgnoreCaseAscii( "Print" ) )
+ {
+ if ( rPar.Count() < 3 )
+ {
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ return;
+ }
+
+ SbxError eOld = SbxBase::GetError();
+ if( eOld != SbxERR_OK )
+ SbxBase::ResetError();
+
+ String aValStr = rPar.Get(2)->GetString();
+ SbxError eErr = SbxBase::GetError();
+ if( eErr != SbxERR_OK )
+ {
+ aValStr = String( RTL_CONSTASCII_USTRINGPARAM( "<ERROR converting value to String>" ) );
+ SbxBase::ResetError();
+ }
+
+ char Buffer[500];
+ const char* pValStr = OUStringToOString( rtl::OUString( aValStr ), RTL_TEXTENCODING_ASCII_US ).getStr();
+
+ sprintf( Buffer, "### TRACE_PRINT: %s ###", pValStr );
+ int nIndent = GnLastCallLvl * GnIndentPerCallLevel;
+ lcl_lineOut( GpTraceFileName, Buffer, lcl_getSpaces( nIndent ) );
+
+ if( eOld != SbxERR_OK )
+ SbxBase::SetError( eOld );
+ }
+}
+
#endif
@@ -431,7 +649,8 @@ BOOL SbModule::Compile()
BOOL bRet = IsCompiled();
if( bRet )
{
- pBasic->ClearAllModuleVars();
+ if( !this->ISA(SbObjModule) )
+ pBasic->ClearAllModuleVars();
RemoveVars(); // remove 'this' Modules variables
// clear all method statics
for( USHORT i = 0; i < pMethods->Count(); i++ )
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 61ca92108b..a6a389026c 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -224,6 +224,30 @@ BOOL SbiScanner::NextSym()
for ( ; (BasicSimpleCharClass::isAlphaNumeric( *pLine, bCompatible ) || ( *pLine == '_' ) ); pLine++ )
nCol++;
aSym = aLine.copy( n, nCol - n );
+
+ // Special handling for "go to"
+ if( bCompatible && *pLine && aSym.EqualsIgnoreCaseAscii( "go" ) )
+ {
+ const sal_Unicode* pTestLine = pLine;
+ short nTestCol = nCol;
+ while( *pTestLine && (( *pTestLine == ' ' ) || ( *pTestLine == '\t' )) )
+ {
+ pTestLine++;
+ nTestCol++;
+ }
+
+ if( *pTestLine && *(pTestLine + 1) )
+ {
+ String aTestSym = aLine.copy( nTestCol, 2 );
+ if( aTestSym.EqualsIgnoreCaseAscii( "to" ) )
+ {
+ aSym = String::CreateFromAscii( "goto" );
+ pLine = pTestLine + 2;
+ nCol = nTestCol + 2;
+ }
+ }
+ }
+
// Abschliessendes '_' durch Space ersetzen, wenn Zeilenende folgt
// (sonst falsche Zeilenfortsetzung)
if( !bUsedForHilite && !*pLine && *(pLine-1) == '_' )
diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index a09cc4490b..7f6db9cd38 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -206,9 +206,10 @@ void SbiSymPool::Add( SbiSymDef* pDef )
SbiSymDef* SbiSymPool::Find( const String& rName ) const
{
- for( USHORT i = 0; i < aData.Count(); i++ )
+ USHORT nCount = aData.Count();
+ for( USHORT i = 0; i < nCount; i++ )
{
- SbiSymDef* p = aData.GetObject( i );
+ SbiSymDef* p = aData.GetObject( nCount - i - 1 );
if( ( !p->nProcId || ( p->nProcId == nProcId ) )
&& ( p->aName.EqualsIgnoreCaseAscii( rName ) ) )
return p;
diff --git a/basic/source/inc/expr.hxx b/basic/source/inc/expr.hxx
index 96604cbdd9..2de0f121b4 100644
--- a/basic/source/inc/expr.hxx
+++ b/basic/source/inc/expr.hxx
@@ -188,6 +188,7 @@ protected:
SbiExprNode* AddSub();
SbiExprNode* Cat();
SbiExprNode* Like();
+ SbiExprNode* VBA_Not();
SbiExprNode* Comp();
SbiExprNode* Boolean();
public:
diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx
index 96de7e5ce6..3bab07fe03 100644
--- a/basic/source/inc/runtime.hxx
+++ b/basic/source/inc/runtime.hxx
@@ -276,6 +276,8 @@ struct RefSaveItem
class SbiRuntime
{
+ friend void SbRtl_CallByName( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
+
typedef void( SbiRuntime::*pStep0 )();
typedef void( SbiRuntime::*pStep1 )( UINT32 nOp1 );
typedef void( SbiRuntime::*pStep2 )( UINT32 nOp1, UINT32 nOp2 );
@@ -434,7 +436,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 );
+ void implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, UINT32 nOp2 );
public:
void SetVBAEnabled( bool bEnabled );
USHORT GetImageFlag( USHORT n ) const;
diff --git a/basic/source/inc/sbtrace.hxx b/basic/source/inc/sbtrace.hxx
index 6d24325c94..bf2caf12cb 100755
--- a/basic/source/inc/sbtrace.hxx
+++ b/basic/source/inc/sbtrace.hxx
@@ -28,15 +28,17 @@
#ifndef _SBTRACE_HXX
#define _SBTRACE_HXX
-// #define DBG_TRACE_BASIC
+//#define DBG_TRACE_BASIC
#ifdef DBG_TRACE_BASIC
void dbg_InitTrace( void );
+void dbg_DeInitTrace( void );
void dbg_traceStep( SbModule* pModule, UINT32 nPC, INT32 nCallLvl );
void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, INT32 nCallLvl, bool bLeave = false );
void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, INT32 nCallLvl );
void dbg_RegisterTraceTextForPC( SbModule* pModule, UINT32 nPC,
const String& aTraceStr_STMNT, const String& aTraceStr_PCode );
+void RTL_Impl_TraceCommand( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
#endif
#endif
diff --git a/basic/source/inc/sbunoobj.hxx b/basic/source/inc/sbunoobj.hxx
index f2277e99d0..11d3299cb8 100644
--- a/basic/source/inc/sbunoobj.hxx
+++ b/basic/source/inc/sbunoobj.hxx
@@ -52,7 +52,7 @@ class SbUnoObject: public SbxObject
::com::sun::star::uno::Reference< ::com::sun::star::beans::XExactName > mxExactName;
::com::sun::star::uno::Reference< ::com::sun::star::beans::XExactName > mxExactNameInvocation;
BOOL bNeedIntrospection;
- BOOL bIgnoreNativeCOMObjectMembers;
+ BOOL bNativeCOMObject;
::com::sun::star::uno::Any maTmpUnoObj; // Only to save obj for doIntrospection!
// Hilfs-Methode zum Anlegen der dbg_-Properties
@@ -84,17 +84,22 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > getInvocation( void ) { return mxInvocation; }
void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
+
+ bool isNativeCOMObject( void )
+ { return bNativeCOMObject; }
};
SV_DECL_IMPL_REF(SbUnoObject);
// #67781 Rueckgabewerte der Uno-Methoden loeschen
void clearUnoMethods( void );
+void clearUnoMethodsForBasic( StarBASIC* pBasic );
class SbUnoMethod : public SbxMethod
{
friend class SbUnoObject;
friend void clearUnoMethods( void );
+ friend void clearUnoMethodsForBasic( StarBASIC* pBasic );
::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlMethod > m_xUnoMethod;
::com::sun::star::uno::Sequence< ::com::sun::star::reflection::ParamInfo >* pParamInfoSeq;
@@ -103,13 +108,15 @@ class SbUnoMethod : public SbxMethod
SbUnoMethod* pPrev;
SbUnoMethod* pNext;
- bool mbInvocation; // Method is based on invocation
+ bool mbInvocation; // Method is based on invocation
+ bool mbDirectInvocation; // Method should be used with XDirectInvocation interface
public:
TYPEINFO();
SbUnoMethod( const String& aName_, SbxDataType eSbxType, ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlMethod > xUnoMethod_,
- bool bInvocation );
+ bool bInvocation,
+ bool bDirect = false );
virtual ~SbUnoMethod();
virtual SbxInfo* GetInfo();
@@ -117,6 +124,8 @@ public:
bool isInvocationBased( void )
{ return mbInvocation; }
+ bool needsDirectInvocation( void )
+ { return mbDirectInvocation; }
};
@@ -293,6 +302,9 @@ void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
void RTL_Impl_GetDefaultContext( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
+void disposeComVariablesForBasic( StarBASIC* pBasic );
+void clearNativeObjectWrapperVector( void );
+
//========================================================================
// #118116 Collection object
diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx
index 71ad535600..789f9da7b4 100644
--- a/basic/source/inc/scriptcont.hxx
+++ b/basic/source/inc/scriptcont.hxx
@@ -43,6 +43,7 @@ namespace basic
class SfxScriptLibraryContainer : public SfxLibraryContainer, public OldBasicPassword
{
::rtl::OUString maScriptLanguage;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > mxCodeNameAccess;
// Methods to distinguish between deffirent library types
virtual SfxLibrary* SAL_CALL implCreateLibrary( const ::rtl::OUString& aName );
diff --git a/basic/source/runtime/comenumwrapper.cxx b/basic/source/runtime/comenumwrapper.cxx
new file mode 100644
index 0000000000..627f2cdaf7
--- /dev/null
+++ b/basic/source/runtime/comenumwrapper.cxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "precompiled_basic.hxx"
+#include "comenumwrapper.hxx"
+
+using namespace ::com::sun::star;
+
+::sal_Bool SAL_CALL ComEnumerationWrapper::hasMoreElements()
+ throw ( uno::RuntimeException )
+{
+ sal_Bool bResult = sal_False;
+
+ try
+ {
+ if ( m_xInvocation.is() )
+ {
+ sal_Int32 nLength = 0;
+ bResult =
+ ( ( m_xInvocation->getValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "length" ) ) ) >>= nLength )
+ && nLength > m_nCurInd );
+ }
+ }
+ catch( uno::Exception& )
+ {}
+
+ return bResult;
+}
+
+uno::Any SAL_CALL ComEnumerationWrapper::nextElement()
+ throw ( container::NoSuchElementException,
+ lang::WrappedTargetException,
+ uno::RuntimeException )
+{
+ try
+ {
+ if ( m_xInvocation.is() )
+ {
+ uno::Sequence< sal_Int16 > aNamedParamIndex;
+ uno::Sequence< uno::Any > aNamedParam;
+ uno::Sequence< uno::Any > aArgs( 1 );
+
+ aArgs[0] <<= m_nCurInd++;
+
+ return m_xInvocation->invoke( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "item" ) ),
+ aArgs,
+ aNamedParamIndex,
+ aNamedParam );
+ }
+ }
+ catch( uno::Exception& )
+ {}
+
+ throw container::NoSuchElementException();
+}
+
+
diff --git a/basic/source/runtime/comenumwrapper.hxx b/basic/source/runtime/comenumwrapper.hxx
new file mode 100644
index 0000000000..9ebe052b9d
--- /dev/null
+++ b/basic/source/runtime/comenumwrapper.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#ifndef _COMENUMWRAPPER_HXX
+#define _COMENUMWRAPPER_HXX
+
+#include <com/sun/star/container/XEnumeration.hpp>
+#include <com/sun/star/script/XInvocation.hpp>
+
+#include <cppuhelper/implbase1.hxx>
+
+class ComEnumerationWrapper : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XEnumeration >
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation > m_xInvocation;
+ sal_Int32 m_nCurInd;
+
+public:
+ ComEnumerationWrapper( const ::com::sun::star::uno::Reference< ::com::sun::star::script::XInvocation >& xInvocation )
+ : m_xInvocation( xInvocation )
+ , m_nCurInd( 0 )
+ {
+ }
+
+ // container::XEnumeration
+ virtual ::sal_Bool SAL_CALL hasMoreElements() throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL nextElement() throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+};
+
+#endif // _COMENUMWRAPPER_HXX
+
diff --git a/basic/source/runtime/makefile.mk b/basic/source/runtime/makefile.mk
index f2ed11196b..8ca052aaae 100644
--- a/basic/source/runtime/makefile.mk
+++ b/basic/source/runtime/makefile.mk
@@ -41,6 +41,7 @@ ENABLE_EXCEPTIONS = TRUE
SLOFILES= \
$(SLO)$/basrdll.obj \
+ $(SLO)$/comenumwrapper.obj \
$(SLO)$/inputbox.obj \
$(SLO)$/runtime.obj \
$(SLO)$/step0.obj \
diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx
index acf6cb92ba..49e3c15f03 100644..100755
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -112,6 +112,126 @@ static Reference< XCalendar > getLocaleCalendar( void )
return xCalendar;
}
+RTLFUNC(CallByName)
+{
+ (void)pBasic;
+ (void)bWrite;
+
+ const INT16 vbGet = 2;
+ const INT16 vbLet = 4;
+ const INT16 vbMethod = 1;
+ const INT16 vbSet = 8;
+
+ // At least 3 parameter needed plus function itself -> 4
+ USHORT nParCount = rPar.Count();
+ if ( nParCount < 4 )
+ {
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ return;
+ }
+
+ // 1. parameter is object
+ SbxBase* pObjVar = (SbxObject*)rPar.Get(1)->GetObject();
+ SbxObject* pObj = NULL;
+ if( pObjVar )
+ pObj = PTR_CAST(SbxObject,pObjVar);
+ if( !pObj && pObjVar && pObjVar->ISA(SbxVariable) )
+ {
+ SbxBase* pObjVarObj = ((SbxVariable*)pObjVar)->GetObject();
+ pObj = PTR_CAST(SbxObject,pObjVarObj);
+ }
+ if( !pObj )
+ {
+ StarBASIC::Error( SbERR_BAD_PARAMETER );
+ return;
+ }
+
+ // 2. parameter is ProcedureName
+ String aNameStr = rPar.Get(2)->GetString();
+
+ // 3. parameter is CallType
+ INT16 nCallType = rPar.Get(3)->GetInteger();
+
+ //SbxObject* pFindObj = NULL;
+ SbxVariable* pFindVar = pObj->Find( aNameStr, SbxCLASS_DONTCARE );
+ if( pFindVar == NULL )
+ {
+ StarBASIC::Error( SbERR_PROC_UNDEFINED );
+ return;
+ }
+
+ switch( nCallType )
+ {
+ case vbGet:
+ {
+ SbxValues aVals;
+ aVals.eType = SbxVARIANT;
+ pFindVar->Get( aVals );
+
+ SbxVariableRef refVar = rPar.Get(0);
+ refVar->Put( aVals );
+ }
+ break;
+ case vbLet:
+ case vbSet:
+ {
+ if ( nParCount != 5 )
+ {
+ StarBASIC::Error( SbERR_BAD_ARGUMENT );
+ return;
+ }
+ SbxVariableRef pValVar = rPar.Get(4);
+ if( nCallType == vbLet )
+ {
+ SbxValues aVals;
+ aVals.eType = SbxVARIANT;
+ pValVar->Get( aVals );
+ pFindVar->Put( aVals );
+ }
+ else
+ {
+ SbxVariableRef rFindVar = pFindVar;
+ SbiInstance* pInst = pINST;
+ SbiRuntime* pRT = pInst ? pInst->pRun : NULL;
+ if( pRT != NULL )
+ pRT->StepSET_Impl( pValVar, rFindVar, false );
+ }
+ }
+ break;
+ case vbMethod:
+ {
+ SbMethod* pMeth = PTR_CAST(SbMethod,pFindVar);
+ if( pMeth == NULL )
+ {
+ StarBASIC::Error( SbERR_PROC_UNDEFINED );
+ return;
+ }
+
+ // Setup parameters
+ SbxArrayRef xArray;
+ USHORT nMethParamCount = nParCount - 4;
+ if( nMethParamCount > 0 )
+ {
+ xArray = new SbxArray;
+ for( USHORT i = 0 ; i < nMethParamCount ; i++ )
+ {
+ SbxVariable* pPar = rPar.Get( i + 4 );
+ xArray->Put( pPar, i + 1 );
+ }
+ }
+
+ // Call method
+ SbxVariableRef refVar = rPar.Get(0);
+ if( xArray.Is() )
+ pMeth->SetParameters( xArray );
+ pMeth->Call( refVar );
+ pMeth->SetParameters( NULL );
+ }
+ break;
+ default:
+ StarBASIC::Error( SbERR_PROC_UNDEFINED );
+ }
+}
RTLFUNC(CBool) // JSM
{
@@ -527,6 +647,7 @@ RTLFUNC(DoEvents)
//aTimer.Start();
//while ( aTimer.IsActive() )
// Application::Reschedule();
+ Application::Reschedule( true );
}
RTLFUNC(GetGUIVersion)
@@ -1513,6 +1634,12 @@ RTLFUNC(GetDefaultContext)
RTL_Impl_GetDefaultContext( pBasic, rPar, bWrite );
}
+#ifdef DBG_TRACE_BASIC
+RTLFUNC(TraceCommand)
+{
+ RTL_Impl_TraceCommand( pBasic, rPar, bWrite );
+}
+#endif
RTLFUNC(Join)
{
diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx
index e3b2a05395..a7e2a5ee38 100644
--- a/basic/source/runtime/rtlproto.hxx
+++ b/basic/source/runtime/rtlproto.hxx
@@ -26,6 +26,7 @@
************************************************************************/
#include <basic/sbstar.hxx>
+#include "sbtrace.hxx"
#define RTLFUNC( name ) void SbRtl_##name( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
#define RTLNAME( name ) &SbRtl_##name
@@ -271,6 +272,7 @@ extern RTLFUNC(AboutStarBasic);
extern RTLFUNC(LoadPicture);
extern RTLFUNC(SavePicture);
+extern RTLFUNC(CallByName);
extern RTLFUNC(CBool); // JSM
extern RTLFUNC(CByte); // JSM
extern RTLFUNC(CCur); // JSM
@@ -345,5 +347,9 @@ extern RTLFUNC(CDec);
extern RTLFUNC(Partition); // Fong
+#ifdef DBG_TRACE_BASIC
+extern RTLFUNC(TraceCommand);
+#endif
+
extern double Now_Impl();
extern void Wait_Impl( bool bDurationBased, SbxArray& rPar );
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index a8eff4d55d..022cc40a5f 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -45,6 +45,7 @@
#include "sbunoobj.hxx"
#include "errobject.hxx"
#include "sbtrace.hxx"
+#include "comenumwrapper.hxx"
using namespace ::com::sun::star;
@@ -890,11 +891,12 @@ void SbiRuntime::Error( SbError _errCode, const String& _details )
{
if ( _errCode )
{
- OSL_ENSURE( pInst->pRun == this, "SbiRuntime::Error: can't propagate the error message details!" );
+ // Not correct for class module usage, remove for now
+ //OSL_ENSURE( pInst->pRun == this, "SbiRuntime::Error: can't propagate the error message details!" );
if ( pInst->pRun == this )
{
pInst->Error( _errCode, _details );
- OSL_POSTCOND( nError == _errCode, "SbiRuntime::Error: the instance is expecte to propagate the error code back to me!" );
+ //OSL_POSTCOND( nError == _errCode, "SbiRuntime::Error: the instance is expecte to propagate the error code back to me!" );
}
else
{
@@ -1176,6 +1178,23 @@ void SbiRuntime::PushForEach()
p->xEnumeration = xEnumerationAccess->createEnumeration();
p->eForType = FOR_EACH_XENUMERATION;
}
+ else if ( isVBAEnabled() && pUnoObj->isNativeCOMObject() )
+ {
+ uno::Reference< script::XInvocation > xInvocation;
+ if ( ( aAny >>= xInvocation ) && xInvocation.is() )
+ {
+ try
+ {
+ p->xEnumeration = new ComEnumerationWrapper( xInvocation );
+ p->eForType = FOR_EACH_XENUMERATION;
+ }
+ catch( uno::Exception& )
+ {}
+ }
+
+ if ( !p->xEnumeration.is() )
+ bError_ = true;
+ }
else
{
bError_ = true;
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index d621a12f0f..cea7f3907c 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -94,6 +94,10 @@ static Methods aMethods[] = {
{ "Blue", SbxINTEGER, 1 | _FUNCTION, RTLNAME(Blue),0 },
{ "RGB-Value", SbxLONG, 0,NULL,0 },
+{ "CallByName", SbxVARIANT, 3 | _FUNCTION, RTLNAME(CallByName),0 },
+ { "Object", SbxOBJECT, 0,NULL,0 },
+ { "ProcedureName",SbxSTRING, 0,NULL,0 },
+ { "CallType", SbxINTEGER, 0,NULL,0 },
{ "CBool", SbxBOOL, 1 | _FUNCTION, RTLNAME(CBool),0 },
{ "expression", SbxVARIANT, 0,NULL,0 },
{ "CByte", SbxBYTE, 1 | _FUNCTION, RTLNAME(CByte),0 },
@@ -531,6 +535,10 @@ static Methods aMethods[] = {
{ "TimeValue", SbxDATE, 1 | _FUNCTION, RTLNAME(TimeValue),0 },
{ "String", SbxSTRING, 0,NULL,0 },
{ "TOGGLE", SbxINTEGER, _CPROP, RTLNAME(TOGGLE),0 },
+#ifdef DBG_TRACE_BASIC
+{ "TraceCommand", SbxNULL, 1 | _FUNCTION, RTLNAME(TraceCommand),0 },
+ { "Command", SbxSTRING, 0,NULL,0 },
+#endif
{ "Trim", SbxSTRING, 1 | _FUNCTION, RTLNAME(Trim),0 },
{ "String", SbxSTRING, 0,NULL,0 },
{ "True", SbxBOOL, _CPROP, RTLNAME(True),0 },
diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx
index f5c9d5dce1..20577b673f 100644
--- a/basic/source/runtime/step0.cxx
+++ b/basic/source/runtime/step0.cxx
@@ -47,6 +47,7 @@ Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl::
const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj );
#include <algorithm>
+#include <hash_map>
SbxVariable* getDefaultProp( SbxVariable* pRef );
@@ -418,9 +419,53 @@ void SbiRuntime::StepPUT()
}
+// VBA Dim As New behavior handling, save init object information
+struct DimAsNewRecoverItem
+{
+ String m_aObjClass;
+ String m_aObjName;
+ SbxObject* m_pObjParent;
+ SbModule* m_pClassModule;
+
+ DimAsNewRecoverItem( void )
+ : m_pObjParent( NULL )
+ , m_pClassModule( NULL )
+ {}
+
+ DimAsNewRecoverItem( const String& rObjClass, const String& rObjName,
+ SbxObject* pObjParent, SbModule* pClassModule )
+ : m_aObjClass( rObjClass )
+ , m_aObjName( rObjName )
+ , m_pObjParent( pObjParent )
+ , m_pClassModule( pClassModule )
+ {}
+
+};
+
+
+struct SbxVariablePtrHash
+{
+ size_t operator()( SbxVariable* pVar ) const
+ { return (size_t)pVar; }
+};
+
+typedef std::hash_map< SbxVariable*, DimAsNewRecoverItem, SbxVariablePtrHash > DimAsNewRecoverHash;
+
+static DimAsNewRecoverHash GaDimAsNewRecoverHash;
+
+void removeDimAsNewRecoverItem( SbxVariable* pVar )
+{
+ DimAsNewRecoverHash::iterator it = GaDimAsNewRecoverHash.find( pVar );
+ if( it != GaDimAsNewRecoverHash.end() )
+ GaDimAsNewRecoverHash.erase( it );
+}
+
+
// Speichern Objektvariable
// Nicht-Objekt-Variable fuehren zu Fehlern
+static const char pCollectionStr[] = "Collection";
+
void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, bool bHandleDefaultProp )
{
// #67733 Typen mit Array-Flag sind auch ok
@@ -523,6 +568,12 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
}
}
+ // Handle Dim As New
+ BOOL bDimAsNew = bVBAEnabled && refVar->IsSet( SBX_DIM_AS_NEW );
+ SbxBaseRef xPrevVarObj;
+ if( bDimAsNew )
+ xPrevVarObj = refVar->GetObject();
+
// Handle withevents
BOOL bWithEvents = refVar->IsSet( SBX_WITH_EVENTS );
if ( bWithEvents )
@@ -541,7 +592,7 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
xComListener = createComListener( aControlAny, aVBAType, aPrefix, xScopeObj );
refVal->SetDeclareClassName( aDeclareClassName );
- refVal->SetComListener( xComListener ); // Hold reference
+ refVal->SetComListener( xComListener, &rBasic ); // Hold reference
}
*refVar = *refVal;
@@ -551,6 +602,68 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b
*refVar = *refVal;
}
+ if ( bDimAsNew )
+ {
+ if( !refVar->ISA(SbxObject) )
+ {
+ SbxBase* pValObjBase = refVal->GetObject();
+ if( pValObjBase == NULL )
+ {
+ if( xPrevVarObj.Is() )
+ {
+ // Object is overwritten with NULL, instantiate init object
+ DimAsNewRecoverHash::iterator it = GaDimAsNewRecoverHash.find( refVar );
+ if( it != GaDimAsNewRecoverHash.end() )
+ {
+ const DimAsNewRecoverItem& rItem = it->second;
+ if( rItem.m_pClassModule != NULL )
+ {
+ SbClassModuleObject* pNewObj = new SbClassModuleObject( rItem.m_pClassModule );
+ pNewObj->SetName( rItem.m_aObjName );
+ pNewObj->SetParent( rItem.m_pObjParent );
+ refVar->PutObject( pNewObj );
+ }
+ else if( rItem.m_aObjClass.EqualsIgnoreCaseAscii( pCollectionStr ) )
+ {
+ BasicCollection* pNewCollection = new BasicCollection( String( RTL_CONSTASCII_USTRINGPARAM(pCollectionStr) ) );
+ pNewCollection->SetName( rItem.m_aObjName );
+ pNewCollection->SetParent( rItem.m_pObjParent );
+ refVar->PutObject( pNewCollection );
+ }
+ }
+ }
+ }
+ else
+ {
+ // Does old value exist?
+ bool bFirstInit = !xPrevVarObj.Is();
+ if( bFirstInit )
+ {
+ // Store information to instantiate object later
+ SbxObject* pValObj = PTR_CAST(SbxObject,pValObjBase);
+ if( pValObj != NULL )
+ {
+ String aObjClass = pValObj->GetClassName();
+
+ SbClassModuleObject* pClassModuleObj = PTR_CAST(SbClassModuleObject,pValObjBase);
+ if( pClassModuleObj != NULL )
+ {
+ SbModule* pClassModule = pClassModuleObj->getClassModule();
+ GaDimAsNewRecoverHash[refVar] =
+ DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), pClassModule );
+ }
+ else if( aObjClass.EqualsIgnoreCaseAscii( "Collection" ) )
+ {
+ GaDimAsNewRecoverHash[refVar] =
+ DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), NULL );
+ }
+ }
+ }
+ }
+ }
+ }
+
+
// 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
diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx
index 995c425c0e..4279abe002 100755
--- a/basic/source/runtime/step2.cxx
+++ b/basic/source/runtime/step2.cxx
@@ -143,15 +143,19 @@ SbxVariable* SbiRuntime::FindElement
else
pElem = getVBAConstant( aName );
}
- // #72382 VORSICHT! Liefert jetzt wegen unbekannten
- // Modulen IMMER ein Ergebnis!
- SbUnoClass* pUnoClass = findUnoClass( aName );
- if( pUnoClass )
+
+ if( !pElem )
{
- pElem = new SbxVariable( t );
- SbxValues aRes( SbxOBJECT );
- aRes.pObj = pUnoClass;
- pElem->SbxVariable::Put( aRes );
+ // #72382 VORSICHT! Liefert jetzt wegen unbekannten
+ // Modulen IMMER ein Ergebnis!
+ SbUnoClass* pUnoClass = findUnoClass( aName );
+ if( pUnoClass )
+ {
+ pElem = new SbxVariable( t );
+ SbxValues aRes( SbxOBJECT );
+ aRes.pObj = pUnoClass;
+ pElem->SbxVariable::Put( aRes );
+ }
}
// #62939 Wenn eine Uno-Klasse gefunden wurde, muss
@@ -407,6 +411,34 @@ void SbiRuntime::SetupArgs( SbxVariable* p, UINT32 nOp1 )
}
}
}
+ else if( bVBAEnabled && p->GetType() == SbxOBJECT && (!p->ISA(SbxMethod) || !p->IsBroadcaster()) )
+ {
+ // Check for default method with named parameters
+ SbxBaseRef pObj = (SbxBase*)p->GetObject();
+ if( pObj && pObj->ISA(SbUnoObject) )
+ {
+ SbUnoObject* pUnoObj = (SbUnoObject*)(SbxBase*)pObj;
+ Any aAny = pUnoObj->getUnoAny();
+
+ if( aAny.getValueType().getTypeClass() == TypeClass_INTERFACE )
+ {
+ Reference< XInterface > x = *(Reference< XInterface >*)aAny.getValue();
+ Reference< XDefaultMethod > xDfltMethod( x, UNO_QUERY );
+
+ rtl::OUString sDefaultMethod;
+ if ( xDfltMethod.is() )
+ sDefaultMethod = xDfltMethod->getDefaultMethodName();
+ if ( sDefaultMethod.getLength() )
+ {
+ SbxVariable* meth = pUnoObj->Find( sDefaultMethod, SbxCLASS_METHOD );
+ if( meth != NULL )
+ pInfo = meth->GetInfo();
+ if( pInfo )
+ bError_ = false;
+ }
+ }
+ }
+ }
if( bError_ )
Error( SbERR_NO_NAMED_ARGS );
}
@@ -489,7 +521,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
pPar->Put( NULL, 0 );
}
// Index-Access bei UnoObjekten beruecksichtigen
- else if( pElem->GetType() == SbxOBJECT && !pElem->ISA(SbxMethod) )
+ else if( pElem->GetType() == SbxOBJECT && (!pElem->ISA(SbxMethod) || !pElem->IsBroadcaster()) )
{
pPar = pElem->GetParameters();
if ( pPar )
@@ -589,6 +621,12 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem )
pCol->CollItem( pPar );
}
}
+ else if( bVBAEnabled ) // !pObj
+ {
+ SbxArray* pParam = pElem->GetParameters();
+ if( pParam != NULL )
+ Error( SbERR_NO_OBJECT );
+ }
}
}
@@ -1085,12 +1123,24 @@ void SbiRuntime::StepTCREATE( UINT32 nOp1, UINT32 nOp2 )
PushVar( pNew );
}
-void SbiRuntime::implCreateFixedString( SbxVariable* pStrVar, UINT32 nOp2 )
+void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, UINT32 nOp2 )
{
- USHORT nCount = static_cast<USHORT>( nOp2 >> 17 ); // len = all bits above 0x10000
- String aStr;
- aStr.Fill( nCount, 0 );
- pStrVar->PutString( aStr );
+ bool bWithEvents = ((t & 0xff) == SbxOBJECT && (nOp2 & SBX_TYPE_WITH_EVENTS_FLAG) != 0);
+ if( bWithEvents )
+ pVar->SetFlag( SBX_WITH_EVENTS );
+
+ bool bDimAsNew = ((nOp2 & SBX_TYPE_DIM_AS_NEW_FLAG) != 0);
+ if( bDimAsNew )
+ pVar->SetFlag( SBX_DIM_AS_NEW );
+
+ bool bFixedString = ((t & 0xff) == SbxSTRING && (nOp2 & SBX_FIXED_LEN_STRING_FLAG) != 0);
+ if( bFixedString )
+ {
+ USHORT nCount = static_cast<USHORT>( nOp2 >> 17 ); // len = all bits above 0x10000
+ String aStr;
+ aStr.Fill( nCount, 0 );
+ pVar->PutString( aStr );
+ }
}
// Einrichten einer lokalen Variablen (+StringID+Typ)
@@ -1105,12 +1155,7 @@ void SbiRuntime::StepLOCAL( UINT32 nOp1, UINT32 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 );
+ implHandleSbxFlags( p, t, nOp2 );
refLocals->Put( p, refLocals->Count() );
}
}
@@ -1137,12 +1182,7 @@ void SbiRuntime::StepPUBLIC_Impl( UINT32 nOp1, UINT32 nOp2, bool bUsedForClassMo
// 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 );
+ implHandleSbxFlags( pProp, t, nOp2 );
}
}
diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx
index c96d9b5b35..43ee8e6944 100644
--- a/basic/source/sbx/sbxobj.cxx
+++ b/basic/source/sbx/sbxobj.cxx
@@ -112,6 +112,9 @@ SbxObject::~SbxObject()
CheckParentsOnDelete( this, pProps );
CheckParentsOnDelete( this, pMethods );
CheckParentsOnDelete( this, pObjs );
+
+ // avoid handling in ~SbxVariable as SBX_DIM_AS_NEW == SBX_GBLSEARCH
+ ResetFlag( SBX_DIM_AS_NEW );
}
SbxDataType SbxObject::GetType() const
diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx
index 9cbdeafdb2..945e66ceaf 100644..100755
--- a/basic/source/sbx/sbxvalue.cxx
+++ b/basic/source/sbx/sbxvalue.cxx
@@ -436,6 +436,8 @@ SbxValue* SbxValue::TheRealValue() const
}
// #55226 Zusaetzliche Info transportieren
+bool handleToStringForCOMObjects( SbxObject* pObj, SbxValue* pVal ); // sbunoobj.cxx
+
SbxValue* SbxValue::TheRealValue( BOOL bObjInObjError ) const
{
SbxValue* p = (SbxValue*) this;
@@ -461,8 +463,12 @@ SbxValue* SbxValue::TheRealValue( BOOL bObjInObjError ) const
((SbxValue*) pObj)->aData.eType == SbxOBJECT &&
((SbxValue*) pObj)->aData.pObj == pObj )
{
- SetError( SbxERR_BAD_PROP_VALUE );
- p = NULL;
+ bool bSuccess = handleToStringForCOMObjects( pObj, p );
+ if( !bSuccess )
+ {
+ SetError( SbxERR_BAD_PROP_VALUE );
+ p = NULL;
+ }
}
else if( pDflt )
p = pDflt;
diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index 4ce6eaf961..e11a408a14 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -59,13 +59,17 @@ class SbxVariableImpl
friend class SbxVariable;
String m_aDeclareClassName;
Reference< XInterface > m_xComListener;
+ StarBASIC* m_pComListenerParentBasic;
SbxVariableImpl( void )
+ : m_pComListenerParentBasic( NULL )
{}
SbxVariableImpl( const SbxVariableImpl& r )
: m_aDeclareClassName( r.m_aDeclareClassName )
, m_xComListener( r.m_xComListener )
- {}
+ , m_pComListenerParentBasic( r.m_pComListenerParentBasic )
+ {
+ }
};
@@ -84,12 +88,18 @@ SbxVariable::SbxVariable() : SbxValue()
#endif
}
+void registerComListenerVariableForBasic( SbxVariable* pVar, StarBASIC* pBasic );
+
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 );
+ if( mpSbxVariableImpl->m_xComListener.is() )
+ registerComListenerVariableForBasic( this, mpSbxVariableImpl->m_pComListenerParentBasic );
+ }
pCst = NULL;
if( r.CanRead() )
{
@@ -126,6 +136,8 @@ SbxVariable::SbxVariable( SbxDataType t, void* p ) : SbxValue( t, p )
#endif
}
+void removeDimAsNewRecoverItem( SbxVariable* pVar );
+
SbxVariable::~SbxVariable()
{
#ifdef DBG_UTIL
@@ -136,6 +148,8 @@ SbxVariable::~SbxVariable()
maName.AssignAscii( aCellsStr, sizeof( aCellsStr )-1 );
GetSbxData_Impl()->aVars.Remove( this );
#endif
+ if( IsSet( SBX_DIM_AS_NEW ))
+ removeDimAsNewRecoverItem( this );
delete mpSbxVariableImpl;
delete pCst;
}
@@ -315,7 +329,11 @@ SbxVariable& SbxVariable::operator=( const SbxVariable& r )
SbxValue::operator=( r );
delete mpSbxVariableImpl;
if( r.mpSbxVariableImpl != NULL )
+ {
mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl );
+ if( mpSbxVariableImpl->m_xComListener.is() )
+ registerComListenerVariableForBasic( this, mpSbxVariableImpl->m_pComListenerParentBasic );
+ }
else
mpSbxVariableImpl = NULL;
return *this;
@@ -396,10 +414,19 @@ void SbxVariable::SetDeclareClassName( const String& rDeclareClassName )
pImpl->m_aDeclareClassName = rDeclareClassName;
}
-void SbxVariable::SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener )
+void SbxVariable::SetComListener( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xComListener,
+ StarBASIC* pParentBasic )
{
SbxVariableImpl* pImpl = getImpl();
pImpl->m_xComListener = xComListener;
+ pImpl->m_pComListenerParentBasic = pParentBasic;
+ registerComListenerVariableForBasic( this, pParentBasic );
+}
+
+void SbxVariable::ClearComListener( void )
+{
+ SbxVariableImpl* pImpl = getImpl();
+ pImpl->m_xComListener.clear();
}
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 2eb7a4e77e..4668ca4418 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -2815,19 +2815,37 @@ OUString SAL_CALL SfxLibraryContainer::getOriginalLibraryLinkURL( const OUString
void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (RuntimeException)
{
- BasicManager* pBasMgr = getBasicManager();
- if( pBasMgr )
+ /* The member variable mbVBACompat must be set first, the following call
+ to getBasicManager() may call getVBACompatibilityMode() which returns
+ this value. */
+ mbVBACompat = _vbacompatmodeon;
+ if( BasicManager* pBasMgr = getBasicManager() )
{
// get the standard library
- String aLibName( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
- if ( pBasMgr->GetName().Len() )
- aLibName = pBasMgr->GetName();
+ String aLibName = pBasMgr->GetName();
+ if ( aLibName.Len() == 0 )
+ aLibName = String( RTL_CONSTASCII_USTRINGPARAM( "Standard" ) );
- StarBASIC* pBasic = pBasMgr->GetLib( aLibName );
- if( pBasic )
+ if( StarBASIC* pBasic = pBasMgr->GetLib( aLibName ) )
pBasic->SetVBAEnabled( _vbacompatmodeon );
+
+ /* If in VBA compatibility mode, force creation of the VBA Globals
+ object. Each application will create an instance of its own
+ implementation and store it in its Basic manager. Implementations
+ will do all necessary additional initialization, such as
+ registering the global "This***Doc" UNO constant, starting the
+ document events processor etc.
+ */
+ if( mbVBACompat ) try
+ {
+ Reference< frame::XModel > xModel( mxOwnerDocument ); // weak-ref -> ref
+ Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
+ xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) );
+ }
+ catch( Exception& )
+ {
+ }
}
- mbVBACompat = _vbacompatmodeon;
}
// Methods XServiceInfo
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index 87391bceff..b4222e7fb5 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -80,10 +80,9 @@ using namespace com::sun::star::script;
using namespace com::sun::star::xml::sax;
using namespace com::sun::star;
using namespace cppu;
-using namespace rtl;
using namespace osl;
-using com::sun::star::uno::Reference;
+using ::rtl::OUString;
//============================================================================
// Implementation class SfxScriptLibraryContainer
@@ -311,24 +310,21 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement
// aMod.aName ignored
if( aMod.aModuleType.getLength() > 0 )
{
- if( !getVBACompatibilityMode() )
+ /* If in VBA compatibility mode, force creation of the VBA Globals
+ object. Each application will create an instance of its own
+ implementation and store it in its Basic manager. Implementations
+ will do all necessary additional initialization, such as
+ registering the global "This***Doc" UNO constant, starting the
+ document events processor etc.
+ */
+ if( getVBACompatibilityMode() ) try
+ {
+ Reference< frame::XModel > xModel( mxOwnerDocument ); // weak-ref -> ref
+ Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW );
+ xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) );
+ }
+ catch( Exception& )
{
- setVBACompatibilityMode( 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;
@@ -353,25 +349,21 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement
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() )
+
+ // #163691# use the same codename access instance for all document modules
+ if( !mxCodeNameAccess.is() ) try
{
- try
- {
- xVBACodeNameAccess.set( xSF->createInstance(
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
- "ooo.vba.VBAObjectModuleObjectProvider"))),
- UNO_QUERY );
- }
- catch(uno::Exception&) {}
+ Reference<frame::XModel > xModel( mxOwnerDocument );
+ Reference< XMultiServiceFactory> xSF( xModel, UNO_QUERY_THROW );
+ mxCodeNameAccess.set( xSF->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAObjectModuleObjectProvider" ) ) ), UNO_QUERY );
}
- if( xVBACodeNameAccess.is() )
+ catch( Exception& ) {}
+
+ if( mxCodeNameAccess.is() )
{
try
{
- aModInfo.ModuleObject.set( xVBACodeNameAccess->getByName( aElementName), uno::UNO_QUERY );
+ aModInfo.ModuleObject.set( mxCodeNameAccess->getByName( aElementName), uno::UNO_QUERY );
}
catch(uno::Exception&)
{
diff --git a/framework/source/fwi/helper/mischelper.cxx b/framework/source/fwi/helper/mischelper.cxx
index 6fce055238..d774c05f0c 100644
--- a/framework/source/fwi/helper/mischelper.cxx
+++ b/framework/source/fwi/helper/mischelper.cxx
@@ -127,14 +127,17 @@ uno::Reference< linguistic2::XLanguageGuessing > LanguageGuessingHelper::GetGues
{
rtl::OUString aStr;
Sequence< PropertyValue > aPropSeq;
- if ( _xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq )
+ if( _xUICommandLabels->hasByName( aCmdURL ) )
{
- for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
+ if ( _xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq )
{
- if ( aPropSeq[i].Name.equalsAscii( _pName/*"Label"*/ ))
+ for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ )
{
- aPropSeq[i].Value >>= aStr;
- break;
+ if ( aPropSeq[i].Name.equalsAscii( _pName/*"Label"*/ ))
+ {
+ aPropSeq[i].Value >>= aStr;
+ break;
+ }
}
}
}
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index a388e8b468..ee903138f0 100755
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -522,7 +522,7 @@ sal_Bool LayoutManager::implts_readWindowStateData( const rtl::OUString& aName,
try
{
Sequence< PropertyValue > aWindowState;
- if ( xPersistentWindowState->getByName( aName ) >>= aWindowState )
+ if ( xPersistentWindowState->hasByName( aName ) && (xPersistentWindowState->getByName( aName ) >>= aWindowState) )
{
sal_Bool bValue( sal_False );
for ( sal_Int32 n = 0; n < aWindowState.getLength(); n++ )
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
index bc86ca431b..b187d45962 100644
--- a/framework/source/services/pathsettings.cxx
+++ b/framework/source/services/pathsettings.cxx
@@ -245,21 +245,24 @@ void PathSettings::impl_readAll()
OUStringList PathSettings::impl_readOldFormat(const ::rtl::OUString& sPath)
{
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "PathSettings::impl_readOldFormat" );
- css::uno::Reference< css::container::XNameAccess > xCfg = fa_getCfgOld();
- css::uno::Any aVal = xCfg->getByName(sPath);
+ css::uno::Reference< css::container::XNameAccess > xCfg( fa_getCfgOld() );
+ OUStringList aPathVal;
- ::rtl::OUString sStringVal;
- css::uno::Sequence< ::rtl::OUString > lStringListVal;
- OUStringList aPathVal;
-
- if (aVal >>= sStringVal)
+ if( xCfg->hasByName(sPath) )
{
- aPathVal.push_back(sStringVal);
- }
- else
- if (aVal >>= lStringListVal)
- {
- aPathVal << lStringListVal;
+ css::uno::Any aVal( xCfg->getByName(sPath) );
+
+ ::rtl::OUString sStringVal;
+ css::uno::Sequence< ::rtl::OUString > lStringListVal;
+
+ if (aVal >>= sStringVal)
+ {
+ aPathVal.push_back(sStringVal);
+ }
+ else if (aVal >>= lStringListVal)
+ {
+ aPathVal << lStringListVal;
+ }
}
return aPathVal;
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index 025f3bdf84..74ee45e5d9 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -723,8 +723,9 @@ void ModuleUIConfigurationManager::impl_Initialize()
Reference< XStorage > xElementTypeStorage;
try
{
- Any a = xNameAccess->getByName( OUString::createFromAscii( UIELEMENTTYPENAMES[i] ));
- a >>= xElementTypeStorage;
+ const OUString sName( OUString::createFromAscii( UIELEMENTTYPENAMES[i] ) );
+ if( xNameAccess->hasByName( sName ) )
+ xNameAccess->getByName( sName ) >>= xElementTypeStorage;
}
catch ( com::sun::star::container::NoSuchElementException& )
{
diff --git a/framework/source/uiconfiguration/windowstateconfiguration.cxx b/framework/source/uiconfiguration/windowstateconfiguration.cxx
index 5d5fa60f14..421676db83 100644
--- a/framework/source/uiconfiguration/windowstateconfiguration.cxx
+++ b/framework/source/uiconfiguration/windowstateconfiguration.cxx
@@ -364,16 +364,20 @@ throw ( RuntimeException )
sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasByName( const ::rtl::OUString& rResourceURL )
throw (::com::sun::star::uno::RuntimeException)
{
- try
- {
- getByName( rResourceURL );
- }
- catch ( NoSuchElementException& )
+ // SAFE
+ ResetableGuard aLock( m_aLock );
+
+ ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
+ if ( pIter != m_aResourceURLToInfoCache.end() )
+ return sal_True;
+ else
{
- return sal_False;
+ Any a( impl_getWindowStateFromResourceURL( rResourceURL ) );
+ if ( a == Any() )
+ return sal_False;
+ else
+ return sal_True;
}
-
- return sal_True;
}
// XElementAccess
@@ -1044,12 +1048,11 @@ Any ConfigurationAccess_WindowState::impl_getWindowStateFromResourceURL( const r
try
{
// Try to ask our configuration access
- if ( m_xConfigAccess.is() )
+ if ( m_xConfigAccess.is() && m_xConfigAccess->hasByName( rResourceURL ) )
{
- Reference< XNameAccess > xNameAccess;
- Any a( m_xConfigAccess->getByName( rResourceURL ));
- if ( a >>= xNameAccess )
+ Reference< XNameAccess > xNameAccess( m_xConfigAccess->getByName( rResourceURL ), UNO_QUERY );
+ if ( xNameAccess.is() )
return impl_insertCacheAndReturnSequence( rResourceURL, xNameAccess );
}
}
diff --git a/framework/source/uielement/uicommanddescription.cxx b/framework/source/uielement/uicommanddescription.cxx
index a6fedb6624..4f07fc5dde 100644
--- a/framework/source/uielement/uicommanddescription.cxx
+++ b/framework/source/uielement/uicommanddescription.cxx
@@ -144,6 +144,8 @@ class ConfigurationAccess_UICommand : // Order is neccessary for right initializ
virtual void SAL_CALL disposing( const EventObject& aEvent ) throw(RuntimeException);
protected:
+ virtual ::com::sun::star::uno::Any SAL_CALL getByNameImpl( const ::rtl::OUString& aName );
+
struct CmdToInfoMap
{
CmdToInfoMap() : bPopup( false ),
@@ -253,9 +255,9 @@ ConfigurationAccess_UICommand::~ConfigurationAccess_UICommand()
xContainer->removeContainerListener( this );
}
+
// XNameAccess
-Any SAL_CALL ConfigurationAccess_UICommand::getByName( const ::rtl::OUString& rCommandURL )
-throw ( NoSuchElementException, WrappedTargetException, RuntimeException)
+Any SAL_CALL ConfigurationAccess_UICommand::getByNameImpl( const ::rtl::OUString& rCommandURL )
{
static sal_Int32 nRequests = 0;
@@ -280,19 +282,24 @@ throw ( NoSuchElementException, WrappedTargetException, RuntimeException)
else if ( rCommandURL.equalsIgnoreAsciiCaseAscii( UICOMMANDDESCRIPTION_NAMEACCESS_COMMANDMIRRORIMAGELIST ))
return makeAny( m_aCommandMirrorImageList );
else
- throw NoSuchElementException();
+ return Any();
}
else
{
// SAFE
++nRequests;
- Any a = getInfoFromCommand( rCommandURL );
+ return getInfoFromCommand( rCommandURL );
+ }
+}
- if ( !a.hasValue() )
- throw NoSuchElementException();
+Any SAL_CALL ConfigurationAccess_UICommand::getByName( const ::rtl::OUString& rCommandURL )
+throw ( NoSuchElementException, WrappedTargetException, RuntimeException)
+{
+ Any aRet( getByNameImpl( rCommandURL ) );
+ if( !aRet.hasValue() )
+ throw NoSuchElementException();
- return a;
- }
+ return aRet;
}
Sequence< ::rtl::OUString > SAL_CALL ConfigurationAccess_UICommand::getElementNames()
@@ -304,7 +311,7 @@ throw ( RuntimeException )
sal_Bool SAL_CALL ConfigurationAccess_UICommand::hasByName( const ::rtl::OUString& rCommandURL )
throw (::com::sun::star::uno::RuntimeException)
{
- return getByName( rCommandURL ).hasValue();
+ return getByNameImpl( rCommandURL ).hasValue();
}
// XElementAccess
@@ -470,7 +477,7 @@ Any ConfigurationAccess_UICommand::getInfoFromCommand( const rtl::OUString& rCom
{
// First try to ask our global commands configuration access. It also caches maybe
// we find the entry in its cache first.
- if ( m_xGenericUICommands.is() )
+ if ( m_xGenericUICommands.is() && m_xGenericUICommands->hasByName( rCommandURL ) )
{
try
{
diff --git a/oovbaapi/ooo/vba/XApplicationBase.idl b/oovbaapi/ooo/vba/XApplicationBase.idl
index 2a9830568d..c5ed2518aa 100644
--- a/oovbaapi/ooo/vba/XApplicationBase.idl
+++ b/oovbaapi/ooo/vba/XApplicationBase.idl
@@ -49,9 +49,9 @@ interface XApplicationBase
void Quit();
- any CommandBars( [in] any aIndex );
- void Run([in] string MacroName, [in] /*Optional*/ any varg1, [in] /*Optional*/ any varg2, [in] /*Optional*/ any varg3, [in] /*Optional*/ any varg4, [in] /*Optional*/ any varg5, [in] /*Optional*/ any varg6, [in] /*Optional*/ any varg7, [in] /*Optional*/ any varg8, [in] /*Optional*/ any varg9, [in] /*Optional*/ any varg10, [in] /*Optional*/ any varg11, [in] /*Optional*/ any varg12, [in] /*Optional*/ any varg13, [in] /*Optional*/ any varg14, [in] /*Optional*/ any varg15, [in] /*Optional*/ any varg16, [in] /*Optional*/ any varg17, [in] /*Optional*/ any varg18, [in] /*Optional*/ any varg19, [in] /*Optional*/ any varg20, [in] /*Optional*/ any varg21, [in] /*Optional*/ any varg22, [in] /*Optional*/ any varg23, [in] /*Optional*/ any varg24, [in] /*Optional*/ any varg25, [in] /*Optional*/ any varg26, [in] /*Optional*/ any varg27, [in] /*Optional*/ any varg28, [in] /*Optional*/ any varg29, [in] /*Optional*/ any varg30);
- void OnTime( [in] any aEarliestTime, [in] string aFunction, [in] any aLatestTime, [in] any aSchedule );
+ any CommandBars( [in] any Index );
+ void Run( [in] string Macro, [in] /*Optional*/ any Arg1, [in] /*Optional*/ any Arg2, [in] /*Optional*/ any Arg3, [in] /*Optional*/ any Arg4, [in] /*Optional*/ any Arg5, [in] /*Optional*/ any Arg6, [in] /*Optional*/ any Arg7, [in] /*Optional*/ any Arg8, [in] /*Optional*/ any Arg9, [in] /*Optional*/ any Arg10, [in] /*Optional*/ any Arg11, [in] /*Optional*/ any Arg12, [in] /*Optional*/ any Arg13, [in] /*Optional*/ any Arg14, [in] /*Optional*/ any Arg15, [in] /*Optional*/ any Arg16, [in] /*Optional*/ any Arg17, [in] /*Optional*/ any Arg18, [in] /*Optional*/ any Arg19, [in] /*Optional*/ any Arg20, [in] /*Optional*/ any Arg21, [in] /*Optional*/ any Arg22, [in] /*Optional*/ any Arg23, [in] /*Optional*/ any Arg24, [in] /*Optional*/ any Arg25, [in] /*Optional*/ any Arg26, [in] /*Optional*/ any Arg27, [in] /*Optional*/ any Arg28, [in] /*Optional*/ any Arg29, [in] /*Optional*/ any Arg30);
+ void OnTime( [in] any EarliestTime, [in] string Procedure, [in] any LatestTime, [in] any Schedule );
float CentimetersToPoints([in] float Centimeters );
void Undo();
};
diff --git a/oovbaapi/ooo/vba/XVBAAppService.idl b/oovbaapi/ooo/vba/XVBAAppService.idl
deleted file mode 100755
index 38cb0f9a1a..0000000000
--- a/oovbaapi/ooo/vba/XVBAAppService.idl
+++ /dev/null
@@ -1,72 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: XWorkbook.idl,v $
- * $Revision: 1.4 $
- *
- * 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.
- *
- ************************************************************************/
-#ifndef __ooo_vba_appservice_idl__
-#define __ooo_vba_appservice_idl__
-
-#ifndef __com_sun_star_uno_XInterface_idl__
-#include <com/sun/star/uno/XInterface.idl>
-#endif
-
-#ifndef __com_sun_star_uno_XComponentContext_idl__
-#include <com/sun/star/uno/XComponentContext.idl>
-#endif
-
-#ifndef __com_sun_star_frame_XModel_idl__
-#include <com/sun/star/frame/XModel.idl>
-#endif
-
-#ifndef __com_sun_star_script_XLibraryContainer_idl__
-#include <com/sun/star/script/XLibraryContainer.idl>
-#endif
-
-//=============================================================================
-
-module ooo { module vba {
-
-//=============================================================================
-
-
-interface XHelperInterface;
-interface XComponentContext;
-interface XModel;
-
-interface XVBAAppService
-{
- interface ::com::sun::star::uno::XInterface;
-
- any getVBE([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel);
- any getVBProjects([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel, [in] ::com::sun::star::script::XLibraryContainer xMacroLibraryContainer, [in] com::sun::star::script::XLibraryContainer xDialogLibraryContainer);
-
-
-};
-
- }; };
-
-#endif
diff --git a/oovbaapi/ooo/vba/XVBADocService.idl b/oovbaapi/ooo/vba/XVBADocService.idl
deleted file mode 100755
index 2028772702..0000000000
--- a/oovbaapi/ooo/vba/XVBADocService.idl
+++ /dev/null
@@ -1,72 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: XVBADocService.idl,v $
- * $Revision: 1.4 $
- *
- * 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.
- *
- ************************************************************************/
-#ifndef __ooo_vba_socservice_idl__
-#define __ooo_vba_appservice_idl__
-
-#ifndef __com_sun_star_uno_XInterface_idl__
-#include <com/sun/star/uno/XInterface.idl>
-#endif
-
-#ifndef __com_sun_star_uno_XComponentContext_idl__
-#include <com/sun/star/uno/XComponentContext.idl>
-#endif
-
-#ifndef __com_sun_star_frame_XModel_idl__
-#include <com/sun/star/frame/XModel.idl>
-#endif
-
-#ifndef __com_sun_star_script_XLibraryContainer_idl__
-#include <com/sun/star/script/XLibraryContainer.idl>
-#endif
-
-//=============================================================================
-
-module ooo { module vba {
-
-//=============================================================================
-
-
-interface XHelperInterface;
-interface XComponentContext;
-interface XModel;
-
-interface XVBADocService
-{
- interface ::com::sun::star::uno::XInterface;
-
-
- any getVBProject([in] XHelperInterface xParent, [in] ::com::sun::star::uno::XComponentContext xContext, [in] ::com::sun::star::frame::XModel xModel, [in] ::com::sun::star::script::XLibraryContainer xMacroLibraryContainer, [in] com::sun::star::script::XLibraryContainer xDialogLibraryContainer);
-
-
-};
-
- }; };
-
-#endif
diff --git a/oovbaapi/ooo/vba/excel/SheetObject.idl b/oovbaapi/ooo/vba/excel/SheetObject.idl
index 5d8e6efb39..618c0962d5 100755..100644
--- a/oovbaapi/ooo/vba/excel/SheetObject.idl
+++ b/oovbaapi/ooo/vba/excel/SheetObject.idl
@@ -111,7 +111,7 @@ interface XButton : com::sun::star::uno::XInterface
[attribute] long Orientation;
/** Access to text and text formatting of the button caption. */
- XCharacters Characters( [in] any aStart, [in] any aLength );
+ XCharacters Characters( [in] any Start, [in] any Length );
};
//=============================================================================
diff --git a/oovbaapi/ooo/vba/excel/SheetObjects.idl b/oovbaapi/ooo/vba/excel/SheetObjects.idl
index 4c93bb3bf5..a88ab6b162 100755..100644
--- a/oovbaapi/ooo/vba/excel/SheetObjects.idl
+++ b/oovbaapi/ooo/vba/excel/SheetObjects.idl
@@ -81,7 +81,7 @@ interface XGraphicObjects : com::sun::star::uno::XInterface
@return The created graphic object.
*/
- any Add( [in] any fLeft, [in] any fTop, [in] any fWidth, [in] any fHeight );
+ any Add( [in] any Left, [in] any Top, [in] any Width, [in] any Height );
};
//=============================================================================
@@ -109,7 +109,7 @@ interface XLineObjects : com::sun::star::uno::XInterface
@return The created line object.
*/
- any Add( [in] any fX1, [in] any fY1, [in] any fX2, [in] any fY2 );
+ any Add( [in] any X1, [in] any Y1, [in] any X2, [in] any Y2 );
};
//=============================================================================
@@ -131,7 +131,7 @@ interface XDrawings : com::sun::star::uno::XInterface
@return The created polygon object.
*/
- any Add( [in] any fX1, [in] any fY1, [in] any fX2, [in] any fY2, [in] any bClosed );
+ any Add( [in] any X1, [in] any Y1, [in] any X2, [in] any Y2, [in] any Closed );
};
//=============================================================================
diff --git a/oovbaapi/ooo/vba/excel/XApplication.idl b/oovbaapi/ooo/vba/excel/XApplication.idl
index ac1f4c4ee0..9716b4810a 100644
--- a/oovbaapi/ooo/vba/excel/XApplication.idl
+++ b/oovbaapi/ooo/vba/excel/XApplication.idl
@@ -73,10 +73,10 @@ interface XApplication
string LibraryPath() raises(com::sun::star::script::BasicErrorException);
string TemplatesPath() raises(com::sun::star::script::BasicErrorException);
string PathSeparator() raises(com::sun::star::script::BasicErrorException);
- //any CommandBars( [in] any aIndex );
- any Workbooks( [in] any aIndex );
- any Worksheets( [in] any aIndex );
- any Windows( [in] any aIndex );
+ //any CommandBars( [in] any Index );
+ any Workbooks( [in] any Index );
+ any Worksheets( [in] any Index );
+ any Windows( [in] any Index );
any WorksheetFunction();
any Evaluate( [in] string Name );
any Dialogs( [in] any DialogIndex );
@@ -92,7 +92,7 @@ interface XApplication
raises(com::sun::star::script::BasicErrorException);
void Volatile([in] any Volatile);
void DoEvents();
- any Caller( [in] any aIndex );
+ any Caller( [in] any Index );
};
}; }; };
diff --git a/oovbaapi/ooo/vba/excel/XFormat.idl b/oovbaapi/ooo/vba/excel/XFormat.idl
index 7b3622ecc5..3cbb678dad 100644
--- a/oovbaapi/ooo/vba/excel/XFormat.idl
+++ b/oovbaapi/ooo/vba/excel/XFormat.idl
@@ -46,7 +46,7 @@ interface XFormat
interface ::ooo::vba::XHelperInterface;
// void Clear( ) raises ( com::sun::star::script::BasicErrorException );
- any Borders( [in] any item )
+ any Borders( [in] any Item )
raises(com::sun::star::script::BasicErrorException);
XFont Font()
diff --git a/oovbaapi/ooo/vba/excel/XGlobals.idl b/oovbaapi/ooo/vba/excel/XGlobals.idl
index ad9d85eb45..52ebfdadaf 100644
--- a/oovbaapi/ooo/vba/excel/XGlobals.idl
+++ b/oovbaapi/ooo/vba/excel/XGlobals.idl
@@ -65,18 +65,18 @@ interface XGlobals: com::sun::star::uno::XInterface
void Calculate() raises(com::sun::star::script::BasicErrorException);
XRange Cells([in] any RowIndex, [in] any ColumnIndex);
- XRange Columns([in] any aIndex);
- any CommandBars( [in] any aIndex );
+ XRange Columns([in] any Index);
+ any CommandBars( [in] any Index );
any Evaluate( [in] string Name );
XRange Intersect([in] XRange Arg1, [in] XRange Arg2, [in] /*Optional*/ any Arg3, [in] /*Optional*/ any Arg4, [in] /*Optional*/ any Arg5, [in] /*Optional*/ any Arg6, [in] /*Optional*/ any Arg7, [in] /*Optional*/ any Arg8, [in] /*Optional*/ any Arg9, [in] /*Optional*/ any Arg10, [in] /*Optional*/ any Arg11, [in] /*Optional*/ any Arg12, [in] /*Optional*/ any Arg13, [in] /*Optional*/ any Arg14, [in] /*Optional*/ any Arg15, [in] /*Optional*/ any Arg16, [in] /*Optional*/ any Arg17, [in] /*Optional*/ any Arg18, [in] /*Optional*/ any Arg19, [in] /*Optional*/ any Arg20, [in] /*Optional*/ any Arg21, [in] /*Optional*/ any Arg22, [in] /*Optional*/ any Arg23, [in] /*Optional*/ any Arg24, [in] /*Optional*/ any Arg25, [in] /*Optional*/ any Arg26, [in] /*Optional*/ any Arg27, [in] /*Optional*/ any Arg28, [in] /*Optional*/ any Arg29, [in] /*Optional*/ any Arg30)
raises(com::sun::star::script::BasicErrorException);
- any WorkSheets( [in] any aIndex );
- any WorkBooks( [in] any aIndex );
+ any WorkSheets( [in] any Index );
+ any WorkBooks( [in] any Index );
any WorksheetFunction();
- any Windows( [in] any aIndex );
- any Sheets( [in] any aIndex );
+ any Windows( [in] any Index );
+ any Sheets( [in] any Index );
any Range( [in] any Cell1, [in] any Cell2 );
- XRange Rows([in] any aIndex);
+ XRange Rows([in] any Index);
any Names( [in] any Index );
XRange Union([in] XRange Arg1, [in] XRange Arg2, [in] /*Optional*/ any Arg3, [in] /*Optional*/ any Arg4, [in] /*Optional*/ any Arg5, [in] /*Optional*/ any Arg6, [in] /*Optional*/ any Arg7, [in] /*Optional*/ any Arg8, [in] /*Optional*/ any Arg9, [in] /*Optional*/ any Arg10, [in] /*Optional*/ any Arg11, [in] /*Optional*/ any Arg12, [in] /*Optional*/ any Arg13, [in] /*Optional*/ any Arg14, [in] /*Optional*/ any Arg15, [in] /*Optional*/ any Arg16, [in] /*Optional*/ any Arg17, [in] /*Optional*/ any Arg18, [in] /*Optional*/ any Arg19, [in] /*Optional*/ any Arg20, [in] /*Optional*/ any Arg21, [in] /*Optional*/ any Arg22, [in] /*Optional*/ any Arg23, [in] /*Optional*/ any Arg24, [in] /*Optional*/ any Arg25, [in] /*Optional*/ any Arg26, [in] /*Optional*/ any Arg27, [in] /*Optional*/ any Arg28, [in] /*Optional*/ any Arg29, [in] /*Optional*/ any Arg30)
raises(com::sun::star::script::BasicErrorException);
diff --git a/oovbaapi/ooo/vba/excel/XHyperlinks.idl b/oovbaapi/ooo/vba/excel/XHyperlinks.idl
index 76c6daf3e3..0b8a6c28b6 100755..100644
--- a/oovbaapi/ooo/vba/excel/XHyperlinks.idl
+++ b/oovbaapi/ooo/vba/excel/XHyperlinks.idl
@@ -47,11 +47,11 @@ interface XHyperlinks
// ------------------------------------------------------------------------
XHyperlink Add(
- [in] any aAnchor,
- [in] any aAddress,
- [in] any aSubAddress,
- [in] any aScreenTip,
- [in] any aTextToDisplay );
+ [in] any Anchor,
+ [in] any Address,
+ [in] any SubAddress,
+ [in] any ScreenTip,
+ [in] any TextToDisplay );
// ------------------------------------------------------------------------
diff --git a/oovbaapi/ooo/vba/excel/XRange.idl b/oovbaapi/ooo/vba/excel/XRange.idl
index 5d59a3baec..bdc3500f21 100644
--- a/oovbaapi/ooo/vba/excel/XRange.idl
+++ b/oovbaapi/ooo/vba/excel/XRange.idl
@@ -113,7 +113,7 @@ interface XRange
void FillRight();
void FillUp();
void FillDown();
- XRange Item([in] any row, [in] any column) raises(com::sun::star::script::BasicErrorException);
+ XRange Item([in] any RowIndex, [in] any ColumnIndex) raises(com::sun::star::script::BasicErrorException);
XRange Offset([in] any RowOffset, [in] any ColumnOffset);
XRange CurrentRegion();
XRange CurrentArray();
@@ -146,7 +146,7 @@ interface XRange
XCharacters characters([in] any Start, [in] any Length);
void Delete( [in] any Shift );
- any Areas( [in] any item );
+ any Areas( [in] any Item );
any BorderAround( [in] any LineStyle, [in] any Weight, [in] any ColorIndex, [in] any Color );
void AutoFilter([in ] any Field, [in] any Criteria1, [in] any Operator, [in] any Criteria2, [in] any VisibleDropDown);
void Insert([in] any Shift, [in] any CopyOrigin);
@@ -165,7 +165,7 @@ interface XRange
void RemoveSubtotal() raises ( com::sun::star::script::BasicErrorException );
void Subtotal( [in] long GroupBy, [in] long Function, [in] /*Optional*/ sequence<long> TotalList, [in] /*Optional*/ any Replace, [in] /*Optional*/ any PageBreaks, [in] any SummaryBelowData ) raises ( com::sun::star::script::BasicErrorException );
XRange MergeArea( ) raises ( com::sun::star::script::BasicErrorException );
- any Hyperlinks( [in] any aIndex );
+ any Hyperlinks( [in] any Index );
};
//=============================================================================
diff --git a/oovbaapi/ooo/vba/excel/XWindow.idl b/oovbaapi/ooo/vba/excel/XWindow.idl
index e2bf39a699..3e2e55eac3 100644
--- a/oovbaapi/ooo/vba/excel/XWindow.idl
+++ b/oovbaapi/ooo/vba/excel/XWindow.idl
@@ -60,7 +60,7 @@ interface XWindow : com::sun::star::uno::XInterface
[attribute, readonly] XRange VisibleRange;
[attribute] any WindowState;
[attribute] any Zoom;
- any SelectedSheets( [in] any aIndex );
+ any SelectedSheets( [in] any Index );
void SmallScroll( [in] any Down, [in] any Up, [in] any ToRight, [in] any ToLeft );
void LargeScroll( [in] any Down, [in] any Up, [in] any ToRight, [in] any ToLeft );
void ScrollWorkbookTabs( [in] any Sheets, [in] any Position );
diff --git a/oovbaapi/ooo/vba/excel/XWorkbook.idl b/oovbaapi/ooo/vba/excel/XWorkbook.idl
index e35b661a44..7d8a30760c 100644
--- a/oovbaapi/ooo/vba/excel/XWorkbook.idl
+++ b/oovbaapi/ooo/vba/excel/XWorkbook.idl
@@ -52,14 +52,14 @@ interface XWorkbook : com::sun::star::uno::XInterface
[attribute, readonly] string CodeName;
[attribute] boolean PrecisionAsDisplayed;
- any Worksheets([in] any sheet);
- any Styles([in] any Index );
- any Sheets([in] any sheet);
- any Windows([in] any index );
+ any Worksheets( [in] any Index );
+ any Styles( [in] any Index );
+ any Sheets( [in] any Index );
+ any Windows( [in] any Index );
void ResetColors() raises (com::sun::star::script::BasicErrorException);
void Activate();
any Names( [in] any Index );
- any Colors([in] any Index) raises (com::sun::star::script::BasicErrorException);
+ any Colors( [in] any Index ) raises (com::sun::star::script::BasicErrorException);
long FileFormat() raises (com::sun::star::script::BasicErrorException);
void SaveCopyAs( [in] string Filename );
};
diff --git a/oovbaapi/ooo/vba/excel/XWorkbooks.idl b/oovbaapi/ooo/vba/excel/XWorkbooks.idl
index 721411b987..add5909e1c 100644
--- a/oovbaapi/ooo/vba/excel/XWorkbooks.idl
+++ b/oovbaapi/ooo/vba/excel/XWorkbooks.idl
@@ -44,7 +44,7 @@ module ooo { module vba { module excel {
interface XWorkbooks : com::sun::star::uno::XInterface
{
- any Add();
+ any Add([in] any Template);
any Open([in] string Filename, [in] any UpdateLinks, [in] any ReadOnly, [in] any Format, [in] any Password, [in] any WriteResPassword, [in] any IgnoreReadOnlyRecommended, [in] any Origin, [in] any Delimiter, [in] any Editable, [in] any Notify, [in] any Converter, [in] any AddToMru);
void Close();
diff --git a/oovbaapi/ooo/vba/excel/XWorksheet.idl b/oovbaapi/ooo/vba/excel/XWorksheet.idl
index a6d86957ec..9a5cd58118 100644
--- a/oovbaapi/ooo/vba/excel/XWorksheet.idl
+++ b/oovbaapi/ooo/vba/excel/XWorksheet.idl
@@ -60,7 +60,7 @@ interface XWorksheet
interface ::com::sun::star::script::XInvocation;
interface ::com::sun::star::container::XNamed;
- [attribute] boolean Visible;
+ [attribute] long Visible;
[attribute, readonly] long StandardHeight;
[attribute, readonly] long StandardWidth;
[attribute, readonly] boolean ProtectionMode;
@@ -101,26 +101,26 @@ interface XWorksheet
/* The following form control related symbols do not refer to ActiveX form
controls embedded in the sheet, but to the old-style drawing controls
of Excel. This is an Excel-only feature. */
- any Buttons( [in] any aIndex );
- any CheckBoxes( [in] any aIndex );
- any DropDowns( [in] any aIndex );
- any GroupBoxes( [in] any aIndex );
- any Labels( [in] any aIndex );
- any ListBoxes( [in] any aIndex );
- any OptionButtons( [in] any aIndex );
- any ScrollBars( [in] any aIndex );
- any Spinners( [in] any aIndex );
+ any Buttons( [in] any Index );
+ any CheckBoxes( [in] any Index );
+ any DropDowns( [in] any Index );
+ any GroupBoxes( [in] any Index );
+ any Labels( [in] any Index );
+ any ListBoxes( [in] any Index );
+ any OptionButtons( [in] any Index );
+ any ScrollBars( [in] any Index );
+ any Spinners( [in] any Index );
// FIXME: should prolly inherit from Range somehow...
- XRange Cells([in] any RowIndex, [in] any ColumnIndex);
- XRange Rows([in] any aIndex);
- XRange Columns([in] any aIndex);
- any Hyperlinks( [in] any aIndex );
+ XRange Cells( [in] any RowIndex, [in] any ColumnIndex );
+ XRange Rows( [in] any Index );
+ XRange Columns( [in] any Index );
+ any Hyperlinks( [in] any Index );
any Names( [in] any Index );
- any Evaluate( [in] string Name);
+ any Evaluate( [in] string Name );
- void setEnableCalculation([in] boolean EnableCalculation) raises(com::sun::star::script::BasicErrorException);
+ void setEnableCalculation( [in] boolean EnableCalculation ) raises(com::sun::star::script::BasicErrorException);
boolean getEnableCalculation() raises(com::sun::star::script::BasicErrorException);
void PrintOut( [in] any From, [in] any To, [in] any Copies, [in] any Preview, [in] any ActivePrinter, [in] any PrintToFile, [in] any Collate, [in] any PrToFileName, [in] any IgnorePrintAreas );
};
diff --git a/oovbaapi/ooo/vba/word/XApplication.idl b/oovbaapi/ooo/vba/word/XApplication.idl
index e6cde02f81..e34a26ad55 100644
--- a/oovbaapi/ooo/vba/word/XApplication.idl
+++ b/oovbaapi/ooo/vba/word/XApplication.idl
@@ -53,10 +53,10 @@ interface XApplication : com::sun::star::uno::XInterface
[attribute] boolean DisplayAutoCompleteTips;
[attribute] long EnableCancelKey;
- any CommandBars( [in] any aIndex );
- any Documents( [in] any aIndex );
- any Addins( [in] any aIndex );
- any Dialogs( [in] any aIndex );
+ any CommandBars( [in] any Index );
+ any Documents( [in] any Index );
+ any Addins( [in] any Index );
+ any Dialogs( [in] any Index );
float CentimetersToPoints([in] float Centimeters );
};
diff --git a/oovbaapi/ooo/vba/word/XDocument.idl b/oovbaapi/ooo/vba/word/XDocument.idl
index 4b55552856..0f1aea780d 100644
--- a/oovbaapi/ooo/vba/word/XDocument.idl
+++ b/oovbaapi/ooo/vba/word/XDocument.idl
@@ -51,16 +51,16 @@ interface XDocument : com::sun::star::script::XInvocation
[attribute] any AttachedTemplate;
XRange Range( [in] any Start, [in] any End );
- any BuiltInDocumentProperties( [in] any index );
- any CustomDocumentProperties( [in] any index );
- any Bookmarks( [in] any aIndex );
- any Variables( [in] any aIndex );
- any Paragraphs( [in] any aIndex );
- any Styles( [in] any aIndex );
- any Tables( [in] any aIndex );
- any Fields( [in] any aIndex );
- any Shapes([in] any Index);
- any Sections([in] any Index);
+ any BuiltInDocumentProperties( [in] any Index );
+ any CustomDocumentProperties( [in] any Index );
+ any Bookmarks( [in] any Index );
+ any Variables( [in] any Index );
+ any Paragraphs( [in] any Index );
+ any Styles( [in] any Index );
+ any Tables( [in] any Index );
+ any Fields( [in] any Index );
+ any Shapes( [in] any Index );
+ any Sections( [in] any Index );
void Activate();
any PageSetup();
};
diff --git a/oovbaapi/ooo/vba/word/XGlobals.idl b/oovbaapi/ooo/vba/word/XGlobals.idl
index 45b52fc2fb..443d48ab51 100644
--- a/oovbaapi/ooo/vba/word/XGlobals.idl
+++ b/oovbaapi/ooo/vba/word/XGlobals.idl
@@ -45,10 +45,10 @@ interface XGlobals : com::sun::star::uno::XInterface
[attribute, readonly] ooo::vba::word::XSystem System;
[attribute, readonly] ooo::vba::word::XOptions Options;
[attribute, readonly] ooo::vba::word::XSelection Selection;
- any CommandBars( [in] any aIndex );
- any Documents( [in] any aIndex );
- any Addins( [in] any aIndex );
- any Dialogs( [in] any aIndex );
+ any CommandBars( [in] any Index );
+ any Documents( [in] any Index );
+ any Addins( [in] any Index );
+ any Dialogs( [in] any Index );
float CentimetersToPoints([in] float Centimeters );
};
diff --git a/oovbaapi/ooo/vba/word/XSelection.idl b/oovbaapi/ooo/vba/word/XSelection.idl
index 053cbc67e1..5a00650526 100644
--- a/oovbaapi/ooo/vba/word/XSelection.idl
+++ b/oovbaapi/ooo/vba/word/XSelection.idl
@@ -59,8 +59,8 @@ interface XSelection
[attribute] long Start;
[attribute] long End;
- any Tables( [in] any aIndex );
- any Fields( [in] any aIndex );
+ any Tables( [in] any Index );
+ any Fields( [in] any Index );
void TypeText( [in] string Text );
void HomeKey( [in] any Unit, [in] any Extend );
void EndKey( [in] any Unit, [in] any Extend );
diff --git a/oovbaapi/ooo/vba/word/XTable.idl b/oovbaapi/ooo/vba/word/XTable.idl
index 235067c4bf..8e15093d4b 100644
--- a/oovbaapi/ooo/vba/word/XTable.idl
+++ b/oovbaapi/ooo/vba/word/XTable.idl
@@ -68,7 +68,7 @@ interface XTable
XRange ConvertToText([in] any Separator, [in] any NestedTables)
raises(com::sun::star::script::BasicErrorException);
*/
- any Borders( [in] any aIndex );
+ any Borders( [in] any Index );
};
diff --git a/oovbaapi/ooo/vba/word/XTemplate.idl b/oovbaapi/ooo/vba/word/XTemplate.idl
index 0a5f0ed38c..d4c8f31779 100644
--- a/oovbaapi/ooo/vba/word/XTemplate.idl
+++ b/oovbaapi/ooo/vba/word/XTemplate.idl
@@ -43,7 +43,7 @@ interface XTemplate
[attribute, readonly] string Name;
- any AutoTextEntries( [in] any aIndex );
+ any AutoTextEntries( [in] any Index );
};
}; }; };
diff --git a/oovbaapi/ooo/vba/word/XWindow.idl b/oovbaapi/ooo/vba/word/XWindow.idl
index 225a92381c..1f23009251 100644
--- a/oovbaapi/ooo/vba/word/XWindow.idl
+++ b/oovbaapi/ooo/vba/word/XWindow.idl
@@ -46,7 +46,7 @@ interface XWindow : com::sun::star::uno::XInterface
[attribute] any View;
void Activate();
void Close([in] any SaveChanges, [in] any RouteDocument);
- any Panes( [in] any aIndex ); // this is a fake api for it seems not support in Write
+ any Panes( [in] any Index ); // this is a fake api for it seems not support in Write
any ActivePane(); // this is a fake api for it seems not support in Write
};
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 995f42a7bd..83619b0265 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -805,11 +805,33 @@ void SfxObjectShell::InitBasicManager_Impl()
*/
{
+ /* #163556# (DR) - Handling of recursive calls while creating the Bacic
+ manager.
+
+ It is possible that (while creating the Basic manager) the code that
+ imports the Basic storage wants to access the Basic manager again.
+ Especially in VBA compatibility mode, there is code that wants to
+ access the "VBA Globals" object which is stored as global UNO constant
+ in the Basic manager.
+
+ To achieve correct handling of the recursive calls of this function
+ from lcl_getBasicManagerForDocument(), the implementation of the
+ function BasicManagerRepository::getDocumentBasicManager() has been
+ changed to return the Basic manager currently under construction, when
+ called repeatedly.
+
+ The variable pImp->bBasicInitialized will be set to TRUE after
+ construction now, to ensure that the recursive call of the function
+ lcl_getBasicManagerForDocument() will be routed into this function too.
+
+ Calling BasicManagerHolder::reset() twice is not a big problem, as it
+ does not take ownership but stores only the raw pointer. Owner of all
+ Basic managers is the global BasicManagerRepository instance.
+ */
DBG_ASSERT( !pImp->bBasicInitialized && !pImp->pBasicManager->isValid(), "Lokaler BasicManager bereits vorhanden");
- pImp->bBasicInitialized = TRUE;
-
pImp->pBasicManager->reset( BasicManagerRepository::getDocumentBasicManager( GetModel() ) );
DBG_ASSERT( pImp->pBasicManager->isValid(), "SfxObjectShell::InitBasicManager_Impl: did not get a BasicManager!" );
+ pImp->bBasicInitialized = TRUE;
}
//--------------------------------------------------------------------
diff --git a/svx/source/form/fmview.cxx b/svx/source/form/fmview.cxx
index ef0ca7e4f9..438cab3c30 100644
--- a/svx/source/form/fmview.cxx
+++ b/svx/source/form/fmview.cxx
@@ -139,9 +139,7 @@ void FmFormView::Init()
const SfxPoolItem *pItem=0;
if ( pObjShell->GetMedium()->GetItemSet()->GetItemState( SID_COMPONENTDATA, sal_False, &pItem ) == SFX_ITEM_SET )
{
- Sequence< PropertyValue > aSeq;
- ( ((SfxUnoAnyItem*)pItem)->GetValue() ) >>= aSeq;
- ::comphelper::NamedValueCollection aComponentData( aSeq );
+ ::comphelper::NamedValueCollection aComponentData( ((SfxUnoAnyItem*)pItem)->GetValue() );
bInitDesignMode = aComponentData.getOrDefault( "ApplyFormDesignMode", bInitDesignMode );
}
}
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 55bf0e2e98..603117048f 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -1800,8 +1800,7 @@ struct SvxStyleToolBoxControl::Impl
static const sal_Char* aCalcStyles[] =
{
"Default",
- "Heading 1",
- "Heading 2",
+ "Heading1",
"Result",
"Result2"
};
@@ -1813,12 +1812,15 @@ struct SvxStyleToolBoxControl::Impl
{
try
{
- Reference< beans::XPropertySet > xStyle;
- xCellStyles->getByName( rtl::OUString::createFromAscii( aCalcStyles[nStyle] )) >>= xStyle;
- ::rtl::OUString sName;
- xStyle->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName")))>>= sName;
- if( sName.getLength() )
- aDefaultStyles.push_back(sName);
+ const rtl::OUString sStyleName( rtl::OUString::createFromAscii( aCalcStyles[nStyle] ) );
+ if( xCellStyles->hasByName( sStyleName ) )
+ {
+ Reference< beans::XPropertySet > xStyle( xCellStyles->getByName( sStyleName), UNO_QUERY_THROW );
+ ::rtl::OUString sName;
+ xStyle->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DisplayName"))) >>= sName;
+ if( sName.getLength() )
+ aDefaultStyles.push_back(sName);
+ }
}
catch( const uno::Exception& )
{}
diff --git a/vbahelper/inc/vbahelper/vbadocumentsbase.hxx b/vbahelper/inc/vbahelper/vbadocumentsbase.hxx
index 82f9ead18d..3a5c0f48f0 100644
--- a/vbahelper/inc/vbahelper/vbadocumentsbase.hxx
+++ b/vbahelper/inc/vbahelper/vbadocumentsbase.hxx
@@ -57,10 +57,10 @@ public:
// VbaDocumentsBase_BASE
virtual css::uno::Any createCollectionObject( const css::uno::Any& aSource ) = 0;
- // XDocumentsBase
- virtual css::uno::Any SAL_CALL Add() throw (css::uno::RuntimeException);
- virtual void SAL_CALL Close( ) throw (css::uno::RuntimeException);
- virtual css::uno::Any SAL_CALL Open( const ::rtl::OUString& Filename, const css::uno::Any& ReadOnly, const css::uno::Sequence< css::beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException);
+protected:
+ css::uno::Any createDocument() throw (css::uno::RuntimeException);
+ void closeDocuments() throw (css::uno::RuntimeException);
+ css::uno::Any openDocument( const ::rtl::OUString& Filename, const css::uno::Any& ReadOnly, const css::uno::Sequence< css::beans::PropertyValue >& rProps ) throw (css::uno::RuntimeException);
};
#endif /* SC_VBA_WORKBOOKS_HXX */
diff --git a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
index b0dd184c1a..c328e316ff 100755
--- a/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
+++ b/vbahelper/inc/vbahelper/vbaeventshelperbase.hxx
@@ -58,6 +58,17 @@ public:
// XEventListener
virtual void SAL_CALL disposing( const css::lang::EventObject& aSource ) throw (css::uno::RuntimeException);
+ // little helpers ---------------------------------------------------------
+
+ /** Throws, if the passed sequence does not contain a value at the specified index. */
+ static inline void checkArgument( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException)
+ { if( (nIndex < 0) || (nIndex >= rArgs.getLength()) ) throw css::lang::IllegalArgumentException(); }
+
+ /** Throws, if the passed sequence does not contain a value of a specific at the specified index. */
+ template< typename Type >
+ static inline void checkArgumentType( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException)
+ { checkArgument( rArgs, nIndex ); if( !rArgs[ nIndex ].has< Type >() ) throw css::lang::IllegalArgumentException(); }
+
protected:
// ------------------------------------------------------------------------
@@ -73,7 +84,7 @@ protected:
/** Registers a supported event handler.
- @param nEventId Event identifier from com.sun.star.script.vba.EventIdentifier.
+ @param nEventId Event identifier from com.sun.star.script.vba.VBAEventId.
@param pcMacroName Name of the associated VBA event handler macro.
@param eType Document event or global event.
@param nCancelIndex 0-based index of Cancel parameter, or -1.
@@ -85,15 +96,6 @@ protected:
sal_Int32 nCancelIndex = -1,
const css::uno::Any& rUserData = css::uno::Any() );
- /** Throws, if the passed sequence does not contain a value at the specified index. */
- static inline void checkArgument( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException)
- { if( rArgs.getLength() <= nIndex ) throw css::lang::IllegalArgumentException(); }
-
- /** Throws, if the passed sequence does not contain a value of a specific at the specified index. */
- template< typename Type >
- static inline void checkArgumentType( const css::uno::Sequence< css::uno::Any >& rArgs, sal_Int32 nIndex ) throw (css::lang::IllegalArgumentException)
- { if( (rArgs.getLength() <= nIndex) || !rArgs[ nIndex ].has< Type >() ) throw css::lang::IllegalArgumentException(); }
-
// ------------------------------------------------------------------------
struct EventQueueEntry
@@ -105,10 +107,6 @@ protected:
};
typedef ::std::deque< EventQueueEntry > EventQueue;
- /** Derived classes return whether event processing is enabled. Throws if
- the instance is in an invalid state. */
- virtual bool implEventsEnabled() throw (css::uno::RuntimeException) = 0;
-
/** Derived classes do additional prpeparations and return whether the
event handler has to be called. */
virtual bool implPrepareEvent(
diff --git a/vbahelper/inc/vbahelper/vbahelper.hxx b/vbahelper/inc/vbahelper/vbahelper.hxx
index 77c5338442..4a73ec2e03 100644
--- a/vbahelper/inc/vbahelper/vbahelper.hxx
+++ b/vbahelper/inc/vbahelper/vbahelper.hxx
@@ -194,11 +194,8 @@ public:
#define VBA_WIDTH "Width"
class VBAHELPER_DLLPUBLIC UserFormGeometryHelper : public AbstractGeometryAttributes
{
- css::uno::Reference< css::awt::XUnitConversion > mxControlUnits;
- css::uno::Reference< css::beans::XPropertySet > mxModel;
-
- sal_Int32 ConvertLogicToPixel( sal_Int32 nValue, sal_Bool bIsPoint, sal_Bool bIsX, sal_Int16 nSourceUnit );
- sal_Int32 ConvertPixelToLogic( sal_Int32 nValue, sal_Bool bIsPoint, sal_Bool bIsX, sal_Int16 nTargetUnit );
+ css::uno::Reference< css::awt::XWindow > mxWindow;
+ sal_Bool mbDialog;
public:
UserFormGeometryHelper( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Reference< css::awt::XControl >& xControl );
diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index 7485073321..28f6d7f61c 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -227,7 +227,6 @@ void SAL_CALL
ScVbaControl::setLeft( double _left ) throw (uno::RuntimeException)
{
mpGeometryHelper->setLeft( _left );
-
}
double SAL_CALL
diff --git a/vbahelper/source/msforms/vbauserform.cxx b/vbahelper/source/msforms/vbauserform.cxx
index 33e357b00c..3db05ee747 100644
--- a/vbahelper/source/msforms/vbauserform.cxx
+++ b/vbahelper/source/msforms/vbauserform.cxx
@@ -28,7 +28,9 @@
#include "vbauserform.hxx"
#include <com/sun/star/awt/XControl.hpp>
#include <com/sun/star/awt/XControlContainer.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/beans/PropertyConcept.hpp>
+#include <com/sun/star/util/MeasureUnit.hpp>
#include <basic/sbx.hxx>
#include <basic/sbstar.hxx>
#include <basic/sbmeth.hxx>
@@ -64,9 +66,28 @@ ScVbaUserForm::Show( ) throw (uno::RuntimeException)
{
OSL_TRACE("ScVbaUserForm::Show( )");
short aRet = 0;
- mbDispose = true;
+ mbDispose = true;
+
if ( m_xDialog.is() )
+ {
+ // try to center dialog on model window
+ if( m_xModel.is() ) try
+ {
+ uno::Reference< frame::XController > xController( m_xModel->getCurrentController(), uno::UNO_SET_THROW );
+ uno::Reference< frame::XFrame > xFrame( xController->getFrame(), uno::UNO_SET_THROW );
+ uno::Reference< awt::XWindow > xWindow( xFrame->getContainerWindow(), uno::UNO_SET_THROW );
+ awt::Rectangle aPosSize = xWindow->getPosSize(); // already in pixel
+
+ uno::Reference< awt::XControl > xControl( m_xDialog, uno::UNO_QUERY_THROW );
+ uno::Reference< awt::XWindow > xControlWindow( xControl->getPeer(), uno::UNO_QUERY_THROW );
+ xControlWindow->setPosSize( (aPosSize.Width - getWidth()) / 2.0, (aPosSize.Height - getHeight()) / 2.0, 0, 0, awt::PosSize::POS );
+ }
+ catch( uno::Exception& )
+ {
+ }
+
aRet = m_xDialog->execute();
+ }
OSL_TRACE("ScVbaUserForm::Show() execute returned %d", aRet);
if ( mbDispose )
{
@@ -180,11 +201,14 @@ ScVbaUserForm::getValue( const ::rtl::OUString& aPropertyName ) throw (beans::Un
uno::Reference< awt::XControl > xDialogControl( m_xDialog, uno::UNO_QUERY_THROW );
uno::Reference< awt::XControlContainer > xContainer( m_xDialog, uno::UNO_QUERY_THROW );
uno::Reference< awt::XControl > xControl = xContainer->getControl( aPropertyName );
- ScVbaControlFactory aFac( mxContext, xControl, m_xModel );
- uno::Reference< msforms::XControl > xVBAControl( aFac.createControl( xDialogControl->getModel() ) );
- ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() );
- pControl->setGeometryHelper( new UserFormGeometryHelper( mxContext, xControl ) );
- aResult = uno::makeAny( xVBAControl );
+ if ( xControl.is() )
+ {
+ ScVbaControlFactory aFac( mxContext, xControl, m_xModel );
+ uno::Reference< msforms::XControl > xVBAControl( aFac.createControl( xDialogControl->getModel() ) );
+ ScVbaControl* pControl = dynamic_cast< ScVbaControl* >( xVBAControl.get() );
+ pControl->setGeometryHelper( new UserFormGeometryHelper( mxContext, xControl ) );
+ aResult = uno::makeAny( xVBAControl );
+ }
}
return aResult;
diff --git a/vbahelper/source/vbahelper/vbaapplicationbase.cxx b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
index 57e303893e..36ef6c7b23 100644
--- a/vbahelper/source/vbahelper/vbaapplicationbase.cxx
+++ b/vbahelper/source/vbahelper/vbaapplicationbase.cxx
@@ -295,54 +295,23 @@ VbaApplicationBase::getVersion() throw (uno::RuntimeException)
void SAL_CALL VbaApplicationBase::Run( const ::rtl::OUString& MacroName, const uno::Any& varg1, const uno::Any& varg2, const uno::Any& varg3, const uno::Any& varg4, const uno::Any& varg5, const uno::Any& varg6, const uno::Any& varg7, const uno::Any& varg8, const uno::Any& varg9, const uno::Any& varg10, const uno::Any& varg11, const uno::Any& varg12, const uno::Any& varg13, const uno::Any& varg14, const uno::Any& varg15, const uno::Any& varg16, const uno::Any& varg17, const uno::Any& varg18, const uno::Any& varg19, const uno::Any& varg20, const uno::Any& varg21, const uno::Any& varg22, const uno::Any& varg23, const uno::Any& varg24, const uno::Any& varg25, const uno::Any& varg26, const uno::Any& varg27, const uno::Any& varg28, const uno::Any& varg29, const uno::Any& varg30 ) throw (uno::RuntimeException)
{
- ::rtl::OUString sSeparator = ::rtl::OUString::createFromAscii("/");
- ::rtl::OUString sMacroSeparator = ::rtl::OUString::createFromAscii("!");
- ::rtl::OUString sMacro_only_Name;
- sal_Int32 Position_MacroSeparator = MacroName.indexOf(sMacroSeparator);
+ ::rtl::OUString aMacroName = MacroName.trim();
+ if (0 == aMacroName.indexOf('!'))
+ aMacroName = aMacroName.copy(1).trim();
- uno::Reference< frame::XModel > aMacroDocumentModel;
- if (-1 != Position_MacroSeparator)
- {
- uno::Reference< container::XEnumerationAccess > xComponentEnumAccess;
- uno::Reference< lang::XMultiComponentFactory > xServiceManager = mxContext->getServiceManager();
- try
- {
- uno::Reference< frame::XDesktop > xDesktop (xServiceManager->createInstanceWithContext( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" )),mxContext ), uno::UNO_QUERY_THROW );
- xComponentEnumAccess = xDesktop->getComponents();
- }
- catch(uno::Exception&)
- {
- }
-
- //rem look for the name of the document in the cmpoonents collection
- uno::Reference < container::XEnumeration > xEnum = xComponentEnumAccess->createEnumeration();
-
- // iterate through the collection by name
- while (xEnum->hasMoreElements())
- {
- // get the next element as a UNO Any
- uno::Any aComponentHelper = xEnum->nextElement();
- uno::Reference <frame::XModel> xDocModel( aComponentHelper, uno::UNO_QUERY_THROW );
-
- // get the name of the sheet from its XNamed interface
- ::rtl::OUString aName = xDocModel->getURL();
-
-
- if (aName.match(MacroName.copy(0,Position_MacroSeparator-1),aName.lastIndexOf(sSeparator)+1))
- {
- aMacroDocumentModel = xDocModel;
- sMacro_only_Name = MacroName.copy(Position_MacroSeparator+1);
- }
- }
- }
- else
+ uno::Reference< frame::XModel > xModel;
+ SbMethod* pMeth = StarBASIC::GetActiveMethod();
+ if ( pMeth )
{
- aMacroDocumentModel = getCurrentDocument();
- sMacro_only_Name = MacroName.copy(0);
+ SbModule* pMod = dynamic_cast< SbModule* >( pMeth->GetParent() );
+ if ( pMod )
+ xModel = StarBASIC::GetModelFromBasic( pMod );
}
-
- VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( aMacroDocumentModel ), sMacro_only_Name );
+ if ( !xModel.is() )
+ xModel = getCurrentDocument();
+
+ VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( getSfxObjShell( xModel ), aMacroName );
if( aMacroInfo.IsResolved() )
{
// handle the arguments
diff --git a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
index 1b2d01367d..309d1b878c 100644
--- a/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
+++ b/vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
@@ -91,27 +91,33 @@ ScVbaCommandBarControl::setOnAction( const ::rtl::OUString& _onaction ) throw (u
::sal_Bool SAL_CALL
ScVbaCommandBarControl::getVisible() throw (uno::RuntimeException)
{
- sal_Bool bVisible = sal_True;
+ /*sal_Bool bVisible = sal_True;
uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") );
if( aValue.hasValue() )
aValue >>= bVisible;
- return bVisible;
+ return bVisible;*/
+ return getEnabled();
+
}
void SAL_CALL
ScVbaCommandBarControl::setVisible( ::sal_Bool _visible ) throw (uno::RuntimeException)
{
- uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") );
+ /*uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible") );
if( aValue.hasValue() )
{
setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("IsVisible"), uno::makeAny( _visible ) );
ApplyChange();
- }
+ }*/
+ setEnabled( _visible);
}
::sal_Bool SAL_CALL
ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException)
{
sal_Bool bEnabled = sal_True;
+ rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___");
+ rtl::OUString aCommandURL ;
+
if( m_xParentMenu.is() )
{
// currently only the menu in the MenuBat support Enable/Disable
@@ -121,7 +127,14 @@ ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException)
else
{
// emulated with Visible
- bEnabled = getVisible();
+ //bEnabled = getVisible();
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") );
+ if (aValue >>= aCommandURL){
+ if (0 == aCommandURL.indexOf(aCommandURLappendix)){
+ bEnabled = sal_False;
+ }
+ }
+
}
return bEnabled;
}
@@ -129,6 +142,9 @@ ScVbaCommandBarControl::getEnabled() throw (uno::RuntimeException)
void SAL_CALL
ScVbaCommandBarControl::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeException)
{
+ rtl::OUString aCommandURL ;
+ rtl::OUString aCommandURLappendix = rtl::OUString::createFromAscii("___");
+ rtl::OUStringBuffer aCommandURLSringBuffer;
if( m_xParentMenu.is() )
{
// currently only the menu in the MenuBat support Enable/Disable
@@ -136,8 +152,20 @@ ScVbaCommandBarControl::setEnabled( sal_Bool _enabled ) throw (uno::RuntimeExcep
}
else
{
+ uno::Any aValue = getPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL") );
+ if (aValue >>= aCommandURL){
+ if (0 == aCommandURL.indexOf(aCommandURLappendix)){
+ aCommandURL = aCommandURL.copy(3);
+ }
+ if (false == _enabled){
+ aCommandURLSringBuffer = aCommandURLappendix;
+ }
+ aCommandURLSringBuffer.append(aCommandURL);
+ setPropertyValue( m_aPropertyValues, rtl::OUString::createFromAscii("CommandURL"), uno::makeAny( aCommandURLSringBuffer.makeStringAndClear()) );
+ ApplyChange();
+ }
// emulated with Visible
- setVisible( _enabled );
+ //setVisible( _enabled );
}
}
diff --git a/vbahelper/source/vbahelper/vbadocumentbase.cxx b/vbahelper/source/vbahelper/vbadocumentbase.cxx
index 0eba699a07..caa2a37db2 100644
--- a/vbahelper/source/vbahelper/vbadocumentbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentbase.cxx
@@ -28,14 +28,18 @@
#include "vbahelper/vbadocumentbase.hxx"
#include "vbahelper/helperdecl.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/util/XProtectable.hpp>
#include <com/sun/star/util/XCloseable.hpp>
+#include <com/sun/star/util/XURLTransformer.hpp>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/frame/XFrame.hpp>
#include <com/sun/star/document/XEmbeddedScripts.hpp> //Michael E. Bohn
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <cppuhelper/exc_hlp.hxx>
#include <comphelper/unwrapargs.hxx>
#include <tools/urlobj.hxx>
#include <osl/file.hxx>
@@ -74,7 +78,8 @@ VbaDocumentBase::getName() throw (uno::RuntimeException)
uno::Reference< beans::XPropertySet > xProps( xFrame, uno::UNO_QUERY_THROW );
xProps->getPropertyValue(sTitle ) >>= sName;
sal_Int32 pos = 0;
- sName = sName.getToken(0,' ',pos);
+ sName = sName.getToken(0,'-',pos);
+ sName = sName.trim();
}
return sName;
}
@@ -92,8 +97,8 @@ VbaDocumentBase::getPath() throw (uno::RuntimeException)
::rtl::OUString
VbaDocumentBase::getFullName() throw (uno::RuntimeException)
{
- rtl::OUString sPath;
- ::osl::File::getSystemPathFromFileURL( getModel()->getURL(), sPath );
+ rtl::OUString sPath = getName();
+ //::osl::File::getSystemPathFromFileURL( getModel()->getURL(), sPath );
return sPath;
}
@@ -127,23 +132,56 @@ VbaDocumentBase::Close( const uno::Any &rSaveArg, const uno::Any &rFileArg,
else
xModifiable->setModified( false );
- uno::Reference< util::XCloseable > xCloseable( getModel(), uno::UNO_QUERY );
-
- if( xCloseable.is() )
- // use close(boolean DeliverOwnership)
-
- // The boolean parameter DeliverOwnership tells objects vetoing the close process that they may
- // assume ownership if they object the closure by throwing a CloseVetoException
- // Here we give up ownership. To be on the safe side, catch possible veto exception anyway.
- xCloseable->close(sal_True);
- // If close is not supported by this model - try to dispose it.
- // But if the model disagree with a reset request for the modify state
- // we shouldn't do so. Otherwhise some strange things can happen.
- else
+ // first try to close the document using UI dispatch functionality
+ sal_Bool bUIClose = sal_False;
+ try
+ {
+ uno::Reference< frame::XController > xController( getModel()->getCurrentController(), uno::UNO_SET_THROW );
+ uno::Reference< frame::XDispatchProvider > xDispatchProvider( xController->getFrame(), uno::UNO_QUERY_THROW );
+
+ uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
+ uno::Reference< util::XURLTransformer > xURLTransformer(
+ xServiceManager->createInstanceWithContext(
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.util.URLTransformer" ) ),
+ mxContext ),
+ uno::UNO_QUERY_THROW );
+
+ util::URL aURL;
+ aURL.Complete = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CloseDoc" ) );
+ xURLTransformer->parseStrict( aURL );
+
+ uno::Reference< css::frame::XDispatch > xDispatch(
+ xDispatchProvider->queryDispatch( aURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ), 0 ),
+ uno::UNO_SET_THROW );
+ xDispatch->dispatch( aURL, uno::Sequence< beans::PropertyValue >() );
+ bUIClose = sal_True;
+ }
+ catch( uno::Exception& )
+ {
+ }
+
+ if ( !bUIClose )
{
- uno::Reference< lang::XComponent > xDisposable ( getModel(), uno::UNO_QUERY );
- if ( xDisposable.is() )
- xDisposable->dispose();
+ // if it is not possible to use UI dispatch, try to close the model directly
+ uno::Reference< util::XCloseable > xCloseable( getModel(), uno::UNO_QUERY );
+ if( xCloseable.is() )
+ {
+ // use close(boolean DeliverOwnership)
+
+ // The boolean parameter DeliverOwnership tells objects vetoing the close process that they may
+ // assume ownership if they object the closure by throwing a CloseVetoException
+ // Here we give up ownership. To be on the safe side, catch possible veto exception anyway.
+ xCloseable->close(sal_True);
+ }
+ else
+ {
+ // If close is not supported by this model - try to dispose it.
+ // But if the model disagree with a reset request for the modify state
+ // we shouldn't do so. Otherwhise some strange things can happen.
+ uno::Reference< lang::XComponent > xDisposable ( getModel(), uno::UNO_QUERY );
+ if ( xDisposable.is() )
+ xDisposable->dispose();
+ }
}
}
@@ -181,7 +219,22 @@ void
VbaDocumentBase::setSaved( sal_Bool bSave ) throw (uno::RuntimeException)
{
uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY_THROW );
- xModifiable->setModified( !bSave );
+ try
+ {
+ xModifiable->setModified( !bSave );
+ }
+ catch ( lang::DisposedException& )
+ {
+ // impossibility to set the modified state on disposed document should not trigger an error
+ }
+ catch ( beans::PropertyVetoException& )
+ {
+ uno::Any aCaught( ::cppu::getCaughtException() );
+ throw lang::WrappedTargetRuntimeException(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can't change modified state of model!" ) ),
+ uno::Reference< uno::XInterface >(),
+ aCaught );
+ }
}
sal_Bool
@@ -213,7 +266,7 @@ VbaDocumentBase::getVBProject() throw (uno::RuntimeException)
{
uno::Sequence< uno::Any > aArgs( 2 );
aArgs[ 0 ] <<= uno::Reference< XHelperInterface >( this );
- aArgs[ 1 ] <<= mxModel;
+ aArgs[ 1 ] <<= getModel();
uno::Reference< lang::XMultiComponentFactory > xServiceManager( mxContext->getServiceManager(), uno::UNO_SET_THROW );
uno::Reference< uno::XInterface > xVBProjects = xServiceManager->createInstanceWithArgumentsAndContext(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBProject" ) ), aArgs, mxContext );
diff --git a/vbahelper/source/vbahelper/vbadocumentsbase.cxx b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
index 61cdb52ca3..911cfdef40 100644
--- a/vbahelper/source/vbahelper/vbadocumentsbase.cxx
+++ b/vbahelper/source/vbahelper/vbadocumentsbase.cxx
@@ -25,6 +25,7 @@
*
************************************************************************/
#include <vbahelper/vbadocumentsbase.hxx>
+#include <comphelper/mediadescriptor.hxx>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase3.hxx>
@@ -212,10 +213,9 @@ VbaDocumentsBase::VbaDocumentsBase( const uno::Reference< XHelperInterface >& xP
{
}
-uno::Any SAL_CALL
-VbaDocumentsBase::Add() throw (uno::RuntimeException)
+uno::Any VbaDocumentsBase::createDocument() throw (uno::RuntimeException)
{
- uno::Reference< lang::XMultiComponentFactory > xSMgr(
+ uno::Reference< lang::XMultiComponentFactory > xSMgr(
mxContext->getServiceManager(), uno::UNO_QUERY_THROW );
uno::Reference< frame::XComponentLoader > xLoader(
@@ -229,15 +229,21 @@ VbaDocumentsBase::Add() throw (uno::RuntimeException)
sURL = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc") );
else
throw uno::RuntimeException( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Not implemented") ), uno::Reference< uno::XInterface >() );
+
+ // prepare the media descriptor
+ ::comphelper::MediaDescriptor aMediaDesc;
+ aMediaDesc[ ::comphelper::MediaDescriptor::PROP_MACROEXECUTIONMODE() ] <<= document::MacroExecMode::USE_CONFIG;
+ aMediaDesc.setComponentDataEntry( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ApplyFormDesignMode" ) ), uno::Any( false ) );
+
+ // craete the new document
uno::Reference< lang::XComponent > xComponent = xLoader->loadComponentFromURL(
sURL ,
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") ), 0,
- uno::Sequence< beans::PropertyValue >(0) );
+ rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("_blank") ), 0,
+ aMediaDesc.getAsConstPropertyValueList() );
return uno::makeAny( xComponent );
}
-void
-VbaDocumentsBase::Close() throw (uno::RuntimeException)
+void VbaDocumentsBase::closeDocuments() throw (uno::RuntimeException)
{
// #FIXME this *MUST* be wrong documents::close surely closes ALL documents
// in the collection, use of getCurrentDocument here is totally wrong
@@ -251,8 +257,7 @@ VbaDocumentsBase::Close() throw (uno::RuntimeException)
}
// #TODO# #FIXME# can any of the unused params below be used?
-uno::Any
-VbaDocumentsBase::Open( const rtl::OUString& rFileName, const uno::Any& ReadOnly, const uno::Sequence< beans::PropertyValue >& rProps ) throw (uno::RuntimeException)
+uno::Any VbaDocumentsBase::openDocument( const rtl::OUString& rFileName, const uno::Any& ReadOnly, const uno::Sequence< beans::PropertyValue >& rProps ) throw (uno::RuntimeException)
{
// we need to detect if this is a URL, if not then assume its a file path
rtl::OUString aURL;
diff --git a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
index ee6eccbdd6..7c64e7fa3d 100755
--- a/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
+++ b/vbahelper/source/vbahelper/vbaeventshelperbase.cxx
@@ -74,10 +74,6 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un
EventQueue aEventQueue;
aEventQueue.push_back( EventQueueEntry( nEventId, rArgs ) );
- /* bEnabled will track if event processing is enabled. Every event handler
- may disable handling of other events. */
- bool bEnabled = true;
-
/* bCancel will contain the current Cancel value. It is possible that
multiple events will try to modify the Cancel value. Every event
handler receives the Cancel value of the previous event handler. */
@@ -87,10 +83,10 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un
executed successfully. */
bool bSuccess = false;
- /* Loop as long as there are more events to be processed, and as event
- handling is still enabled. Derived classes may add new events to be
- processed in the virtual implPrepareEvent() function. */
- while( bEnabled && !aEventQueue.empty() )
+ /* Loop as long as there are more events to be processed. Derived classes
+ may add new events to be processed in the virtual implPrepareEvent()
+ function. */
+ while( !aEventQueue.empty() )
{
/* Check that all class members are available, and that we are not
disposed (this may have happened at any time during execution of
@@ -103,14 +99,14 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un
uno::Sequence< uno::Any > aEventArgs = aEventQueue.front().maArgs;
aEventQueue.pop_front();
- // let derived classes decide whether event processing is still enabled
- bEnabled = implEventsEnabled();
- // let derived classes prepare the event, they may add new events for next iteration
- if( bEnabled && implPrepareEvent( aEventQueue, rInfo, aEventArgs ) )
+ /* Let derived classes prepare the event, they may add new events for
+ next iteration. If false is returned, the event handler must not be
+ called. */
+ bool bEventSuccess = false;
+ if( implPrepareEvent( aEventQueue, rInfo, aEventArgs ) )
{
// search the event handler macro in the document
::rtl::OUString aMacroPath = getEventHandlerPath( rInfo, aEventArgs );
- bool bEventSuccess = false;
if( aMacroPath.getLength() > 0 )
{
// build the argument list
@@ -139,11 +135,11 @@ void SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, const un
bCancel = nNewCancel != 0;
}
}
- // post processing (also, if event handler does not exist, or on error
- implPostProcessEvent( aEventQueue, rInfo, bEventSuccess, bCancel );
// global success, if at least one event handler succeeded
bSuccess |= bEventSuccess;
}
+ // post processing (also, if event handler does not exist, or disabled, or on error
+ implPostProcessEvent( aEventQueue, rInfo, bEventSuccess, bCancel );
}
// if event handlers want to cancel the event, do so regardless of any errors
@@ -200,7 +196,8 @@ const VbaEventsHelperBase::EventHandlerInfo& VbaEventsHelperBase::getEventHandle
append( sal_Unicode( '.' ) ).append( rInfo.maMacroName ).makeStringAndClear();
break;
}
- return resolveVBAMacro( mpShell, aMacroName ).ResolvedMacro();
+ VBAMacroResolvedInfo aMacroInfo = resolveVBAMacro( mpShell, aMacroName, false );
+ return aMacroInfo.IsResolved() ? ::rtl::OUString( aMacroInfo.ResolvedMacro() ) : ::rtl::OUString();
}
void VbaEventsHelperBase::stopListening()
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx b/vbahelper/source/vbahelper/vbahelper.cxx
index cf1981fa8f..542667b37e 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -39,6 +39,9 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XIntrospection.hpp>
#include <com/sun/star/util/MeasureUnit.hpp>
+#include <com/sun/star/awt/XWindow.hpp>
+#include <com/sun/star/awt/XDialog.hpp>
+#include <com/sun/star/awt/PosSize.hpp>
#include <ooo/vba/msforms/XShape.hpp>
@@ -989,277 +992,122 @@ sal_Bool setPropertyValue( uno::Sequence< beans::PropertyValue >& aProp, const r
// ====UserFormGeomentryHelper====
//---------------------------------------------
UserFormGeometryHelper::UserFormGeometryHelper( const uno::Reference< uno::XComponentContext >& /*xContext*/, const uno::Reference< awt::XControl >& xControl )
+: mbDialog( uno::Reference< awt::XDialog >( xControl, uno::UNO_QUERY ).is() )
{
if ( !xControl.is() )
- throw uno::RuntimeException();
-
- mxControlUnits.set( xControl->getPeer(), uno::UNO_QUERY_THROW );
- mxModel.set( xControl->getModel(), uno::UNO_QUERY_THROW );
-}
-
-//---------------------------------------------
-sal_Int32 UserFormGeometryHelper::ConvertPixelToLogic( sal_Int32 nValue, sal_Bool bIsPoint, sal_Bool bIsX, sal_Int16 nTargetUnit )
-{
- sal_Int32 nResult = 0;
- if ( bIsPoint )
- {
- // conversion for a point
- awt::Point aPixelPoint( 0, 0 );
- ( bIsX ? aPixelPoint.X : aPixelPoint.Y ) = nValue;
- awt::Point aTargetPoint( 0, 0 );
- aTargetPoint = mxControlUnits->convertPointToLogic( aPixelPoint, nTargetUnit );
-
- nResult = bIsX ? aTargetPoint.X : aTargetPoint.Y;
- }
- else
- {
- // conversion for a size
- awt::Size aPixelSize( 0, 0 );
- ( bIsX ? aPixelSize.Width : aPixelSize.Height ) = nValue;
- awt::Size aTargetSize( 0, 0 );
- aTargetSize = mxControlUnits->convertSizeToLogic( aPixelSize, nTargetUnit );
-
- nResult = bIsX ? aTargetSize.Width : aTargetSize.Height;
- }
+ throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "No control is provided!" ) ),
+ uno::Reference< uno::XInterface >() );
- return nResult;
+ mxWindow.set( xControl->getPeer(), uno::UNO_QUERY_THROW );
}
//---------------------------------------------
-sal_Int32 UserFormGeometryHelper::ConvertLogicToPixel( sal_Int32 nValue, sal_Bool bIsPoint, sal_Bool bIsX, sal_Int16 nSourceUnit )
-{
- sal_Int32 nResult = 0;
- if ( bIsPoint )
- {
- // conversion for a point
- awt::Point aSourcePoint( 0, 0 );
- ( bIsX ? aSourcePoint.X : aSourcePoint.Y ) = nValue;
-
- awt::Point aPixelPoint( 0, 0 );
- aPixelPoint = mxControlUnits->convertPointToPixel( aSourcePoint, nSourceUnit );
-
- nResult = bIsX ? aPixelPoint.X : aPixelPoint.Y;
- }
- else
- {
- // conversion for a size
- awt::Size aSourceSize( 0, 0 );
- ( bIsX ? aSourceSize.Width : aSourceSize.Height ) = nValue;
-
- awt::Size aPixelSize( 0, 0 );
- aPixelSize = mxControlUnits->convertSizeToPixel( aSourceSize, nSourceUnit );
-
- nResult = bIsX ? aPixelSize.Width : aPixelSize.Height;
- }
-
- return nResult;
-}
-//---------------------------------------------
double UserFormGeometryHelper::getLeft()
{
- double nResult = 0;
-
- try
- {
- sal_Int32 nLeft = 0;
- mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ) ) >>= nLeft;
- nResult = ConvertLogicToPixel( nLeft,
- sal_True, // Point
- sal_True, // X
- util::MeasureUnit::APPFONT );
- }
- catch ( uno::RuntimeException& )
- {
- throw;
- }
- catch ( uno::Exception& e )
- {
- throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not get position X!" ) ),
- uno::Reference< uno::XInterface >(),
- uno::makeAny( e ) );
- }
-
- return nResult;
+ return mxWindow->getPosSize().X;
}
//---------------------------------------------
void UserFormGeometryHelper::setLeft( double nLeft )
{
- try
- {
- mxModel->setPropertyValue(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_LEFT ) ),
- uno::makeAny( ConvertPixelToLogic( nLeft,
- sal_True, // Point
- sal_True, // X
- util::MeasureUnit::APPFONT ) ) );
- }
- catch ( uno::RuntimeException& )
- {
- throw;
- }
- catch ( uno::Exception& e )
- {
- throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not set position X!" ) ),
- uno::Reference< uno::XInterface >(),
- uno::makeAny( e ) );
- }
+ mxWindow->setPosSize( nLeft, mxWindow->getPosSize().Y, 0, 0, awt::PosSize::POS );
}
//---------------------------------------------
double UserFormGeometryHelper::getTop()
{
- double nResult = 0;
-
- try
- {
- sal_Int32 nTop = 0;
- mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ) ) >>= nTop;
- nResult = ConvertLogicToPixel( nTop,
- sal_True, // Point
- sal_False, // Y
- util::MeasureUnit::APPFONT );
- }
- catch ( uno::RuntimeException& )
- {
- throw;
- }
- catch ( uno::Exception& e )
- {
- throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not get position Y!" ) ),
- uno::Reference< uno::XInterface >(),
- uno::makeAny( e ) );
- }
-
- return nResult;
+ return mxWindow->getPosSize().Y;
}
//---------------------------------------------
void UserFormGeometryHelper::setTop( double nTop )
{
- try
- {
- mxModel->setPropertyValue(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_TOP ) ),
- uno::makeAny( ConvertPixelToLogic( nTop,
- sal_True, // Point
- sal_False, // Y
- util::MeasureUnit::APPFONT ) ) );
- }
- catch ( uno::RuntimeException& )
- {
- throw;
- }
- catch ( uno::Exception& e )
- {
- throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not set position X!" ) ),
- uno::Reference< uno::XInterface >(),
- uno::makeAny( e ) );
- }
+ mxWindow->setPosSize( mxWindow->getPosSize().X, nTop, 0, 0, awt::PosSize::POS );
}
//---------------------------------------------
double UserFormGeometryHelper::getWidth()
{
- double nResult = 0;
-
- try
+ if ( mbDialog )
{
- sal_Int32 nWidth = 0;
- mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_WIDTH ) ) ) >>= nWidth;
- nResult = ConvertLogicToPixel( nWidth,
- sal_False, // Size
- sal_True, // X
- util::MeasureUnit::APPFONT );
- }
- catch ( uno::RuntimeException& )
- {
- throw;
- }
- catch ( uno::Exception& e )
- {
- throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not get width!" ) ),
- uno::Reference< uno::XInterface >(),
- uno::makeAny( e ) );
+ const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
+ if ( pWindow )
+ {
+ // get the size with decoration
+ Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL );
+ return aResult.getWidth();
+ }
}
- return nResult;
+ return mxWindow->getPosSize().Width;
}
//---------------------------------------------
-void UserFormGeometryHelper::setWidth( double nWidth)
+void UserFormGeometryHelper::setWidth( double nWidth )
{
- try
- {
- mxModel->setPropertyValue(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_WIDTH ) ),
- uno::makeAny( ConvertPixelToLogic( nWidth,
- sal_False, // Size
- sal_True, // X
- util::MeasureUnit::APPFONT ) ) );
- }
- catch ( uno::RuntimeException& )
- {
- throw;
- }
- catch ( uno::Exception& e )
+ sal_Int64 nNewWidth = nWidth;
+
+ if ( mbDialog )
{
- throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not set width!" ) ),
- uno::Reference< uno::XInterface >(),
- uno::makeAny( e ) );
+ const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
+ if ( pWindow )
+ {
+ // set the size with decoration
+ Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL );
+ if ( !aRDecor.IsEmpty() )
+ {
+ sal_Int64 nDecor = aRDecor.getWidth();
+ sal_Int64 nUnDecor = mxWindow->getPosSize().Width;
+ if ( nWidth < nDecor - nUnDecor )
+ nUnDecor = nDecor - nWidth; // avoid negative size
+ nNewWidth = nWidth + nUnDecor - nDecor;
+ }
+ }
}
+
+ mxWindow->setPosSize( 0, 0, nNewWidth, 0, awt::PosSize::WIDTH );
}
//---------------------------------------------
double UserFormGeometryHelper::getHeight()
{
- double nResult = 0;
-
- try
+ if ( mbDialog )
{
- sal_Int32 nHeight = 0;
- mxModel->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_HEIGHT ) ) ) >>= nHeight;
- nResult = ConvertLogicToPixel( nHeight,
- sal_False, // Size
- sal_False, // Y
- util::MeasureUnit::APPFONT );
- }
- catch ( uno::RuntimeException& )
- {
- throw;
- }
- catch ( uno::Exception& e )
- {
- throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not get height!" ) ),
- uno::Reference< uno::XInterface >(),
- uno::makeAny( e ) );
+ const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
+ if ( pWindow )
+ {
+ // get the size with decoration
+ Rectangle aResult = pWindow->GetWindowExtentsRelative( NULL );
+ return aResult.getHeight();
+ }
}
- return nResult;
+ return mxWindow->getPosSize().Height;
}
//---------------------------------------------
void UserFormGeometryHelper::setHeight( double nHeight )
{
- try
- {
- mxModel->setPropertyValue(
- rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( VBA_HEIGHT ) ),
- uno::makeAny( ConvertPixelToLogic( nHeight,
- sal_False, // Size
- sal_False, // Y
- util::MeasureUnit::APPFONT ) ) );
- }
- catch ( uno::RuntimeException& )
- {
- throw;
- }
- catch ( uno::Exception& e )
+ sal_Int64 nNewHeight = nHeight;
+ if ( mbDialog )
{
- throw lang::WrappedTargetException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Can not set height!" ) ),
- uno::Reference< uno::XInterface >(),
- uno::makeAny( e ) );
+ const Window* pWindow = VCLUnoHelper::GetWindow( mxWindow );
+ if ( pWindow )
+ {
+ // set the size with decoration
+ Rectangle aRDecor = pWindow->GetWindowExtentsRelative( NULL );
+ if ( !aRDecor.IsEmpty() )
+ {
+ sal_Int64 nDecor = aRDecor.getHeight();
+ sal_Int64 nUnDecor = mxWindow->getPosSize().Height;
+ if ( nHeight < nDecor - nUnDecor )
+ nUnDecor = nDecor - nHeight; // avoid negative size
+ nNewHeight = nHeight + nUnDecor - nDecor;
+ }
+ }
}
+
+ mxWindow->setPosSize( 0, 0, 0, nNewHeight, awt::PosSize::HEIGHT );
}
// ============