diff options
Diffstat (limited to 'basic')
202 files changed, 6013 insertions, 5933 deletions
diff --git a/basic/inc/basic/basicmanagerrepository.hxx b/basic/inc/basic/basicmanagerrepository.hxx index c4ff6d515026..e486c3880f41 100644 --- a/basic/inc/basic/basicmanagerrepository.hxx +++ b/basic/inc/basic/basicmanagerrepository.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -144,3 +145,4 @@ namespace basic #endif // BASICMANAGERREPOSITORY_HXX +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/basicrt.hxx b/basic/inc/basic/basicrt.hxx index 7af0e0fe9db7..2d39eb79ca02 100644 --- a/basic/inc/basic/basicrt.hxx +++ b/basic/inc/basic/basicrt.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -77,3 +78,4 @@ public: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/basmgr.hxx b/basic/inc/basic/basmgr.hxx index d8cc5498dfd5..8dc90817c936 100644 --- a/basic/inc/basic/basmgr.hxx +++ b/basic/inc/basic/basmgr.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -24,7 +25,6 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -// #ifndef _BASMGR_HXX #define _BASMGR_HXX @@ -87,7 +87,6 @@ public: }; -// class BasicLibs; class ErrorManager; @@ -166,7 +165,7 @@ protected: BasicLibInfo* FindLibInfo( StarBASIC* pBasic ) const; void CheckModules( StarBASIC* pBasic, sal_Bool bReference ) const; void SetFlagToAllLibs( short nFlag, sal_Bool bSet ) const; - BasicManager(); // Nur zum anpassen von Pfaden bei 'Speichern unter'. + BasicManager(); // This is used only to customize the paths for 'Save as'. ~BasicManager(); public: @@ -211,7 +210,7 @@ public: sal_Bool LoadLib( sal_uInt16 nLib ); sal_Bool RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage ); - // Modify-Flag wird nur beim Speichern zurueckgesetzt. + // Modify-Flag will be reset only during save. sal_Bool IsModified() const; sal_Bool IsBasicModified() const; @@ -236,7 +235,7 @@ public: takes the names of modules whose size exceeds the legacy limit */ bool LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequence< rtl::OUString >& _out_rModuleNames ); - + bool HasExeCode( const String& ); /// determines whether the Basic Manager has a given macro, given by fully qualified name bool HasMacro( String const& i_fullyQualifiedName ) const; /// executes a given macro @@ -266,3 +265,5 @@ private: void SetAppBasicManager( BasicManager* pBasMgr ); #endif //_BASMGR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/basrdll.hxx b/basic/inc/basic/basrdll.hxx index 2265bd354ec4..b11607201bb5 100644 --- a/basic/inc/basic/basrdll.hxx +++ b/basic/inc/basic/basrdll.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -57,3 +58,5 @@ public: #define BASIC_DLL() (*(BasicDLL**)GetAppData( SHL_BASIC ) ) #endif //_BASRDLL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/dispdefs.hxx b/basic/inc/basic/dispdefs.hxx index 3b86d54d6b39..9feb0edbef98 100644 --- a/basic/inc/basic/dispdefs.hxx +++ b/basic/inc/basic/dispdefs.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -36,3 +37,4 @@ #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/modsizeexceeded.hxx b/basic/inc/basic/modsizeexceeded.hxx index e2d716259f09..414b7aff72e0 100644 --- a/basic/inc/basic/modsizeexceeded.hxx +++ b/basic/inc/basic/modsizeexceeded.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -59,3 +60,4 @@ class ModuleSizeExceeded : public ::cppu::WeakImplHelper1< ::com::sun::star::tas #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/mybasic.hxx b/basic/inc/basic/mybasic.hxx index 9522dbe7b997..3a2ab068d4c4 100644 --- a/basic/inc/basic/mybasic.hxx +++ b/basic/inc/basic/mybasic.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,11 +30,16 @@ #define _MYBASIC_HXX #include <basic/sbstar.hxx> +#include <vector> class BasicApp; class AppBasEd; class ErrorEntry; +#define SBXID_MYBASIC 0x594D // MyBasic: MY +#define SBXCR_TEST 0x54534554 // TEST + +//----------------------------------------------------------------------------- class BasicError { AppBasEd* pWin; sal_uInt16 nLine, nCol1, nCol2; @@ -43,11 +49,7 @@ public: void Show(); }; -DECLARE_LIST( ErrorList, BasicError* ) - -#define SBXID_MYBASIC 0x594D // MyBasic: MY -#define SBXCR_TEST 0x54534554 // TEST - +//----------------------------------------------------------------------------- class MyBasic : public StarBASIC { SbError nError; @@ -55,6 +57,8 @@ class MyBasic : public StarBASIC virtual sal_uInt16 BreakHdl(); protected: + ::std::vector< BasicError* > aErrors; + size_t CurrentError; Link GenLogHdl(); Link GenWinInfoHdl(); Link GenModuleWinExistsHdl(); @@ -67,14 +71,17 @@ protected: public: SBX_DECL_PERSIST_NODATA(SBXCR_TEST,SBXID_MYBASIC,1); TYPEINFO(); - ErrorList aErrors; MyBasic(); virtual ~MyBasic(); virtual sal_Bool Compile( SbModule* ); void Reset(); SbError GetErrors() { return nError; } + size_t GetCurrentError() { return CurrentError; } + BasicError* FirstError(); + BasicError* NextError(); + BasicError* PrevError(); - // Do not use #ifdefs here because this header file is both used for testtool and basic + // Do not use #ifdefs here because this header file is both used for testtool and basic SbxObject *pTestObject; // for Testool; otherwise NULL virtual void LoadIniFile(); @@ -92,3 +99,5 @@ public: SV_DECL_IMPL_REF(MyBasic) #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/process.hxx b/basic/inc/basic/process.hxx index e683bf527173..b88391b412ca 100644 --- a/basic/inc/basic/process.hxx +++ b/basic/inc/basic/process.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,7 +30,7 @@ #define _PROCESS_HXX #include <tools/string.hxx> -#include <vos/process.hxx> +#include <osl/process.h> #include <map> @@ -39,9 +40,12 @@ typedef Environment::value_type EnvironmentVariable; class Process { // Internal members and methods - vos::OArgumentList *pArgumentList; - vos::OEnvironment *pEnvList; - vos::OProcess *pProcess; + sal_uInt32 m_nArgumentCount; + rtl_uString **m_pArgumentList; + sal_uInt32 m_nEnvCount; + rtl_uString **m_pEnvList; + rtl::OUString m_aProcessName; + oslProcess m_pProcess; sal_Bool ImplIsRunning(); long ImplGetExitCode(); sal_Bool bWasGPF; @@ -61,3 +65,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbdef.hxx b/basic/inc/basic/sbdef.hxx index 70512584f9b7..7877ea5f9060 100644 --- a/basic/inc/basic/sbdef.hxx +++ b/basic/inc/basic/sbdef.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,6 +31,9 @@ #include <basic/sbxdef.hxx> #include <svl/svarray.hxx> +#include <rtl/ustring.hxx> + +using rtl::OUString; #define _BASIC_TEXTPORTIONS @@ -75,7 +79,7 @@ String getBasicTypeName( SbxDataType eType ); // important for SbUnoObj instances // implementation: basic/source/classes/sbunoobj.cxx class SbxObject; -String getBasicObjectTypeName( SbxObject* pObj ); +::rtl::OUString getBasicObjectTypeName( SbxObject* pObj ); // Allows Basic IDE to set watch mode to suppress errors // implementation: basic/source/runtime/runtime.cxx @@ -98,7 +102,6 @@ void setBasicWatchMode( bool bOn ); #define SBX_HINT_BASICSTART SFX_HINT_USER04 #define SBX_HINT_BASICSTOP SFX_HINT_USER05 -// #115826 enum PropertyMode { PROPERTY_MODE_NONE, @@ -108,3 +111,5 @@ enum PropertyMode }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sberrors.hxx b/basic/inc/basic/sberrors.hxx index 4eeb28d43e32..f2e40ac2e05c 100644 --- a/basic/inc/basic/sberrors.hxx +++ b/basic/inc/basic/sberrors.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -560,3 +561,5 @@ typedef sal_uIntPtr SbError; // OLE messages from 31000-31999 #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbmeth.hxx b/basic/inc/basic/sbmeth.hxx index fea6644db270..4c8deafef29c 100644 --- a/basic/inc/basic/sbmeth.hxx +++ b/basic/inc/basic/sbmeth.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -46,6 +47,7 @@ class SbMethod : public SbxMethod friend class SbIfaceMapperMethod; SbMethodImpl* mpSbMethodImpl; // Impl data + SbxVariable* mCaller; // caller SbModule* pMod; sal_uInt16 nDebugFlags; sal_uInt16 nLine1, nLine2; @@ -71,8 +73,8 @@ public: void SetDebugFlags( sal_uInt16 n ) { nDebugFlags = n; } void GetLineRange( sal_uInt16&, sal_uInt16& ); - // Schnittstelle zum Ausfuehren einer Methode aus den Applikationen - virtual ErrCode Call( SbxValue* pRet = NULL ); + // Interface to execute a method from the applications + virtual ErrCode Call( SbxValue* pRet = NULL, SbxVariable* pCaller = NULL ); virtual void Broadcast( sal_uIntPtr nHintId ); }; @@ -99,3 +101,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbmod.hxx b/basic/inc/basic/sbmod.hxx index a0552cdf3d4b..cba5714b9c36 100644 --- a/basic/inc/basic/sbmod.hxx +++ b/basic/inc/basic/sbmod.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -62,6 +63,8 @@ class SbModule : public SbxObject SbModuleImpl* mpSbModuleImpl; // Impl data std::vector< String > mModuleVariableNames; + SbModule(); + SbModule(const SbModule&); void implClearIfVarDependsOnDeletedBasic( SbxVariable* pVar, StarBASIC* pDeletedBasic ); @@ -139,6 +142,7 @@ public: sal_Bool LoadBinaryData( SvStream& ); sal_Bool ExceedsLegacyModuleSize(); void fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg = NULL ) const; + bool HasExeCode(); sal_Bool IsVBACompat() const; void SetVBACompat( sal_Bool bCompat ); sal_Int32 GetModuleType() { return mnType; } @@ -192,3 +196,5 @@ SV_DECL_IMPL_REF(SbClassModuleObject); #endif #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbobjmod.hxx b/basic/inc/basic/sbobjmod.hxx index f8c515b13108..af602191cdd5 100644 --- a/basic/inc/basic/sbobjmod.hxx +++ b/basic/inc/basic/sbobjmod.hxx @@ -1,13 +1,8 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * OpenOffice.org - a multi-platform office productivity suite * - * $RCSfile: sbobjmod.hxx,v $ - * - * $Revision: 1.4 $ - * - * last change: $Author: $ $Date: 2007/08/27 16:31:39 $ - * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. * @@ -130,3 +125,4 @@ SV_DECL_IMPL_REF(SbObjModule); #endif #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbprop.hxx b/basic/inc/basic/sbprop.hxx index 88f6504bff76..730ee6fa0aa7 100644 --- a/basic/inc/basic/sbprop.hxx +++ b/basic/inc/basic/sbprop.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -78,3 +79,5 @@ SV_DECL_IMPL_REF(SbProcedureProperty) #endif #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbstar.hxx b/basic/inc/basic/sbstar.hxx index 5b00fe68a421..73d80a4345b7 100644 --- a/basic/inc/basic/sbstar.hxx +++ b/basic/inc/basic/sbstar.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,9 +31,7 @@ #include <basic/sbx.hxx> #include <basic/sbxobj.hxx> -#ifndef _RTL_USTRING_HXX #include <rtl/ustring.hxx> -#endif #include <osl/mutex.hxx> #include <basic/sbdef.hxx> @@ -225,3 +224,4 @@ SV_DECL_IMPL_REF(StarBASIC) #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbstdobj.hxx b/basic/inc/basic/sbstdobj.hxx index b1c061161896..8120e6d25631 100644 --- a/basic/inc/basic/sbstdobj.hxx +++ b/basic/inc/basic/sbstdobj.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,7 @@ #define _SBSTDOBJ1_HXX #include <basic/sbxobj.hxx> -#ifndef _GRAPH_HXX //autogen #include <vcl/graph.hxx> -#endif #include <basic/sbxfac.hxx> class StarBASIC; class SbStdFactory; @@ -143,3 +142,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbuno.hxx b/basic/inc/basic/sbuno.hxx index d816d424313b..faeb99ef2160 100644 --- a/basic/inc/basic/sbuno.hxx +++ b/basic/inc/basic/sbuno.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,10 +35,11 @@ namespace com { namespace sun { namespace star { namespace uno { class Any; }}}} // Returns a SbxObject that wrapps an Uno Interface // Implementation in basic/source/classes/sbunoobj.cxx -SbxObjectRef GetSbUnoObject( const String& aName, const com::sun::star::uno::Any& aUnoObj_ ); +SbxObjectRef GetSbUnoObject( const ::rtl::OUString& aName, const com::sun::star::uno::Any& aUnoObj_ ); // Force creation of all properties for debugging void createAllObjectProperties( SbxObject* pObj ); +void SetSbUnoObjectDfltPropName( SbxObject* pObj ); ::com::sun::star::uno::Any sbxToUnoValue( SbxVariable* pVar ); @@ -45,3 +47,4 @@ void unoToSbxValue( SbxVariable* pVar, const ::com::sun::star::uno::Any& aValue #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbx.hxx b/basic/inc/basic/sbx.hxx index 7f0681ccce6c..ea8cc1e4f24e 100644 --- a/basic/inc/basic/sbx.hxx +++ b/basic/inc/basic/sbx.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,16 +33,13 @@ #include "svl/svarray.hxx" #include "svl/smplhint.hxx" #include "svl/lstner.hxx" + #include <basic/sbxdef.hxx> #include <basic/sbxform.hxx> - -#ifndef __SBX_SBXOBJECT_HXX #include <basic/sbxobj.hxx> -#endif #include <basic/sbxprop.hxx> #include <basic/sbxmeth.hxx> -class BigInt; class String; class UniString; class SvStream; @@ -53,15 +51,11 @@ class SbxObject; class SbxArray; class SbxDimArray; class SbxFactory; -struct SbxINT64; -struct SbxUINT64; class SfxBroadcaster; class SvDispatch; -/////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// #ifndef __SBX_SBXPARAMINFO #define __SBX_SBXPARAMINFO @@ -79,11 +73,7 @@ struct SbxParamInfo ~SbxParamInfo() {} }; -//#if 0 // _SOLAR__PRIVATE SV_DECL_PTRARR_DEL(SbxParams,SbxParamInfo*,4,4) -//#else -//typedef SvPtrarr SbxParams; -//#endif #endif @@ -158,9 +148,9 @@ public: #ifndef __SBX_SBXARRAY #define __SBX_SBXARRAY -// SbxArray ist ein eindimensionales, dynamisches Array -// von SbxVariablen. Put()/Insert() konvertieren die Variablen in den -// angegebenen Datentyp, falls er nicht SbxVARIANT ist. +// SbxArray is an unidimensional, dynamic Array +// The variables convert from SbxVariablen. Put()/Insert() into the +// declared datatype, if they are not SbxVARIANT. class SbxVarRefs; class SbxVariableRef; @@ -367,3 +357,5 @@ SV_IMPL_REF(SbxDimArray) #endif #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbxbase.hxx b/basic/inc/basic/sbxbase.hxx index 0812b2622828..057b4e0a261b 100644 --- a/basic/inc/basic/sbxbase.hxx +++ b/basic/inc/basic/sbxbase.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,7 +30,6 @@ #define _SBXBASE_HXX #include <i18npool/lang.h> -#include "tools/list.hxx" #include "svl/svarray.hxx" #include <basic/sbxdef.hxx> @@ -38,14 +38,12 @@ class SbxVariable; class SbxBasicFormater; SV_DECL_PTRARR_DEL(SbxFacs,SbxFactory*,5,5) -DECLARE_LIST(SbxVarList_Impl, SbxVariable*) // AppData-Struktur for SBX: struct SbxAppData { SbxError eSbxError; // Error code SbxFacs aFacs; // Factories - SbxVarList_Impl aVars; // for Dump SbxBasicFormater *pBasicFormater; // Pointer to Format()-Command helper class LanguageType eBasicFormaterLangType; @@ -58,3 +56,5 @@ struct SbxAppData SbxAppData* GetSbxData_Impl(); #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbxcore.hxx b/basic/inc/basic/sbxcore.hxx index b4e80a49f168..f16bcde9449d 100644 --- a/basic/inc/basic/sbxcore.hxx +++ b/basic/inc/basic/sbxcore.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -179,3 +180,5 @@ inline sal_Bool SbxBase::IsVisible() const { DBG_CHKTHIS( SbxBase, 0 ); return IsReset( SBX_INVISIBLE ); } #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbxdef.hxx b/basic/inc/basic/sbxdef.hxx index cc669fd03649..0eda93dcf102 100644 --- a/basic/inc/basic/sbxdef.hxx +++ b/basic/inc/basic/sbxdef.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -31,9 +32,7 @@ #ifndef __RSC -#ifndef _SOLAR_H #include <tools/solar.h> -#endif #include "tools/errcode.hxx" #ifndef _SBX_CLASS_TYPE @@ -55,54 +54,61 @@ enum SbxClassType { // SBX-class-IDs (order is important!) #define _SBX_DATA_TYPE enum SbxDataType { - SbxEMPTY = 0, // * Uninitialized - SbxNULL = 1, // * Contains no valid data - SbxINTEGER = 2, // * Integer (sal_Int16) - SbxLONG = 3, // * Long integer (sal_Int32) - SbxSINGLE = 4, // * Single-precision floating point number (float) - SbxDOUBLE = 5, // * Double-precision floating point number (double) - SbxCURRENCY = 6, // Currency (sal_Int64) - SbxDATE = 7, // * Date (double) - SbxSTRING = 8, // * String (StarView) - SbxOBJECT = 9, // * SbxBase object pointer - SbxERROR = 10, // * Error (sal_uInt16) - SbxBOOL = 11, // * Boolean (0 or -1) - SbxVARIANT = 12, // * Anzeige fuer varianten Datentyp - SbxDATAOBJECT = 13, // * Common data object w/o ref count - - SbxCHAR = 16, // * signed char - SbxBYTE = 17, // * unsigned char - SbxUSHORT = 18, // * unsigned short (sal_uInt16) - SbxULONG = 19, // * unsigned long (sal_uInt32) - SbxLONG64 = 20, // signed 64-bit int - SbxULONG64 = 21, // unsigned 64-bit int - SbxINT = 22, // * signed machine-dependent int - SbxUINT = 23, // * unsigned machine-dependent int - SbxVOID = 24, // * no value (= SbxEMPTY) - SbxHRESULT = 25, // HRESULT - SbxPOINTER = 26, // generic pointer - SbxDIMARRAY = 27, // dimensioned array - SbxCARRAY = 28, // C style array - SbxUSERDEF = 29, // user defined - SbxLPSTR = 30, // * null terminated string - SbxLPWSTR = 31, // wide null terminated string - SbxCoreSTRING = 32, // AB 10.4.97, fuer GetCoreString(), nur zum Konvertieren - SbxWSTRING = 33, // AB 4.10.2000 Reimplemented for backwards compatibility (#78919) - SbxWCHAR = 34, // AB 4.10.2000 Reimplemented for backwards compatibility (#78919) - SbxSALINT64 = 35, // for UNO hyper - SbxSALUINT64 = 36, // for UNO unsigned hyper - SbxDECIMAL = 37, // for UNO/automation Decimal - - SbxVECTOR = 0x1000, // simple counted array - SbxARRAY = 0x2000, // array - SbxBYREF = 0x4000, // access by reference - - SbxSV1 = 128, // first defined data type for StarView - SbxMEMORYSTREAM, // SvMemoryStream - SbxSTORAGE, // SvStorage - - SbxUSER1 = 256, // first user defined data type - SbxUSERn = 2047 // last user defined data type + SbxEMPTY = 0, // * Uninitialized + SbxNULL = 1, // * Contains no valid data + SbxINTEGER = 2, // * Integer (sal_Int16) + SbxLONG = 3, // * Long integer (sal_Int32) + SbxSINGLE = 4, // * Single-precision floating point number (float) + SbxDOUBLE = 5, // * Double-precision floating point number (double) + SbxCURRENCY = 6, // Currency (sal_Int64) + SbxDATE = 7, // * Date (double) + SbxSTRING = 8, // * String (StarView) + SbxOBJECT = 9, // * SbxBase object pointer + SbxERROR = 10, // * Error (sal_uInt16) + SbxBOOL = 11, // * Boolean (0 or -1) + + SbxVARIANT = 12, // * Display for variant datatype + SbxDATAOBJECT = 13, // * Common data object w/o ref count + + SbxCHAR = 16, // * signed char + SbxBYTE = 17, // * unsigned char + SbxUSHORT = 18, // * unsigned short (sal_uInt16) + SbxULONG = 19, // * unsigned long (sal_uInt32) + +//deprecated: // old 64bit types kept for backward compatibility in file I/O + SbxLONG64 = 20, // moved to SbxSALINT64 as 64bit int + SbxULONG64 = 21, // moved to SbxSALUINT64 as 64bit int + + SbxINT = 22, // * signed machine-dependent int + SbxUINT = 23, // * unsigned machine-dependent int + + SbxVOID = 24, // * no value (= SbxEMPTY) + SbxHRESULT = 25, // HRESULT + SbxPOINTER = 26, // generic pointer + SbxDIMARRAY = 27, // dimensioned array + SbxCARRAY = 28, // C style array + SbxUSERDEF = 29, // user defined + SbxLPSTR = 30, // * null terminated string + + SbxLPWSTR = 31, // wide null terminated string + SbxCoreSTRING = 32, // from 1997-4-10 for GetCoreString(), only for converting< + + SbxWSTRING = 33, // from 2000-10-4 Reimplemented for backwards compatibility (#78919) + SbxWCHAR = 34, // from 2000-10-4 Reimplemented for backwards compatibility (#78919) + SbxSALINT64 = 35, // for currency internal, signed 64-bit int and UNO hyper + SbxSALUINT64= 36, // for currency internal, unsigned 64-bit int and UNO unsigned hyper + SbxDECIMAL = 37, // for UNO/automation Decimal + + SbxVECTOR = 0x1000, // simple counted array + SbxARRAY = 0x2000, // array + SbxBYREF = 0x4000, // access by reference + + SbxSV1 = 128, // first defined data type for StarView + SbxMEMORYSTREAM, // SvMemoryStream + SbxSTORAGE, // SvStorage + + SbxUSER1 = 256, // first user defined data type + SbxUSERn = 2047 // last user defined data type }; const sal_uInt32 SBX_TYPE_WITH_EVENTS_FLAG = 0x10000; @@ -116,31 +122,34 @@ const sal_uInt32 SBX_TYPE_VAR_TO_DIM_FLAG = 0x40000; #define _SBX_OPERATOR enum SbxOperator { - // Arithmetical: - SbxEXP, // this ^ var - SbxMUL, // this * var - SbxDIV, // this / var - SbxMOD, // this MOD var - SbxPLUS, // this + var - SbxMINUS, // this - var - SbxNEG, // -this (var is ignored) + // Arithmetical: + SbxEXP, // this ^ var + SbxMUL, // this * var + SbxDIV, // this / var + SbxMOD, // this MOD var (max INT32!) + SbxPLUS, // this + var + SbxMINUS, // this - var + SbxNEG, // -this (var is ignored) SbxIDIV, // this / var (both operands max. sal_Int32!) // Boolean operators (max sal_Int32!): - SbxAND, // this & var - SbxOR, // this | var - SbxXOR, // this ^ var - SbxEQV, // ~this ^ var - SbxIMP, // ~this | var - SbxNOT, // ~this (var is ignored) - // String-concat: - SbxCAT, // this & var - // Comparisons: - SbxEQ, // this = var - SbxNE, // this <> var - SbxLT, // this < var - SbxGT, // this > var - SbxLE, // this <= var - SbxGE // this >= var + // Boolean operators (TODO deprecate this limit: max INT32!) + SbxAND, // this & var + SbxOR, // this | var + SbxXOR, // this ^ var + SbxEQV, // ~this ^ var + SbxIMP, // ~this | var + SbxNOT, // ~this (var is ignored) + + // String concatenation: + SbxCAT, // this & var (VBA: this + var) + + // Comparisons: + SbxEQ, // this = var + SbxNE, // this <> var + SbxLT, // this < var + SbxGT, // this > var + SbxLE, // this <= var + SbxGE // this >= var }; #endif @@ -148,167 +157,100 @@ enum SbxOperator { #ifndef _SBX_NAME_TYPE #define _SBX_NAME_TYPE -enum SbxNameType { // Type of the questioned name of a variable - SbxNAME_NONE, // plain name - SbxNAME_SHORT, // Name(A,B) - SbxNAME_SHORT_TYPES, // Name%(A%,B$) - SbxNAME_LONG_TYPES // Name(A As Integer, B As String) As Integer +enum SbxNameType { // Type of the questioned name of a variable + SbxNAME_NONE, // plain name + SbxNAME_SHORT, // Name(A,B) + SbxNAME_SHORT_TYPES, // Name%(A%,B$) + SbxNAME_LONG_TYPES // Name(A As Integer, B As String) As Integer }; #endif -// AB: 20.3.96: New error messages +// from 1996/3/20: New error messages typedef sal_uIntPtr SbxError; // Preserve old type #endif -// von #ifndef __RSC // New error codes per define -#define ERRCODE_SBX_OK ERRCODE_NONE // processed -#define ERRCODE_SBX_SYNTAX (1UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_COMPILER) // Syntaxerror in parser (where else could syntax errors happen? ;-) -#define ERRCODE_SBX_NOTIMP (2UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_NOTSUPPORTED) // not possible -#define ERRCODE_SBX_OVERFLOW (3UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_SBX) // overflow -#define ERRCODE_SBX_BOUNDS (4UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_SBX) // Invalid array index -#define ERRCODE_SBX_ZERODIV (5UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_SBX) // Division by zero -#define ERRCODE_SBX_CONVERSION (6UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_SBX) // wrong data type -#define ERRCODE_SBX_BAD_PARAMETER (7UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // invalid Parameter -#define ERRCODE_SBX_PROC_UNDEFINED (8UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // BASIC-Sub or Function undefined -#define ERRCODE_SBX_ERROR (9UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_UNKNOWN) // other object-related error -#define ERRCODE_SBX_NO_OBJECT (10UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // Object variable unassigned -#define ERRCODE_SBX_CANNOT_LOAD (11UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_CREATE) // Object cannot be loaded or initialized -#define ERRCODE_SBX_BAD_INDEX (12UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_SBX) // Invalid object index -#define ERRCODE_SBX_NO_ACTIVE_OBJECT (13UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_ACCESS) // Object ist not activated -#define ERRCODE_SBX_BAD_PROP_VALUE (14UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // Bad property value -#define ERRCODE_SBX_PROP_READONLY (15UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_READ) // Property is read only -#define ERRCODE_SBX_PROP_WRITEONLY (16UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_WRITE) // Property is write only -#define ERRCODE_SBX_INVALID_OBJECT (17UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_ACCESS) // Invalid object reference -#define ERRCODE_SBX_NO_METHOD (18UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // Property oder Methode unbekannt -#define ERRCODE_SBX_INVALID_USAGE_OBJECT (19UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_ACCESS) // Invalid object usage -#define ERRCODE_SBX_NO_OLE (20UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_ACCESS) // No OLE-Object -#define ERRCODE_SBX_BAD_METHOD (21UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // Method not supported -#define ERRCODE_SBX_OLE_ERROR (22UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // OLE Automation Error -#define ERRCODE_SBX_BAD_ACTION (23UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_NOTSUPPORTED) // Action not supported -#define ERRCODE_SBX_NO_NAMED_ARGS (24UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // No named arguments -#define ERRCODE_SBX_BAD_LOCALE (25UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_NOTSUPPORTED) // Locale settings not supported -#define ERRCODE_SBX_NAMED_NOT_FOUND (26UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // Unknown named argument -#define ERRCODE_SBX_NOT_OPTIONAL (27UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // Argument not optional -#define ERRCODE_SBX_WRONG_ARGS (28UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_SBX) // Invalid number of arguments -#define ERRCODE_SBX_NOT_A_COLL (29UL | ERRCODE_AREA_SBX | \ - ERRCODE_CLASS_RUNTIME) // Object contains no elements -#define LAST_SBX_ERROR_ID 29UL - - -// Less important for resources +#define ERRCODE_SBX_OK ERRCODE_NONE // processed + +#define ERRCODE_SBX_SYNTAX (1UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_COMPILER) +#define ERRCODE_SBX_NOTIMP (2UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_NOTSUPPORTED) +#define ERRCODE_SBX_OVERFLOW (3UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // overflow +#define ERRCODE_SBX_BOUNDS (4UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Invalid array index +#define ERRCODE_SBX_ZERODIV (5UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Division by zero +#define ERRCODE_SBX_CONVERSION (6UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // wrong data type +#define ERRCODE_SBX_BAD_PARAMETER (7UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // invalid Parameter +#define ERRCODE_SBX_PROC_UNDEFINED (8UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Sub or Func not def +#define ERRCODE_SBX_ERROR (9UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_UNKNOWN) // generic object error +#define ERRCODE_SBX_NO_OBJECT (10UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Object var not object +#define ERRCODE_SBX_CANNOT_LOAD (11UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_CREATE) // Object init/load fail +#define ERRCODE_SBX_BAD_INDEX (12UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Invalid object index +#define ERRCODE_SBX_NO_ACTIVE_OBJECT (13UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // Object not active +#define ERRCODE_SBX_BAD_PROP_VALUE (14UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Bad property value +#define ERRCODE_SBX_PROP_READONLY (15UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_READ) // Property is read only +#define ERRCODE_SBX_PROP_WRITEONLY (16UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_WRITE) // Property is write only +#define ERRCODE_SBX_INVALID_OBJECT (17UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // Invalid object reference +#define ERRCODE_SBX_NO_METHOD (18UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Property oder Methode unbekannt +#define ERRCODE_SBX_INVALID_USAGE_OBJECT (19UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // Invalid object usage +#define ERRCODE_SBX_NO_OLE (20UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_ACCESS) // No OLE-Object +#define ERRCODE_SBX_BAD_METHOD (21UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Method not supported +#define ERRCODE_SBX_OLE_ERROR (22UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // OLE Automation Error +#define ERRCODE_SBX_BAD_ACTION (23UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_NOTSUPPORTED) // Action not supported +#define ERRCODE_SBX_NO_NAMED_ARGS (24UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // No named arguments +#define ERRCODE_SBX_BAD_LOCALE (25UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_NOTSUPPORTED) // Locale not supported +#define ERRCODE_SBX_NAMED_NOT_FOUND (26UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Unknown named argument +#define ERRCODE_SBX_NOT_OPTIONAL (27UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Argument not optional +#define ERRCODE_SBX_WRONG_ARGS (28UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_SBX) // Invalid number of arguments +#define ERRCODE_SBX_NOT_A_COLL (29UL | ERRCODE_AREA_SBX | ERRCODE_CLASS_RUNTIME) // Object contains no elements +#define LAST_SBX_ERROR_ID 29UL + #ifndef __RSC // Map old codes to new ones -#define SbxERR_OK ERRCODE_SBX_OK -#define SbxERR_SYNTAX ERRCODE_SBX_SYNTAX -#define SbxERR_NOTIMP ERRCODE_SBX_NOTIMP -#define SbxERR_OVERFLOW ERRCODE_SBX_OVERFLOW -#define SbxERR_BOUNDS ERRCODE_SBX_BOUNDS -#define SbxERR_ZERODIV ERRCODE_SBX_ZERODIV -#define SbxERR_CONVERSION ERRCODE_SBX_CONVERSION -#define SbxERR_BAD_PARAMETER ERRCODE_SBX_BAD_PARAMETER -#define SbxERR_PROC_UNDEFINED ERRCODE_SBX_PROC_UNDEFINED -#define SbxERR_ERROR ERRCODE_SBX_ERROR -#define SbxERR_NO_OBJECT ERRCODE_SBX_NO_OBJECT -#define SbxERR_CANNOT_LOAD ERRCODE_SBX_CANNOT_LOAD -#define SbxERR_BAD_INDEX ERRCODE_SBX_BAD_INDEX -#define SbxERR_NO_ACTIVE_OBJECT ERRCODE_SBX_NO_ACTIVE_OBJECT -#define SbxERR_BAD_PROP_VALUE ERRCODE_SBX_BAD_PROP_VALUE -#define SbxERR_PROP_READONLY ERRCODE_SBX_PROP_READONLY -#define SbxERR_PROP_WRITEONLY ERRCODE_SBX_PROP_WRITEONLY -#define SbxERR_INVALID_OBJECT ERRCODE_SBX_INVALID_OBJECT -#define SbxERR_NO_METHOD ERRCODE_SBX_NO_METHOD -#define SbxERR_INVALID_USAGE_OBJECT ERRCODE_SBX_INVALID_USAGE_OBJECT -#define SbxERR_NO_OLE ERRCODE_SBX_NO_OLE -#define SbxERR_BAD_METHOD ERRCODE_SBX_BAD_METHOD -#define SbxERR_OLE_ERROR ERRCODE_SBX_OLE_ERROR -#define SbxERR_BAD_ACTION ERRCODE_SBX_BAD_ACTION -#define SbxERR_NO_NAMED_ARGS ERRCODE_SBX_NO_NAMED_ARGS -#define SbxERR_BAD_LOCALE ERRCODE_SBX_BAD_LOCALE -#define SbxERR_NAMED_NOT_FOUND ERRCODE_SBX_NAMED_NOT_FOUND -#define SbxERR_NOT_OPTIONAL ERRCODE_SBX_NOT_OPTIONAL -#define SbxERR_WRONG_ARGS ERRCODE_SBX_WRONG_ARGS -#define SbxERR_NOT_A_COLL ERRCODE_SBX_NOT_A_COLL - - -/* Old codes with VB error codes -enum SbxError { // Ergebnis einer Rechenoperation/Konversion - SbxERR_OK = 0, // durchgefuehrt - SbxERR_SYNTAX = 2, // Syntaxfehler im Parser - SbxERR_NOTIMP = 5, // nicht moeglich - SbxERR_OVERFLOW = 6, // Ueberlauf - SbxERR_BOUNDS = 9, // Array-Index ungueltig - SbxERR_ZERODIV = 11, // Division durch Null - SbxERR_CONVERSION = 13, // falscher Datentyp - SbxERR_BAD_PARAMETER = 14, // ungltiger Parameter - SbxERR_PROC_UNDEFINED = 35, // BASIC-Sub oder Function undefiniert - SbxERR_ERROR = 51, // andere Fehler - // Objektbezogene Fehler - SbxERR_NO_OBJECT = 91, // Objektvariable nicht belegt - SbxERR_CANNOT_LOAD = 323, // Objekt kann nicht geladen/eingerichtet werden - SbxERR_BAD_INDEX = 341, // Invalid object index - SbxERR_NO_ACTIVE_OBJECT=366,// Objekt ist nicht aktiviert - SbxERR_BAD_PROP_VALUE = 380,// Bad property value - SbxERR_PROP_READONLY = 382, // Property is read only - SbxERR_PROP_WRITEONLY = 394,// Property is write only - SbxERR_INVALID_OBJECT = 420,// Invalid object reference - SbxERR_NO_METHOD = 423, // Property oder Methode unbekannt - SbxERR_INVALID_USAGE_OBJECT=425,// Falsche Verwendung eines Objekts - SbxERR_NO_OLE = 430, // Kein OLE-Objekt - SbxERR_BAD_METHOD = 438, // Methode nicht untersttzt - SbxERR_OLE_ERROR = 440, // OLE Automation-Fehler - SbxERR_BAD_ACTION = 445, // Aktion nicht untersttzt - SbxERR_NO_NAMED_ARGS = 446, // Keine benannten Argumente - SbxERR_BAD_LOCALE = 447, // Laenderspezifische Einstellungen nicht untersttzt - SbxERR_NAMED_NOT_FOUND = 448,// Unbekanntes benanntes Argument - SbxERR_NOT_OPTIONAL = 449, // Argument nicht optional - SbxERR_WRONG_ARGS = 450, // Falsche Zahl von Argumenten - SbxERR_NOT_A_COLL = 451 // Objekt enth„lt keine Elemente -}; -*/ +#define SbxERR_OK ERRCODE_SBX_OK +#define SbxERR_SYNTAX ERRCODE_SBX_SYNTAX +#define SbxERR_NOTIMP ERRCODE_SBX_NOTIMP +#define SbxERR_OVERFLOW ERRCODE_SBX_OVERFLOW +#define SbxERR_BOUNDS ERRCODE_SBX_BOUNDS +#define SbxERR_ZERODIV ERRCODE_SBX_ZERODIV +#define SbxERR_CONVERSION ERRCODE_SBX_CONVERSION +#define SbxERR_BAD_PARAMETER ERRCODE_SBX_BAD_PARAMETER +#define SbxERR_PROC_UNDEFINED ERRCODE_SBX_PROC_UNDEFINED +#define SbxERR_ERROR ERRCODE_SBX_ERROR +#define SbxERR_NO_OBJECT ERRCODE_SBX_NO_OBJECT +#define SbxERR_CANNOT_LOAD ERRCODE_SBX_CANNOT_LOAD +#define SbxERR_BAD_INDEX ERRCODE_SBX_BAD_INDEX +#define SbxERR_NO_ACTIVE_OBJECT ERRCODE_SBX_NO_ACTIVE_OBJECT +#define SbxERR_BAD_PROP_VALUE ERRCODE_SBX_BAD_PROP_VALUE +#define SbxERR_PROP_READONLY ERRCODE_SBX_PROP_READONLY +#define SbxERR_PROP_WRITEONLY ERRCODE_SBX_PROP_WRITEONLY +#define SbxERR_INVALID_OBJECT ERRCODE_SBX_INVALID_OBJECT +#define SbxERR_NO_METHOD ERRCODE_SBX_NO_METHOD +#define SbxERR_INVALID_USAGE_OBJECT ERRCODE_SBX_INVALID_USAGE_OBJECT +#define SbxERR_NO_OLE ERRCODE_SBX_NO_OLE +#define SbxERR_BAD_METHOD ERRCODE_SBX_BAD_METHOD +#define SbxERR_OLE_ERROR ERRCODE_SBX_OLE_ERROR +#define SbxERR_BAD_ACTION ERRCODE_SBX_BAD_ACTION +#define SbxERR_NO_NAMED_ARGS ERRCODE_SBX_NO_NAMED_ARGS +#define SbxERR_BAD_LOCALE ERRCODE_SBX_BAD_LOCALE +#define SbxERR_NAMED_NOT_FOUND ERRCODE_SBX_NAMED_NOT_FOUND +#define SbxERR_NOT_OPTIONAL ERRCODE_SBX_NOT_OPTIONAL +#define SbxERR_WRONG_ARGS ERRCODE_SBX_WRONG_ARGS +#define SbxERR_NOT_A_COLL ERRCODE_SBX_NOT_A_COLL + // Flag-Bits: -#define SBX_READ 0x0001 // Read permission -#define SBX_WRITE 0x0002 // Write permission -#define SBX_READWRITE 0x0003 // Read/Write permission -#define SBX_DONTSTORE 0x0004 // Don't store object -#define SBX_MODIFIED 0x0008 // Object was changed -#define SBX_FIXED 0x0010 // Fixed data type (SbxVariable) -#define SBX_CONST 0x0020 // Definition of const value -#define SBX_OPTIONAL 0x0040 // Parameter is optional -#define SBX_HIDDEN 0x0080 // Element is invisible +#define SBX_READ 0x0001 // Read permission +#define SBX_WRITE 0x0002 // Write permission +#define SBX_READWRITE 0x0003 // Read/Write permission +#define SBX_DONTSTORE 0x0004 // Don't store object +#define SBX_MODIFIED 0x0008 // Object was changed +#define SBX_FIXED 0x0010 // Fixed data type (SbxVariable) +#define SBX_CONST 0x0020 // Definition of const value +#define SBX_OPTIONAL 0x0040 // Parameter is optional +#define SBX_HIDDEN 0x0080 // Element is invisible #define SBX_INVISIBLE 0x0100 // Element is not found by Find() #define SBX_EXTSEARCH 0x0200 // Object is searched completely #define SBX_EXTFOUND 0x0400 // Variable was found through extended search @@ -334,7 +276,7 @@ enum SbxError { // Ergebnis einer Rechenoperation/Konversion // List of all creators for Load/Store -#define SBXCR_SBX 0x20584253 // SBX(blank) +#define SBXCR_SBX 0x20584253 // SBX(blank) // List of predefined SBX-IDs. New SBX-IDs must be precisly defined so that // they are unique within the Stream and appropriate Factory. @@ -350,41 +292,49 @@ enum SbxError { // Ergebnis einer Rechenoperation/Konversion #define SBXID_PROPERTY 0x5250 // PR: SbxProperty // StarBASIC restricts the base data type to different intervals. -// These intervals are fixed due to portability and independent +// These intervals are fixed to create 'portability and independent // of the implementation. Only type double is greedy and takes // what it gets. -#define SbxMAXCHAR ((sal_Unicode)65535) -#define SbxMINCHAR (0) -#define SbxMAXBYTE ( 255) -#define SbxMAXINT ( 32767) -#define SbxMININT (-32768) -#define SbxMAXUINT ((sal_uInt16) 65535) -#define SbxMAXLNG ( 2147483647) -#define SbxMINLNG ((sal_Int32)(-2147483647-1)) -#define SbxMAXULNG ((sal_uInt32) 0xffffffff) +#define SbxMAXCHAR ((sal_Unicode)65535) +#define SbxMINCHAR (0) +#define SbxMAXBYTE ( 255) +#define SbxMAXINT ( 32767) +#define SbxMININT (-32768) +#define SbxMAXUINT ((sal_uInt16) 65535) +#define SbxMAXLNG ( 2147483647) +#define SbxMINLNG ((sal_Int32)(-2147483647-1)) +#define SbxMAXULNG ((sal_uInt32) 0xffffffff) +#define SbxMAXSALUINT64 SAL_MAX_UINT64 #define SbxMAXSALINT64 SAL_MAX_INT64 #define SbxMINSALINT64 SAL_MIN_INT64 -#define SbxMAXSALUINT64 SAL_MAX_UINT64 -#define SbxMAXSNG ( 3.402823e+38) -#define SbxMINSNG (-3.402823e+38) -#define SbxMAXSNG2 ( 1.175494351e-38) -#define SbxMINSNG2 (-1.175494351e-38) -#define SbxMAXCURR ( 922337203685477.5807) -#define SbxMINCURR (-922337203685477.5808) -#define CURRENCY_FACTOR 10000 -#define SbxMAXCURRLNG (SbxMAXLNG/CURRENCY_FACTOR) -#define SbxMINCURRLNG (SbxMINLNG/CURRENCY_FACTOR) + // Currency stored as SbxSALINT64 == sal_Int64 + // value range limits are ~(2^63 - 1)/10000 + // fixed precision has 4 digits right of decimal pt +#define CURRENCY_FACTOR (10000) +#define CURRENCY_FACTOR_SQUARE (100000000) + +// TODO effective MAX/MINCURR limits: +// true value ( 922337203685477.5807) is too precise for correct comparison to 64bit double +#define SbxMAXCURR ( 922337203685477.5807) +#define SbxMINCURR (-922337203685477.5808) + +#define SbxMAXSNG ( 3.402823e+38) +#define SbxMINSNG (-3.402823e+38) +#define SbxMAXSNG2 ( 1.175494351e-38) +#define SbxMINSNG2 (-1.175494351e-38) // Max valid offset index of a Sbx-Array (due to 64K limit) -#define SBX_MAXINDEX 0x3FF0 -#define SBX_MAXINDEX32 SbxMAXLNG +#define SBX_MAXINDEX 0x3FF0 +#define SBX_MAXINDEX32 SbxMAXLNG // The numeric values of sal_True and FALSE enum SbxBOOL { SbxFALSE = 0, SbxTRUE = -1 }; -#endif // __RSC +#endif //ifndef __RSC #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbxfac.hxx b/basic/inc/basic/sbxfac.hxx index 372785657266..8597458c5ec2 100644 --- a/basic/inc/basic/sbxfac.hxx +++ b/basic/inc/basic/sbxfac.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -46,3 +47,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbxform.hxx b/basic/inc/basic/sbxform.hxx index 9f31e3529d04..27d372d8ccf1 100644 --- a/basic/inc/basic/sbxform.hxx +++ b/basic/inc/basic/sbxform.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -114,8 +115,6 @@ class SbxBasicFormater { static sal_Bool isBasicFormat( String sFormatStrg ); private: - //*** some helper methods *** - //void ShowError( char *sErrMsg ); inline void ShiftString( String& sStrg, sal_uInt16 nStartPos ); inline void StrAppendChar( String& sStrg, sal_Unicode ch ); void AppendDigit( String& sStrg, short nDigit ); @@ -179,3 +178,4 @@ class SbxBasicFormater { #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbxmeth.hxx b/basic/inc/basic/sbxmeth.hxx index 1f812cdb6260..31b07fdca18d 100644 --- a/basic/inc/basic/sbxmeth.hxx +++ b/basic/inc/basic/sbxmeth.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -60,3 +61,4 @@ SV_IMPL_REF(SbxMethod) #endif #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbxmstrm.hxx b/basic/inc/basic/sbxmstrm.hxx index c382269f6903..d3197bff883d 100644 --- a/basic/inc/basic/sbxmstrm.hxx +++ b/basic/inc/basic/sbxmstrm.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -47,3 +48,5 @@ class SbxMemoryStream : public SbxBase, public SvMemoryStream SV_IMPL_REF(SbxMemoryStream) #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbxobj.hxx b/basic/inc/basic/sbxobj.hxx index 8b973eee59cb..ab2b46422209 100644 --- a/basic/inc/basic/sbxobj.hxx +++ b/basic/inc/basic/sbxobj.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -31,7 +32,6 @@ #include <svl/lstner.hxx> #include <basic/sbxvar.hxx> -/////////////////////////////////////////////////////////////////////////// class SbxProperty; class SvDispatch; @@ -123,3 +123,5 @@ SV_IMPL_REF(SbxObject) #endif /* __SBX_SBXOBJECTREF_HXX */ #endif /* _SBX_SBXOBJECT_HXX */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbxprop.hxx b/basic/inc/basic/sbxprop.hxx index 467b86ee604c..25c875df9222 100644 --- a/basic/inc/basic/sbxprop.hxx +++ b/basic/inc/basic/sbxprop.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -59,3 +60,5 @@ SV_IMPL_REF(SbxProperty) #endif #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/sbxvar.hxx b/basic/inc/basic/sbxvar.hxx index 5a2fc4601586..7f0e5d878225 100644 --- a/basic/inc/basic/sbxvar.hxx +++ b/basic/inc/basic/sbxvar.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -33,169 +34,47 @@ #include <com/sun/star/bridge/oleautomation/Decimal.hpp> #include <basic/sbxcore.hxx> -#ifndef __SBX_64 -#define __SBX_64 - -struct SbxINT64 -{ - sal_Int32 nHigh; sal_uInt32 nLow; - -#if FALSE - SbxINT64() : nHigh( 0 ), nLow( 0 ) {} - SbxINT64( sal_uInt8 n ) : nHigh( 0 ), nLow( n ) {} - SbxINT64( sal_uInt16 n ) : nHigh( 0 ), nLow( n ) {} - SbxINT64( sal_uInt32 n ) : nHigh( 0 ), nLow( n ) {} - SbxINT64( unsigned int n ) : nHigh( 0 ), nLow( n ) {} - SbxINT64( sal_Int8 n ) : nHigh( n < 0 ? -1 : 0 ), nLow( n ) {} - SbxINT64( sal_Int16 n ) : nHigh( n < 0 ? -1 : 0 ), nLow( n ) {} - SbxINT64( sal_Int32 n ) : nHigh( n < 0 ? -1 : 0 ), nLow( n ) {} - SbxINT64( int n ) : nHigh( n < 0 ? -1 : 0 ), nLow( n ) {} - SbxINT64( SbxINT64 &r ) : nHigh( r.nHigh ), nLow( r.nLow ) {} - - SbxINT64( BigInt &r ); - SbxINT64( double n ); -#endif - void CHS() - { - nLow ^= (sal_uInt32)-1; - nHigh ^= -1; - nLow++; - if( !nLow ) - nHigh++; - } - - // blc/os2i do not like operator = - void Set(double n) - { - if( n >= 0 ) - { - nHigh = (sal_Int32)(n / (double)4294967296.0); - nLow = (sal_uInt32)(n - ((double)nHigh * (double)4294967296.0) + 0.5); - } - else { - nHigh = (sal_Int32)(-n / (double)4294967296.0); - nLow = (sal_uInt32)(-n - ((double)nHigh * (double)4294967296.0) + 0.5); - CHS(); - } - } - void Set(sal_Int32 n) { nHigh = n < 0 ? -1 : 0; nLow = n; } - - void SetMax() { nHigh = 0x7FFFFFFF; nLow = 0xFFFFFFFF; } - void SetMin() { nHigh = 0x80000000; nLow = 0x00000000; } - void SetNull() { nHigh = 0x00000000; nLow = 0x00000000; } - - int operator ! () const { return !nHigh && !nLow; } - - SbxINT64 &operator -= ( const SbxINT64 &r ); - SbxINT64 &operator += ( const SbxINT64 &r ); - SbxINT64 &operator /= ( const SbxINT64 &r ); - SbxINT64 &operator %= ( const SbxINT64 &r ); - SbxINT64 &operator *= ( const SbxINT64 &r ); - SbxINT64 &operator &= ( const SbxINT64 &r ); - SbxINT64 &operator |= ( const SbxINT64 &r ); - SbxINT64 &operator ^= ( const SbxINT64 &r ); - - friend SbxINT64 operator - ( const SbxINT64 &l, const SbxINT64 &r ); - friend SbxINT64 operator + ( const SbxINT64 &l, const SbxINT64 &r ); - friend SbxINT64 operator / ( const SbxINT64 &l, const SbxINT64 &r ); - friend SbxINT64 operator % ( const SbxINT64 &l, const SbxINT64 &r ); - friend SbxINT64 operator * ( const SbxINT64 &l, const SbxINT64 &r ); - friend SbxINT64 operator & ( const SbxINT64 &l, const SbxINT64 &r ); - friend SbxINT64 operator | ( const SbxINT64 &l, const SbxINT64 &r ); - friend SbxINT64 operator ^ ( const SbxINT64 &l, const SbxINT64 &r ); - - friend SbxINT64 operator - ( const SbxINT64 &r ); - friend SbxINT64 operator ~ ( const SbxINT64 &r ); - - static double GetMin() { return ((double)0x7FFFFFFF*(double)4294967296.0 - + (double)0xFFFFFFFF) - / CURRENCY_FACTOR; } - static double GetMax() { return ((double)0x80000000*(double)4294967296.0 - + (double)0xFFFFFFFF) - / CURRENCY_FACTOR; } -}; - -struct SbxUINT64 -{ - sal_uInt32 nHigh; sal_uInt32 nLow; - void Set(double n) - { - nHigh = (sal_uInt32)(n / (double)4294967296.0); - nLow = (sal_uInt32)(n - ((double)nHigh * (double)4294967296.0)); - } - - void Set(sal_uInt32 n) { nHigh = 0; nLow = n; } - - void SetMax() { nHigh = 0xFFFFFFFF; nLow = 0xFFFFFFFF; } - void SetMin() { nHigh = 0x00000000; nLow = 0x00000000; } - void SetNull() { nHigh = 0x00000000; nLow = 0x00000000; } - - int operator ! () const { return !nHigh && !nLow; } - - SbxUINT64 &operator -= ( const SbxUINT64 &r ); - SbxUINT64 &operator += ( const SbxUINT64 &r ); - SbxUINT64 &operator /= ( const SbxUINT64 &r ); - SbxUINT64 &operator %= ( const SbxUINT64 &r ); - SbxUINT64 &operator *= ( const SbxUINT64 &r ); - SbxUINT64 &operator &= ( const SbxUINT64 &r ); - SbxUINT64 &operator |= ( const SbxUINT64 &r ); - SbxUINT64 &operator ^= ( const SbxUINT64 &r ); - - friend SbxUINT64 operator - ( const SbxUINT64 &l, const SbxUINT64 &r ); - friend SbxUINT64 operator + ( const SbxUINT64 &l, const SbxUINT64 &r ); - friend SbxUINT64 operator / ( const SbxUINT64 &l, const SbxUINT64 &r ); - friend SbxUINT64 operator % ( const SbxUINT64 &l, const SbxUINT64 &r ); - friend SbxUINT64 operator * ( const SbxUINT64 &l, const SbxUINT64 &r ); - friend SbxUINT64 operator & ( const SbxUINT64 &l, const SbxUINT64 &r ); - friend SbxUINT64 operator | ( const SbxUINT64 &l, const SbxUINT64 &r ); - friend SbxUINT64 operator ^ ( const SbxUINT64 &l, const SbxUINT64 &r ); - - friend SbxUINT64 operator ~ ( const SbxUINT64 &r ); -}; - -#endif - #ifndef __SBX_SBXVALUES_HXX #define __SBX_SBXVALUES_HXX -class BigInt; class SbxDecimal; struct SbxValues { union { + sal_uInt8 nByte; + sal_uInt16 nUShort; sal_Unicode nChar; - sal_uInt8 nByte; - sal_Int16 nInteger; - sal_Int32 nLong; - sal_uInt16 nUShort; - sal_uInt32 nULong; + sal_Int16 nInteger; + sal_uInt32 nULong; + sal_Int32 nLong; + unsigned int nUInt; + int nInt; + sal_uInt64 uInt64; + sal_Int64 nInt64; + float nSingle; double nDouble; - SbxINT64 nLong64; - SbxUINT64 nULong64; - sal_Int64 nInt64; - sal_uInt64 uInt64; - int nInt; - unsigned int nUInt; - ::rtl::OUString* pOUString; + + rtl::OUString* pOUString; SbxDecimal* pDecimal; SbxBase* pObj; + + sal_uInt8* pByte; + sal_uInt16* pUShort; sal_Unicode* pChar; - sal_uInt8* pByte; - sal_Int16* pInteger; - sal_Int32* pLong; - sal_uInt16* pUShort; - sal_uInt32* pULong; + sal_Int16* pInteger; + sal_uInt32* pULong; + sal_Int32* pLong; + unsigned int* pUInt; + int* pInt; + sal_uInt64* puInt64; + sal_Int64* pnInt64; + float* pSingle; double* pDouble; - SbxINT64* pLong64; - SbxUINT64* pULong64; - sal_Int64* pnInt64; - sal_uInt64* puInt64; - int* pInt; - unsigned int* pUInt; + void* pData; }; SbxDataType eType; @@ -208,15 +87,15 @@ struct SbxValues SbxValues( long _nLong ): nLong( _nLong ), eType(SbxLONG) {} SbxValues( sal_uInt16 _nUShort ): nUShort( _nUShort ), eType(SbxUSHORT) {} SbxValues( sal_uIntPtr _nULong ): nULong( _nULong ), eType(SbxULONG) {} - SbxValues( float _nSingle ): nSingle( _nSingle ), eType(SbxSINGLE) {} - SbxValues( double _nDouble ): nDouble( _nDouble ), eType(SbxDOUBLE) {} SbxValues( int _nInt ): nInt( _nInt ), eType(SbxINT) {} SbxValues( unsigned int _nUInt ): nUInt( _nUInt ), eType(SbxUINT) {} + SbxValues( float _nSingle ): nSingle( _nSingle ), eType(SbxSINGLE) {} + SbxValues( double _nDouble ): nDouble( _nDouble ), eType(SbxDOUBLE) {} SbxValues( const ::rtl::OUString* _pString ): pOUString( (::rtl::OUString*)_pString ), eType(SbxSTRING) {} SbxValues( SbxBase* _pObj ): pObj( _pObj ), eType(SbxOBJECT) {} SbxValues( sal_Unicode* _pChar ): pChar( _pChar ), eType(SbxLPSTR) {} SbxValues( void* _pData ): pData( _pData ), eType(SbxPOINTER) {} - SbxValues( const BigInt &rBig ); + }; #endif @@ -290,36 +169,33 @@ public: inline SbxValues * data() { return &aData; } - SbxINT64 GetCurrency() const; - SbxINT64 GetLong64() const; - SbxUINT64 GetULong64() const; - sal_Int64 GetInt64() const; - sal_uInt64 GetUInt64() const; - sal_Int16 GetInteger() const; - sal_Int32 GetLong() const; - float GetSingle() const; - double GetDouble() const; - double GetDate() const; + sal_Unicode GetChar() const; + sal_Int16 GetInteger() const; + sal_Int32 GetLong() const; + sal_Int64 GetInt64() const; + sal_uInt64 GetUInt64() const; + + sal_Int64 GetCurrency() const; + SbxDecimal* GetDecimal() const; + + float GetSingle() const; + double GetDouble() const; + double GetDate() const; + sal_Bool GetBool() const; sal_uInt16 GetErr() const; - const String& GetString() const; - const String& GetCoreString() const; - ::rtl::OUString GetOUString() const; - SbxDecimal* GetDecimal() const; - SbxBase* GetObject() const; - sal_Bool HasObject() const; - void* GetData() const; - sal_Unicode GetChar() const; + const String& GetString() const; + const String& GetCoreString() const; + rtl::OUString GetOUString() const; + + SbxBase* GetObject() const; + sal_Bool HasObject() const; + void* GetData() const; sal_uInt8 GetByte() const; sal_uInt16 GetUShort() const; sal_uInt32 GetULong() const; int GetInt() const; - sal_Bool PutCurrency( const SbxINT64& ); - sal_Bool PutLong64( const SbxINT64& ); - sal_Bool PutULong64( const SbxUINT64& ); - sal_Bool PutInt64( sal_Int64 ); - sal_Bool PutUInt64( sal_uInt64 ); sal_Bool PutInteger( sal_Int16 ); sal_Bool PutLong( sal_Int32 ); sal_Bool PutSingle( float ); @@ -328,12 +204,11 @@ public: sal_Bool PutBool( sal_Bool ); sal_Bool PutErr( sal_uInt16 ); sal_Bool PutStringExt( const ::rtl::OUString& ); // with extended analysis (International, "sal_True"/"sal_False") + sal_Bool PutInt64( sal_Int64 ); + sal_Bool PutUInt64( sal_uInt64 ); sal_Bool PutString( const ::rtl::OUString& ); sal_Bool PutString( const sal_Unicode* ); // Type = SbxSTRING sal_Bool PutpChar( const sal_Unicode* ); // Type = SbxLPSTR - sal_Bool PutDecimal( SbxDecimal* pDecimal ); - sal_Bool PutObject( SbxBase* ); - sal_Bool PutData( void* ); sal_Bool PutChar( sal_Unicode ); sal_Bool PutByte( sal_uInt8 ); sal_Bool PutUShort( sal_uInt16 ); @@ -342,9 +217,16 @@ public: sal_Bool PutEmpty(); sal_Bool PutNull(); - // Special decimal methods + // Special methods sal_Bool PutDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ); sal_Bool fillAutomationDecimal( com::sun::star::bridge::oleautomation::Decimal& rAutomationDec ); + sal_Bool PutDecimal( SbxDecimal* pDecimal ); + sal_Bool PutCurrency( const sal_Int64& ); + // Interface for CDbl in Basic + static SbxError ScanNumIntnl( const String& rSrc, double& nVal, sal_Bool bSingle = sal_False ); + + sal_Bool PutObject( SbxBase* ); + sal_Bool PutData( void* ); virtual sal_Bool Convert( SbxDataType ); virtual sal_Bool Compute( SbxOperator, const SbxValue& ); @@ -352,12 +234,9 @@ public: sal_Bool Scan( const String&, sal_uInt16* = NULL ); void Format( String&, const String* = NULL ) const; - // Interface for CDbl in Basic - static SbxError ScanNumIntnl( const String& rSrc, double& nVal, sal_Bool bSingle=sal_False ); - // The following operators are definied for easier handling. - // Error conditions (overflow, conversions) are not - // taken into consideration. + // TODO: Ensure error conditions (overflow, conversions) + // are taken into consideration in Compute and Compare inline int operator ==( const SbxValue& ) const; inline int operator !=( const SbxValue& ) const; @@ -446,7 +325,7 @@ class SbxVariable : public SbxValue friend class SbMethod; SbxVariableImpl* mpSbxVariableImpl; // Impl data - SfxBroadcaster* pCst; // Broadcaster, if needed + SfxBroadcaster* pCst; // Broadcaster, if needed String maName; // Name, if available SbxArrayRef mpPar; // Parameter-Array, if set sal_uInt16 nHash; // Hash-ID for search @@ -515,3 +394,5 @@ SV_DECL_REF(SbxVariable) #endif #endif // _SBXVAR_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/svtmsg.hrc b/basic/inc/basic/svtmsg.hrc index ff215d3fc9cb..ff215d3fc9cb 100644..100755 --- a/basic/inc/basic/svtmsg.hrc +++ b/basic/inc/basic/svtmsg.hrc diff --git a/basic/inc/basic/testtool.hrc b/basic/inc/basic/testtool.hrc index 075b462944c9..075b462944c9 100644..100755 --- a/basic/inc/basic/testtool.hrc +++ b/basic/inc/basic/testtool.hrc diff --git a/basic/inc/basic/testtool.hxx b/basic/inc/basic/testtool.hxx index 179d28152561..b7de4a88b007 100644 --- a/basic/inc/basic/testtool.hxx +++ b/basic/inc/basic/testtool.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -38,11 +39,10 @@ #define ASSERTION_STACK_PREFIX "Backtrace:" -// #94145# Due to a tab in TT_SIGNATURE_FOR_UNICODE_TEXTFILES which is changed to blanks by some editors +// Due to a tab in TT_SIGNATURE_FOR_UNICODE_TEXTFILES which is changed to blanks by some editors // this routine became necessary sal_Bool IsTTSignatureForUnicodeTextfile( String aLine ); -//#include "testapp.hxx" #define ADD_ERROR_QUIET(nNr, aStr) \ { \ ErrorEntry *pErr; \ @@ -158,3 +158,5 @@ public: }; #endif // _BASIC_TESTTOOL_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basic/ttglobal.hrc b/basic/inc/basic/ttglobal.hrc index 0248a06c7247..0248a06c7247 100644..100755 --- a/basic/inc/basic/ttglobal.hrc +++ b/basic/inc/basic/ttglobal.hrc diff --git a/basic/inc/basic/ttmsg.hrc b/basic/inc/basic/ttmsg.hrc index 26f250bc6a6a..26f250bc6a6a 100644..100755 --- a/basic/inc/basic/ttmsg.hrc +++ b/basic/inc/basic/ttmsg.hrc diff --git a/basic/inc/basic/ttstrhlp.hxx b/basic/inc/basic/ttstrhlp.hxx index 27867a97996d..adf9068fbdf7 100644 --- a/basic/inc/basic/ttstrhlp.hxx +++ b/basic/inc/basic/ttstrhlp.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -74,3 +75,4 @@ UniString GEN_RES_STR3( sal_uIntPtr nResId, const UniString &Text1, const UniStr #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/basrid.hxx b/basic/inc/basrid.hxx index d12d05c3436a..f79778c61ee0 100644 --- a/basic/inc/basrid.hxx +++ b/basic/inc/basrid.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -43,3 +44,5 @@ class BasResId : public ResId }; #endif //_BASRID_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/makefile.mk b/basic/inc/makefile.mk index 1b56b6774806..1b56b6774806 100644..100755 --- a/basic/inc/makefile.mk +++ b/basic/inc/makefile.mk diff --git a/basic/inc/pch/precompiled_basic.cxx b/basic/inc/pch/precompiled_basic.cxx index c27c1c7a66a6..29280bf5059a 100644 --- a/basic/inc/pch/precompiled_basic.cxx +++ b/basic/inc/pch/precompiled_basic.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,3 +28,4 @@ #include "precompiled_basic.hxx" +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/pch/precompiled_basic.hxx b/basic/inc/pch/precompiled_basic.hxx index ae45c383c74d..1b7a57032830 100644 --- a/basic/inc/pch/precompiled_basic.hxx +++ b/basic/inc/pch/precompiled_basic.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -148,6 +149,7 @@ #include "i18npool/lang.h" +#include "osl/diagnose.h" #include "osl/file.hxx" #include "osl/module.h" #include "osl/mutex.hxx" @@ -211,7 +213,6 @@ #include "tools/fsys.hxx" #include "tools/gen.hxx" #include "tools/link.hxx" -#include "tools/list.hxx" #include "tools/rc.hxx" #include "tools/rcid.h" #include "tools/ref.hxx" @@ -275,14 +276,11 @@ #include "tools/wintypes.hxx" #include "vcl/wrkwin.hxx" -#include "vos/diagnose.hxx" -#include "vos/macros.hxx" -#include "vos/mutex.hxx" -#include "vos/process.hxx" - #include "xmlscript/xmldlg_imexp.hxx" #include "xmlscript/xmllib_imexp.hxx" #include "xmlscript/xmlmod_imexp.hxx" //---MARKER--- #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/inc/sb.hrc b/basic/inc/sb.hrc index c371d2abc046..c371d2abc046 100644..100755 --- a/basic/inc/sb.hrc +++ b/basic/inc/sb.hrc diff --git a/basic/inc/sb.hxx b/basic/inc/sb.hxx index ecc85bfa4000..b54d77974fef 100644 --- a/basic/inc/sb.hxx +++ b/basic/inc/sb.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -40,3 +41,5 @@ #include <basic/sbstar.hxx> #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/prj/build.lst b/basic/prj/build.lst index 17a34fa5bd9f..c6f684fefadc 100644 --- a/basic/prj/build.lst +++ b/basic/prj/build.lst @@ -1,4 +1,4 @@ -sb basic : L10N:l10n offuh oovbaapi svtools xmlscript framework salhelper LIBXSLT:libxslt NULL +sb basic : TRANSLATIONS:translations offuh oovbaapi svtools xmlscript framework salhelper LIBXSLT:libxslt NULL sb basic usr1 - all sb_mkout NULL sb basic\inc nmake - all sb_inc NULL sb basic\source\app nmake - all sb_app sb_class sb_inc NULL diff --git a/basic/prj/d.lst b/basic/prj/d.lst index 41d1a59550f0..8aa0b8399c78 100644 --- a/basic/prj/d.lst +++ b/basic/prj/d.lst @@ -1,29 +1,29 @@ -mkdir: %COMMON_DEST%\bin%_EXT%\hid -mkdir: %COMMON_DEST%\res%_EXT% +mkdir: %COMMON_DEST%\bin\hid +mkdir: %COMMON_DEST%\res -..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid -..\%__SRC%\lib\basic.lib %_DEST%\lib%_EXT%\basic.lib -..\%__SRC%\lib\lib*.so %_DEST%\lib%_EXT% -..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib -..\%__SRC%\lib\*.a %_DEST%\lib%_EXT%\*.a -..\%__SRC%\slb\sb.lib %_DEST%\lib%_EXT%\xsb.lib -..\%__SRC%\srs\classes.srs %_DEST%\res%_EXT%\basic.srs -..\%COMMON_OUTDIR%\srs\classes_srs.hid %COMMON_DEST%\res%_EXT%\basic_srs.hid -..\%__SRC%\bin\sb?????.dll %_DEST%\bin%_EXT%\sb?????.dll -..\%__SRC%\bin\sb?????.sym %_DEST%\bin%_EXT%\sb?????.sym -..\%__SRC%\misc\sb?????.map %_DEST%\bin%_EXT%\sb?????.map -..\%__SRC%\bin\stt*.res %_DEST%\bin%_EXT%\stt*.res -..\%__SRC%\bin\sb*.res %_DEST%\bin%_EXT%\sb*.res -..\%__SRC%\lib\app.lib %_DEST%\lib%_EXT%\app.lib -..\%__SRC%\lib\libapp.a %_DEST%\lib%_EXT%\libapp.a -..\%__SRC%\lib\sample.lib %_DEST%\lib%_EXT%\sample.lib -..\%__SRC%\lib\libsample.a %_DEST%\lib%_EXT%\libsample.a +..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin\hid\*.hid +..\%__SRC%\lib\basic.lib %_DEST%\lib\basic.lib +..\%__SRC%\lib\lib*.so %_DEST%\lib +..\%__SRC%\lib\*.dylib %_DEST%\lib\*.dylib +..\%__SRC%\lib\*.a %_DEST%\lib\*.a +..\%__SRC%\slb\sb.lib %_DEST%\lib\xsb.lib +..\%__SRC%\srs\classes.srs %_DEST%\res\basic.srs +..\%COMMON_OUTDIR%\srs\classes_srs.hid %COMMON_DEST%\res\basic_srs.hid +..\%__SRC%\bin\sb?????.dll %_DEST%\bin\sb?????.dll +..\%__SRC%\bin\sb?????.sym %_DEST%\bin\sb?????.sym +..\%__SRC%\misc\sb?????.map %_DEST%\bin\sb?????.map +..\%__SRC%\bin\stt*.res %_DEST%\bin\stt*.res +..\%__SRC%\bin\sb*.res %_DEST%\bin\sb*.res +..\%__SRC%\lib\app.lib %_DEST%\lib\app.lib +..\%__SRC%\lib\libapp.a %_DEST%\lib\libapp.a +..\%__SRC%\lib\sample.lib %_DEST%\lib\sample.lib +..\%__SRC%\lib\libsample.a %_DEST%\lib\libsample.a -mkdir: %_DEST%\inc%_EXT%\basic -..\inc\basic\*.hxx %_DEST%\inc%_EXT%\basic\*.hxx -..\inc\basic\*.hrc %_DEST%\inc%_EXT%\basic\*.hrc -..\inc\basic\*.h %_DEST%\inc%_EXT%\basic\*.h +mkdir: %_DEST%\inc\basic +..\inc\basic\*.hxx %_DEST%\inc\basic\*.hxx +..\inc\basic\*.hrc %_DEST%\inc\basic\*.hrc +..\inc\basic\*.h %_DEST%\inc\basic\*.h -..\inc\modsizeexceeded.hxx %_DEST%\inc%_EXT%\basic\modsizeexceeded.hxx -..\%__SRC%\misc\sb.component %_DEST%\xml%_EXT%\sb.component +..\inc\modsizeexceeded.hxx %_DEST%\inc\basic\modsizeexceeded.hxx +..\%__SRC%\misc\sb.component %_DEST%\xml\sb.component diff --git a/basic/source/app/app.cxx b/basic/source/app/app.cxx index 34f9e5096fb1..558a01353fbd 100644 --- a/basic/source/app/app.cxx +++ b/basic/source/app/app.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,20 +29,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <tools/fsys.hxx> -#ifndef _SV_FILEDLG_HXX //autogen #include <svtools/filedlg.hxx> -#endif #include <tools/config.hxx> #include <vcl/font.hxx> -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif #include <basic/sbx.hxx> #include <svtools/filedlg.hxx> @@ -60,12 +55,9 @@ #include <basic/basrdll.hxx> #include "basrid.hxx" -#ifndef _RUNTIME_HXX #include "runtime.hxx" -#endif #include "sbintern.hxx" -#ifdef _USE_UNO #include <ucbhelper/contentbroker.hxx> #include <ucbhelper/configurationkeys.hxx> #include <comphelper/regpathhelper.hxx> @@ -81,14 +73,14 @@ using namespace comphelper; using namespace cppu; -using namespace rtl; using namespace com::sun::star; using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::ucb; using namespace com::sun::star::beans; -#endif /* _USE_UNO */ +using ::rtl::OUString; +using ::rtl::OUStringToOString; IMPL_GEN_RES_STR; @@ -161,23 +153,23 @@ void TestToolDebugMessageFilter( const sal_Char *pString, sal_Bool bIsOsl ) printf("DbgPrintMsgBox failed: %s\n", pString ); } } -/* DBG_INSTOUTERROR( DBG_OUT_MSGBOX ) - DBG_ERROR( pString ); - DBG_INSTOUTERROR( DBG_OUT_TESTTOOL )*/ static_bInsideFilter = sal_False; } + void SAL_CALL DBG_TestToolDebugMessageFilter( const sal_Char *pString ) { TestToolDebugMessageFilter( pString, sal_False ); } + extern "C" void SAL_CALL osl_TestToolDebugMessageFilter( const sal_Char *pString ) { if ( !getenv( "DISABLE_SAL_DBGBOX" ) ) TestToolDebugMessageFilter( pString, sal_True ); } + #endif -// #94145# Due to a tab in TT_SIGNATURE_FOR_UNICODE_TEXTFILES which is changed to blanks by some editors +// Due to a tab in TT_SIGNATURE_FOR_UNICODE_TEXTFILES which is changed to blanks by some editors // this routine became necessary sal_Bool IsTTSignatureForUnicodeTextfile( String aLine ) { @@ -209,38 +201,18 @@ uno::Reference< XContentProviderManager > InitializeUCB( void ) } - ////////////////////////////////////////////////////////////////////// // set global factory setProcessServiceFactory( xSMgr ); -/* // Create simple ConfigManager - Sequence< Any > aConfArgs(3); - aConfArgs[0] <<= PropertyValue( OUString::createFromAscii("servertype"), 0, makeAny( OUString::createFromAscii("local") ), ::com::sun::star::beans::PropertyState_DIRECT_VALUE ); - aConfArgs[1] <<= PropertyValue( OUString::createFromAscii("sourcepath"), 0, makeAny( OUString::createFromAscii("g:\\") ), ::com::sun::star::beans::PropertyState_DIRECT_VALUE ); - aConfArgs[2] <<= PropertyValue( OUString::createFromAscii("updatepath"), 0, makeAny( OUString::createFromAscii("g:\\") ), ::com::sun::star::beans::PropertyState_DIRECT_VALUE ); - - uno::Reference< XContentProvider > xConfProvider - ( xSMgr->createInstanceWithArguments( OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ), aConfArgs), UNO_QUERY ); -*/ - - // Create unconfigured Ucb: -/* Sequence< Any > aArgs(1); - aArgs[1] = makeAny ( xConfProvider );*/ Sequence< Any > aArgs; ::ucbhelper::ContentBroker::initialize( xSMgr, aArgs ); uno::Reference< XContentProviderManager > xUcb = ::ucbhelper::ContentBroker::get()->getContentProviderManagerInterface(); uno::Reference< XContentProvider > xFileProvider - ( xSMgr->createInstance( OUString::createFromAscii( "com.sun.star.ucb.FileContentProvider" ) ), UNO_QUERY ); - xUcb->registerContentProvider( xFileProvider, OUString::createFromAscii( "file" ), sal_True ); - - -/* uno::Reference< XContentProvider > xPackageProvider - ( xSMgr->createInstance( OUString::createFromAscii( "com.sun.star.ucb.PackageContentProvider" ) ), UNO_QUERY ); - xUcb->registerContentProvider( xPackageProvider, OUString::createFromAscii( "vnd.sun.star.pkg" ), sal_True ); - */ + ( xSMgr->createInstance( OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.FileContentProvider" )) ), UNO_QUERY ); + xUcb->registerContentProvider( xFileProvider, OUString(RTL_CONSTASCII_USTRINGPARAM( "file" )), sal_True ); return xUcb; } @@ -252,17 +224,10 @@ static void ReplaceStringHookProc( UniString& rStr ) if ( rStr.SearchAscii( "%PRODUCT" ) != STRING_NOTFOUND ) { rStr.SearchAndReplaceAllAscii( "%PRODUCTNAME", aTestToolName ); - /* - rStr.SearchAndReplaceAllAscii( "%PRODUCTVERSION", rVersion ); - rStr.SearchAndReplaceAllAscii( "%ABOUTBOXPRODUCTVERSION", rAboutBoxVersion ); - rStr.SearchAndReplaceAllAscii( "%PRODUCTEXTENSION", rExtension ); - rStr.SearchAndReplaceAllAscii( "%PRODUCTXMLFILEFORMATNAME", rXMLFileFormatName ); - rStr.SearchAndReplaceAllAscii( "%PRODUCTXMLFILEFORMATVERSION", rXMLFileFormatVersion ); - */ } } -void BasicApp::Main( ) +int BasicApp::Main( ) { #ifdef DBG_UTIL // Install filter for OSLAsserts @@ -271,17 +236,15 @@ void BasicApp::Main( ) DBG_INSTOUTERROR( DBG_OUT_TESTTOOL ); if ( osl_setDebugMessageFunc( osl_TestToolDebugMessageFilter ) ) - DBG_ERROR("osl_setDebugMessageFunc returns non NULL pointer"); + OSL_FAIL("osl_setDebugMessageFunc returns non NULL pointer"); #endif ResMgr::SetReadStringHook( ReplaceStringHookProc ); try { -#ifdef _USE_UNO + // this line is not ( afaics ) necessary ( remove from master ) uno::Reference< XContentProviderManager > xUcb = InitializeUCB(); -#endif - { DirEntry aIniPath( Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ) ); if ( !aIniPath.Exists() ) @@ -289,8 +252,8 @@ void BasicApp::Main( ) DirEntry aAppFileName( GetAppFileName() ); String aAppDir ( aAppFileName.GetPath().GetFull() ); -// DirEntry aDefIniPath( Config::GetConfigName( aAppDir, CUniString("testtool") ) ); -// Do not use Config::GetConfigName here because is uses a hidden file for UNIX + // Do not use Config::GetConfigName here because is uses a hidden + // file for UNIX DirEntry aDefIniPath( aAppDir ); ByteString aFileName; @@ -322,31 +285,12 @@ void BasicApp::Main( ) AllSettings aSettings = GetSettings(); aSettings.SetUILanguage( aRequestedLanguage ); aSettings.SetLanguage( aRequestedLanguage ); -// International aInternational; -// aInternational = GetSettings().GetInternational(); -// aInternational = International( aRequestedLanguage ); -// aSettings.SetInternational( aInternational ); SetSettings( aSettings ); -// aInternational = GetSettings().GetInternational(); } -// ResMgr::CreateResMgr( CREATEVERSIONRESMGR( stt ), ) -//const char* ResMgr::GetLang( LanguageType& nType, sal_uInt16 nPrio ) - -// ResMgr::CreateResMgr( CREATEVERSIONRESMGR( stt ) -// ResMgr *pRes = new ResMgr( "testtool.res" ); -// Resource::SetResManager( pRes ); - BasicDLL aBasicDLL; nWait = 0; - // Hilfe: -// pHelp = new Help; -// SetHelp( pHelp ); -// Help::EnableContextHelp(); -// Help::EnableExtHelp(); -// DeactivateExtHelp(); - // Acceleratoren Accelerator aAccel( SttResId( MAIN_ACCEL ) ); InsertAccel( &aAccel ); @@ -370,7 +314,6 @@ void BasicApp::Main( ) PostUserEvent( LINK( this, BasicApp, LateInit ) ); Execute(); -// delete pHelp; delete pFrame; RemoveAccel( pMainAccel ); @@ -390,6 +333,7 @@ void BasicApp::Main( ) InfoBox( NULL, String::CreateFromAscii( "unknown Exception not caught" ) ).Execute(); throw; } + return EXIT_SUCCESS; } void BasicApp::LoadIniFile() @@ -467,7 +411,6 @@ IMPL_LINK( BasicApp, LateInit, void *, pDummy ) return 0; } -////////////////////////////////////////////////////////////////////////// class FloatingExecutionStatus : public FloatingWindow { @@ -518,7 +461,6 @@ IMPL_LINK(FloatingExecutionStatus, HideNow, FloatingExecutionStatus*, pFLC ) return 0; } -////////////////////////////////////////////////////////////////////////// TYPEINIT1(TTExecutionStatusHint, SfxSimpleHint); @@ -543,16 +485,13 @@ BasicFrame::BasicFrame() : WorkWindow( NULL, bInBreak = sal_False; bDisas = sal_False; nFlags = 0; -// Icon aAppIcon; if ( pBasic->pTestObject ) // Are we the testtool? { -// aAppIcon = Icon( ResId( RID_APPICON2 ) ); aAppName = String( SttResId( IDS_APPNAME2 ) ); } else { -// aAppIcon = Icon( ResId( RID_APPICON ) ); aAppName = String( SttResId( IDS_APPNAME ) ); } @@ -625,7 +564,6 @@ BasicFrame::BasicFrame() : WorkWindow( NULL, LoadIniFile(); UpdateTitle(); -// SetIcon( aAppIcon ); // Size: half width, 0.75 * height - 2 * IconSize { @@ -634,15 +572,10 @@ BasicFrame::BasicFrame() : WorkWindow( NULL, SetWindowState( aConf.ReadKey("WinParams", "") ); } -// pWork = new AppEdit( this, NULL ); -// pWork->Show(); -// pWork->Close(); - aLineNum.SetTimeoutHdl( LINK( this, BasicFrame, ShowLineNr ) ); aLineNum.SetTimeout(200); aLineNum.Start(); - aCheckFiles.SetTimeout( 10000 ); aCheckFiles.SetTimeoutHdl( LINK( this, BasicFrame, CheckAllFiles ) ); aCheckFiles.Start(); @@ -688,17 +621,15 @@ void BasicFrame::LoadIniFile() if ( pBasic ) pBasic->LoadIniFile(); - for ( i = 0 ; i < pList->Count() ; i++ ) - pList->GetObject( i )->LoadIniFile(); + for ( i = 0 ; i < pList->size() ; i++ ) + pList->at( i )->LoadIniFile(); } BasicFrame::~BasicFrame() { - AppWin* p = pList->First(); - DBG_ASSERT( !p, "Still open FileWindows"); - if( p ) - while( (p = pList->Remove() ) != NULL ) - delete p; + for ( size_t i = 0, n = pList->size(); i < n; ++i ) + delete pList->at( i ); + pList->clear(); MenuBar *pBar = GetMenuBar(); SetMenuBar( NULL ); @@ -707,8 +638,6 @@ BasicFrame::~BasicFrame() delete pStatus; delete pPrn; delete pList; -// delete pExecutionStatus; -// delete pBasic; pBasic.Clear(); } @@ -762,8 +691,8 @@ IMPL_LINK( BasicFrame, CheckAllFiles, Timer*, pTimer ) { AppWin* pStartWin = pWork; Window* pFocusWin = Application::GetFocusWindow(); - for ( int i = pList->Count()-1 ; i >= 0 ; i-- ) - pList->GetObject( i )->CheckReload(); + for ( size_t i = pList->size() ; i > 0 ; ) + pList->at( --i )->CheckReload(); if ( pWork != pStartWin ) { @@ -810,19 +739,10 @@ void BasicFrame::Notify( SfxBroadcaster&, const SfxHint& rHint ) aTotalStatus.AppendAscii( " " ); aTotalStatus.Append( pStatusHint->GetAdditionalExecutionStatus() ); pStatus->Message( aTotalStatus ); -/* if ( !pExecutionStatus ) - pExecutionStatus = new FloatingExecutionStatus( this ); - pExecutionStatus->SetStatus( pStatusHint->GetExecutionStatus() ); - pExecutionStatus->SetAdditionalInfo( pStatusHint->GetAdditionalExecutionStatus() );*/ } break; case TT_EXECUTION_HIDE_ACTION: { -/* if ( pExecutionStatus ) - { - delete pExecutionStatus; - pExecutionStatus = NULL; - }*/ } break; } @@ -849,11 +769,10 @@ void BasicFrame::Resize() // Resize possibly maximized window - sal_uIntPtr i; - for( i = pList->Count(); i > 0 ; i-- ) + for( size_t i = pList->size(); i > 0 ; i-- ) { - if ( pList->GetObject( i-1 )->GetWinState() == TT_WIN_STATE_MAX ) - pList->GetObject( i-1 )->Maximize(); + if ( pList->at( i-1 )->GetWinState() == TT_WIN_STATE_MAX ) + pList->at( i-1 )->Maximize(); } } @@ -882,42 +801,58 @@ void BasicFrame::GetFocus() IMPL_LINK( BasicFrame, CloseButtonClick, void*, EMPTYARG ) { AppWin* p; - for ( p = pList->Last() ; p && p->GetWinState() != TT_WIN_STATE_MAX ; p = pList->Prev() ) - {}; - if ( p ) - p->GrabFocus(); + for ( size_t i = pList->size(); i > 0; --i ) + { + p = pList->at( i - 1 ); + if ( p->GetWinState() == TT_WIN_STATE_MAX ) + { + p->GrabFocus(); + break; + } + } return Command( RID_FILECLOSE, sal_False ); } IMPL_LINK( BasicFrame, FloatButtonClick, void*, EMPTYARG ) { AppWin* p; - for ( p = pList->Last() ; p && p->GetWinState() != TT_WIN_STATE_MAX ; p = pList->Prev() ) - {}; - if ( p ) - p->TitleButtonClick( TITLE_BUTTON_DOCKING ); + for ( size_t i = pList->size(); i > 0; --i ) + { + p = pList->at( i - 1 ); + if ( p->GetWinState() == TT_WIN_STATE_MAX ) + { + p->TitleButtonClick( TITLE_BUTTON_DOCKING ); + break; + } + } return 1; } IMPL_LINK( BasicFrame, HideButtonClick, void*, EMPTYARG ) { AppWin* p; - for ( p = pList->Last() ; p && p->GetWinState() != TT_WIN_STATE_MAX ; p = pList->Prev() ) - {}; - if ( p ) - p->TitleButtonClick( TITLE_BUTTON_HIDE ); + for ( size_t i = pList->size(); i > 0; --i ) + { + p = pList->at( i - 1 ); + if ( p->GetWinState() == TT_WIN_STATE_MAX ) + { + p->TitleButtonClick( TITLE_BUTTON_HIDE ); + break; + } + } return 1; } void BasicFrame::WinShow_Hide() { - if ( !pList->Count() ) + if ( pList->empty() ) return; AppWin* p; sal_Bool bWasFullscreen = sal_False; - for ( p = pList->Last() ; p ; p = pList->Prev() ) + for ( size_t i = pList->size(); i > 0; --i ) { + p = pList->at( i - 1 ); if ( p->pDataEdit ) { if ( p->GetWinState() & TT_WIN_STATE_HIDE // Hidden @@ -936,17 +871,26 @@ void BasicFrame::WinMax_Restore() // The application buttons AppWin* p; sal_Bool bHasFullscreenWin = sal_False; - for( p = pList->First(); p && !bHasFullscreenWin ; p = pList->Next() ) - bHasFullscreenWin |= ( p->GetWinState() == TT_WIN_STATE_MAX ); + for ( size_t i = 0, n = pList->size(); i < n && !bHasFullscreenWin; ++i ) + { + p = pList->at( i ); + bHasFullscreenWin = ( p->GetWinState() == TT_WIN_STATE_MAX ); + } GetMenuBar()->ShowButtons( bHasFullscreenWin, sal_False, sal_False ); WinShow_Hide(); } void BasicFrame::RemoveWindow( AppWin *pWin ) { -// delete pIcon; - pList->Remove( pWin ); - pWork = pList->Last(); + for ( EditList::iterator it = pList->begin(); it < pList->end(); ++it ) + { + if ( *it == pWin ) + { + pList->erase( it ); + break; + } + } + pWork = ( pList->empty() ) ? NULL : pList->back(); WinShow_Hide(); @@ -956,7 +900,8 @@ void BasicFrame::RemoveWindow( AppWin *pWin ) WinMax_Restore(); Menu* pMenu = GetMenuBar(); - if( pList->Count() == 0 ) { + if( pList->empty() ) + { pMenu->EnableItem( RID_APPEDIT, sal_False ); pMenu->EnableItem( RID_APPRUN, sal_False ); pMenu->EnableItem( RID_APPWINDOW, sal_False ); @@ -975,14 +920,15 @@ void BasicFrame::RemoveWindow( AppWin *pWin ) void BasicFrame::AddWindow( AppWin *pWin ) { - pList->Insert( pWin, LIST_APPEND ); + pList->push_back( pWin ); pWork = pWin; WinMax_Restore(); // Enable main menu MenuBar* pMenu = GetMenuBar(); - if( pList->Count() > 0 ) { + if( !pList->empty() ) + { pMenu->EnableItem( RID_APPEDIT, sal_True ); pMenu->EnableItem( RID_APPRUN, sal_True ); pMenu->EnableItem( RID_APPWINDOW, sal_True ); @@ -1020,8 +966,15 @@ void BasicFrame::WindowRenamed( AppWin *pWin ) void BasicFrame::FocusWindow( AppWin *pWin ) { pWork = pWin; - pList->Remove( pWin ); - pList->Insert( pWin, LIST_APPEND ); + for ( EditList::iterator it = pList->begin(); it < pList->end(); ++it ) + { + if ( *it == pWin ) + { + pList->erase( it ); + break; + } + } + pList->push_back( pWin ); pWin->Minimize( sal_False ); aAppFile = pWin->GetText(); @@ -1058,8 +1011,8 @@ sal_Bool BasicFrame::Close() sal_Bool BasicFrame::CloseAll() { - while ( pList->Count() ) - if ( !pList->Last()->Close() ) + while ( !pList->empty() ) + if ( !pList->back()->Close() ) return sal_False; return sal_True; } @@ -1067,8 +1020,11 @@ sal_Bool BasicFrame::CloseAll() sal_Bool BasicFrame::CompileAll() { AppWin* p; - for( p = pList->First(); p; p = pList->Next() ) - if( p->ISA(AppBasEd) && !((AppBasEd*)p)->Compile() ) return sal_False; + for ( size_t i = 0, n = pList->size(); i < n; ++i ) + { + p = pList->at( i ); + if ( p->ISA(AppBasEd) && !((AppBasEd*)p)->Compile() ) return sal_False; + } return sal_True; } @@ -1168,10 +1124,8 @@ IMPL_LINK( BasicFrame, InitMenu, Menu *, pMenu ) sal_Bool bNormal = sal_Bool( !bInBreak ); pMenu->EnableItem( RID_RUNCOMPILE, bNormal ); - sal_Bool bHasEdit = sal_Bool( /*bNormal &&*/ pWork != NULL ); + sal_Bool bHasEdit = sal_Bool( pWork != NULL ); -// pMenu->EnableItem( RID_FILENEW, bNormal ); // always possible -// pMenu->EnableItem( RID_FILEOPEN, bNormal ); pMenu->EnableItem( RID_FILECLOSE, bHasEdit ); pMenu->EnableItem( RID_FILESAVE, bHasEdit ); pMenu->EnableItem( RID_FILESAVEAS, bHasEdit ); @@ -1185,10 +1139,10 @@ IMPL_LINK( BasicFrame, InitMenu, Menu *, pMenu ) sal_Bool bPrev = bHasErr & bNormal; if( bHasErr ) { - sal_uIntPtr n = pBasic->aErrors.GetCurPos(); + size_t n = pBasic->GetCurrentError(); if( n == 0 ) bPrev = sal_False; - if( sal_uInt16(n+1) == pBasic->GetErrors() ) + if( SbError(n+1) == pBasic->GetErrors() ) bNext = sal_False; } pMenu->EnableItem( RID_RUNNEXTERR, bNext ); @@ -1203,20 +1157,7 @@ IMPL_LINK( BasicFrame, InitMenu, Menu *, pMenu ) IMPL_LINK_INLINE_START( BasicFrame, DeInitMenu, Menu *, pMenu ) { (void) pMenu; /* avoid warning about unused parameter */ -/* pMenu->EnableItem( RID_RUNCOMPILE ); - - pMenu->EnableItem( RID_FILECLOSE ); - pMenu->EnableItem( RID_FILESAVE ); - pMenu->EnableItem( RID_FILESAVEAS ); - pMenu->EnableItem( RID_FILEPRINT ); - pMenu->EnableItem( RID_FILESETUP ); - pMenu->EnableItem( RID_FILELOADLIB ); - pMenu->EnableItem( RID_FILESAVELIB ); - - pMenu->EnableItem( RID_RUNNEXTERR ); - pMenu->EnableItem( RID_RUNPREVERR ); - if( pWork ) pWork->DeInitMenu( pMenu ); -*/ + SetAutoRun( sal_False ); String aString; pStatus->Message( aString ); @@ -1350,7 +1291,6 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) AppBasEd* p = new AppBasEd( this, NULL ); p->Show(); p->GrabFocus(); - // InitMenu(GetMenuBar()->GetPopupMenu( RID_APPRUN )); } break; case RID_FILEOPEN: { @@ -1358,7 +1298,6 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) if( QueryFileName( s, FT_BASIC_SOURCE | FT_RESULT_FILE, sal_False ) ) { AddToLRU( s ); LoadFile( s ); -// InitMenu(GetMenuBar()->GetPopupMenu( RID_APPRUN )); } } break; case RID_FILELOADLIB: @@ -1369,7 +1308,6 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) break; case RID_FILECLOSE: if( pWork && pWork->Close() ){}; -// InitMenu(GetMenuBar()->GetPopupMenu( RID_APPRUN )); break; case RID_FILEPRINT: if( pWork ) @@ -1414,7 +1352,6 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) nFlags = SbDEBUG_BREAK; goto start; start: { -// InitMenu(GetMenuBar()->GetPopupMenu( RID_APPRUN )); if ( !Basic().IsRunning() || bInBreak ) { AppBasEd* p = NULL; @@ -1426,7 +1363,14 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) else { AppWin *w = NULL; - for ( w = pList->Last() ; w ? !w->ISA(AppBasEd) : sal_False ; w = pList->Prev() ) ; + for ( size_t i = pList->size(); i > 0; --i ) + { + if ( pList->at( i-1 )->ISA( AppBasEd ) ) + { + w = pList->at( i-1 ); + break; + } + } if ( w ) { p = ((AppBasEd*)w); @@ -1453,11 +1397,9 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) p->Run(); BasicDLL::SetDebugMode( sal_False ); // If cancelled during Interactive=FALSE -// BasicDLL::EnableBreak( sal_True ); } }} } -// InitMenu(GetMenuBar()->GetPopupMenu( RID_APPRUN )); // after run break; case RID_RUNCOMPILE: if( pWork && pWork->ISA(AppBasEd) && SaveAll() ) @@ -1473,7 +1415,6 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) case RID_RUNBREAK: if ( Basic().IsRunning() && !bInBreak ) { -// pINST->CalcBreakCallLevel(SbDEBUG_STEPINTO); pINST->nBreakCallLvl = pINST->nCallLvl; } break; @@ -1482,11 +1423,11 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) bInBreak = sal_False; break; case RID_RUNNEXTERR: - pErr = pBasic->aErrors.Next(); + pErr = pBasic->NextError(); if( pErr ) pErr->Show(); break; case RID_RUNPREVERR: - pErr = pBasic->aErrors.Prev(); + pErr = pBasic->PrevError(); if( pErr ) pErr->Show(); break; @@ -1503,13 +1444,12 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) case RID_WINTILE: { WindowArrange aArange; - for ( sal_uIntPtr i = 0 ; i < pList->Count() ; i++ ) + for ( size_t i = 0, n = pList->size(); i < n ; i++ ) { - aArange.AddWindow( pList->GetObject( i ) ); - pList->GetObject( i )->Restore(); + aArange.AddWindow( pList->at( i ) ); + pList->at( i )->Restore(); } - sal_Int32 nTitleHeight; { sal_Int32 nDummy1, nDummy2, nDummy3; @@ -1527,10 +1467,10 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) case RID_WINTILEHORZ: { WindowArrange aArange; - for ( sal_uIntPtr i = 0 ; i < pList->Count() ; i++ ) + for ( size_t i = 0, n = pList->size(); i < n ; i++ ) { - aArange.AddWindow( pList->GetObject( i ) ); - pList->GetObject( i )->Restore(); + aArange.AddWindow( pList->at( i ) ); + pList->at( i )->Restore(); } @@ -1549,16 +1489,12 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) } break; case RID_WINTILEVERT: -//#define WINDOWARRANGE_TILE 1 -//#define WINDOWARRANGE_HORZ 2 -//#define WINDOWARRANGE_VERT 3 -//#define WINDOWARRANGE_CASCADE 4 { WindowArrange aArange; - for ( sal_uIntPtr i = 0 ; i < pList->Count() ; i++ ) + for ( size_t i = 0, n = pList->size(); i < n ; i++ ) { - aArange.AddWindow( pList->GetObject( i ) ); - pList->GetObject( i )->Restore(); + aArange.AddWindow( pList->at( i ) ); + pList->at( i )->Restore(); } @@ -1578,26 +1514,14 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) break; case RID_WINCASCADE: { - for ( sal_uInt16 i = 0 ; i < pList->Count() ; i++ ) + for ( size_t i = 0, n = pList->size(); i < n ; i++ ) { - pList->GetObject( i )->Cascade( i ); + pList->at( i )->Cascade( i ); } } break; -/* case RID_HELPTOPIC: - if( pWork ) pWork->Help(); - break; - case RID_HELPKEYS: - aBasicApp.pHelp->Start( CUniString( "Keyboard" ) ); - break; - case RID_HELPINDEX: - aBasicApp.pHelp->Start( OOO_HELP_INDEX ); - break; - case RID_HELPINTRO: - aBasicApp.pHelp->Start( OOO_HELP_HELPONHELP ); - break; -*/ case RID_HELPABOUT: + case RID_HELPABOUT: { SttResId aResId( IDD_ABOUT_DIALOG ); if ( Basic().pTestObject ) // Are we TestTool? @@ -1630,14 +1554,11 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) AddToLRU( s ); LoadFile( s ); -// InitMenu(GetMenuBar()->GetPopupMenu( RID_APPRUN )); } else { -// InitMenu(GetMenuBar()->GetPopupMenu( RID_APPEDIT )); // So daß Delete richtig ist if( pWork ) pWork->Command( CommandEvent( Point(), nID ) ); -// InitMenu(GetMenuBar()->GetPopupMenu( RID_APPEDIT )); // So daß Delete richtig ist } } return sal_True; @@ -1646,8 +1567,9 @@ long BasicFrame::Command( short nID, sal_Bool bChecked ) sal_Bool BasicFrame::SaveAll() { AppWin* p, *q = pWork; - for( p = pList->First(); p; p = pList->Next() ) + for ( size_t i = 0, n = pList->size(); i < n ; i++ ) { + p = pList->at( i ); sal_uInt16 nRes = p->QuerySave( QUERY_DISK_CHANGED ); if( (( nRes == SAVE_RES_ERROR ) && QueryBox(this,SttResId(IDS_ASKSAVEERROR)).Execute() == RET_NO ) || ( nRes == SAVE_RES_CANCEL ) ) @@ -1666,8 +1588,9 @@ IMPL_LINK( BasicFrame, ModuleWinExists, String*, pFilename ) AppBasEd* BasicFrame::FindModuleWin( const String& rName ) { AppWin* p; - for( p = pList->First(); p; p = pList->Next() ) + for ( size_t i = 0, n = pList->size(); i < n ; i++ ) { + p = pList->at( i ); if( p->ISA(AppBasEd) && ((AppBasEd*)p)->GetModName() == rName ) return ((AppBasEd*)p); } @@ -1677,8 +1600,9 @@ AppBasEd* BasicFrame::FindModuleWin( const String& rName ) AppError* BasicFrame::FindErrorWin( const String& rName ) { AppWin* p; - for( p = pList->First(); p; p = pList->Next() ) + for ( size_t i = 0, n = pList->size(); i < n ; i++ ) { + p = pList->at( i ); if( p->ISA(AppError) && ((AppError*)p)->GetText() == rName ) return ((AppError*)p); } @@ -1688,8 +1612,9 @@ AppError* BasicFrame::FindErrorWin( const String& rName ) AppWin* BasicFrame::FindWin( const String& rName ) { AppWin* p; - for( p = pList->First(); p; p = pList->Next() ) + for ( size_t i = 0, n = pList->size(); i < n ; i++ ) { + p = pList->at( i ); if( p->GetText() == rName ) return p; } @@ -1699,8 +1624,9 @@ AppWin* BasicFrame::FindWin( const String& rName ) AppWin* BasicFrame::FindWin( sal_uInt16 nWinId ) { AppWin* p; - for( p = pList->First(); p; p = pList->Next() ) + for ( size_t i = 0, n = pList->size(); i < n ; i++ ) { + p = pList->at( i ); if( p->GetWinId() == nWinId ) return p; } @@ -1710,8 +1636,9 @@ AppWin* BasicFrame::FindWin( sal_uInt16 nWinId ) AppWin* BasicFrame::IsWinValid( AppWin* pMaybeWin ) { AppWin* p; - for( p = pList->First(); p; p = pList->Next() ) + for ( size_t i = 0, n = pList->size(); i < n ; i++ ) { + p = pList->at( i ); if( p == pMaybeWin ) return p; } @@ -1720,9 +1647,9 @@ AppWin* BasicFrame::IsWinValid( AppWin* pMaybeWin ) IMPL_LINK( BasicFrame, WriteString, String*, pString ) { - if ( pList->Last() ) + if ( !pList->empty() ) { - pList->Last()->pDataEdit->ReplaceSelected( *pString ); + pList->back()->pDataEdit->ReplaceSelected( *pString ); return sal_True; } else @@ -1762,8 +1689,6 @@ void NewFileDialog::FilterSelect() aConf.SetGroup( aCurrentProfile ); aLastPath = UniString( aConf.ReadKey( aFilterType, aConf.ReadKey( "BaseDir" ) ), RTL_TEXTENCODING_UTF8 ); SetPath( aLastPath ); -// if ( IsInExecute() ) -// SetPath( "" ); } short NewFileDialog::Execute() @@ -1822,19 +1747,12 @@ sal_Bool BasicFrame::QueryFileName aDlg.SetCurFilter( String( SttResId( IDS_BASFILTER ) ) ); aDlg.FilterSelect(); // Selects the last used path -// if ( bSave ) if ( rName.Len() > 0 ) aDlg.SetPath( rName ); if( aDlg.Execute() ) { rName = aDlg.GetPath(); -/* rExtension = aDlg.GetCurrentFilter(); - var i:integer; - for ( i = 0 ; i < aDlg.GetFilterCount() ; i++ ) - if ( rExtension == aDlg.GetFilterName( i ) ) - rExtension = aDlg.GetFilterType( i ); -*/ return sal_True; } else return sal_False; } @@ -1842,15 +1760,14 @@ sal_Bool BasicFrame::QueryFileName sal_uInt16 BasicFrame::BreakHandler() { bInBreak = sal_True; -// InitMenu(GetMenuBar()->GetPopupMenu( RID_APPRUN )); -// MenuBar aBar( ResId( RID_APPMENUBAR ) ); -// aBar.EnableItem( RID_APPEDIT, sal_False ); SetAppMode( String( SttResId ( IDS_APPMODE_BREAK ) ) ); - while( bInBreak ) + + while( bInBreak ) { GetpApp()->Yield(); + } + SetAppMode( String( SttResId ( IDS_APPMODE_RUN ) ) ); -// aBar.EnableItem( RID_APPEDIT, sal_True ); -// InitMenu(GetMenuBar()->GetPopupMenu( RID_APPRUN )); + return nFlags; } @@ -1919,13 +1836,8 @@ String BasicFrame::GenRealString( const String &aResString ) nEnd = nEnd + aString.Len(); aString.Erase(); } -// if ( Resource::GetResManager()->IsAvailable( ResId( aValue ) ) ) - aString = String( SttResId( (sal_uInt16)(aValue.ToInt32()) ) ); -// else - { -// DBG_ERROR( "Could not load resource!" ); -// return aResString; - } + + aString = String( SttResId( (sal_uInt16)(aValue.ToInt32()) ) ); nInsertPos = nStart; nStartPos = nStart; aResult.Erase( nStart, nEnd-nStart+1 ); @@ -1942,7 +1854,7 @@ String BasicFrame::GenRealString( const String &aResString ) } else { - DBG_ERROR( CByteString("Unknown replacement in String: ").Append( ByteString( aResult.Copy(nStart,nEnd-nStart), RTL_TEXTENCODING_UTF8 ) ).GetBuffer() ); + OSL_FAIL( CByteString("Unknown replacement in String: ").Append( ByteString( aResult.Copy(nStart,nEnd-nStart), RTL_TEXTENCODING_UTF8 ) ).GetBuffer() ); nStartPos = nStartPos + StartKenn.Len(); } } @@ -1955,3 +1867,4 @@ String BasicFrame::GenRealString( const String &aResString ) } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/app.hxx b/basic/source/app/app.hxx index 47dd5056fb58..3ef46edc2cb1 100644 --- a/basic/source/app/app.hxx +++ b/basic/source/app/app.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,23 +30,17 @@ #define _BASICAPP_HXX #include <vcl/svapp.hxx> -#ifndef _HELP_HXX //autogen #include <vcl/help.hxx> -#endif -#ifndef _MENU_HXX //autogen #include <vcl/menu.hxx> -#endif -#ifndef _WRKWIN_HXX //autogen #include <vcl/wrkwin.hxx> -#endif #include <vcl/timer.hxx> #include <svl/brdcst.hxx> #include <svl/lstner.hxx> class BasicFrame; #include <basic/mybasic.hxx> +#include <vector> -class EditList; class AppWin; class AppEdit; class AppBasEd; @@ -55,15 +50,15 @@ class StatusLine; class BasicPrinter; struct TTLogMsg; +typedef ::std::vector< AppWin* > EditList; + class BasicApp : public Application { short nWait; // Wait-Zaehler public: -// Help* pHelp; // Hilfesystem BasicFrame* pFrame; // Frame Window -// MenuBar* pMainMenu; // Hauptmenue Accelerator* pMainAccel; // Acceleratoren - void Main( ); + int Main( ); void LoadIniFile(); void SetFocus(); @@ -95,19 +90,18 @@ class BasicFrame : public WorkWindow, public SfxBroadcaster, public SfxListener using SystemWindow::Notify; using Window::Command; -virtual sal_Bool Close(); + virtual sal_Bool Close(); sal_Bool CloseAll(); // Close all windows sal_Bool CompileAll(); // Compile all texts AutoTimer aLineNum; // Show the line numbers -virtual void Resize(); -virtual void Move(); -virtual void GetFocus(); + virtual void Resize(); + virtual void Move(); + virtual void GetFocus(); void LoadLibrary(); void SaveLibrary(); sal_Bool bIsAutoRun; DisplayHidDlg* pDisplayHidDlg; -// BreakPoint *pRunToCursorBP; SbxVariable *pEditVar; @@ -195,3 +189,5 @@ public: extern BasicApp aBasicApp; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/appbased.cxx b/basic/source/app/appbased.cxx index fd7637fe26bf..4a3b94d057ec 100644 --- a/basic/source/app/appbased.cxx +++ b/basic/source/app/appbased.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,18 +29,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <basic/sbx.hxx> #include <svtools/texteng.hxx> #include <svtools/textview.hxx> #include <basic/sbmeth.hxx> #include <svtools/stringtransfer.hxx> -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif #include "basic.hrc" #include "status.hxx" @@ -59,10 +56,8 @@ AppBasEd::AppBasEd( BasicFrame* pParent, SbModule* p ) pBreakpoints->Show(); - ((TextEdit*)pDataEdit)->GetTextEditImp().pTextView->SetAutoIndentMode( sal_True ); ((TextEdit*)pDataEdit)->GetTextEditImp().pTextEngine->SetMaxTextLen( STRING_MAXLEN ); -// ((TextEdit*)pDataEdit)->GetTextEditImp().pTextEngine->SetWordDelimiters( CUniString(" ,.;:(){}[]\"'+-*/<>^\\") ); ((TextEdit*)pDataEdit)->GetTextEditImp().SyntaxHighlight( sal_True ); ((TextEdit*)pDataEdit)->SaveAsUTF8( sal_True ); @@ -79,10 +74,6 @@ AppBasEd::AppBasEd( BasicFrame* pParent, SbModule* p ) pBreakpoints->SetModule( pMod ); - // Define icon: -// pIcon = new Icon( ResId( RID_WORKICON ) ); -// if( pIcon ) SetIcon( *pIcon ); - SetText( pMod->GetName() ); pDataEdit->SetText( pMod->GetSource() ); @@ -210,7 +201,6 @@ void AppBasEd::LoadSource() { sal_Bool bErr; -// if( pDataEdit->GetText().Len() != 0 ) return; String aName = pMod->GetName(); bErr = !pDataEdit->Load( aName ); pBreakpoints->LoadBreakpoints( GetText() ); @@ -250,7 +240,7 @@ sal_Bool AppBasEd::Compile() } else { - BasicError* pErr = pFrame->Basic().aErrors.First(); + BasicError* pErr = pFrame->Basic().FirstError(); if( pErr ) pErr->Show(); } return bCompiled = bRes; @@ -287,7 +277,7 @@ void AppBasEd::Run() pMain->Run(); if (aBasicApp.pFrame) { - BasicError* pErr = aBasicApp.pFrame->Basic().aErrors.First(); + BasicError* pErr = aBasicApp.pFrame->Basic().FirstError(); if( pErr ) pErr->Show(); aBasicApp.pFrame->SetAppMode( String() ); @@ -297,3 +287,4 @@ void AppBasEd::Run() } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/appbased.hxx b/basic/source/app/appbased.hxx index ccda8ce68c69..22e9afa37bc1 100644 --- a/basic/source/app/appbased.hxx +++ b/basic/source/app/appbased.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,12 +30,8 @@ #define _APPBASED_HXX #include <basic/sbmod.hxx> -#ifndef _SB_APPEDIT_HXX #include "appedit.hxx" -#endif -#ifndef _SB_TEXTEDIT_HXX #include "textedit.hxx" -#endif class BasicFrame; class BreakpointWindow; @@ -72,3 +69,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/appedit.cxx b/basic/source/app/appedit.cxx index 9aa06ffad38e..1cf75d13c58a 100644 --- a/basic/source/app/appedit.cxx +++ b/basic/source/app/appedit.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -33,9 +34,7 @@ #include <svtools/texteng.hxx> #include <svl/undo.hxx> -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif #include "basic.hrc" #include "appedit.hxx" @@ -53,9 +52,6 @@ AppEdit::AppEdit( BasicFrame* pParent ) pDataEdit = new TextEdit( this, WB_LEFT ); LoadIniFile(); - // define Icon: -// pIcon = new Icon( ResId( RID_WORKICON ) ); -// if( pIcon ) SetIcon( *pIcon ); pDataEdit->SetText( aEmpty ); @@ -93,9 +89,7 @@ void AppEdit::LoadIniFile() String aFontStyle = String( aConf.ReadKey( "ScriptFontStyle", "normal" ), RTL_TEXTENCODING_UTF8 ); String aFontSize = String( aConf.ReadKey( "ScriptFontSize", "12" ), RTL_TEXTENCODING_UTF8 ); Font aFont = aFontList.Get( aFontName, aFontStyle ); -// sal_uIntPtr nFontSize = aFontSize.GetValue( FUNIT_POINT ); sal_uIntPtr nFontSize = aFontSize.ToInt32(); -// aFont.SetSize( Size( nFontSize, nFontSize ) ); aFont.SetHeight( nFontSize ); #if OSL_DEBUG_LEVEL > 1 @@ -104,8 +98,6 @@ void AppEdit::LoadIniFile() } #endif aFont.SetTransparent( sal_False ); -// aFont.SetAlign( ALIGN_BOTTOM ); -// aFont.SetHeight( aFont.GetHeight()+2 ); pDataEdit->SetFont( aFont ); if ( ((TextEdit*)pDataEdit)->GetBreakpointWindow() ) @@ -277,7 +269,6 @@ void AppEdit::Resize() aStartDocPos.Y() = nMaxVisAreaStart; pTextView->SetStartDocPos( aStartDocPos ); pTextView->ShowCursor(); -// pModulWindow->GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y(); } InitScrollBars(); if ( nVisY != pTextView->GetStartDocPos().Y() ) @@ -299,3 +290,4 @@ void AppEdit::Highlight( sal_uInt16 nLine, sal_uInt16 nCol1, sal_uInt16 nCol2 ) ToTop(); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/appedit.hxx b/basic/source/app/appedit.hxx index b2c71c09c454..67cb4337c6b0 100644 --- a/basic/source/app/appedit.hxx +++ b/basic/source/app/appedit.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,9 +29,7 @@ #ifndef _APPEDIT_HXX #define _APPEDIT_HXX -#ifndef _SCRBAR_HXX //autogen #include <vcl/scrbar.hxx> -#endif #include "appwin.hxx" #include "textedit.hxx" @@ -68,3 +67,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/apperror.cxx b/basic/source/app/apperror.cxx index 03c8aebd0bbe..04b9e8e34f0f 100644 --- a/basic/source/app/apperror.cxx +++ b/basic/source/app/apperror.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,7 @@ #include "precompiled_basic.hxx" #include <tools/config.hxx> #include <svtools/ctrltool.hxx> -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif #include "basic.hrc" #include "apperror.hxx" @@ -45,9 +44,6 @@ AppError::AppError( BasicFrame* pParent, String aFileName ) bHasFile = pDataEdit->Load( aFileName ); DirEntry aEntry( aFileName ); UpdateFileInfo( HAS_BEEN_LOADED ); - // Define icon -// pIcon = new Icon( ResId( RID_WORKICON ) ); -// if( pIcon ) SetIcon( *pIcon ); pDataEdit->Show(); GrabFocus(); @@ -103,13 +99,11 @@ void AppError::LoadIniFile() String aFontStyle = String( aConf.ReadKey( "ScriptFontStyle", "normal" ), RTL_TEXTENCODING_UTF8 ); String aFontSize = String( aConf.ReadKey( "ScriptFontSize", "12" ), RTL_TEXTENCODING_UTF8 ); Font aFont = aFontList.Get( aFontName, aFontStyle ); -// sal_uIntPtr nFontSize = aFontSize.GetValue( FUNIT_POINT ); sal_uIntPtr nFontSize = aFontSize.ToInt32(); -// aFont.SetSize( Size( nFontSize, nFontSize ) ); aFont.SetHeight( nFontSize ); aFont.SetTransparent( sal_False ); -// aFont.SetAlign( ALIGN_BOTTOM ); -// aFont.SetHeight( aFont.GetHeight()+2 ); pDataEdit->SetFont( aFont ); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/apperror.hxx b/basic/source/app/apperror.hxx index 3a7028aeae4b..a56645a262d8 100644 --- a/basic/source/app/apperror.hxx +++ b/basic/source/app/apperror.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -36,7 +37,6 @@ public: TYPEINFO(); AppError( BasicFrame*, String ); ~AppError(); -// long Command( short nID ); virtual long InitMenu( Menu* ); virtual long DeInitMenu( Menu* ); sal_uInt16 GetLineNr(); @@ -47,3 +47,4 @@ public: DirEntry aBaseDir; }; +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/appwin.cxx b/basic/source/app/appwin.cxx index eb80a96f4183..fc6d5ecfa548 100644 --- a/basic/source/app/appwin.cxx +++ b/basic/source/app/appwin.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,7 @@ #include "precompiled_basic.hxx" #include <stdio.h> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <tools/fsys.hxx> #include <svtools/stringtransfer.hxx> @@ -188,11 +187,9 @@ void AppWin::Help() // Trim leading whitespaces while( s.GetChar(0) == ' ' ) s.Erase( 0, 1 ); -// aBasicApp.pHelp->Start( s ); } else { -// aBasicApp.pHelp->Start( OOO_HELP_INDEX ); } } @@ -211,7 +208,6 @@ void AppWin::GetFocus() if( pDataEdit ) // GetFocus is called by the destructor, so this check { pDataEdit->GrabFocus(); -// InitMenu(GetpApp()->GetAppMenu()->GetPopupMenu( RID_APPEDIT )); } } @@ -221,7 +217,7 @@ long AppWin::PreNotify( NotifyEvent& rNEvt ) if ( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN ) Activate(); if ( rNEvt.GetType() == EVENT_GETFOCUS ) - if ( pFrame->pList->Last() != this ) + if ( pFrame->pList->back() != this ) Activate(); return sal_False; // Der event soll weiter verarbeitet werden } @@ -249,7 +245,6 @@ long AppWin::InitMenu( Menu* pMenu ) pMenu->EnableItem( RID_EDITCOPY, bMarked ); pMenu->EnableItem( RID_EDITPASTE, ( ::svt::OStringTransfer::PasteString( aTemp, this ) ) ); pMenu->EnableItem( RID_EDITDEL, bMarked ); -// pMenu->EnableItem( RID_HELPTOPIC, bMarked ); sal_Bool bHasText; if( pDataEdit ) @@ -317,7 +312,7 @@ void AppWin::Command( const CommandEvent& rCEvt ) } break; case RID_EDITDEL: - /*if( bHasMark ) */pDataEdit->Delete(); + pDataEdit->Delete(); break; case RID_EDITUNDO: pDataEdit->Undo(); @@ -370,8 +365,6 @@ sal_Bool AppWin::DiskFileChanged( sal_uInt16 nWhat ) else return DiskFileChanged( SINCE_LAST_ASK_RELOAD ); } -// uncomment to avoid compiler warning -// break; case SINCE_LAST_ASK_RELOAD: { String aFilename( GetText() ); @@ -382,10 +375,8 @@ sal_Bool AppWin::DiskFileChanged( sal_uInt16 nWhat ) return ( !aLastAccess.GetError() != !aStat.GetError() ) || aLastAccess.IsYounger( aStat ) || aStat.IsYounger( aLastAccess ); } -// uncomment to avoid compiler warning -// break; default: - DBG_ERROR("Not Implemented in AppWin::DiskFileChanged"); + OSL_FAIL("Not Implemented in AppWin::DiskFileChanged"); } return sal_True; } @@ -410,7 +401,7 @@ void AppWin::UpdateFileInfo( sal_uInt16 nWhat ) } break; default: - DBG_ERROR("Not Implemented in AppWin::UpdateFileInfo"); + OSL_FAIL("Not Implemented in AppWin::UpdateFileInfo"); } } @@ -427,7 +418,6 @@ void AppWin::CheckReload() if ( !aFile.Exists() ) return; -// FileStat aStat( aFile ); if ( DiskFileChanged( SINCE_LAST_ASK_RELOAD ) && ReloadAllowed() ) { @@ -461,8 +451,6 @@ sal_Bool AppWin::Load( const String& aName ) SkipReload(); sal_Bool bErr; -// if( !QuerySave() ) -// return; bErr = !pDataEdit->Load( aName ); if( bErr ) { @@ -585,7 +573,7 @@ sal_uInt16 AppWin::QuerySave( QueryBits nBits ) nReturn = SAVE_RES_CANCEL; break; default: - DBG_ERROR("switch default where no default should be: Internal error"); + OSL_FAIL("switch default where no default should be: Internal error"); nReturn = SAVE_RES_CANCEL; } SkipReload( sal_False ); @@ -603,18 +591,12 @@ sal_Bool AppWin::Close() delete this; return sal_True; } -// uncomment to avoid compiler warning -// break; case SAVE_RES_ERROR: return sal_False; -// uncomment to avoid compiler warning -// break; case SAVE_RES_CANCEL: return sal_False; -// uncomment to avoid compiler warning -// break; default: - DBG_ERROR("Not Implemented in AppWin::Close"); + OSL_FAIL("Not Implemented in AppWin::Close"); return sal_False; } } @@ -649,3 +631,4 @@ void AppWin::Repeat() pDataEdit->ReplaceSelected( aReplace ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/appwin.hxx b/basic/source/app/appwin.hxx index 928380d50df8..e5a79e042d8b 100644 --- a/basic/source/app/appwin.hxx +++ b/basic/source/app/appwin.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,14 +29,15 @@ #ifndef _APPWIN_HXX #define _APPWIN_HXX -//#include <sb.hxx> #include <vcl/dockwin.hxx> #include <tools/fsys.hxx> #include "app.hxx" #include "dataedit.hxx" +#include <vector> typedef sal_uInt16 QueryBits; + #define QUERY_NONE ( QueryBits ( 0x00 ) ) #define QUERY_DIRTY ( QueryBits ( 0x01 ) ) #define QUERY_DISK_CHANGED ( QueryBits ( 0x02 ) ) @@ -75,7 +77,6 @@ protected: short nId; // ID-Nummer( "Unnamed n" ) BasicFrame* pFrame; // Parent-Window -// Icon* pIcon; // Document icon String aFind; // Search string String aReplace; // Replace string sal_Bool bFind; // sal_True if search not replace @@ -133,6 +134,8 @@ public: void SetWinId( sal_uInt16 nWId ) { nWinId = nWId; } }; -DECLARE_LIST( EditList, AppWin* ) +typedef ::std::vector< AppWin* > EditList; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/basic.hrc b/basic/source/app/basic.hrc index e4a69d9d2942..e4a69d9d2942 100644..100755 --- a/basic/source/app/basic.hrc +++ b/basic/source/app/basic.hrc diff --git a/basic/source/app/basic.src b/basic/source/app/basic.src index 7f83ba8db2ba..754b35e1b56f 100644 --- a/basic/source/app/basic.src +++ b/basic/source/app/basic.src @@ -34,12 +34,6 @@ ModalDialog RID_CALLDLG { SVLook = TRUE; MOVEABLE = TRUE; CLOSEABLE = TRUE; -// WinChilds = { -// FixedText { -// Text = "Aktuelle Parameter"; -// PosSize = MAP_SYSFONT (10,10,120,8); -// }; -// }; FixedText RID_RETTYPE { PosSize = MAP_SYSFONT (10,70,120,8); }; @@ -68,41 +62,6 @@ ModalDialog IDD_ABOUT_DIALOG { Pos = MAP_APPFONT( 58, 17 ); Size = MAP_APPFONT( 155, 106 ); SVLook = TRUE; -/* - WINCHILDS = { - FixedText { - Pos = MAP_APPFONT( 40, 5 ); - Size = MAP_APPFONT( 110, 10 ); - TEXT = "Testtool"; - CENTER = TRUE; - }; - FixedText { - Pos = MAP_APPFONT( 40, 20 ); - Size = MAP_APPFONT( 110, 20 ); - TEXT = "Ojektorientiertes BASIC-Entwicklungssystem"; - CENTER = TRUE; - }; - FixedText { - Pos = MAP_APPFONT( 40, 45 ); - Size = MAP_APPFONT( 110, 10 ); - TEXT = "Version 2.0 May 2002"; - CENTER = TRUE; - }; - FixedText { - Pos = MAP_APPFONT( 40, 60 ); - Size = MAP_APPFONT( 110, 10 ); - TEXT = "®1995-2010 Oracle"; - CENTER = TRUE; - }; - }; -*/ -// FixedIcon RID_ICON { -// Pos = MAP_APPFONT( 20, 26 ); -// Size = MAP_APPFONT( 20, 20 ); -// FIXED = Icon { -// FILE = "basic.ico"; -// }; -// }; OKButton RID_OK { Pos = MAP_APPFONT( 55, 80 ); Size = MAP_APPFONT( 40, 14 ); @@ -148,7 +107,6 @@ ModalDialog IDD_FIND_DIALOG { Size = MAP_APPFONT( 185, 70 ); SVLook = TRUE; MOVEABLE = TRUE; - // CLOSEABLE = TRUE; // Hat cancelbutton FixedText RID_FIXEDTEXT1 { Pos = MAP_APPFONT( 5, 10 ); @@ -184,7 +142,6 @@ ModalDialog IDD_REPLACE_DIALOG { Size = MAP_APPFONT( 185, 88 ); SVLook = TRUE; MOVEABLE = TRUE; - // CLOSEABLE = TRUE; // Hat cancelbutton FixedText RID_FIXEDTEXT1 { Pos = MAP_APPFONT( 5, 10 ); Size = MAP_APPFONT( 55, 10 ); @@ -425,15 +382,6 @@ String IDS_CANCEL { String IDS_DISASWIN { TEXT[ en-US ] = "Disassembly"; }; -//Icon RID_APPICON { -// FILE = "basic.ico"; -//}; -//Icon RID_APPICON2 { -// FILE = "testtool.ico"; -//}; -//Icon RID_WORKICON { -// FILE = "work.ico"; -//}; Bitmap MBP_PLUS { File = "plus.bmp"; @@ -542,12 +490,10 @@ Menu RID_EDIT { MenuItem { Identifier = RID_EDITUNDO; TEXT[ en-US ] = "~Undo"; -// AccelKey = KeyCode { Function = KEYFUNC_CUT; }; }; MenuItem { Identifier = RID_EDITREDO; TEXT[ en-US ] = "~Redo"; -// AccelKey = KeyCode { Function = KEYFUNC_CUT; }; }; MenuItem { SEPARATOR = TRUE; @@ -588,7 +534,6 @@ Menu RID_EDIT { Identifier = RID_EDITREPEAT; TEXT[ en-US ] = "Repeat S~earch"; AccelKey = KeyCode { Code = KEY_F3; }; -// AccelKey = KeyCode { Function = KEYFUNC_REPEAT; }; }; }; }; @@ -617,11 +562,6 @@ Menu RID_RUN { TEXT[ en-US ] = "Si~ngle Step over Procedure"; AccelKey = KeyCode { Code = KEY_F10; }; }; -// MenuItem { -// Identifier = RID_RUNTOCURSOR; -// TEXT = "Run to cursor"; -// AccelKey = KeyCode { Code = KEY_F7; }; -// }; MenuItem { Identifier = RID_TOGLEBRKPNT; TEXT[ en-US ] = "Set / Delete Break Point"; @@ -652,9 +592,9 @@ Menu RID_RUN { }; }; }; -// Wird nur beim Test Tool eingef³gt +// This will be inserted from the Test Tool -// unter Folgendem Name +// under the following name String RID_TT_EXTRAS_NAME { Text[ en-US ] = "E~xtra"; @@ -675,52 +615,11 @@ Menu RID_TT_EXTRAS { }; Menu RID_WINDOW { ITEMLIST = { -/* MenuItem { - Identifier = RID_WINCASCADE; - TEXT[ en-US ] = "~Cascade"; - }; - MenuItem { - Identifier = RID_WINTILE; - TEXT[ en-US ] = "~Tile"; - }; - MenuItem { - Identifier = RID_WINTILEHORZ; - TEXT[ en-US ] = "~Arrange Horizontally"; - }; - MenuItem { - Identifier = RID_WINTILEVERT; - TEXT[ en-US ] = "~Arrange Vertically"; - };*/ }; }; Menu RID_HELP { ITEMLIST = { -/* MenuItem { - Identifier = RID_HELPINDEX; - TEXT = "~Index"; - }; MenuItem { - SEPARATOR = TRUE; - }; - MenuItem { - Identifier = RID_HELPKEYS; - TEXT = "~Tastaturbelegung"; - }; - MenuItem { - Identifier = RID_HELPINTRO; - TEXT = "~Anleitung"; - }; - MenuItem { - SEPARATOR = TRUE; - }; - MenuItem { - Identifier = RID_HELPTOPIC; - TEXT = "~Markierter Text"; - }; - MenuItem { - SEPARATOR = TRUE; - }; -*/ MenuItem { ABOUT = TRUE; Identifier = RID_HELPABOUT; TEXT[ en-US ] = "~About..."; @@ -1243,12 +1142,6 @@ FloatingWindow IDD_DISPLAY_HID { Border = TRUE; Pos = MAP_APPFONT( 0, 0 ); Size = MAP_APPFONT( 260, 14 ); -/* ItemList = { - ToolBoxItem { - Text = "erster der Toolbox"; - }; - };*/ -// Hide = TRUE; }; FixedText RID_FT_CONTROLS { Pos = MAP_APPFONT( 4, 16 ); @@ -1335,22 +1228,6 @@ Accelerator MAIN_ACCEL { Identifier = RID_QUIT; Key = KeyCode { Function = KEYFUNC_QUIT; }; }; -// AcceleratorItem { -// Identifier = RID_EDITCUT; -// Key = KeyCode { Function = KEYFUNC_CUT; }; -// }; -// AcceleratorItem { -// Identifier = RID_EDITCOPY; -// Key = KeyCode { Function = KEYFUNC_COPY; }; -// }; -// AcceleratorItem { -// Identifier = RID_EDITPASTE; -// Key = KeyCode { Function = KEYFUNC_PASTE; }; -// }; -// AcceleratorItem { -// Identifier = RID_EDITDEL; -// Key = KeyCode { Function = KEYFUNC_DELETE; }; -// }; AcceleratorItem { Identifier = RID_EDITSEARCH; Key = KeyCode { Function = KEYFUNC_FIND; }; @@ -1358,7 +1235,6 @@ Accelerator MAIN_ACCEL { AcceleratorItem { Identifier = RID_EDITREPEAT; Key = KeyCode { Code = KEY_F3; }; -// Key = KeyCode { Function = KEYFUNC_REPEAT; }; }; AcceleratorItem { Identifier = RID_RUNSTART; diff --git a/basic/source/app/basicrt.cxx b/basic/source/app/basicrt.cxx index 2df8df0d53fe..bd1638587c13 100644 --- a/basic/source/app/basicrt.cxx +++ b/basic/source/app/basicrt.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -142,3 +143,5 @@ sal_Bool BasicRuntimeAccess::IsRunInit() { return GetSbData()->bRunInit; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/basmsg.hrc b/basic/source/app/basmsg.hrc index 5f66605dc725..bfabe2c9759e 100644..100755 --- a/basic/source/app/basmsg.hrc +++ b/basic/source/app/basmsg.hrc @@ -27,17 +27,17 @@ #include "basic/ttglobal.hrc" -// Hier sind die Messages aus dem Verzeichnis /basic/source/app enhalten +// Here are included the messages of the folder /basic/source/app /////////////////////////////// -// Fehlermeldungen, die in das Resultfile gelangen. +// Error messages which go to the result file. // ********************* -// *** !!ACHTUNG!! *** +// *** !!ATTENTION!! *** // ********************* -// Die Nummern dürfen sich NIE! ändern, -// da sie in den Resultfiles gespeichert sind, und bei erneutem Anzeigen -// statdessen die entsprechenden neuen oder garkeine Strings angzeigt werden. +// The numbers must NEVER(!) change, +// because they are saved in the result files and a renewed display +// would display new strings or no strings. /////////////////////////////// #define S_PROG_START ( BAS_START + 0 ) diff --git a/basic/source/app/basmsg.src b/basic/source/app/basmsg.src index 6de25e82a170..1e0e3f5799e7 100644 --- a/basic/source/app/basmsg.src +++ b/basic/source/app/basmsg.src @@ -27,18 +27,17 @@ #include "basmsg.hrc" -// Hier sind die Messages aus dem Verzeichnis /basic/source/app enhalten +// Here are included the messages of the folder /basic/source/app -/////////////////////////////// -// Fehlermeldungen, die in das Resultfile gelangen. +// Error messages which go to the result file. // ********************* -// *** !!ACHTUNG!! *** +// *** !!ATTENTION!! *** // ********************* -// Die Nummern dürfen sich NIE! ändern, -// da sie in den Resultfiles gespeichert sind, und bei erneutem Anzeigen -// statdessen die entsprechenden neuen oder garkeine Strings angzeigt werden. -/////////////////////////////// +// The numbers must NEVER(!) change, +// because they are saved in the result files and a renewed display +// would display new strings or no strings. + String S_PROG_START { Text[ en-US ] = "Program start: ($Arg1); ($Arg2)"; diff --git a/basic/source/app/brkpnts.cxx b/basic/source/app/brkpnts.cxx index e7687222d5da..134c5194b7aa 100644 --- a/basic/source/app/brkpnts.cxx +++ b/basic/source/app/brkpnts.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,7 +28,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#include <tools/list.hxx> #include <basic/sbx.hxx> #include <basic/sbmod.hxx> #include <basic/sbstar.hxx> @@ -37,9 +37,7 @@ #include <tools/config.hxx> #include <vcl/gradient.hxx> -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif #include "brkpnts.hxx" #include "basic.hrc" @@ -48,15 +46,12 @@ struct Breakpoint { - sal_uInt16 nLine; - - Breakpoint( sal_uInt16 nL ) { nLine = nL; } + sal_uInt32 nLine; + Breakpoint( sal_uInt32 nL ) { nLine = nL; } }; - ImageList* BreakpointWindow::pImages = NULL; - BreakpointWindow::BreakpointWindow( Window *pParent ) : Window( pParent ) , nCurYOffset( 0 ) @@ -76,13 +71,9 @@ BreakpointWindow::BreakpointWindow( Window *pParent ) void BreakpointWindow::Reset() { - Breakpoint* pBrk = First(); - while ( pBrk ) - { - delete pBrk; - pBrk = Next(); - } - Clear(); + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) + delete BreakpointList[ i ]; + BreakpointList.clear(); pModule->ClearAllBP(); } @@ -103,14 +94,13 @@ void BreakpointWindow::SetBPsInModule() { pModule->ClearAllBP(); - Breakpoint* pBrk = First(); - while ( pBrk ) + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { + Breakpoint* pBrk = BreakpointList[ i ]; pModule->SetBP( (sal_uInt16)pBrk->nLine ); #if OSL_DEBUG_LEVEL > 1 - DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( (USHORT)pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" ); + DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( (sal_uInt16)pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" ); #endif - pBrk = Next(); } for ( sal_uInt16 nMethod = 0; nMethod < pModule->GetMethods()->Count(); nMethod++ ) { @@ -121,27 +111,30 @@ void BreakpointWindow::SetBPsInModule() } -void BreakpointWindow::InsertBreakpoint( sal_uInt16 nLine ) +void BreakpointWindow::InsertBreakpoint( sal_uInt32 nLine ) { Breakpoint* pNewBrk = new Breakpoint( nLine ); - Breakpoint* pBrk = First(); - while ( pBrk ) + + for ( ::std::vector< Breakpoint* >::iterator i = BreakpointList.begin(); + i < BreakpointList.end(); + ++ i + ) { + Breakpoint* pBrk = *i; if ( nLine <= pBrk->nLine ) { - if ( pBrk->nLine != nLine ) - Insert( pNewBrk ); + if ( nLine != pBrk->nLine ) + BreakpointList.insert( i, pNewBrk ); else delete pNewBrk; pNewBrk = NULL; - pBrk = NULL; + break; } - else - pBrk = Next(); } + // No insert position found => LIST_APPEND if ( pNewBrk ) - Insert( pNewBrk, LIST_APPEND ); + BreakpointList.push_back( pNewBrk ); Invalidate(); @@ -166,35 +159,34 @@ void BreakpointWindow::InsertBreakpoint( sal_uInt16 nLine ) } -Breakpoint* BreakpointWindow::FindBreakpoint( sal_uIntPtr nLine ) +Breakpoint* BreakpointWindow::FindBreakpoint( sal_uInt32 nLine ) { - Breakpoint* pBrk = First(); - while ( pBrk ) + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { - if ( pBrk->nLine == nLine ) - return pBrk; - - pBrk = Next(); + Breakpoint* pBP = BreakpointList[ i ]; + if ( pBP->nLine == nLine ) + return pBP; } - - return (Breakpoint*)0; + return NULL; } -void BreakpointWindow::AdjustBreakpoints( sal_uIntPtr nLine, sal_Bool bInserted ) +void BreakpointWindow::AdjustBreakpoints( sal_uInt32 nLine, bool bInserted ) { if ( nLine == 0 ) //TODO: nLine == TEXT_PARA_ALL+1 return; - Breakpoint* pBrk = First(); - while ( pBrk ) + + for ( size_t i = 0; i < BreakpointList.size(); ) { - sal_Bool bDelBrk = sal_False; + Breakpoint* pBrk = BreakpointList[ i ]; + bool bDelBrk = false; + if ( pBrk->nLine == nLine ) { if ( bInserted ) pBrk->nLine++; else - bDelBrk = sal_True; + bDelBrk = true; } else if ( pBrk->nLine > nLine ) { @@ -203,18 +195,19 @@ void BreakpointWindow::AdjustBreakpoints( sal_uIntPtr nLine, sal_Bool bInserted else pBrk->nLine--; } - if ( bDelBrk ) { - sal_uIntPtr n = GetCurPos(); - delete Remove( pBrk ); - pBrk = Seek( n ); + delete pBrk; + ::std::vector< Breakpoint* >::iterator it = BreakpointList.begin(); + ::std::advance( it, i ); + BreakpointList.erase( it ); } else { - pBrk = Next(); + ++i; } } + Invalidate(); } @@ -241,14 +234,12 @@ void BreakpointWindow::SaveBreakpoints( String aFilename ) { ByteString aBreakpoints; - Breakpoint* pBrk = First(); - while ( pBrk ) + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { + Breakpoint* pBrk = BreakpointList[ i ]; if ( aBreakpoints.Len() ) aBreakpoints += ';'; - aBreakpoints += ByteString::CreateFromInt32( pBrk->nLine ); - pBrk = Next(); } Config aConfig(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") )); @@ -274,16 +265,15 @@ void BreakpointWindow::Paint( const Rectangle& ) aBmpOff.X() = ( aOutSz.Width() - aBmpSz.Width() ) / 2; aBmpOff.Y() = ( nLineHeight - aBmpSz.Height() ) / 2; - Breakpoint* pBrk = First(); - while ( pBrk ) + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { + Breakpoint* pBrk = BreakpointList[ i ]; #if OSL_DEBUG_LEVEL > 1 DBG_ASSERT( !pModule->IsCompiled() || pModule->IsBP( pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" ); #endif - sal_uIntPtr nLine = pBrk->nLine-1; - sal_uIntPtr nY = nLine*nLineHeight - nCurYOffset; + sal_Int32 nLine = pBrk->nLine-1; + sal_Int32 nY = nLine*nLineHeight - nCurYOffset; DrawImage( Point( 0, nY ) + aBmpOff, aBrk ); - pBrk = Next(); } ShowMarker( sal_True ); } @@ -291,39 +281,46 @@ void BreakpointWindow::Paint( const Rectangle& ) Breakpoint* BreakpointWindow::FindBreakpoint( const Point& rMousePos ) { - long nLineHeight = GetTextHeight(); - long nYPos = rMousePos.Y() + nCurYOffset; + sal_Int32 nLineHeight = GetTextHeight(); + sal_Int32 nYPos = rMousePos.Y() + nCurYOffset; - Breakpoint* pBrk = First(); - while ( pBrk ) + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { - sal_uIntPtr nLine = pBrk->nLine-1; - long nY = nLine*nLineHeight; + Breakpoint* pBrk = BreakpointList[ i ]; + sal_Int32 nLine = pBrk->nLine-1; + sal_Int32 nY = nLine * nLineHeight; if ( ( nYPos > nY ) && ( nYPos < ( nY + nLineHeight ) ) ) return pBrk; - pBrk = Next(); } - return 0; + return NULL; } -void BreakpointWindow::ToggleBreakpoint( sal_uInt16 nLine ) +void BreakpointWindow::ToggleBreakpoint( sal_uInt32 nLine ) { - Breakpoint* pBrk = FindBreakpoint( nLine ); - if ( pBrk ) // remove + bool Removed = false; + for ( size_t i = 0, n = BreakpointList.size(); i < n; ++i ) { - pModule->ClearBP( nLine ); - delete Remove( pBrk ); + Breakpoint* pBP = BreakpointList[ i ]; + if ( pBP->nLine == nLine ) // remove + { + pModule->ClearBP( nLine ); + delete pBP; + ::std::vector< Breakpoint* >::iterator it = BreakpointList.begin(); + ::std::advance( it, i ); + BreakpointList.erase( it ); + Removed = true; + break; + } } - else // create one - { + + if ( !Removed ) // create one InsertBreakpoint( nLine ); - } Invalidate(); } -void BreakpointWindow::ShowMarker( sal_Bool bShow ) +void BreakpointWindow::ShowMarker( bool bShow ) { if ( nMarkerPos == MARKER_NOMARKER ) return; @@ -367,12 +364,12 @@ void BreakpointWindow::MouseButtonDown( const MouseEvent& rMEvt ) } -void BreakpointWindow::SetMarkerPos( sal_uInt16 nLine, sal_Bool bError ) +void BreakpointWindow::SetMarkerPos( sal_uInt32 nLine, bool bError ) { - ShowMarker( sal_False ); // Remove old one + ShowMarker( false ); // Remove old one nMarkerPos = nLine; bErrorMarker = bError; - ShowMarker( sal_True ); // Draw new one + ShowMarker( true ); // Draw new one Update(); } @@ -384,3 +381,4 @@ void BreakpointWindow::Scroll( long nHorzScroll, long nVertScroll, sal_uInt16 nF Window::Scroll( nHorzScroll, nVertScroll ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/brkpnts.hxx b/basic/source/app/brkpnts.hxx index 64d5c0a9d0d7..5ea60c8e7608 100644 --- a/basic/source/app/brkpnts.hxx +++ b/basic/source/app/brkpnts.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,69 +27,52 @@ ************************************************************************/ #include <vcl/window.hxx> +#include <vector> #define MARKER_NOMARKER 0xFFFF - class SbModule; -class BreakpointListe; struct Breakpoint; class ImageList; -DECLARE_LIST( BreakpointList, Breakpoint* ) - -class BreakpointWindow : public Window, public BreakpointList +class BreakpointWindow : public Window { using Window::Scroll; public: BreakpointWindow( Window *pParent ); -// ~BreakpointWindow(); void Reset(); void SetModule( SbModule *pMod ); void SetBPsInModule(); - void InsertBreakpoint( sal_uInt16 nLine ); - void ToggleBreakpoint( sal_uInt16 nLine ); - void AdjustBreakpoints( sal_uIntPtr nLine, sal_Bool bInserted ); + void InsertBreakpoint( sal_uInt32 nLine ); + void ToggleBreakpoint( sal_uInt32 nLine ); + void AdjustBreakpoints( sal_uInt32 nLine, bool bInserted ); void LoadBreakpoints( String aFilename ); void SaveBreakpoints( String aFilename ); -protected: - Breakpoint* FindBreakpoint( sal_uIntPtr nLine ); - private: - long nCurYOffset; - sal_uInt16 nMarkerPos; - SbModule* pModule; - sal_Bool bErrorMarker; - static ImageList *pImages; + ::std::vector< Breakpoint* > BreakpointList; + long nCurYOffset; + sal_uInt32 nMarkerPos; + SbModule* pModule; + bool bErrorMarker; + static ImageList* pImages; protected: virtual void Paint( const Rectangle& ); Breakpoint* FindBreakpoint( const Point& rMousePos ); - void ShowMarker( sal_Bool bShow ); + Breakpoint* FindBreakpoint( sal_uInt32 nLine ); + void ShowMarker( bool bShow ); virtual void MouseButtonDown( const MouseEvent& rMEvt ); public: - -// void SetModulWindow( ModulWindow* pWin ) -// { pModulWindow = pWin; } - - void SetMarkerPos( sal_uInt16 nLine, sal_Bool bErrorMarker = sal_False ); - - virtual void Scroll( long nHorzScroll, long nVertScroll, - sal_uInt16 nFlags = 0 ); + void SetMarkerPos( sal_uInt32 nLine, bool bErrorMarker = false ); + virtual void Scroll( long nHorzScroll, long nVertScroll, sal_uInt16 nFlags = 0 ); long& GetCurYOffset() { return nCurYOffset; } }; - - - - - - - +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/dataedit.hxx b/basic/source/app/dataedit.hxx index 29148bc79919..60ab6626a85f 100644 --- a/basic/source/app/dataedit.hxx +++ b/basic/source/app/dataedit.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -114,3 +115,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/dialogs.cxx b/basic/source/app/dialogs.cxx index 85f09b6b6cd0..20b7bd1c7cf8 100644 --- a/basic/source/app/dialogs.cxx +++ b/basic/source/app/dialogs.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,36 +33,22 @@ #include <algorithm> #include <tools/rc.hxx> #include <vcl/metric.hxx> -#ifndef _DIALOG_HXX //autogen #include <vcl/dialog.hxx> -#endif -#ifndef _BUTTON_HXX //autogen #include <vcl/button.hxx> -#endif -#ifndef _FIXED_HXX //autogen #include <vcl/fixed.hxx> -#endif -#ifndef _EDIT_HXX //autogen #include <vcl/edit.hxx> -#endif #include <tools/config.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <tools/debug.hxx> -#ifndef _SV_FILEDLG_HXX //autogen #include <svtools/filedlg.hxx> -#endif #include <tools/stream.hxx> #include <tools/fsys.hxx> #include <svtools/stringtransfer.hxx> #include <vcl/splitwin.hxx> -#ifndef _ZFORLIST_HXX //autogen #include <svl/zformat.hxx> -#endif #include <svtools/ctrltool.hxx> -// Ohne Includeschutz + #include <svtools/svtdata.hxx> #include <svl/solar.hrc> @@ -87,7 +74,6 @@ AboutDialog::AboutDialog( Window* pParent, const ResId& id ) FreeResource(); } -//////////////////////////////////////////////////////////////////// FindDialog::FindDialog( Window* pParent, const ResId& id, String& Text ) : ModalDialog( pParent, id ) @@ -143,7 +129,6 @@ IMPL_LINK( ReplaceDialog, ButtonClick, Button *, pB ) return sal_True; } -//////////////////////////////////////////////////////////////////// void CheckButtons( ComboBox &aCB, Button &aNewB, Button &aDelB ) @@ -219,12 +204,18 @@ OptConfEdit::OptConfEdit( Window* pParent, sal_uInt16 nResCheck, sal_uInt16 nRes rBase.SetModifyHdl( LINK( this, OptConfEdit, BaseModifyHdl ) ); } +#if defined(WNT) + #define FSYS_STYLE_DEFAULT FSYS_STYLE_NTFS +# else + #define FSYS_STYLE_DEFAULT FSYS_STYLE_UNX +#endif + void OptConfEdit::Reload( Config &aConf ) { ConfEdit::Reload( aConf ); DirEntry aCalculatedHIDDir( rBase.GetValue() ); - aCalculatedHIDDir += DirEntry( "global/hid", FSYS_STYLE_FAT ); + aCalculatedHIDDir += DirEntry( "global/hid", FSYS_STYLE_DEFAULT ); DirEntry aCurrentHIDDir( aEdit.GetText() ); @@ -246,7 +237,7 @@ IMPL_LINK( OptConfEdit, BaseModifyHdl, Edit*, EMPTYARG ) if ( aCheck.IsChecked() ) { DirEntry aCalculatedHIDDir( rBase.GetValue() ); - aCalculatedHIDDir += DirEntry( "global/hid", FSYS_STYLE_FAT ); + aCalculatedHIDDir += DirEntry( "global/hid", FSYS_STYLE_DEFAULT ); aEdit.SetText( aCalculatedHIDDir.GetFull() ); } return 0; @@ -314,7 +305,7 @@ IMPL_LINK( OptionsDialog, ActivatePageHdl, TabControl *, pTabCtrl ) case RID_TP_FON: pNewTabPage = new FontOptions( pTabCtrl, aConfig ); break; - default: DBG_ERROR( "PageHdl: Unbekannte ID!" ); + default: OSL_FAIL( "PageHdl: Unbekannte ID!" ); } DBG_ASSERT( pNewTabPage, "Keine Page!" ); pTabCtrl->SetTabPage( nId, pNewTabPage ); @@ -690,9 +681,6 @@ FontOptions::FontOptions( Window* pParent, Config &aConfig ) aFontName.EnableWYSIWYG(); aFontName.EnableSymbols(); -// aFontSize.SetUnit( FUNIT_POINT ); -// MapMode aMode( MAP_POINT ); -// aFTPreview.SetMapMode( aMode ); aFontName.SetModifyHdl( LINK( this, FontOptions, FontNameChanged ) ); aFontStyle.SetModifyHdl( LINK( this, FontOptions, FontStyleChanged ) ); @@ -735,7 +723,6 @@ IMPL_LINK( FontOptions, FontSizeChanged, void*, EMPTYARG ) void FontOptions::UpdatePreview() { Font aFont = aFontList.Get( aFontName.GetText(), aFontStyle.GetText() ); -// sal_uIntPtr nFontSize = aFontSize.GetValue( FUNIT_POINT ); sal_uIntPtr nFontSize = static_cast<sal_uIntPtr>((aFontSize.GetValue() + 5) / 10); aFont.SetHeight( nFontSize ); aFTPreview.SetFont( aFont ); @@ -805,7 +792,7 @@ StringList* GenericOptions::GetAllGroups() for ( sal_uInt16 i = 0 ; i < aConf.GetGroupCount() ; i++ ) { String *pGroup = new String( aConf.GetGroupName( i ), RTL_TEXTENCODING_UTF8 ); - pGroups->Insert( pGroup ); + pGroups->push_back( pGroup ); } return pGroups; } @@ -813,31 +800,29 @@ StringList* GenericOptions::GetAllGroups() void GenericOptions::LoadData() { StringList* pGroups = GetAllGroups(); - String* pGroup; - while ( (pGroup = pGroups->First()) != NULL ) + for ( size_t i = 0, n = pGroups->size(); i < n; ++i ) { - pGroups->Remove( pGroup ); + String* pGroup = pGroups->at( i ); aConf.SetGroup( ByteString( *pGroup, RTL_TEXTENCODING_UTF8 ) ); if ( aConf.ReadKey( C_KEY_AKTUELL ).Len() > 0 ) - { aCbArea.InsertEntry( *pGroup ); - } delete pGroup; } + pGroups->clear(); delete pGroups; - aCbArea.SetText( aCbArea.GetEntry( 0 ) ); + aCbArea.SetText( aCbArea.GetEntry( 0 ) ); CheckButtons( aCbArea, aPbNewArea, aPbDelArea ); // Add load the data LINK( this, GenericOptions, LoadGroup ).Call( NULL ); } -void GenericOptions::ShowSelectPath( const String aType ) +void GenericOptions::ShowSelectPath( const String &rType ) { Point aNPos = aPbNewValue.GetPosPixel(); Point aDPos = aPbDelValue.GetPosPixel(); long nDelta = aDPos.Y() - aNPos.Y(); - if ( aType.EqualsIgnoreCaseAscii( "PATH" ) && !bShowSelectPath ) + if ( rType.EqualsIgnoreCaseAscii( "PATH" ) && !bShowSelectPath ) { // Show Path button nMoveButtons += nDelta; aMoveTimer.Start(); @@ -845,7 +830,7 @@ void GenericOptions::ShowSelectPath( const String aType ) aPbSelectPath.Show( sal_True ); aPbSelectPath.Enable( sal_True ); } - else if ( !aType.EqualsIgnoreCaseAscii( "PATH" ) && bShowSelectPath ) + else if ( !rType.EqualsIgnoreCaseAscii( "PATH" ) && bShowSelectPath ) { // Hide Path button nMoveButtons -= nDelta; aMoveTimer.Start(); @@ -1096,15 +1081,6 @@ DisplayHidDlg::DisplayHidDlg( Window * pParent ) { FreeResource(); -/* ResMgr* pRM = CREATERESMGR( svt ); - ToolBox aOrig( this, ResId( 12345, pRM ) ); - delete pRM; - - aTbConf.CopyItem( aOrig, 4 ); - aTbConf.InsertSeparator(); - aTbConf.CopyItem( aOrig, 5 ); - aTbConf.CopyItem( aOrig, 6 ); - aTbConf.CopyItem( aOrig, 7 ); */ aTbConf.SetOutStyle( TOOLBOX_STYLE_FLAT ); #if OSL_DEBUG_LEVEL < 2 @@ -1199,8 +1175,6 @@ void DisplayHidDlg::AddData( WinInfoRec* pWinInfo ) if ( pWinInfo->nRType & DH_MODE_DATA_VALID ) // no old office nDisplayMode = pWinInfo->nRType; // Is used for mode transmission while reset -// if ( pWinInfo->aUId.GetULONG() & DH_MODE_DATA_VALID ) // kein altes Office -// nDisplayMode = pWinInfo->aUId.GetULONG(); // Wird im Reset zur �bermittlung des Modus verwendet return; } @@ -1266,8 +1240,6 @@ void DisplayHidDlg::Resize() } else { -// SetUpdateMode( sal_False ); - // Minimum size Size aSize( GetOutputSizePixel() ); aSize.Width() = std::max( aSize.Width(), (long)(aOKClose.GetSizePixel().Width() * 3 )); @@ -1321,9 +1293,6 @@ void DisplayHidDlg::Resize() aPos.Move( nSpace, -aOKClose.GetSizePixel().Height() ); aPos.Move( pSplit->GetSizePixel().Width(), pSplit->GetSizePixel().Height() ); aOKClose.SetPosPixel( aPos ); - -// SetUpdateMode( sal_True ); -// Invalidate(); } FloatingWindow::Resize(); } @@ -1363,9 +1332,6 @@ VarEditDialog::VarEditDialog( Window * pParent, SbxVariable *pPVar ) else aRadioButtonRID_RB_NEW_BOOL_F.Check(); break; -// case SbxCURRENCY: -// case SbxDATE: -// break; case SbxINTEGER: aNumericFieldRID_NF_NEW_INTEGER.Show(); aNumericFieldRID_NF_NEW_INTEGER.SetText( pVar->GetString() ); @@ -1379,8 +1345,6 @@ VarEditDialog::VarEditDialog( Window * pParent, SbxVariable *pPVar ) aNumericFieldRID_NF_NEW_LONG.SetMin( -aNumericFieldRID_NF_NEW_LONG.GetMax()-1 ); aNumericFieldRID_NF_NEW_LONG.SetFirst( -aNumericFieldRID_NF_NEW_LONG.GetLast()-1 ); break; -// case SbxOBJECT: // cannot be edited -// break; case SbxSINGLE: case SbxDOUBLE: case SbxSTRING: @@ -1406,41 +1370,6 @@ IMPL_LINK( VarEditDialog, OKClick, Button *, pButton ) SbxDataType eType = pVar->GetType(); -/* -Boolean -Currency -Date -Double -Integer -Long -Object -Single -String -Variant - - -atof - - ecvt - f - gcvt - -SvNumberformat:: - static double StringToDouble( const xub_Unicode* pStr, - const International& rIntl, - int& nErrno, - const xub_Unicode** ppEnd = NULL ); - // Converts just as strtod a decimal string to a double. - // Decimal and thousand separators come from International, - // leading spaces are omitted. - // If ppEnd!=NULL then *ppEnd is set after the parsed data. - // If pStr contains only the String to be parsed, then if success: - // **ppEnd=='\0' and *ppEnd-pStr==strlen(pStr). - // If overflow fVal=+/-HUGE_VAL, if underflow 0, - // nErrno is in this cases set to ERANGE otherwise 0. - // "+/-1.#INF" are recognized as +/-HUGE_VAL. - - */ @@ -1451,12 +1380,6 @@ SvNumberformat:: case SbxBOOL: pVar->PutBool( aRadioButtonRID_RB_NEW_BOOL_T.IsChecked() ); break; -// case SbxCURRENCY: -// pVar->PutCurrency( aContent ); -// break; -// case SbxDATE: -// pVar->PutDate( aContent ); -// break; case SbxINTEGER: pVar->PutInteger( (sal_Int16)aNumericFieldRID_NF_NEW_INTEGER.GetValue() ); break; @@ -1479,7 +1402,6 @@ SvNumberformat:: } -// pVar->PutStringExt( aEditRID_ED_NEW_STRING.GetText() ); if ( !bWasError && SbxBase::IsError() ) { bError = sal_True; @@ -1492,12 +1414,6 @@ SvNumberformat:: return 1; } -// if ( aEditRID_ED_NEW_STRING.GetText().Compare( pVar->GetString() ) != COMPARE_EQUAL ) -// { -// aFixedTextRID_FT_CONTENT_VALUE.SetText( pVar->GetString() ); -// aEditRID_ED_NEW_STRING.SetText( pVar->GetString() ); -// return 1; -// } Close(); return 0; @@ -1505,3 +1421,4 @@ SvNumberformat:: +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/dialogs.hxx b/basic/source/app/dialogs.hxx index e0a2409ad937..ce06a1154420 100644 --- a/basic/source/app/dialogs.hxx +++ b/basic/source/app/dialogs.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,37 +29,25 @@ #ifndef _DIALOGS_HXX #define _DIALOGS_HXX -#ifndef _DIALOG_HXX //autogen #include <vcl/dialog.hxx> -#endif -#ifndef _BUTTON_HXX //autogen #include <vcl/button.hxx> -#endif -#ifndef _EDIT_HXX //autogen #include <vcl/edit.hxx> -#endif -#ifndef _FIELD_HXX //autogen #include <vcl/field.hxx> -#endif #include <vcl/fixed.hxx> #include <vcl/tabdlg.hxx> #include <vcl/tabctrl.hxx> #include <vcl/tabpage.hxx> #include <tools/config.hxx> -#ifndef _TOOLS_LIST_HXX -#include <tools/list.hxx> -#endif #include <vcl/lstbox.hxx> #include <vcl/floatwin.hxx> #include <vcl/toolbox.hxx> #include <svtools/ctrltool.hxx> #include <svtools/ctrlbox.hxx> +#include <vector> class SbxVariable; -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif class AboutDialog : public ModalDialog { FixedText a1,a4,aVersionString; @@ -92,7 +81,6 @@ public: ReplaceDialog (Window*, const ResId&, String&, String&); }; -//////////////////////////////////////////////////////////////////// class ConfEdit : public PushButton { @@ -250,8 +238,7 @@ public: void Save( Config &aConfig ); }; - -DECLARE_LIST( StringList, String * ) +typedef ::std::vector< String* > StringList; #define C_KEY_ALLE CByteString("All") #define C_KEY_AKTUELL CByteString("Current") #define C_KEY_TYPE CByteString("Type") @@ -284,7 +271,7 @@ class GenericOptions : public TabPage StringList* GetAllGroups(); void LoadData(); - void ShowSelectPath( const String aType ); + void ShowSelectPath( const String& rType ); DECL_LINK( LoadGroup, ComboBox* ); DECL_LINK( DelGroup, Button* ); @@ -360,12 +347,11 @@ protected: DECL_LINK( OKClick, Button * ); -// sal_Bool bCompare = sal_False; -// String aCompareString; - public: VarEditDialog( Window * pParent, SbxVariable *pPVar ); }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/makefile.mk b/basic/source/app/makefile.mk index 07ceed6e5116..e62b11c0beb4 100644..100755 --- a/basic/source/app/makefile.mk +++ b/basic/source/app/makefile.mk @@ -38,32 +38,21 @@ LIBTARGET = NO # --- Common ------------------------------------------------------------ -OBJFILES = \ - $(OBJ)$/ttbasic.obj \ - $(OBJ)$/basicrt.obj \ - $(OBJ)$/processw.obj \ - $(OBJ)$/process.obj \ - $(OBJ)$/brkpnts.obj \ - $(OBJ)$/mybasic.obj \ - $(OBJ)$/status.obj \ - $(OBJ)$/printer.obj \ - $(OBJ)$/appwin.obj \ - $(OBJ)$/appedit.obj \ - $(OBJ)$/appbased.obj \ - $(OBJ)$/apperror.obj \ - $(OBJ)$/textedit.obj \ - $(OBJ)$/msgedit.obj \ - $(OBJ)$/dialogs.obj \ - EXCEPTIONSFILES = \ - $(OBJ)$/app.obj \ - $(OBJ)$/printer.obj \ - $(OBJ)$/process.obj - -.IF "$(GUI)" == "WNT" -EXCEPTIONSFILES += \ - $(OBJ)$/process.obj -.ENDIF + $(OBJ)$/app.obj \ + $(OBJ)$/appbased.obj \ + $(OBJ)$/appedit.obj \ + $(OBJ)$/apperror.obj \ + $(OBJ)$/appwin.obj \ + $(OBJ)$/basicrt.obj \ + $(OBJ)$/brkpnts.obj \ + $(OBJ)$/dialogs.obj \ + $(OBJ)$/msgedit.obj \ + $(OBJ)$/mybasic.obj \ + $(OBJ)$/printer.obj \ + $(OBJ)$/process.obj \ + $(OBJ)$/status.obj \ + $(OBJ)$/textedit.obj SRS1NAME=$(TARGET) SRC1FILES = \ @@ -76,21 +65,8 @@ SRC1FILES = \ LIB1TARGET=$(LB)$/app.lib LIB1ARCHIV=$(LB)$/libapp.a LIB1OBJFILES = \ - $(OBJ)$/basicrt.obj \ + $(EXCEPTIONSFILES) \ $(OBJ)$/processw.obj \ - $(OBJ)$/process.obj \ - $(OBJ)$/brkpnts.obj \ - $(OBJ)$/app.obj \ - $(OBJ)$/mybasic.obj \ - $(OBJ)$/status.obj \ - $(OBJ)$/printer.obj \ - $(OBJ)$/appwin.obj \ - $(OBJ)$/appedit.obj \ - $(OBJ)$/appbased.obj \ - $(OBJ)$/apperror.obj \ - $(OBJ)$/textedit.obj \ - $(OBJ)$/msgedit.obj \ - $(OBJ)$/dialogs.obj \ $(OBJ)$/sbintern.obj # --- Targets ------------------------------------------------------------ diff --git a/basic/source/app/msgedit.cxx b/basic/source/app/msgedit.cxx index 21febe8b3393..1cd6f8fc5e25 100644 --- a/basic/source/app/msgedit.cxx +++ b/basic/source/app/msgedit.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -37,18 +38,12 @@ Version 3 Changed Charset from CHARSET_IBMPC to RTL_TEXTENCODING_UTF8 #include <cstdio> #include <tools/time.hxx> #include <tools/stream.hxx> -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif -#ifndef _SOUND_HXX //autogen #include <vcl/sound.hxx> -#endif #include <tools/fsys.hxx> #include <svtools/stringtransfer.hxx> #include <unotools/syslocale.hxx> -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif #include "basic.hrc" #include "msgedit.hxx" #include "app.hxx" @@ -80,7 +75,6 @@ MsgEdit::MsgEdit( AppError* pParent, BasicFrame *pBF, const WinBits& aBits ) , pAppError( pParent ) , aEditTree( pParent, pBF, aBits | WB_HASBUTTONS | WB_HASLINES | WB_HASBUTTONSATROOT ) { -// SetFont( aEditTree.GetDefaultFont( DEFAULTFONT_FIXED, aEditTree.GetSettings().GetLanguage(), 0, &aEditTree ) ); aEditTree.SetNodeBitmaps( Bitmap( SttResId (MBP_PLUS) ), Bitmap( SttResId (MBP_MINUS) ) ); aEditTree.SetSelectionMode( MULTIPLE_SELECTION ); if ( aEditTree.GetModel()->GetSortMode() != SortNone ) @@ -116,20 +110,6 @@ void MsgEdit::AddAnyMsg( TTLogMsg *LogMsg ) if ( LogMsg->aDebugData.aFilename.Copy(0,2).CompareToAscii( "--" ) == COMPARE_EQUAL ) LogMsg->aDebugData.aFilename.Erase(0,2); - if ( LogMsg->aDebugData.aFilename.Len() && LogMsg->aDebugData.aFilename.GetChar(0) != '~' ) // do we want to convert - { - DirEntry aConvert( LogMsg->aDebugData.aFilename ); - if ( pAppError->aBaseDir.Contains( aConvert ) ) - { - aConvert.ToRel( pAppError->aBaseDir ); - LogMsg->aDebugData.aFilename = CUniString("~"); // mark as converted - LogMsg->aDebugData.aFilename += aConvert.GetFull( FSYS_STYLE_VFAT ); - } - else if ( !bFileLoading ) - { - LogMsg->aDebugData.aFilename.Insert( CUniString("~-"), 0); // mark as unconvertable - } - } xub_StrLen nPos; LogMsg->aDebugData.aMsg.ConvertLineEnd(); // does the message have several lines -> repeat the call for each line @@ -172,7 +152,7 @@ void MsgEdit::AddAnyMsg( TTLogMsg *LogMsg ) case LOG_ASSERTION: AddAssertion( aUILogMsg, LogMsg->aDebugData ); break; case LOG_ASSERTION_STACK: AddAssertionStack( aUILogMsg, LogMsg->aDebugData ); break; case LOG_QA_ERROR: AddQAError( aUILogMsg, LogMsg->aDebugData ); break; - default:DBG_ERROR("Unbekannter Typ in ResultFile. Speichern des ResultFile resultiert in Informationsverlust"); + default:OSL_FAIL("Unbekannter Typ in ResultFile. Speichern des ResultFile resultiert in Informationsverlust"); } if ( !bFileLoading ) @@ -217,7 +197,7 @@ void MsgEdit::AddAnyMsg( TTLogMsg *LogMsg ) // restore Original Msg LogMsg->aDebugData.aMsg = aOriginalMsg; - printf( ByteString( aPrintMsg, RTL_TEXTENCODING_UTF8 ).GetBuffer() ); + printf( "%s", ByteString( aPrintMsg, RTL_TEXTENCODING_UTF8 ).GetBuffer() ); } } } @@ -427,36 +407,6 @@ void MsgEdit::AddQAError( String aMsg, TTDebugData aDebugData ) aEditTree.InvalidateEntry( pThisEntry ); } -/* - SvLBoxEntry* GetEntry( SvLBoxEntry* pParent, sal_uIntPtr nPos ) const { return SvLBox::GetEntry(pParent,nPos); } - SvLBoxEntry* GetEntry( sal_uIntPtr nRootPos ) const { return SvLBox::GetEntry(nRootPos);} - - - - SvLBoxEntry* FirstChild(SvLBoxEntry* pParent ) const { return (SvLBoxEntry*)(pModel->FirstChild(pParent)); } - SvLBoxEntry* NextSibling(SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->NextSibling( pEntry )); } - SvLBoxEntry* PrevSibling(SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->PrevSibling( pEntry )); } - - SvLBoxEntry* FirstSelected() const { return (SvLBoxEntry*)SvListView::FirstSelected(); } - SvLBoxEntry* NextSelected( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(SvListView::NextSelected(pEntry)); } - SvLBoxEntry* PrevSelected( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(SvListView::PrevSelected(pEntry)); } - SvLBoxEntry* LastSelected() const { return (SvLBoxEntry*)(SvListView::LastSelected()); } - - SvLBoxEntry* GetEntry( SvLBoxEntry* pParent, sal_uIntPtr nPos ) const { return (SvLBoxEntry*)(pModel->GetEntry(pParent,nPos)); } - SvLBoxEntry* GetEntry( sal_uIntPtr nRootPos ) const { return (SvLBoxEntry*)(pModel->GetEntry(nRootPos)); } - - SvLBoxEntry* GetParent( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->GetParent(pEntry)); } - SvLBoxEntry* GetRootLevelParent(SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->GetRootLevelParent( pEntry ));} - - sal_Bool IsInChildList( SvListEntry* pParent, SvListEntry* pChild) const; - SvListEntry* GetEntry( SvListEntry* pParent, sal_uIntPtr nPos ) const; - SvListEntry* GetEntry( sal_uIntPtr nRootPos ) const; - SvListEntry* GetEntryAtAbsPos( sal_uIntPtr nAbsPos ) const; - SvListEntry* GetParent( SvListEntry* pEntry ) const; - SvListEntry* GetRootLevelParent( SvListEntry* pEntry ) const; -*/ - -//#define CHECK( pMemo ) if ( pMemo && !aEditTree.GetViewData( pMemo ) ) pMemo = NULL #define CHECK( pMemo ) if ( pMemo && !aEditTree.GetModel()->IsInChildList( NULL, pMemo ) ) pMemo = NULL void MsgEdit::Delete() { @@ -491,7 +441,7 @@ String MsgEdit::Impl_MakeText( SvLBoxEntry *pEntry ) const case LOG_ASSERTION: break; case LOG_ASSERTION_STACK:aRet.AppendAscii("--> "); break; case LOG_QA_ERROR: break; - default:DBG_ERROR("Unknown type in ResultWindow!"); + default:OSL_FAIL("Unknown type in ResultWindow!"); } aRet += aEditTree.GetEntryText( pEntry ); return aRet; @@ -548,10 +498,9 @@ String MsgEdit::GetSelected() TextSelection MsgEdit::GetSelection() const { - sal_uIntPtr nStart=0,nEnd=0; - if ( aEditTree.FirstSelected() ) { + sal_uIntPtr nStart=0,nEnd=0; nStart = aEditTree.GetModel()->GetAbsPos(aEditTree.FirstSelected() ); if ( aEditTree.LastSelected() ) nEnd = aEditTree.GetModel()->GetAbsPos(aEditTree.LastSelected() ); @@ -590,7 +539,7 @@ void MsgEdit::ReplaceSelected( const String& rStr ) { (void) rStr; /* avoid warning about unused parameter */ Sound::Beep(); - DBG_ERROR("Not Implemented"); + OSL_FAIL("Not Implemented"); } sal_Bool MsgEdit::IsModified(){ return bModified; } @@ -614,7 +563,7 @@ void MsgEdit::SetText( const String& rStr ) { (void) rStr; /* avoid warning about unused parameter */ Sound::Beep(); - DBG_ERROR("Not Implemented"); + OSL_FAIL("Not Implemented"); } sal_Bool MsgEdit::HasText() const @@ -777,7 +726,6 @@ TTTreeListBox::TTTreeListBox( AppError* pParent, BasicFrame* pBF, WinBits nWinSt : SvTreeListBox( pParent, nWinStyle ) , pBasicFrame(pBF) , pAppError( pParent ) -//, nDeselectParent(0) {} sal_Bool TTTreeListBox::JumpToSourcecode( SvLBoxEntry *pThisEntry ) @@ -795,9 +743,6 @@ sal_Bool TTTreeListBox::JumpToSourcecode( SvLBoxEntry *pThisEntry ) else { aFilename.Erase( 0,1 ); - DirEntry aConvert( pAppError->aBaseDir ); - aConvert += DirEntry( aFilename, FSYS_STYLE_VFAT ); - aFilename = aConvert.GetFull(); } } @@ -826,47 +771,6 @@ sal_Bool TTTreeListBox::DoubleClickHdl() return JumpToSourcecode( GetHdlEntry() ); } -/*sal_uIntPtr TTTreeListBox::SelectChildren( SvLBoxEntry* pParent, sal_Bool bSelect ) -{ - SvLBoxEntry *pEntry = FirstChild( pParent ); - sal_uIntPtr nRet = 0; - while ( pEntry ) - { - nRet++; - Select( pEntry, bSelect ); - pEntry = NextSibling( pEntry ); - } - return nRet; -} - - -void TTTreeListBox::SelectHdl() -{ - SvLBoxEntry* pHdlEntry = GetHdlEntry(); - - SelectChildren( pHdlEntry, sal_True ); - Select( pHdlEntry, sal_True ); -// InitMenu(pApp->GetAppMenu()->GetPopupMenu( RID_APPEDIT )); // So daß Delete richtig ist -} - -void TTTreeListBox::DeselectHdl() -{ - SvLBoxEntry* pHdlEntry = GetHdlEntry(); - if ( GetParent( pHdlEntry ) ) - { - nDeselectParent++; - Select( GetParent( pHdlEntry ), sal_False ); - nDeselectParent--; - } - if ( !nDeselectParent ) - { - SelectChildren( pHdlEntry, sal_False ); - Select( pHdlEntry, sal_False ); - } - Invalidate(); -} */ - - void TTTreeListBox::KeyInput( const KeyEvent& rKEvt ) { switch ( rKEvt.GetKeyCode().GetFunction() ) @@ -922,7 +826,7 @@ TTFeatures TTTreeListBox::GetFeatures( SvLBoxEntry* pEntry ) case LOG_QA_ERROR: return HasQAError; default: - DBG_ERROR("Unknown type in ResultWindow"); + OSL_FAIL("Unknown type in ResultWindow"); } return HasNothing; } @@ -953,7 +857,7 @@ void TTLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, if ( ( aFeatures & HasError ) == HasError ) aCol = Color( 255, 130, 130 ); // Red else if ( ( aFeatures & HasWarning ) == HasWarning ) - aCol = Color( 255, 200, 120 ); // Ocker oder so + aCol = Color( 255, 200, 120 ); // Ochre or so else if ( ( aFeatures & HasAssertion ) == HasAssertion ) aCol = Color( 0xd0, 0xd0, 0xff ); // blueish else @@ -997,3 +901,4 @@ void TTTreeListBox::InitEntry(SvLBoxEntry* pEntry, pEntry->ReplaceItem( pStr, nColToHilite ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/msgedit.hxx b/basic/source/app/msgedit.hxx index c3e4d6413db4..0da878cf48f5 100644 --- a/basic/source/app/msgedit.hxx +++ b/basic/source/app/msgedit.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -35,7 +36,7 @@ class BasicFrame; class AppError; -#define SelectChildren SelectChilds // Sonst wird mir schlecht +#define SelectChildren SelectChilds typedef sal_uInt16 TTFeatures; // Bitfield for features of the entries #define HasNothing TTFeatures(0x00) @@ -48,8 +49,6 @@ typedef sal_uInt16 TTFeatures; // Bitfield for features of the entries class TTTreeListBox : public SvTreeListBox { protected: -// virtual void Command( const CommandEvent& rCEvt ); -// sal_uInt16 nDeselectParent; BasicFrame *pBasicFrame; void InitEntry( SvLBoxEntry*, const String&, const Image&, const Image&, SvLBoxButtonKind eButtonKind ); @@ -61,13 +60,10 @@ public: TTTreeListBox( AppError* pParent, BasicFrame* pBF, WinBits nWinStyle=0 ); ~TTTreeListBox(){} -// virtual void SelectHdl(); -// virtual void DeselectHdl(); virtual sal_Bool DoubleClickHdl(); virtual void KeyInput( const KeyEvent& rKEvt ); -// sal_uIntPtr SelectChildren( SvLBoxEntry* pParent, sal_Bool bSelect ); TTFeatures GetFeatures( SvLBoxEntry* ); }; @@ -112,3 +108,5 @@ DATA_FUNC_DEF( aEditTree, TTTreeListBox ) }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/mybasic.cxx b/basic/source/app/mybasic.cxx index 791c267cda44..61a2c817729f 100644 --- a/basic/source/app/mybasic.cxx +++ b/basic/source/app/mybasic.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,26 +29,12 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include <basic/sbx.hxx> -// AB-Uno-Test -//#define unotest -#ifdef unotest -#ifndef _USR_UNO_HXX -#include <usr/uno.hxx> -#endif -#include <basic/sbuno.hxx> -#include <sbunoobj.hxx> -#endif - #include "sbintern.hxx" -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif #include <basic/mybasic.hxx> #include "basic.hrc" #include "appbased.hxx" @@ -84,6 +71,7 @@ SbxBase* MyFactory::Create( sal_uInt16 nSbxId, sal_uInt32 nCr ) MyBasic::MyBasic() : StarBASIC() { nError = 0; + CurrentError = 0; if( !nInst++ ) { AddFactory( &aFac1 ); @@ -94,21 +82,6 @@ MyBasic::MyBasic() : StarBASIC() p->SetName( CUniString("Objects") ); Insert( p ); - // AB-Uno-Test -#ifdef unotest - // Get Uno-Service-Manager and Reflection Service - createAndSetDefaultServiceManager(); // done later - - // Get Uno-Test-Object - UsrAny aObjAny = getIntrospectionTestObject(); - - // Box object into SbUnoObject - String aName( "UnoObject" ); - SbxObjectRef xSbUnoObj = GetSbUnoObject( aName, aObjAny ); - //SbxObjectRef xSbUnoObj = new SbUnoObject( aName, aObjAny ); - Insert( (SbxObject*)xSbUnoObj ); -#endif - pTestObject = NULL; } @@ -166,7 +139,7 @@ SbTextType MyBasic::GetSymbolType( const String &rSymbol, sal_Bool bWasTTControl MyBasic::~MyBasic() { - aErrors.Clear(); + Reset(); if( !--nInst ) { RemoveFactory( &aFac1 ); @@ -177,8 +150,10 @@ MyBasic::~MyBasic() void MyBasic::Reset() { - aErrors.Clear(); + for ( size_t i = 0, n = aErrors.size(); i < n; ++i ) delete aErrors[ i ]; + aErrors.clear(); nError = 0; + CurrentError = 0; } sal_Bool MyBasic::Compile( SbModule* p ) @@ -187,6 +162,36 @@ sal_Bool MyBasic::Compile( SbModule* p ) return StarBASIC::Compile( p ); } +BasicError* MyBasic::NextError() +{ + if ( CurrentError < ( aErrors.size() - 1 ) ) + { + ++CurrentError; + return aErrors[ CurrentError ]; + } + return NULL; +} + +BasicError* MyBasic::PrevError() +{ + if ( !aErrors.empty() && CurrentError > 0 ) + { + --CurrentError; + return aErrors[ CurrentError ]; + } + return NULL; +} + +BasicError* MyBasic::FirstError() +{ + if ( !aErrors.empty() ) + { + CurrentError = 0; + return aErrors[ CurrentError ]; + } + return NULL; +} + sal_Bool MyBasic::ErrorHdl() { AppBasEd* pWin = aBasicApp.pFrame->FindModuleWin( GetActiveModule()->GetName() ); @@ -198,12 +203,13 @@ sal_Bool MyBasic::ErrorHdl() pWin->ToTop(); if( IsCompilerError() ) { - aErrors.Insert( + aErrors.push_back( new BasicError ( pWin, - 0, StarBASIC::GetErrorText(), GetLine(), GetCol1(), GetCol2() ), - LIST_APPEND ); + 0, StarBASIC::GetErrorText(), GetLine(), GetCol1(), GetCol2() ) + ); nError++; + CurrentError = aErrors.size() - 1; return sal_Bool( nError < 20 ); // Cancel after 20 errors } else @@ -251,16 +257,7 @@ sal_uInt16 MyBasic::BreakHdl() pWin->Highlight( GetLine(), GetCol1(), GetCol2() ); } - if( IsBreak() ) // If Breakpoint (or "Run to Cursor") - { -// if ( GetActiveModule()->IsBP(GetLine()) ) -// GetActiveModule()->ClearBP(GetLine()); - return aBasicApp.pFrame->BreakHandler(); - } - else - { - return aBasicApp.pFrame->BreakHandler(); - } + return aBasicApp.pFrame->BreakHandler(); } /*************************************************************************** @@ -302,3 +299,4 @@ void BasicError::Show() } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/printer.cxx b/basic/source/app/printer.cxx index 8e89f5d90c03..675aeed2c7e0 100644 --- a/basic/source/app/printer.cxx +++ b/basic/source/app/printer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,21 +29,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#ifndef _PRINT_HXX //autogen #include <vcl/print.hxx> -#endif -#ifndef _DIALOG_HXX //autogen #include <vcl/dialog.hxx> -#endif -#ifndef _FIXED_HXX //autogen #include <vcl/fixed.hxx> -#endif -#ifndef _BUTTON_HXX //autogen #include <vcl/button.hxx> -#endif -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif #include <algorithm> @@ -120,3 +111,4 @@ void BasicPrinter::Print( const String& rFile, const String& rText, BasicFrame * } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/printer.hxx b/basic/source/app/printer.hxx index 505835278234..b884a642e76f 100644 --- a/basic/source/app/printer.hxx +++ b/basic/source/app/printer.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -36,13 +37,13 @@ class BasicPrinter boost::shared_ptr<Printer> mpPrinter; boost::shared_ptr<vcl::OldStylePrintAdaptor> mpListener; - short nLine; // aktuelle Zeile - short nPage; // aktuelle Seite - short nLines; // Zeilen pro Seite - short nYoff; // Zeilenabstand in Points - String aFile; // Dateiname + short nLine; // current row + short nPage; // current page + short nLines; // lines per page + short nYoff; // line spacing in points + String aFile; // file name - void Header(); // Seitenkopf drucken + void Header(); // print page header void StartPage(); public: BasicPrinter(); @@ -50,3 +51,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/process.cxx b/basic/source/app/process.cxx index 703f684b38de..46b663e9d93f 100644 --- a/basic/source/app/process.cxx +++ b/basic/source/app/process.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,52 +30,61 @@ #include "precompiled_basic.hxx" -#ifdef WNT -#include <tools/prewin.h> -#include "winbase.h" -#include <tools/postwin.h> -#endif #include <tools/errcode.hxx> -#include <vos/process.hxx> #include <basic/sbxcore.hxx> #include <tools/string.hxx> #include <osl/file.hxx> +#include <osl/process.h> -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif - -//#ifndef _BYTE_STRING_LIST -//DECLARE_LIST( ByteStringList, ByteString * ); -//#define _BYTE_STRING_LIST -//#endif - #include <basic/process.hxx> +#ifdef WNT +#include <windows.h> +#endif + Process::Process() -: pArgumentList( NULL ) -, pEnvList( NULL ) -, pProcess( NULL ) +: m_nArgumentCount( 0 ) +, m_pArgumentList( NULL ) +, m_nEnvCount( 0 ) +, m_pEnvList( NULL ) +, m_aProcessName() +, m_pProcess( NULL ) , bWasGPF( sal_False ) , bHasBeenStarted( sal_False ) { } +#define FREE_USTRING_LIST( count, list ) \ + if ( count && list ) \ + { \ + for ( unsigned int i = 0; i < count; ++i ) \ + { \ + rtl_uString_release( list[i] ); \ + list[i] = NULL; \ + } \ + delete[] list; \ + } \ + count = 0; \ + list = NULL; + Process::~Process() { -// delete pArgumentList; -// delete pEnvList; - delete pProcess; + FREE_USTRING_LIST( m_nArgumentCount, m_pArgumentList ); + FREE_USTRING_LIST( m_nEnvCount, m_pEnvList ); + if ( m_pProcess ) + osl_freeProcessHandle( m_pProcess ); } sal_Bool Process::ImplIsRunning() { - if ( pProcess && bHasBeenStarted ) + if ( m_pProcess && bHasBeenStarted ) { - vos::OProcess::TProcessInfo aProcessInfo; - pProcess->getInfo( vos::OProcess::TData_ExitCode, &aProcessInfo ); - if ( !(aProcessInfo.Fields & vos::OProcess::TData_ExitCode) ) + oslProcessInfo aProcessInfo; + aProcessInfo.Size = sizeof(oslProcessInfo); + osl_getProcessInfo(m_pProcess, osl_Process_EXITCODE, &aProcessInfo ); + if ( !(aProcessInfo.Fields & osl_Process_EXITCODE) ) return sal_True; else return sal_False; @@ -85,11 +95,12 @@ sal_Bool Process::ImplIsRunning() long Process::ImplGetExitCode() { - if ( pProcess ) + if ( m_pProcess ) { - vos::OProcess::TProcessInfo aProcessInfo; - pProcess->getInfo( vos::OProcess::TData_ExitCode, &aProcessInfo ); - if ( !(aProcessInfo.Fields & vos::OProcess::TData_ExitCode) ) + oslProcessInfo aProcessInfo; + aProcessInfo.Size = sizeof(oslProcessInfo); + osl_getProcessInfo(m_pProcess, osl_Process_EXITCODE, &aProcessInfo ); + if ( !(aProcessInfo.Fields & osl_Process_EXITCODE) ) SbxBase::SetError( SbxERR_NO_ACTIVE_OBJECT ); return aProcessInfo.Code; } @@ -99,17 +110,17 @@ long Process::ImplGetExitCode() } -//////////////////////////////////////////////////////////////////////////// void Process::SetImage( const String &aAppPath, const String &aAppParams, const Environment *pEnv ) { // Set image file of executable - if ( pProcess && ImplIsRunning() ) + if ( m_pProcess && ImplIsRunning() ) SbxBase::SetError( SbxERR_NO_ACTIVE_OBJECT ); else { - delete pArgumentList; pArgumentList = NULL; - delete pEnvList; pEnvList = NULL; - delete pProcess; pProcess = NULL; + FREE_USTRING_LIST( m_nArgumentCount, m_pArgumentList ); + FREE_USTRING_LIST( m_nEnvCount, m_pEnvList ); + osl_freeProcessHandle( m_pProcess ); + m_pProcess = NULL; xub_StrLen i, nCount = aAppParams.GetQuotedTokenCount( CUniString("\"\"" ), ' ' ); ::rtl::OUString *pParamList = new ::rtl::OUString[nCount]; @@ -124,67 +135,65 @@ void Process::SetImage( const String &aAppPath, const String &aAppParams, const nParamCount++; } } - pArgumentList = new vos::OArgumentList( pParamList, nCount ); - + m_nArgumentCount = nParamCount; + m_pArgumentList = new rtl_uString*[m_nArgumentCount]; + for ( i = 0 ; i < m_nArgumentCount ; i++ ) + { + m_pArgumentList[i] = NULL; + rtl_uString_assign( &(m_pArgumentList[i]), pParamList[i].pData ); + } + delete [] pParamList; - ::rtl::OUString *pEnvArray = NULL; if ( pEnv ) { - pEnvArray = new ::rtl::OUString[pEnv->size()]; + m_pEnvList = new rtl_uString*[pEnv->size()]; - xub_StrLen nEnvCount = 0; + m_nEnvCount = 0; Environment::const_iterator aIter = pEnv->begin(); while ( aIter != pEnv->end() ) { ::rtl::OUString aTemp = ::rtl::OUString( (*aIter).first ); - aTemp += ::rtl::OUString::createFromAscii( "=" ); + aTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "=" )); aTemp += ::rtl::OUString( (*aIter).second ); - pEnvArray[nEnvCount] = aTemp; - nEnvCount++; - aIter++; + m_pEnvList[m_nEnvCount] = NULL; + rtl_uString_assign( &(m_pEnvList[m_nEnvCount]), aTemp.pData ); + ++m_nEnvCount; + ++aIter; } - pEnvList = new vos::OEnvironment( pEnvArray, nEnvCount ); } ::rtl::OUString aNormalizedAppPath; osl::FileBase::getFileURLFromSystemPath( ::rtl::OUString(aAppPath), aNormalizedAppPath ); - pProcess = new vos::OProcess( aNormalizedAppPath ); + m_aProcessName = aNormalizedAppPath;; bHasBeenStarted = sal_False; - delete [] pParamList; - delete [] pEnvArray; } } sal_Bool Process::Start() { // Start program sal_Bool bSuccess=sal_False; - if ( pProcess && !ImplIsRunning() ) + if ( m_aProcessName.getLength() && !ImplIsRunning() ) { bWasGPF = sal_False; #ifdef WNT -// sal_uInt32 nErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_NOALIGNMENTFAULTEXCEPT | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX); sal_uInt32 nErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX); try { #endif - if ( pEnvList ) - { - bSuccess = pProcess->execute( (vos::OProcess::TProcessOption) - ( vos::OProcess::TOption_SearchPath - /*| vos::OProcess::TOption_Detached*/ - /*| vos::OProcess::TOption_Wait*/ ), - *pArgumentList, - *pEnvList ) == vos::OProcess::E_None; - } - else - { - bSuccess = pProcess->execute( (vos::OProcess::TProcessOption) - ( vos::OProcess::TOption_SearchPath - /*| vos::OProcess::TOption_Detached*/ - /*| vos::OProcess::TOption_Wait*/ ), - *pArgumentList ) == vos::OProcess::E_None; - } + bSuccess = osl_executeProcess( + m_aProcessName.pData, + m_pArgumentList, + m_nArgumentCount, + osl_Process_SEARCHPATH + /*| osl_Process_DETACHED*/ + /*| osl_Process_WAIT*/, + NULL, + NULL, + m_pEnvList, + m_nEnvCount, + &m_pProcess ) == osl_Process_E_None; + #ifdef WNT } catch( ... ) @@ -223,7 +232,8 @@ sal_Bool Process::WasGPF() sal_Bool Process::Terminate() { if ( ImplIsRunning() ) - return pProcess->terminate() == vos::OProcess::E_None; + return osl_terminateProcess(m_pProcess) == osl_Process_E_None; return sal_True; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/processw.cxx b/basic/source/app/processw.cxx index 0abf5afc0d57..5c1b66f81079 100644 --- a/basic/source/app/processw.cxx +++ b/basic/source/app/processw.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,14 +33,9 @@ #include <tools/errcode.hxx> #include <basic/sbxobj.hxx> #include <basic/sbx.hxx> -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif -//#include <osl/thread.h> -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif #include "processw.hxx" @@ -204,8 +200,7 @@ void ProcessWrapper::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCT, SbxInfo* ProcessWrapper::GetInfo( short nIdx ) { Methods* p = &pMethods[ nIdx ]; - // Wenn mal eine Hilfedatei zur Verfuegung steht: - // SbxInfo* pResultInfo = new SbxInfo( Hilfedateiname, p->nHelpId ); + // In case there is a help file available: SbxInfo* pResultInfo = new SbxInfo; short nPar = p->nArgs & _ARGSMASK; for( short i = 0; i < nPar; i++ ) @@ -221,10 +216,8 @@ SbxInfo* ProcessWrapper::GetInfo( short nIdx ) } -//////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// // Properties and methods save the return value in argv[0] (Get, bPut = sal_False) // and store the value from argv[0] (Put, bPut = sal_True) @@ -280,3 +273,4 @@ SbxObject* ProcessFactory::CreateObject( const String& rClass ) return NULL; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/processw.hxx b/basic/source/app/processw.hxx index 69f6eb73a793..4fb737f50c9e 100644 --- a/basic/source/app/processw.hxx +++ b/basic/source/app/processw.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,7 @@ #define _PROCESSW_HXX #include <basic/sbxfac.hxx> -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #include <basic/sbxobj.hxx> #include <basic/process.hxx> @@ -40,12 +39,12 @@ class ProcessWrapper : public SbxObject using SbxVariable::GetInfo; // Definition of a table entry. This is done here because // through this methods and property can declared as private. -#if defined ( ICC ) || defined ( HPUX ) || defined ( C50 ) || defined ( C52 ) +#if defined ( ICC ) || defined ( C50 ) public: #endif typedef void( ProcessWrapper::*pMeth ) ( SbxVariable* pThis, SbxArray* pArgs, sal_Bool bWrite ); -#if defined ( ICC ) || defined ( HPUX ) +#if defined ( ICC ) private: #endif @@ -88,3 +87,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/resids.hrc b/basic/source/app/resids.hrc index 5d3fbb098dde..5d3fbb098dde 100644..100755 --- a/basic/source/app/resids.hrc +++ b/basic/source/app/resids.hrc diff --git a/basic/source/app/status.cxx b/basic/source/app/status.cxx index beb43ec1de18..b50aeee5b117 100644 --- a/basic/source/app/status.cxx +++ b/basic/source/app/status.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -81,10 +82,6 @@ IMPL_LINK( StatusLine, ActivateTask, TaskToolBox*, pTTB ) nFirstWinPos += pTTB->GetItemPos( pTTB->GetCurItemId() ) / 2; - sal_uInt16 x; - x = pTTB->GetItemPos( pTTB->GetCurItemId() ); - x = pWinMenu->GetItemId( nFirstWinPos ); - x = pWinMenu->GetItemCount(); AppWin* pWin = pFrame->FindWin( pWinMenu->GetItemText( pWinMenu->GetItemId( nFirstWinPos ) ).EraseAllChars( L'~' ) ); if ( pWin ) { @@ -112,7 +109,7 @@ void StatusLine::LoadTaskToolBox() Window* pWin = pFrame->FindWin( pWinMenu->GetItemId( nFirstWinPos ) ); if ( pWin ) - pTaskToolBox->UpdateTask( Image(), pWin->GetText(), pWin == pFrame->pList->Last() && !( pFrame->pList->Last()->GetWinState() & TT_WIN_STATE_HIDE ) ); + pTaskToolBox->UpdateTask( Image(), pWin->GetText(), pWin == pFrame->pList->back() && !( pFrame->pList->back()->GetWinState() & TT_WIN_STATE_HIDE ) ); nFirstWinPos++; } @@ -123,3 +120,4 @@ void StatusLine::LoadTaskToolBox() } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/status.hxx b/basic/source/app/status.hxx index fd9ab033009e..7c3b04bed8cc 100644 --- a/basic/source/app/status.hxx +++ b/basic/source/app/status.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -52,3 +53,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/svtmsg.src b/basic/source/app/svtmsg.src index 748256bb5564..68c2930236b8 100644 --- a/basic/source/app/svtmsg.src +++ b/basic/source/app/svtmsg.src @@ -27,18 +27,16 @@ #include "basic/svtmsg.hrc" -// Hier sind die Messages aus dem Verzeichnis /basic/source/app enhalten +// Here are included the messages of the folder /basic/source/app -/////////////////////////////// -// Fehlermeldungen, die in das Resultfile gelangen. +// Error messages which go to the result file. // ********************* -// *** !!ACHTUNG!! *** +// *** !!ATTENTION!! *** // ********************* -// Die Nummern dürfen sich NIE! ändern, -// da sie in den Resultfiles gespeichert sind, und bei erneutem Anzeigen -// statdessen die entsprechenden neuen oder garkeine Strings angzeigt werden. -/////////////////////////////// +// The numbers must NEVER(!) change, +// because they are saved in the result files and a renewed display +// would display new strings or no strings. String S_GPF_ABORT { Text[ en-US ] = "Program aborted with GPF"; diff --git a/basic/source/app/testbasi.cxx b/basic/source/app/testbasi.cxx index b63986b63b2d..05818806c8a8 100644 --- a/basic/source/app/testbasi.cxx +++ b/basic/source/app/testbasi.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,3 +30,5 @@ #include "precompiled_basic.hxx" #define testtool #include "mybasic.cxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/testtool.src b/basic/source/app/testtool.src index 090cb735c139..9b89f6da14b1 100644 --- a/basic/source/app/testtool.src +++ b/basic/source/app/testtool.src @@ -27,9 +27,7 @@ #include "basic/testtool.hrc" -/////////////////////////////// // Strings -/////////////////////////////// String S_INVALID_KEYCODE { Text[ en-US ] = "Is an invalid KeyCode!"; diff --git a/basic/source/app/textedit.cxx b/basic/source/app/textedit.cxx index 55e91ea879b5..8c8ea6873033 100644 --- a/basic/source/app/textedit.cxx +++ b/basic/source/app/textedit.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,9 +33,7 @@ #include <svtools/textview.hxx> #include <svtools/txtattr.hxx> #include <basic/sbxmeth.hxx> -#ifndef _BASIC_TTRESHLP_HXX #include <basic/ttstrhlp.hxx> -#endif #include "basic.hrc" #include "textedit.hxx" @@ -199,10 +198,10 @@ void TextEditImp::ImpDoHighlight( const String& rSource, sal_uIntPtr nLineOff ) return; SbTextPortion& rLast = aPortionList[nCount-1]; - if ( rLast.nStart > rLast.nEnd ) // Nur bis Bug von MD behoben + if ( rLast.nStart > rLast.nEnd ) // Only up to the bug of MD repaired { #if OSL_DEBUG_LEVEL > 1 - DBG_ERROR( "MD-Bug nicht beseitigt!" ); + OSL_FAIL( "MD-Bug is not repaired!" ); #endif nCount--; aPortionList.Remove( nCount); @@ -216,8 +215,7 @@ void TextEditImp::ImpDoHighlight( const String& rSource, sal_uIntPtr nLineOff ) for ( i = 0; i < aPortionList.Count(); i++ ) { SbTextPortion& r = aPortionList[i]; -// DBG_ASSERT( r.nStart <= r.nEnd, "Highlight: Start > End?" ); - if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoben + if ( r.nStart > r.nEnd ) // Only up to the bug of MD repaired continue; SbTextType eType = r.eType; @@ -247,7 +245,7 @@ void TextEditImp::ImpDoHighlight( const String& rSource, sal_uIntPtr nLineOff ) } } - // Es muessen nur die Blanks und Tabs mit attributiert werden. + // Only the blanks and tabs had to be attributed. // If there are two equal attributes one after another, // they are optimized by the EditEngine. xub_StrLen nLastEnd = 0; @@ -264,8 +262,8 @@ void TextEditImp::ImpDoHighlight( const String& rSource, sal_uIntPtr nLineOff ) if ( r.nStart > nLastEnd ) { - // Kann ich mich drauf verlassen, dass alle ausser - // Blank und Tab gehighlightet wird ?! + // can I trust that all of them except + // blank und tab will be highlighted?! r.nStart = nLastEnd; } nLastEnd = r.nEnd+1; @@ -277,8 +275,7 @@ void TextEditImp::ImpDoHighlight( const String& rSource, sal_uIntPtr nLineOff ) for ( i = 0; i < aPortionList.Count(); i++ ) { SbTextPortion& r = aPortionList[i]; -// DBG_ASSERT( r.nStart <= r.nEnd, "Highlight: Start > End?" ); - if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoben + if ( r.nStart > r.nEnd ) // Only up to the bug of MD repaired continue; SbTextType eCol = r.eType; @@ -327,7 +324,7 @@ void TextEditImp::ImpDoHighlight( const String& rSource, sal_uIntPtr nLineOff ) default: { aColor = Color( RGB_COLORDATA( 0xff, 0x80, 0x80 ) ); - DBG_ERROR( "Unknown syntax color" ); + OSL_FAIL( "Unknown syntax color" ); } } pTextEngine->SetAttrib( TextAttribFontColor( aColor ), nLine, r.nStart, r.nEnd+1 ); @@ -338,13 +335,11 @@ void TextEditImp::ImpDoHighlight( const String& rSource, sal_uIntPtr nLineOff ) void TextEditImp::DoSyntaxHighlight( sal_uIntPtr nPara ) { - // Due to delayed syntax highlight it can happend that the - // paragraph does no longer exist + // Due to delayed syntax highlight it can happen that the + // paragraph does no longer exist if ( nPara < pTextEngine->GetParagraphCount() ) { - // leider weis ich nicht, ob genau diese Zeile Modified() ... -// if ( pProgress ) -// pProgress->StepProgress(); + // unfortunatly I don't know if exact this line Modified() ... pTextEngine->RemoveAttribs( nPara ); String aSource( pTextEngine->GetText( nPara ) ); ImpDoHighlight( aSource, nPara ); @@ -355,8 +350,6 @@ void TextEditImp::DoDelayedSyntaxHighlight( xub_StrLen nPara ) { // Paragraph is added to 'List', processed in TimerHdl. // => Do not manipulate paragraphs while EditEngine is formatting -// if ( pProgress ) -// pProgress->StepProgress(); if ( !bHighlightning && bDoSyntaxHighlight ) { @@ -382,16 +375,6 @@ IMPL_LINK( TextEditImp, SyntaxTimerHdl, Timer *, EMPTYARG ) nLine = (sal_uInt16)aSyntaxLineTable.GetCurKey(); DoSyntaxHighlight( nLine ); aSyntaxLineTable.Remove( nLine ); -/* if ( Application::AnyInput() ) - { - aSyntaxIdleTimer.Start(); // Starten, falls wir in einem Dialog landen - pTextView->ShowCursor( sal_True, sal_True ); - pTextEngine->SetUpdateMode( sal_True ); - bHighlightning = sal_False; - GetpApp()->Reschedule(); - bHighlightning = sal_True; - pTextEngine->SetUpdateMode( sal_False ); - }*/ } sal_Bool bWasModified = pTextEngine->IsModified(); @@ -402,25 +385,17 @@ IMPL_LINK( TextEditImp, SyntaxTimerHdl, Timer *, EMPTYARG ) } else pTextEngine->SetUpdateMode( sal_True ); // ! With VDev -// pTextView->ForceUpdate(); // SetUpdateMode( sal_True ) soll kein Modify setzen pTextEngine->SetModified( bWasModified ); // SyntaxTimerHdl wird gerufen, wenn Text-Aenderung // => gute Gelegenheit, Textbreite zu ermitteln! -// long nPrevTextWidth = nCurTextWidth; -// nCurTextWidth = pTextEngine->CalcTextWidth(); -// if ( nCurTextWidth != nPrevTextWidth ) -// SetScrollBarRanges(); bHighlightning = sal_False; if ( aSyntaxLineTable.First() ) aImplSyntaxIdleTimer.Start(); -// while ( Application::AnyInput() ) -// Application::Reschedule(); // Reschedule, da der UserEvent keine Paints etc. durchlässt - return 0; } @@ -451,7 +426,6 @@ void TextEditImp::SyntaxHighlight( sal_Bool bNew ) for ( sal_uIntPtr i = 0; i < pTextEngine->GetParagraphCount(); i++ ) pTextEngine->RemoveAttribs( i ); -// pTextEngine->QuickFormatDoc(); pTextEngine->SetUpdateMode( sal_True ); pTextView->ShowCursor(sal_True, sal_True ); } @@ -482,13 +456,15 @@ void TextEditImp::KeyInput( const KeyEvent& rKeyEvent ) pTextView->GetTextEngine()->SetModified( bWasModified ); } -void TextEditImp::Paint( const Rectangle& rRect ){ pTextView->Paint( rRect );} -void TextEditImp::MouseButtonUp( const MouseEvent& rMouseEvent ){ pTextView->MouseButtonUp( rMouseEvent );} -//void TextEditImp::MouseButtonDown( const MouseEvent& rMouseEvent ){ pTextView->MouseButtonDown( rMouseEvent );} -//void TextEditImp::MouseMove( const MouseEvent& rMouseEvent ){ pTextView->MouseMove( rMouseEvent );} -//void TextEditImp::Command( const CommandEvent& rCEvt ){ pTextView->Command( rCEvt );} -//sal_Bool TextEditImp::Drop( const DropEvent& rEvt ){ return sal_False /*pTextView->Drop( rEvt )*/;} -//sal_Bool TextEditImp::QueryDrop( DropEvent& rEvt ){ return sal_False /*pTextView->QueryDrop( rEvt )*/;} +void TextEditImp::Paint( const Rectangle& rRect ) +{ + pTextView->Paint( rRect ); +} + +void TextEditImp::MouseButtonUp( const MouseEvent& rMouseEvent ) +{ + pTextView->MouseButtonUp( rMouseEvent ); +} void TextEditImp::Command( const CommandEvent& rCEvt ) @@ -543,7 +519,7 @@ SbxBase* TextEditImp::GetSbxAtMousePos( String &aWord ) Point aDocPos = pTextView->GetDocPos( aPos ); aWord = pTextEngine->GetWord( pTextEngine->GetPaM( aDocPos ) ); - if ( aWord.Len() /*&& !Application::GetAppInternational().IsNumeric( aWord )*/ ) + if ( aWord.Len() ) { xub_StrLen nLastChar = aWord.Len()-1; String aSuffixes = CUniString( cSuffixes ); @@ -644,12 +620,9 @@ Variant(Empty) switch ( eType ) { case SbxBOOL: -// case SbxCURRENCY: -// case SbxDATE: case SbxDOUBLE: case SbxINTEGER: case SbxLONG: -// case SbxOBJECT: // cannot be edited case SbxSINGLE: case SbxSTRING: @@ -731,7 +704,7 @@ void TextEdit::Highlight( sal_uIntPtr nLine, xub_StrLen nCol1, xub_StrLen nCol2 aEdit.pTextView->SetSelection( TextSelection(TextPaM(nLine,nCol2+1), TextPaM(nLine,nCol1)) ); if ( aEdit.ViewMoved() ) { - aEdit.pTextView->SetSelection( TextSelection(TextPaM(TEXT_PARA_ALL,1)) ); // fix #105169# + aEdit.pTextView->SetSelection( TextSelection(TextPaM(TEXT_PARA_ALL,1)) ); aEdit.pTextView->SetSelection( TextSelection(TextPaM((nLine>=2?nLine-2:0),nCol2+1)) ); aEdit.pTextView->SetSelection( TextSelection(TextPaM(nLine,nCol2+1), TextPaM(nLine,nCol1)) ); } @@ -864,3 +837,4 @@ void TextEdit::BuildKontextMenu( PopupMenu *&pMenu ) } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/textedit.hxx b/basic/source/app/textedit.hxx index 404dc4acb2bd..2d68d11541db 100644 --- a/basic/source/app/textedit.hxx +++ b/basic/source/app/textedit.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -42,7 +43,6 @@ class BreakpointWindow; #include "dataedit.hxx" -//#include <xtextedt.hxx> class TextEditImp : public Window, public SfxListener { @@ -97,10 +97,7 @@ public: void Paint( const Rectangle& rRect ); void MouseButtonUp( const MouseEvent& rMouseEvent ); void MouseButtonDown( const MouseEvent& rMouseEvent ); -// void MouseMove( const MouseEvent& rMouseEvent ); void Command( const CommandEvent& rCEvt ); - //sal_Bool Drop( const DropEvent& rEvt ); - //sal_Bool QueryDrop( DropEvent& rEvt ); sal_Bool ViewMoved(); @@ -136,3 +133,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/ttbasic.cxx b/basic/source/app/ttbasic.cxx index 98ffc1e4c08d..cfc12a85dcc4 100644 --- a/basic/source/app/ttbasic.cxx +++ b/basic/source/app/ttbasic.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,3 +35,5 @@ MyBasic* TTBasic::CreateMyBasic() { return new MyBasic; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/ttbasic.hxx b/basic/source/app/ttbasic.hxx index 04d74daa1bb7..8810da66b5e9 100644 --- a/basic/source/app/ttbasic.hxx +++ b/basic/source/app/ttbasic.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,3 +31,4 @@ public: static MyBasic* CreateMyBasic(); }; +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/app/ttmsg.src b/basic/source/app/ttmsg.src index 076ee83fd879..d5ac293e5115 100644 --- a/basic/source/app/ttmsg.src +++ b/basic/source/app/ttmsg.src @@ -27,18 +27,17 @@ #include "basic/ttmsg.hrc" -// Hier sind die Messages aus dem Verzeichnis /basic/source/testtool enhalten +// Here are included the messages of the folder /basic/source/testtool -/////////////////////////////// -// Fehlermeldungen, die in das Resultfile gelangen. +// Error messages which go to the result file. // ********************* -// *** !!ACHTUNG!! *** +// *** !!ATTENTION!! *** // ********************* -// Die Nummern dürfen sich NIE! ändern, -// da sie in den Resultfiles gespeichert sind, und bei erneutem Anzeigen -// statdessen die entsprechenden neuen oder garkeine Strings angzeigt werden. -/////////////////////////////// +// The numbers must NEVER(!) change, +// because they are saved in the result files and a renewed display +// would display new strings or no strings. + String S_NAME_NOT_THERE { Text[ en-US ] = "Name doesn't exist: #($Arg1)"; @@ -139,22 +138,4 @@ String S_UNKNOWN_METHOD { Text[ en-US ] = "Unknown method on object :($Arg1).($Arg2)"; }; -/* -String -{ - Text[ en-US ] = ; -}; -String -{ - Text[ en-US ] = ; -}; -String -{ - Text[ en-US ] = ; -}; -String -{ - Text[ en-US ] = ; -}; -*/ diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx index e8fe55c2f920..b24c232626f8 100644 --- a/basic/source/basmgr/basicmanagerrepository.cxx +++ b/basic/source/basmgr/basicmanagerrepository.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -52,9 +53,7 @@ #include <comphelper/documentinfo.hxx> #include <unotools/eventlisteneradapter.hxx> -#ifndef INCLUDED_OSL_DOUBLECHECKEDLOCKING_H #include <rtl/instance.hxx> -#endif #include <map> @@ -302,18 +301,18 @@ namespace basic if ( !aAppBasicDir.Len() ) aPathCFG.SetBasicPath( String::CreateFromAscii("$(prog)") ); - // #58293# soffice.new search only in user dir => first dir + // soffice.new search only in user dir => first dir String aAppFirstBasicDir = aAppBasicDir.GetToken(1); // Create basic and load it - // MT: #47347# AppBasicDir is now a PATH + // AppBasicDir is now a PATH INetURLObject aAppBasic( SvtPathOptions().SubstituteVariable( String::CreateFromAscii("$(progurl)") ) ); aAppBasic.insertName( Application::GetAppName() ); BasicManager* pBasicManager = new BasicManager( new StarBASIC, &aAppBasicDir ); setApplicationBasicManager( pBasicManager ); - // Als Destination das erste Dir im Pfad: + // The first dir in the path as destination: String aFileName( aAppBasic.getName() ); aAppBasic = INetURLObject( aAppBasicDir.GetToken(1) ); DBG_ASSERT( aAppBasic.GetProtocol() != INET_PROT_NOT_VALID, "Invalid URL!" ); @@ -365,7 +364,7 @@ namespace basic if ( pos != m_aCreationListeners.end() ) m_aCreationListeners.erase( pos ); else { - DBG_ERROR( "ImplRepository::revokeCreationListener: listener is not registered!" ); + OSL_FAIL( "ImplRepository::revokeCreationListener: listener is not registered!" ); } } @@ -484,14 +483,11 @@ namespace basic LibraryContainerInfo aInfo( xBasicLibs, xDialogLibs, dynamic_cast< OldBasicPassword* >( xBasicLibs.get() ) ); OSL_ENSURE( aInfo.mpOldBasicPassword, "ImplRepository::impl_createManagerForModel: wrong BasicLibraries implementation!" ); _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. // initialize the containers impl_initDocLibraryContainers_nothrow( xBasicLibs, xDialogLibs ); - // damit auch Dialoge etc. 'qualifiziert' angesprochen werden k"onnen + // so that also dialogs etc. could be 'qualified' addressed _out_rpBasicManager->GetLib(0)->SetParent( pAppBasic ); // global properties in the document's Basic @@ -616,7 +612,7 @@ namespace basic // a BasicManager which is still in our repository is being deleted. // That's bad, since by definition, we *own* all instances in our // repository. - OSL_ENSURE( false, "ImplRepository::Notify: nobody should tamper with the managers, except ourself!" ); + OSL_FAIL( "ImplRepository::Notify: nobody should tamper with the managers, except ourself!" ); m_aStore.erase( loop ); break; } @@ -660,3 +656,4 @@ namespace basic } // namespace basic //........................................................................ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index a6a1fb5f23c0..c077246d6fb0 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -52,6 +53,7 @@ #include "sbintern.hxx" #include <sb.hrc> +#include <vector> #define LIB_SEP 0x01 #define LIBINFO_SEP 0x02 @@ -75,6 +77,8 @@ #include <cppuhelper/implbase1.hxx> using com::sun::star::uno::Reference; +using ::std::vector; +using ::std::advance; using namespace com::sun::star::container; using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -86,7 +90,7 @@ typedef WeakImplHelper1< XStarBasicModuleInfo > ModuleInfoHelper; typedef WeakImplHelper1< XStarBasicDialogInfo > DialogInfoHelper; typedef WeakImplHelper1< XStarBasicLibraryInfo > LibraryInfoHelper; typedef WeakImplHelper1< XStarBasicAccess > StarBasicAccessHelper; - +typedef vector< BasicError* > BasErrorLst; #define CURR_VER 2 @@ -116,8 +120,6 @@ DBG_NAME( BasicManager ); StreamMode eStreamReadMode = STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYALL; StreamMode eStorageReadMode = STREAM_READ | STREAM_SHARE_DENYWRITE; -DECLARE_LIST( BasErrorLst, BasicError* ) - //---------------------------------------------------------------------------- // BasicManager impl data struct BasicManagerImpl @@ -389,18 +391,24 @@ class BasicErrorManager { private: BasErrorLst aErrorList; + size_t CurrentError; public: + BasicErrorManager(); ~BasicErrorManager(); void Reset(); void InsertError( const BasicError& rError ); - sal_Bool HasErrors() { return (sal_Bool)aErrorList.Count(); } - BasicError* GetFirstError() { return aErrorList.First(); } - BasicError* GetNextError() { return aErrorList.Next(); } + bool HasErrors() { return !aErrorList.empty(); } + BasicError* GetFirstError(); + BasicError* GetNextError(); }; +BasicErrorManager::BasicErrorManager() + : CurrentError( 0 ) +{ +} BasicErrorManager::~BasicErrorManager() { @@ -409,20 +417,36 @@ BasicErrorManager::~BasicErrorManager() void BasicErrorManager::Reset() { - BasicError* pError = (BasicError*)aErrorList.First(); - while ( pError ) - { - delete pError; - pError = (BasicError*)aErrorList.Next(); - } - aErrorList.Clear(); + for ( size_t i = 0, n = aErrorList.size(); i < n; ++i ) + delete aErrorList[ i ]; + aErrorList.clear(); } void BasicErrorManager::InsertError( const BasicError& rError ) { - aErrorList.Insert( new BasicError( rError ), LIST_APPEND ); + aErrorList.push_back( new BasicError( rError ) ); } +BasicError* BasicErrorManager::GetFirstError() +{ + CurrentError = 0; + return aErrorList.empty() ? NULL : aErrorList[ CurrentError ]; +} + +BasicError* BasicErrorManager::GetNextError() +{ + if ( !aErrorList.empty() + && CurrentError < ( aErrorList.size() - 1) + ) + { + ++CurrentError; + return aErrorList[ CurrentError ]; + } + return NULL; +} + + +//===================================================================== BasicError::BasicError() { @@ -445,6 +469,8 @@ BasicError::BasicError( const BasicError& rErr ) : } +//===================================================================== + class BasicLibInfo { private: @@ -513,14 +539,111 @@ public: { mxScriptCont = xScriptCont; } }; -DECLARE_LIST( BasicLibsBase, BasicLibInfo* ) -class BasicLibs : public BasicLibsBase +//===================================================================== + +class BasicLibs { +private: + vector< BasicLibInfo* > aList; + size_t CurrentLib; + public: - String aBasicLibPath; // TODO: Should be member of manager, but currently not incompatible + ~BasicLibs(); + String aBasicLibPath; // TODO: Should be member of manager, but currently not incompatible + BasicLibInfo* GetObject( size_t i ); + BasicLibInfo* First(); + BasicLibInfo* Last(); + BasicLibInfo* Prev(); + BasicLibInfo* Next(); + size_t GetPos( BasicLibInfo* LibInfo ); + size_t Count() const { return aList.size(); }; + size_t GetCurPos() const { return CurrentLib; }; + void Insert( BasicLibInfo* LibInfo ); + BasicLibInfo* Remove( BasicLibInfo* LibInfo ); }; +BasicLibs::~BasicLibs() { + for ( size_t i = 0, n = aList.size(); i < n; ++i ) + delete aList[ i ]; + aList.clear(); +} + +BasicLibInfo* BasicLibs::GetObject( size_t i ) +{ + if ( aList.empty() + || aList.size() <= i + ) + return NULL; + CurrentLib = i; + return aList[ CurrentLib ]; +} + +BasicLibInfo* BasicLibs::First() +{ + if ( aList.empty() ) + return NULL; + CurrentLib = 0; + return aList[ CurrentLib ]; +} + +BasicLibInfo* BasicLibs::Last() +{ + if ( aList.empty() ) + return NULL; + CurrentLib = aList.size() - 1; + return aList[ CurrentLib ]; +} + +BasicLibInfo* BasicLibs::Prev() +{ + if ( aList.empty() + || CurrentLib == 0 + ) + return NULL; + --CurrentLib; + return aList[ CurrentLib ]; +} + +BasicLibInfo* BasicLibs::Next() +{ + if ( aList.empty() + || CurrentLib >= ( aList.size() - 1 ) + ) + return NULL; + ++CurrentLib; + return aList[ CurrentLib ]; +} + +size_t BasicLibs::GetPos( BasicLibInfo* LibInfo ) +{ + for ( size_t i = 0, n = aList.size(); i < n; ++i ) + if ( aList[ i ] == LibInfo ) + return i; + return size_t( -1 ); +} + +void BasicLibs::Insert( BasicLibInfo* LibInfo ) +{ + aList.push_back( LibInfo ); + CurrentLib = aList.size() - 1; +} + +BasicLibInfo* BasicLibs::Remove( BasicLibInfo* LibInfo ) +{ + size_t i = GetPos( LibInfo ); + if ( i < aList.size() ) + { + vector< BasicLibInfo* >::iterator it = aList.begin(); + advance( it , i ); + it = aList.erase( it ); + } + return LibInfo; +} + + +//===================================================================== + BasicLibInfo::BasicLibInfo() { bReference = sal_False; @@ -681,11 +804,6 @@ BasicManager::BasicManager( SotStorage& rStorage, const String& rBaseURL, StarBA String aStorName( rStorage.GetName() ); maStorageName = INetURLObject(aStorName, INET_PROT_FILE).GetMainURL( INetURLObject::NO_DECODE ); - // #91251: Storage name not longer available for documents < 5.0 - // Should be no real problem, because only relative storage names - // (links) can be affected. - // DBG_ASSERT( aStorName.Len(), "No Storage Name!" ); - // DBG_ASSERT(aStorageName.Len() != 0, "Bad storage name"); // If there is no Manager Stream, no further actions are necessary if ( rStorage.IsStream( String(RTL_CONSTASCII_USTRINGPARAM(szManagerStream)) ) ) @@ -717,7 +835,6 @@ BasicManager::BasicManager( SotStorage& rStorage, const String& rBaseURL, StarBA StarBASIC* pBasic = GetLib( nBasic ); if ( pBasic ) { -// pBasic->SetParent( pStdLib ); pStdLib->Insert( pBasic ); pBasic->SetFlag( SBX_EXTSEARCH ); } @@ -832,7 +949,7 @@ void BasicManager::SetLibraryContainerInfo( const LibraryContainerInfo& rInfo ) { Any aLibAny = xScriptCont->getByName( *pScriptLibName ); - if ( pScriptLibName->equalsAscii( "Standard" ) ) + if ( pScriptLibName->equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("Standard")) ) xScriptCont->loadLibrary( *pScriptLibName ); BasMgrContainerListenerImpl::insertLibraryImpl @@ -940,7 +1057,6 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseUR { DBG_CHKTHIS( BasicManager, 0 ); -// StreamMode eStreamMode = STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE; SotStorageStreamRef xManagerStream = rStorage.OpenSotStream ( String(RTL_CONSTASCII_USTRINGPARAM(szManagerStream)), eStreamReadMode ); @@ -959,8 +1075,6 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseUR String aRealStorageName = maStorageName; // for relative paths, can be modified through BaseURL - // If loaded from template, only BaseURL is used: - //String aBaseURL = INetURLObject::GetBaseURL(); if ( rBaseURL.Len() ) { INetURLObject aObj( rBaseURL ); @@ -976,7 +1090,7 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseUR sal_uInt16 nLibs; *xManagerStream >> nLibs; - // Plausi! + // Plausibility! if( nLibs & 0xF000 ) { DBG_ASSERT( !this, "BasicManager-Stream defect!" ); @@ -996,9 +1110,6 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseUR aObj = aObj.smartRel2Abs( pInfo->GetRelStorageName(), bWasAbsolute ); //*** TODO: Replace if still necessary - /* if ( SfxContentHelper::Exists( aObj.GetMainURL() ) ) - pInfo->SetStorageName( aObj.GetMainURL() ); - else */ //*** TODO-End if ( pLibs->aBasicLibPath.Len() ) { @@ -1013,7 +1124,7 @@ void BasicManager::LoadBasicManager( SotStorage& rStorage, const String& rBaseUR } } - pLibs->Insert( pInfo, LIST_APPEND ); + pLibs->Insert( pInfo ); // Libs from external files should be loaded only when necessary. // But references are loaded at once, otherwise some big customers get into trouble if ( bLoadLibs && pInfo->DoLoad() && @@ -1032,7 +1143,6 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage ) { DBG_CHKTHIS( BasicManager, 0 ); -// StreamMode eStreamMode = STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE; SotStorageStreamRef xManagerStream = rStorage.OpenSotStream ( String::CreateFromAscii(szOldManagerStream), eStreamReadMode ); @@ -1057,11 +1167,9 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage ) xManagerStream->Seek( nBasicStartOff ); if( !ImplLoadBasic( *xManagerStream, pLibs->GetObject(0)->GetLibRef() ) ) { -// String aErrorText( BasicResId( IDS_SBERR_MGROPEN ) ); -// aErrorText.SearchAndReplace( "XX", aStorName ); StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_MGROPEN, aStorName, ERRCODE_BUTTON_OK ); pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_OPENMGRSTREAM, aStorName ) ); - // und es geht weiter... + // and it proceeds ... } xManagerStream->Seek( nBasicEndOff+1 ); // +1: 0x00 as separator String aLibs; @@ -1105,8 +1213,6 @@ void BasicManager::LoadOldBasicManager( SotStorage& rStorage ) AddLib( *xStorageRef, aLibName, sal_False ); else { -// String aErrorText( BasicResId( IDS_SBERR_LIBLOAD ) ); -// aErrorText.SearchAndReplace( "XX", aLibName ); StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, aStorName, ERRCODE_BUTTON_OK ); pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_STORAGENOTFOUND, aStorName ) ); } @@ -1123,13 +1229,6 @@ BasicManager::~BasicManager() // Destroy Basic-Infos... // In reverse order - BasicLibInfo* pInf = pLibs->Last(); - while ( pInf ) - { - delete pInf; - pInf = pLibs->Prev(); - } - pLibs->Clear(); delete pLibs; delete pErrorMgr; delete mpImpl; @@ -1141,6 +1240,25 @@ void BasicManager::LegacyDeleteBasicManager( BasicManager*& _rpManager ) _rpManager = NULL; } + +bool BasicManager::HasExeCode( const String& sLib ) +{ + StarBASIC* pLib = GetLib(sLib); + if ( pLib ) + { + SbxArray* pMods = pLib->GetModules(); + sal_uInt16 nMods = pMods ? pMods->Count() : 0; + for( sal_uInt16 i = 0; i < nMods; i++ ) + { + SbModule* p = (SbModule*) pMods->Get( i ); + if ( p ) + if ( p->HasExeCode() ) + return true; + } + } + return false; +} + void BasicManager::Init() { DBG_CHKTHIS( BasicManager, 0 ); @@ -1156,7 +1274,7 @@ BasicLibInfo* BasicManager::CreateLibInfo() DBG_CHKTHIS( BasicManager, 0 ); BasicLibInfo* pInf = new BasicLibInfo; - pLibs->Insert( pInf, LIST_APPEND ); + pLibs->Insert( pInf ); return pInf; } @@ -1242,7 +1360,7 @@ sal_Bool BasicManager::ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurSt else { // Perhaps there are additional information in the stream... - xBasicStream->SetKey( szCryptingKey ); + xBasicStream->SetCryptMaskKey(szCryptingKey); xBasicStream->RefreshBuffer(); sal_uInt32 nPasswordMarker = 0; *xBasicStream >> nPasswordMarker; @@ -1252,7 +1370,7 @@ sal_Bool BasicManager::ImpLoadLibary( BasicLibInfo* pLibInfo, SotStorage* pCurSt xBasicStream->ReadByteString(aPassword); pLibInfo->SetPassword( aPassword ); } - xBasicStream->SetKey( ByteString() ); + xBasicStream->SetCryptMaskKey(rtl::OString()); CheckModules( pLibInfo->GetLib(), pLibInfo->IsReference() ); } return bLoaded; @@ -1272,7 +1390,7 @@ sal_Bool BasicManager::ImplEncryptStream( SvStream& rStrm ) const { // Should only be the case for encrypted Streams bProtected = sal_True; - rStrm.SetKey( szCryptingKey ); + rStrm.SetCryptMaskKey(szCryptingKey); rStrm.RefreshBuffer(); } return bProtected; @@ -1303,19 +1421,12 @@ sal_Bool BasicManager::ImplLoadBasic( SvStream& rStrm, StarBASICRef& rOldBasic ) // Fill new libray container (5.2 -> 6.0) copyToLibraryContainer( pNew, mpImpl->maContainerInfo ); -/* - if( rOldBasic->GetParent() ) - { - rOldBasic->GetParent()->Insert( rOldBasic ); - rOldBasic->SetFlag( SBX_EXTSEARCH ); - } -*/ pNew->SetModified( sal_False ); bLoaded = sal_True; } } if ( bProtected ) - rStrm.SetKey( ByteString() ); + rStrm.SetCryptMaskKey(rtl::OString()); return bLoaded; } @@ -1338,7 +1449,7 @@ void BasicManager::CheckModules( StarBASIC* pLib, sal_Bool bReference ) const // cause modified if( !bModified && bReference ) { - DBG_ERROR( "Per Reference eingebundene Basic-Library ist nicht compiliert!" ); + OSL_FAIL( "Per Reference eingebundene Basic-Library ist nicht compiliert!" ); pLib->SetModified( sal_False ); } } @@ -1361,7 +1472,6 @@ StarBASIC* BasicManager::AddLib( SotStorage& rStorage, const String& rLibName, s // Use original name otherwise ImpLoadLibary failes... pLibInfo->SetLibName( rLibName ); // Funktioniert so aber nicht, wenn Name doppelt -// sal_uInt16 nLibId = GetLibId( rLibName ); sal_uInt16 nLibId = (sal_uInt16) pLibs->GetPos( pLibInfo ); // Set StorageName before load because it is compared with pCurStorage @@ -1377,7 +1487,6 @@ StarBASIC* BasicManager::AddLib( SotStorage& rStorage, const String& rLibName, s { pLibInfo->GetLib()->SetModified( sal_False ); // Don't save in this case pLibInfo->SetRelStorageName( String() ); -// pLibInfo->CalcRelStorageName( GetStorageName() ); pLibInfo->IsReference() = sal_True; } else @@ -1427,7 +1536,6 @@ sal_Bool BasicManager::RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage if ( !pLibInfo || !nLib ) { -// String aErrorText( BasicResId( IDS_SBERR_REMOVELIB ) ); StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, String(), ERRCODE_BUTTON_OK ); pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_STDLIB, pLibInfo->GetLibName() ) ); return sal_False; @@ -1451,7 +1559,6 @@ sal_Bool BasicManager::RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage if ( !xBasicStorage.Is() || xBasicStorage->GetError() ) { -// String aErrorText( BasicResId( IDS_SBERR_REMOVELIB ) ); StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_REMOVELIB, String(), ERRCODE_BUTTON_OK ); pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_OPENLIBSTORAGE, pLibInfo->GetLibName() ) ); } @@ -1462,18 +1569,18 @@ sal_Bool BasicManager::RemoveLib( sal_uInt16 nLib, sal_Bool bDelBasicFromStorage // If no further stream available, // delete the SubStorage. - SvStorageInfoList aInfoList( 0, 4 ); + SvStorageInfoList aInfoList; xBasicStorage->FillInfoList( &aInfoList ); - if ( !aInfoList.Count() ) + if ( aInfoList.empty() ) { xBasicStorage.Clear(); xStorage->Remove( String(RTL_CONSTASCII_USTRINGPARAM(szBasicStorage)) ); xStorage->Commit(); // If no further Streams or SubStorages available, // delete the Storage, too. - aInfoList.Clear(); + aInfoList.clear(); xStorage->FillInfoList( &aInfoList ); - if ( !aInfoList.Count() ) + if ( aInfoList.empty() ) { String aName_( xStorage->GetName() ); xStorage.Clear(); @@ -1614,7 +1721,6 @@ sal_Bool BasicManager::LoadLib( sal_uInt16 nLib ) StarBASIC* pLib = GetLib( nLib ); if ( pLib ) { - // pLib->SetParent( GetStdLib() ); GetStdLib()->Insert( pLib ); pLib->SetFlag( SBX_EXTSEARCH ); } @@ -1622,8 +1728,6 @@ sal_Bool BasicManager::LoadLib( sal_uInt16 nLib ) } else { -// String aErrorText( BasicResId( IDS_SBERR_LIBLOAD ) ); -// aErrorText.SearchAndReplace( "XX", "" ); StringErrorInfo* pErrInf = new StringErrorInfo( ERRCODE_BASMGR_LIBLOAD, String(), ERRCODE_BUTTON_OK ); pErrorMgr->InsertError( BasicError( *pErrInf, BASERR_REASON_LIBNOTFOUND, String::CreateFromInt32(nLib) ) ); } @@ -1660,16 +1764,7 @@ StarBASIC* BasicManager::CreateLib if( !xStorage->GetError() ) { pLib = AddLib( *xStorage, rLibName, sal_True ); - - //if( !pLibInfo ) - //pLibInfo = FindLibInfo( pLib ); - //pLibInfo->SetStorageName( LinkTargetURL ); - //pLibInfo->GetLib()->SetModified( sal_False ); // Dann nicht speichern - //pLibInfo->SetRelStorageName( String() ); - //pLibInfo->IsReference() = sal_True; } - //else - //Message? DBG_ASSERT( pLib, "XML Import: Linked basic library could not be loaded"); } @@ -1832,7 +1927,7 @@ bool BasicManager::LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequen const ::rtl::OUString* pNamesEnd = aNames.getConstArray() + aNames.getLength(); for ( ; pNames != pNamesEnd; ++pNames ) { - if( /*pLib->mbSharedIndexFile ||*/ !xPassword->isLibraryPasswordProtected( *pNames ) ) + if( !xPassword->isLibraryPasswordProtected( *pNames ) ) continue; StarBASIC* pBasicLib = GetLib( *pNames ); @@ -2600,3 +2695,4 @@ Reference< XStarBasicAccess > getStarBasicAccess( BasicManager* pMgr ) return xRet; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/basmgr/makefile.mk b/basic/source/basmgr/makefile.mk index 615a8e8465ef..615a8e8465ef 100644..100755 --- a/basic/source/basmgr/makefile.mk +++ b/basic/source/basmgr/makefile.mk diff --git a/basic/source/classes/disas.cxx b/basic/source/classes/disas.cxx index 37d777cb8da8..96213a8d68dd 100644 --- a/basic/source/classes/disas.cxx +++ b/basic/source/classes/disas.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -35,7 +36,6 @@ #include "sb.hxx" #include "iosys.hxx" #include "disas.hxx" -#include "sbtrace.hxx" static const char* pOp1[] = { @@ -228,7 +228,7 @@ static const Func pOperand3[] = { // TODO: Why as method? Isn't a simple define sufficient? static const char* _crlf() { -#if defined (UNX) || defined( PM2 ) +#if defined (UNX) return "\n"; #else return "\r\n"; @@ -363,10 +363,6 @@ sal_Bool SbiDisas::DisasLine( String& rText ) if( !Fetch() ) return sal_False; -#ifdef DBG_TRACE_BASIC - String aTraceStr_STMNT; -#endif - // New line? if( eOp == _STMNT && nOp1 != nLine ) { @@ -394,15 +390,9 @@ sal_Bool SbiDisas::DisasLine( String& rText ) n = s.Search( '\n' ); if( n != STRING_NOTFOUND ) bDone = sal_False, s.Erase( n, 1 ); } while( !bDone ); -// snprintf( cBuf, sizeof(cBuf), pMask[ 0 ], nPC ); -// rText += cBuf; rText.AppendAscii( "; " ); rText += s; rText.AppendAscii( _crlf() ); - -#ifdef DBG_TRACE_BASIC - aTraceStr_STMNT = s; -#endif } } @@ -462,10 +452,6 @@ sal_Bool SbiDisas::DisasLine( String& rText ) rText += aPCodeStr; -#ifdef DBG_TRACE_BASIC - dbg_RegisterTraceTextForPC( pMod, nPC, aTraceStr_STMNT, aPCodeStr ); -#endif - return sal_True; } @@ -610,29 +596,21 @@ void SbiDisas::OffOp( String& rText ) } // Data type -#ifdef HP9000 // TODO: remove this! -static char* SbiDisas_TypeOp_pTypes[13] = { - "Empty","Null","Integer","Long","Single","Double", - "Currency","Date","String","Object","Error","Boolean", - "Variant" }; -#define pTypes SbiDisas_TypeOp_pTypes -#endif void SbiDisas::TypeOp( String& rText ) { - // AB 19.1.96: Typ kann Flag für BYVAL enthalten (StepARGTYP) + // From 1996-01-19: type can contain flag for BYVAL (StepARGTYP) if( nOp1 & 0x8000 ) { - nOp1 &= 0x7FFF; // Flag wegfiltern + nOp1 &= 0x7FFF; // filter away the flag rText.AppendAscii( "BYVAL " ); } if( nOp1 < 13 ) { -#ifndef HP9000 static char pTypes[][13] = { "Empty","Null","Integer","Long","Single","Double", "Currency","Date","String","Object","Error","Boolean", "Variant" }; -#endif + rText.AppendAscii( pTypes[ nOp1 ] ); } else @@ -641,9 +619,6 @@ void SbiDisas::TypeOp( String& rText ) rText += (sal_uInt16)nOp1; } } -#ifdef HP9000 -#undef pTypes -#endif // sal_True-Label, condition Opcode void SbiDisas::CaseOp( String& rText ) @@ -685,3 +660,4 @@ void SbiDisas::StrmOp( String& rText ) } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/classes/errobject.cxx b/basic/source/classes/errobject.cxx index 0ec0454e2bb5..44f55aa65f7a 100644 --- a/basic/source/classes/errobject.cxx +++ b/basic/source/classes/errobject.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -174,7 +175,7 @@ void ErrObject::setData( const uno::Any& Number, const uno::Any& Source, const u throw (uno::RuntimeException) { if ( !Number.hasValue() ) - throw uno::RuntimeException( rtl::OUString::createFromAscii("Missing Required Paramater"), uno::Reference< uno::XInterface >() ); + throw uno::RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Missing Required Paramater")), uno::Reference< uno::XInterface >() ); Number >>= m_nNumber; Description >>= m_sDescription; Source >>= m_sSource; @@ -223,3 +224,4 @@ void SbxErrObject::setNumberAndDescription( ::sal_Int32 _number, const ::rtl::OU m_pErrObject->setData( uno::makeAny( _number ), uno::Any(), uno::makeAny( _description ), uno::Any(), uno::Any() ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/classes/eventatt.cxx b/basic/source/classes/eventatt.cxx index 8d9f30e4982f..ceb4ea9230ab 100644 --- a/basic/source/classes/eventatt.cxx +++ b/basic/source/classes/eventatt.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,7 +29,6 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -//#include <stl_queue.h> #include <osl/mutex.hxx> #include <comphelper/processfactory.hxx> @@ -108,18 +108,18 @@ void SFURL_firing_impl( const ScriptEvent& aScriptEvent, Any* pRet, const Refere Reference< XComponentContext > xContext; Reference< XPropertySet > xProps( ::comphelper::getProcessServiceFactory(), UNO_QUERY ); OSL_ASSERT( xProps.is() ); - OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString::createFromAscii( "DefaultContext" ) ) >>= xContext ); + OSL_VERIFY( xProps->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); if ( xContext.is() ) { Reference< provider::XScriptProviderFactory > xFactory( xContext->getValueByName( - ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory" ) ), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.script.provider.theMasterScriptProviderFactory")) ), UNO_QUERY ); OSL_ENSURE( xFactory.is(), "SFURL_firing_impl: failed to get master script provider factory" ); if ( xFactory.is() ) { Any aCtx; - aCtx <<= ::rtl::OUString::createFromAscii( "user" ); + aCtx <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")); xScriptProvider.set( xFactory->createScriptProvider( aCtx ), UNO_QUERY ); } } @@ -207,15 +207,13 @@ Any BasicScriptListener_Impl::approveFiring( const ScriptEvent& aScriptEvent ) void BasicScriptListener_Impl::disposing(const EventObject& ) throw ( RuntimeException ) { // TODO: ??? - //vos::OGuard guard( Application::GetSolarMutex() ); + //SolarMutexGuard aGuard; //xSbxObj.Clear(); } void BasicScriptListener_Impl::firing_impl( const ScriptEvent& aScriptEvent, Any* pRet ) { - //Guard< Mutex > aGuard( Mutex::getGlobalMutex() ); - //{ if( aScriptEvent.ScriptType.compareToAscii( "StarBasic" ) == 0 ) { // Full qualified name? @@ -438,15 +436,8 @@ Any implFindDialogLibForDialogBasic( const Any& aAnyISP, SbxObject* pBasic, Star return aDlgLibAny; } -static ::rtl::OUString aDecorationPropName = - ::rtl::OUString::createFromAscii( "Decoration" ); -static ::rtl::OUString aTitlePropName = - ::rtl::OUString::createFromAscii( "Title" ); - void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ) { - static ::rtl::OUString aResourceResolverPropName = ::rtl::OUString::createFromAscii( "ResourceResolver" ); - (void)pBasic; (void)bWrite; @@ -505,11 +496,14 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit bool bDecoration = true; try { + ::rtl::OUString aDecorationPropName(RTL_CONSTASCII_USTRINGPARAM("Decoration")); Any aDecorationAny = xDlgModPropSet->getPropertyValue( aDecorationPropName ); aDecorationAny >>= bDecoration; if( !bDecoration ) { xDlgModPropSet->setPropertyValue( aDecorationPropName, makeAny( true ) ); + + ::rtl::OUString aTitlePropName(RTL_CONSTASCII_USTRINGPARAM("Title")); xDlgModPropSet->setPropertyValue( aTitlePropName, makeAny( ::rtl::OUString() ) ); } } @@ -522,43 +516,43 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit StarBASIC* pFoundBasic = NULL; OSL_TRACE("About to try get a hold of ThisComponent"); 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 ) - { - Reference< frame::XDesktop > xDesktop( xMSF->createInstance - ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ), - UNO_QUERY ); - Reference< container::XEnumeration > xModels; - if ( xDesktop.is() ) + aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pINST->GetBasic(), pFoundBasic ); + // If we found the dialog then it belongs to the Search basic + if ( !pFoundBasic ) { - Reference< container::XEnumerationAccess > xComponents( xDesktop->getComponents(), UNO_QUERY ); - if ( xComponents.is() ) - xModels.set( xComponents->createEnumeration(), UNO_QUERY ); - if ( xModels.is() ) + Reference< frame::XDesktop > xDesktop( xMSF->createInstance + ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ), + UNO_QUERY ); + Reference< container::XEnumeration > xModels; + if ( xDesktop.is() ) + { + Reference< container::XEnumerationAccess > xComponents( xDesktop->getComponents(), UNO_QUERY ); + if ( xComponents.is() ) + xModels.set( xComponents->createEnumeration(), UNO_QUERY ); + if ( xModels.is() ) + { + while ( xModels->hasMoreElements() ) { - while ( xModels->hasMoreElements() ) + Reference< frame::XModel > xNextModel( xModels->nextElement(), UNO_QUERY ); + if ( xNextModel.is() ) { - Reference< frame::XModel > xNextModel( xModels->nextElement(), UNO_QUERY ); - if ( xNextModel.is() ) + BasicManager* pMgr = basic::BasicManagerRepository::getDocumentBasicManager( xNextModel ); + if ( pMgr ) + aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pMgr->GetLib(0), pFoundBasic ); + if ( aDlgLibAny.hasValue() ) { - BasicManager* pMgr = basic::BasicManagerRepository::getDocumentBasicManager( xNextModel ); - if ( pMgr ) - aDlgLibAny = implFindDialogLibForDialogBasic( aAnyISP, pMgr->GetLib(0), pFoundBasic ); - if ( aDlgLibAny.hasValue() ) - { - bDocDialog = true; - xModel = xNextModel; - break; - } + bDocDialog = true; + xModel = xNextModel; + break; } } } } } + } if ( pFoundBasic ) bDocDialog = pFoundBasic->IsDocBasic(); - Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( pINST->GetBasic(), xModel ); + Reference< XScriptListener > xScriptListener = new BasicScriptListener_Impl( pINST->GetBasic(), xModel ); Sequence< Any > aArgs( 4 ); if( bDocDialog ) @@ -569,23 +563,23 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit aArgs[ 2 ] = aDlgLibAny; aArgs[ 3 ] <<= xScriptListener; // Create a "living" Dialog - Reference< XControl > xCntrl; - try - { + Reference< XControl > xCntrl; + try + { Reference< XDialogProvider > xDlgProv( xMSF->createInstanceWithArguments( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.scripting.DialogProvider" ) ), aArgs ), UNO_QUERY ); - xCntrl.set( xDlgProv->createDialog( rtl::OUString() ), UNO_QUERY_THROW ); - // Add dialog model to dispose vector - Reference< XComponent > xDlgComponent( xCntrl->getModel(), UNO_QUERY ); - pINST->getComponentVector().push_back( xDlgComponent ); - // need ThisCompoent from calling script - } - // preserve existing bad behaviour, it's possible... but probably - // illegal to open 2 dialogs ( they ARE modal ) when this happens, sometimes - // create dialog fails. So, in this case let's not throw, just leave basic - // detect the unset object. - catch( uno::Exception& ) - { - } + xCntrl.set( xDlgProv->createDialog( rtl::OUString() ), UNO_QUERY_THROW ); + // Add dialog model to dispose vector + Reference< XComponent > xDlgComponent( xCntrl->getModel(), UNO_QUERY ); + pINST->getComponentVector().push_back( xDlgComponent ); + // need ThisCompoent from calling script + } + // preserve existing bad behaviour, it's possible... but probably + // illegal to open 2 dialogs ( they ARE modal ) when this happens, sometimes + // create dialog fails. So, in this case let's not throw, just leave basic + // detect the unset object. + catch( uno::Exception& ) + { + } // Return dialog Any aRetVal; @@ -597,3 +591,4 @@ void RTL_Impl_CreateUnoDialog( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit //=================================================================== +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx index fc6228d1aee9..84c6a25dab39 100644 --- a/basic/source/classes/image.cxx +++ b/basic/source/classes/image.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -148,7 +149,6 @@ sal_Bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) sal_uIntPtr nNext; while( ( nNext = r.Tell() ) < nLast ) { - short i; r >> nSign >> nLen >> nCount; nNext += nLen + 8; @@ -157,18 +157,15 @@ sal_Bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) { case B_NAME: r.ReadByteString( aName, eCharSet ); - //r >> aName; break; case B_COMMENT: r.ReadByteString( aComment, eCharSet ); - //r >> aComment; break; case B_SOURCE: { String aTmp; r.ReadByteString( aTmp, eCharSet ); aOUSource = aTmp; - //r >> aSource; break; } #ifdef EXTENDED_BINARY_MODULES @@ -216,6 +213,7 @@ sal_Bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) case B_STRINGPOOL: if( bBadVer ) break; MakeStrings( nCount ); + short i; for( i = 0; i < nStrings && SbiGood( r ); i++ ) { r >> nOff; @@ -249,8 +247,6 @@ sal_Bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) } done: r.Seek( nLast ); - //if( eCharSet != ::GetSystemCharSet() ) - //ConvertStrings(); if( !SbiGood( r ) ) bError = sal_True; return sal_Bool( !bError ); @@ -290,7 +286,6 @@ sal_Bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) { nPos = SbiOpenRecord( r, B_NAME, 1 ); r.WriteByteString( aName, eCharSet ); - //r << aName; SbiCloseRecord( r, nPos ); } // Comment? @@ -298,7 +293,6 @@ sal_Bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) { nPos = SbiOpenRecord( r, B_COMMENT, 1 ); r.WriteByteString( aComment, eCharSet ); - //r << aComment; SbiCloseRecord( r, nPos ); } // Source? @@ -313,7 +307,6 @@ sal_Bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) else aTmp = aOUSource; r.WriteByteString( aTmp, eCharSet ); - //r << aSource; SbiCloseRecord( r, nPos ); #ifdef EXTENDED_BINARY_MODULES @@ -407,8 +400,6 @@ void SbiImage::MakeStrings( short nSize ) bError = sal_True; } -// Hinzufuegen eines Strings an den StringPool. Der String-Puffer -// waechst dynamisch in 1K-Schritten // Add a string to StringPool. The String buffer is dynamically // growing in 1K-Steps void SbiImage::AddString( const String& r ) @@ -441,7 +432,6 @@ void SbiImage::AddString( const String& r ) if( !bError ) { pStringOff[ nStringIdx++ ] = nStringOff; - //ByteString aByteStr( r, eCharSet ); memcpy( pStrings + nStringOff, r.GetBuffer(), len * sizeof( sal_Unicode ) ); nStringOff = nStringOff + len; // Last String? The update the size of the buffer @@ -542,3 +532,5 @@ sal_Bool SbiImage::ExceedsLegacyLimits() return sal_True; return sal_False; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/classes/makefile.mk b/basic/source/classes/makefile.mk index e00ed4674cc1..e00ed4674cc1 100644..100755 --- a/basic/source/classes/makefile.mk +++ b/basic/source/classes/makefile.mk diff --git a/basic/source/classes/propacc.cxx b/basic/source/classes/propacc.cxx index 9168ef915770..89034c31d4a2 100644 --- a/basic/source/classes/propacc.cxx +++ b/basic/source/classes/propacc.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -53,7 +54,7 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty #ifdef WNT #define CDECL _cdecl #endif -#if defined(UNX) || defined(OS2) +#if defined(UNX) #define CDECL #endif @@ -119,7 +120,7 @@ sal_Int32 SbPropertyValues::GetIndex_Impl( const ::rtl::OUString &rPropName ) co bsearch( &rPropName, _aPropVals.GetData(), _aPropVals.Count(), sizeof( PropertyValue* ), SbCompare_UString_PropertyValue_Impl ); - return ppPV ? ( (ppPV-_aPropVals.GetData()) / sizeof(ppPV) ) : USHRT_MAX; + return ppPV ? ppPV - _aPropVals.GetData() : USHRT_MAX; } //---------------------------------------------------------------------------- @@ -238,7 +239,7 @@ sal_Int32 PropertySetInfoImpl::GetIndex_Impl( const ::rtl::OUString &rPropName ) bsearch( &rPropName, _aProps.getConstArray(), _aProps.getLength(), sizeof( Property ), SbCompare_UString_Property_Impl ); - return pP ? sal::static_int_cast<sal_Int32>( (pP-_aProps.getConstArray()) / sizeof(pP) ) : -1; + return pP ? sal::static_int_cast<sal_Int32>( pP - _aProps.getConstArray() ) : -1; } Sequence< Property > PropertySetInfoImpl::getProperties(void) throw() @@ -391,15 +392,7 @@ void RTL_Impl_CreatePropertySet( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWr // Get class names of struct String aServiceName( RTL_CONSTASCII_USTRINGPARAM("stardiv.uno.beans.PropertySet") ); -#if 0 - // Service suchen und instanzieren - Reference< XMultiServiceFactory > xServiceManager = getProcessServiceFactory(); - Reference< XInterface > xInterface; - if( xProv.is() ) - xInterface = xProv->newInstance(); -#else Reference< XInterface > xInterface = (OWeakObject*) new SbPropertyValues(); -#endif SbxVariableRef refVar = rPar.Get(0); if( xInterface.is() ) @@ -428,3 +421,4 @@ void RTL_Impl_CreatePropertySet( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWr refVar->PutObject( NULL ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index bf7b00e2a633..221286e91142 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,11 +35,8 @@ #include <tools/rcid.h> #include <tools/config.hxx> #include <tools/stream.hxx> -#ifndef __RSC //autogen #include <tools/errinf.hxx> -#endif #include <basic/sbx.hxx> -#include <tools/list.hxx> #include <tools/shl.hxx> #include <tools/rc.hxx> #include <vcl/svapp.hxx> @@ -55,21 +53,18 @@ #include "filefmt.hxx" #include "sb.hrc" #include <basrid.hxx> -#include <vos/mutex.hxx> +#include <osl/mutex.hxx> #include <cppuhelper/implbase1.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/util/XCloseBroadcaster.hpp> #include <com/sun/star/util/XCloseListener.hpp> #include "errobject.hxx" -#include <map> -#include <hash_map> +#include <boost/unordered_map.hpp> #include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/ModuleInfo.hpp> using namespace ::com::sun::star::script; -// #pragma SW_SEGMENT_CLASS( SBASIC, SBASIC_CODE ) - SV_IMPL_VARARR(SbTextPortions,SbTextPortion) TYPEINIT1(StarBASIC,SbxObject) @@ -82,9 +77,6 @@ using com::sun::star::uno::Any; using com::sun::star::uno::UNO_QUERY; using com::sun::star::lang::XMultiServiceFactory; -const static String aThisComponent( RTL_CONSTASCII_USTRINGPARAM("ThisComponent") ); -const static String aVBAHook( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobals" ) ); - // ============================================================================ class DocBasicItem : public ::cppu::WeakImplHelper1< util::XCloseListener > @@ -173,7 +165,9 @@ void SAL_CALL DocBasicItem::disposing( const lang::EventObject& /*rEvent*/ ) thr namespace { typedef ::rtl::Reference< DocBasicItem > DocBasicItemRef; -typedef std::map< const StarBASIC*, DocBasicItemRef > DocBasicItemMap; +typedef boost::unordered_map< const StarBASIC *, DocBasicItemRef > DocBasicItemMap; + // ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleInitDependencyMap; + static DocBasicItemMap GaDocBasicItems; const DocBasicItem* lclFindDocBasicItem( const StarBASIC* pDocBasic ) @@ -243,6 +237,7 @@ SbxObject* StarBASIC::getVBAGlobals( ) } } } + const String aVBAHook( RTL_CONSTASCII_USTRINGPARAM( "VBAGlobals" ) ); pVBAGlobals = (SbUnoObject*)Find( aVBAHook , SbxCLASS_DONTCARE ); } return pVBAGlobals; @@ -251,6 +246,7 @@ SbxObject* StarBASIC::getVBAGlobals( ) // i#i68894# SbxVariable* StarBASIC::VBAFind( const String& rName, SbxClassType t ) { + const static String aThisComponent( RTL_CONSTASCII_USTRINGPARAM("ThisComponent") ); if( rName == aThisComponent ) return NULL; // rename to init globals @@ -266,7 +262,7 @@ struct SFX_VB_ErrorItem SbError nErrorSFX; }; -const SFX_VB_ErrorItem __FAR_DATA SFX_VB_ErrorTab[] = +const SFX_VB_ErrorItem SFX_VB_ErrorTab[] = { { 1, SbERR_BASIC_EXCEPTION }, // #87844 Map exception to error code 1 { 2, SbERR_SYNTAX }, @@ -470,7 +466,7 @@ SbxBase* SbOLEFactory::Create( sal_uInt16, sal_uInt32 ) return NULL; } -SbUnoObject* createOLEObject_Impl( const String& aType ); // sbunoobj.cxx +SbUnoObject* createOLEObject_Impl( const ::rtl::OUString& aType ); // sbunoobj.cxx SbxObject* SbOLEFactory::CreateObject( const String& rClassName ) { @@ -547,12 +543,12 @@ SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj ) SbxBase* pParObj = pVar->GetObject(); SbxDimArray* pSource = PTR_CAST(SbxDimArray,pParObj); SbxDimArray* pDest = new SbxDimArray( pVar->GetType() ); - sal_Int32 lb = 0; - sal_Int32 ub = 0; pDest->setHasFixedSize( pSource->hasFixedSize() ); if ( pSource->GetDims() && pSource->hasFixedSize() ) { + sal_Int32 lb = 0; + sal_Int32 ub = 0; for ( sal_Int32 j = 1 ; j <= pSource->GetDims(); ++j ) { pSource->GetDim32( (sal_Int32)j, lb, ub ); @@ -675,7 +671,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) SbMethod* pImplMethod = pIfaceMethod->getImplMethod(); if( !pImplMethod ) { - DBG_ERROR( "No ImplMethod" ); + OSL_FAIL( "No ImplMethod" ); continue; } @@ -685,7 +681,7 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) SbMethod* pImplMethodCopy = p ? PTR_CAST(SbMethod,p) : NULL; if( !pImplMethodCopy ) { - DBG_ERROR( "Found no ImplMethod copy" ); + OSL_FAIL( "Found no ImplMethod copy" ); continue; } SbIfaceMapperMethod* pNewIfaceMethod = @@ -707,7 +703,6 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) pProcedureProp->SetFlag( SBX_NO_BROADCAST ); SbProcedureProperty* pNewProp = new SbProcedureProperty ( pProcedureProp->GetName(), pProcedureProp->GetType() ); - // ( pProcedureProp->GetName(), pProcedureProp->GetType(), this ); pNewProp->SetFlags( nFlags_ ); // Copy flags pNewProp->ResetFlag( SBX_NO_BROADCAST ); // except the Broadcast if it was set pProcedureProp->SetFlags( nFlags_ ); @@ -1019,7 +1014,6 @@ void* StarBASIC::operator new( size_t n ) { if( n < sizeof( StarBASIC ) ) { -// DBG_ASSERT( sal_False, "Warnung: inkompatibler BASIC-Stand!" ); n = sizeof( StarBASIC ); } return ::operator new( n ); @@ -1166,7 +1160,6 @@ struct ClassModuleRunInitItem SbModule* m_pModule; bool m_bProcessing; bool m_bRunInitDone; - //ModuleVector m_vModulesDependingOnThisModule; ClassModuleRunInitItem( void ) : m_pModule( NULL ) @@ -1180,18 +1173,17 @@ struct ClassModuleRunInitItem {} }; -// Derive from has_map type instead of typedef +// Derive from unordered_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 > > + boost::unordered_map< ::rtl::OUString, ClassModuleRunInitItem, + ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > {}; void SbModule::implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassModuleRunInitItem& rItem ) { rItem.m_bProcessing = true; - //bool bAnyDependencies = true; SbModule* pModule = rItem.m_pModule; if( pModule->pClassData != NULL ) { @@ -1210,7 +1202,7 @@ void SbModule::implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassMod if( rParentItem.m_bProcessing ) { // TODO: raise error? - DBG_ERROR( "Cyclic module dependency detected" ); + OSL_FAIL( "Cyclic module dependency detected" ); continue; } @@ -1229,7 +1221,7 @@ void SbModule::implProcessModuleRunInit( ModuleInitDependencyMap& rMap, ClassMod // Run Init-Code of all modules (including inserted libraries) void StarBASIC::InitAllModules( StarBASIC* pBasicNotToInit ) { - ::vos::OGuard guard( Application::GetSolarMutex() ); + SolarMutexGuard guard; // Init own modules for ( sal_uInt16 nMod = 0; nMod < pModules->Count(); nMod++ ) @@ -1361,7 +1353,6 @@ SbxVariable* StarBASIC::Find( const String& rName, SbxClassType t ) sal_Int32 nType = p->GetModuleType(); if ( nType == ModuleType::DOCUMENT || nType == ModuleType::FORM ) continue; - // otherwise check if the element is available // unset GBLSEARCH-Flag (due to Rekursion) sal_uInt16 nGblFlag = p->GetFlags() & SBX_GBLSEARCH; @@ -1517,7 +1508,7 @@ sal_uInt16 StarBASIC::StepPoint( sal_uInt16 l, sal_uInt16 c1, sal_uInt16 c2 ) return BreakHdl(); } -sal_uInt16 __EXPORT StarBASIC::BreakHdl() +sal_uInt16 StarBASIC::BreakHdl() { return (sal_uInt16) ( aBreakHdl.IsSet() ? aBreakHdl.Call( this ) : SbDEBUG_CONTINUE ); @@ -1550,14 +1541,14 @@ SbLanguageMode StarBASIC::GetLanguageMode() return eLanguageMode; } -// AB: 29.3.96 -// Das Mapping zwischen alten und neuen Fehlercodes erfolgt, indem die Tabelle -// SFX_VB_ErrorTab[] durchsucht wird. Dies ist zwar nicht besonders performant, -// verbraucht aber viel weniger Speicher als entsprechende switch-Bloecke. -// Die Umrechnung von Fehlercodes muss nicht schnell sein, daher auch keine -// binaere Suche bei VB-Error -> SFX-Error. +// From 1996-03-29: +// The mapping between the old and the new error codes take place by searching +// through the table SFX_VB_ErrorTab[]. This is indeed not with good performance, +// but it consumes much less memory than corresponding switch blocs. +// Because the conversion of error codes has not to be fast. there is no +// binaere search by VB-Error -> SFX-Error. -// Neue Fehler-Codes auf alte, Sbx-Kompatible zurueckmappen +// Map back new error codes to old, Sbx-compatible sal_uInt16 StarBASIC::GetVBErrorCode( SbError nError ) { sal_uInt16 nRet = 0; @@ -1583,7 +1574,7 @@ sal_uInt16 StarBASIC::GetVBErrorCode( SbError nError ) } } - // Suchschleife + // search loop const SFX_VB_ErrorItem* pErrItem; sal_uInt16 nIndex = 0; do @@ -1596,7 +1587,7 @@ sal_uInt16 StarBASIC::GetVBErrorCode( SbError nError ) } nIndex++; } - while( pErrItem->nErrorVB != 0xFFFF ); // bis End-Marke + while( pErrItem->nErrorVB != 0xFFFF ); // up to end mark return nRet; } @@ -1642,15 +1633,15 @@ SbError StarBASIC::GetSfxFromVBError( sal_uInt16 nError ) break; } else if( pErrItem->nErrorVB > nError ) - break; // kann nicht mehr gefunden werden + break; // couldn't found anymore nIndex++; } - while( pErrItem->nErrorVB != 0xFFFF ); // bis End-Marke + while( pErrItem->nErrorVB != 0xFFFF ); // up to end mark return nRet; } -// Error- / Break-Daten setzen +// set Error- / Break-data void StarBASIC::SetErrorData ( SbError nCode, sal_uInt16 nLine, sal_uInt16 nCol1, sal_uInt16 nCol2 ) { @@ -1662,8 +1653,8 @@ void StarBASIC::SetErrorData } //---------------------------------------------------------------- -// Hilfsklasse zum Zugriff auf String SubResourcen einer Resource. -// Quelle: sfx2\source\doc\docfile.cxx (TLX) +// help class for access to string SubResource of a Resource. +// Source: sfx2\source\doc\docfile.cxx (TLX) struct BasicStringList_Impl : private Resource { ResId aResId; @@ -1678,7 +1669,7 @@ struct BasicStringList_Impl : private Resource }; //---------------------------------------------------------------- -// #60175 Flag, das bei Basic-Fehlern das Anziehen der SFX-Resourcen verhindert +// Flag, that prevent the activation of the SFX-Resources at a Basic error static sal_Bool bStaticSuppressSfxResource = sal_False; void StarBASIC::StaticSuppressSfxResource( sal_Bool bSuppress ) @@ -1695,7 +1686,7 @@ sal_Bool runsInSetup( void ) void StarBASIC::MakeErrorText( SbError nId, const String& aMsg ) { - vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + SolarMutexGuard aSolarGuard; if( bStaticSuppressSfxResource ) { @@ -1705,15 +1696,15 @@ void StarBASIC::MakeErrorText( SbError nId, const String& aMsg ) sal_uInt16 nOldID = GetVBErrorCode( nId ); - // Hilfsklasse instanzieren + // intantiate the help class BasResId aId( RID_BASIC_START ); BasicStringList_Impl aMyStringList( aId, sal_uInt16(nId & ERRCODE_RES_MASK) ); if( aMyStringList.IsErrorTextAvailable() ) { - // Merge Message mit Zusatztext + // merge message with additional text String aMsg1 = aMyStringList.GetString(); - // Argument-Platzhalter durch %s ersetzen + // replace argument placeholder with %s String aSrgStr( RTL_CONSTASCII_USTRINGPARAM("$(ARG1)") ); sal_uInt16 nResult = aMsg1.Search( aSrgStr ); @@ -1739,9 +1730,9 @@ void StarBASIC::MakeErrorText( SbError nId, const String& aMsg ) sal_Bool StarBASIC::CError ( SbError code, const String& rMsg, sal_uInt16 l, sal_uInt16 c1, sal_uInt16 c2 ) { - vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + SolarMutexGuard aSolarGuard; - // Compiler-Fehler waehrend der Laufzeit -> Programm anhalten + // compiler error during runtime -> stop programm if( IsRunning() ) { // #109018 Check if running Basic is affected @@ -1752,13 +1743,13 @@ sal_Bool StarBASIC::CError Stop(); } - // Flag setzen, damit GlobalRunInit den Fehler mitbekommt + // set flag, so that GlobalRunInit notice the error GetSbData()->bGlobalInitErr = sal_True; - // Fehlertext basteln + // tinker the error message MakeErrorText( code, rMsg ); - // Umsetzung des Codes fuer String-Transport in SFX-Error + // Implementation of the code for the string transport to SFX-Error if( rMsg.Len() ) code = (sal_uIntPtr)*new StringErrorInfo( code, String(rMsg) ); @@ -1769,7 +1760,7 @@ sal_Bool StarBASIC::CError bRet = (sal_Bool) GetSbData()->aErrHdl.Call( this ); else bRet = ErrorHdl(); - GetSbData()->bCompiler = sal_False; // nur sal_True fuer Error-Handler + GetSbData()->bCompiler = sal_False; // only true for error handler return bRet; } @@ -1781,14 +1772,14 @@ sal_Bool StarBASIC::RTError sal_Bool StarBASIC::RTError( SbError code, const String& rMsg, sal_uInt16 l, sal_uInt16 c1, sal_uInt16 c2 ) { - vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + SolarMutexGuard aSolarGuard; SbError c = code; if( (c & ERRCODE_CLASS_MASK) == ERRCODE_CLASS_COMPILER ) c = 0; MakeErrorText( c, rMsg ); - // Umsetzung des Codes fuer String-Transport in SFX-Error + // Implementation of the code for the string transport to SFX-Error if( rMsg.Len() ) { // very confusing, even though MakeErrorText sets up the error text @@ -1845,7 +1836,7 @@ SbError StarBASIC::GetErrBasic() return 0; } -// #66536 Zusatz-Message fuer RTL-Funktion Error zugreifbar machen +// make the additional message for the RTL function error accessible String StarBASIC::GetErrorMsg() { if( pINST ) @@ -1862,7 +1853,7 @@ sal_uInt16 StarBASIC::GetErl() return 0; } -sal_Bool __EXPORT StarBASIC::ErrorHdl() +sal_Bool StarBASIC::ErrorHdl() { return (sal_Bool) ( aErrorHdl.IsSet() ? aErrorHdl.Call( this ) : sal_False ); @@ -1938,7 +1929,7 @@ sal_Bool StarBASIC::LoadData( SvStream& r, sal_uInt16 nVer ) return sal_False; else if( pMod->ISA(SbJScriptModule) ) { - // Ref zuweisen, damit pMod deleted wird + // assign Ref, so that pMod will be deleted SbModuleRef xRef = pMod; } else @@ -1947,15 +1938,15 @@ sal_Bool StarBASIC::LoadData( SvStream& r, sal_uInt16 nVer ) pModules->Put( pMod, i ); } } - // HACK fuer SFX-Mist! + // HACK for SFX-Bullshit! SbxVariable* p = Find( String( RTL_CONSTASCII_USTRINGPARAM("FALSE") ), SbxCLASS_PROPERTY ); if( p ) Remove( p ); p = Find( String( RTL_CONSTASCII_USTRINGPARAM("TRUE") ), SbxCLASS_PROPERTY ); if( p ) Remove( p ); - // Ende des Hacks! - // Suche ueber StarBASIC ist immer global + // End of the hacks! + // Search via StarBASIC is at all times global DBG_ASSERT( IsSet( SBX_GBLSEARCH ), "Basic ohne GBLSEARCH geladen" ); SetFlag( SBX_GBLSEARCH ); return sal_True; @@ -2314,3 +2305,4 @@ void BasicCollection::CollRemove( SbxArray* pPar_ ) SetError( SbERR_BAD_ARGUMENT ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/classes/sb.src b/basic/source/classes/sb.src index 73cc1c3a0b2c..df916c64b031 100644 --- a/basic/source/classes/sb.src +++ b/basic/source/classes/sb.src @@ -47,17 +47,14 @@ Resource RID_BASIC_START }; String SbERR_BAD_ARGUMENT & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Ung³ltiger Prozeduraufruf : Ungltiger Prozeduraufruf */ Text [ en-US ] = "Invalid procedure call." ; }; String SbERR_MATH_OVERFLOW & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? šberlauf : Überlauf */ Text [ en-US ] = "Overflow." ; }; String SbERR_NO_MEMORY & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Nicht gen³gend Speicher : Nicht gengend Speicher */ Text [ en-US ] = "Not enough memory." ; }; String SbERR_ALREADY_DIM & ERRCODE_RES_MASK @@ -66,7 +63,6 @@ Resource RID_BASIC_START }; String SbERR_OUT_OF_RANGE & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Index au˜erhalb des definierten Bereichs : Index auÿerhalb des definierten Bereichs */ Text [ en-US ] = "Index out of defined range." ; }; String SbERR_DUPLICATE_DEF & ERRCODE_RES_MASK @@ -83,12 +79,10 @@ Resource RID_BASIC_START }; String SbERR_CONVERSION & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Datentypen unvertrõglich : Datentypen unvertr§glich */ Text [ en-US ] = "Data type mismatch." ; }; String SbERR_BAD_PARAMETER & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Ung³ltiger Parameter : Ungltiger Parameter */ Text [ en-US ] = "Invalid parameter." ; }; String SbERR_USER_ABORT & ERRCODE_RES_MASK @@ -101,7 +95,6 @@ Resource RID_BASIC_START }; String SbERR_STACK_OVERFLOW & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Nicht gen³gend Stapelspeicher : Nicht gengend Stapelspeicher */ Text [ en-US ] = "Not enough stack memory." ; }; String SbERR_PROC_UNDEFINED & ERRCODE_RES_MASK @@ -134,12 +127,10 @@ Resource RID_BASIC_START }; String SbERR_FILE_ALREADY_OPEN & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Datei bereits ge÷ffnet : Datei bereits ge”ffnet */ Text [ en-US ] = "File already open." ; }; String SbERR_IO_ERROR & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Gerõte-E/A-Fehler : Ger§te-E/A-Fehler */ Text [ en-US ] = "Device I/O error." ; }; String SbERR_FILE_EXISTS & ERRCODE_RES_MASK @@ -148,7 +139,6 @@ Resource RID_BASIC_START }; String SbERR_BAD_RECORD_LENGTH & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Falsche Datensatzlõnge : Falsche Datensatzl§nge */ Text [ en-US ] = "Incorrect record length." ; }; String SbERR_DISK_FULL & ERRCODE_RES_MASK @@ -157,7 +147,6 @@ Resource RID_BASIC_START }; String SbERR_READ_PAST_EOF & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Lesen ³ber das Ende der Datei hinaus : Lesen ber das Ende der Datei hinaus */ Text [ en-US ] = "Reading exceeds EOF." ; }; String SbERR_BAD_RECORD_NUMBER & ERRCODE_RES_MASK @@ -170,7 +159,6 @@ Resource RID_BASIC_START }; String SbERR_NO_DEVICE & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Gerõt nicht verf³gbar : Ger§t nicht verfgbar */ Text [ en-US ] = "Device not available." ; }; String SbERR_ACCESS_DENIED & ERRCODE_RES_MASK @@ -187,7 +175,6 @@ Resource RID_BASIC_START }; String SbERR_DIFFERENT_DRIVE & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Umbenennen auf verschiedenen Laufwerken nicht m÷glich : Umbenennen auf verschiedenen Laufwerken nicht m”glich */ Text [ en-US ] = "Renaming on different drives impossible." ; }; String SbERR_ACCESS_ERROR & ERRCODE_RES_MASK @@ -204,12 +191,10 @@ Resource RID_BASIC_START }; String SbERR_BAD_PATTERN & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Zeichenfolgenmuster unzulõssig : Zeichenfolgenmuster unzul§ssig */ Text [ en-US ] = "Invalid string pattern." ; }; String SBERR_IS_NULL & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Verwendung von Null unzulõssig : Verwendung von Null unzul§ssig */ Text [ en-US ] = "Use of zero not permitted." ; }; String SbERR_DDE_ERROR & ERRCODE_RES_MASK @@ -222,7 +207,6 @@ Resource RID_BASIC_START }; String SbERR_DDE_OUTOFCHANNELS & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Keine freien DDE-Kanõle : Keine freien DDE-Kan§le */ Text [ en-US ] = "No DDE channels available." ; }; String SbERR_DDE_NO_RESPONSE & ERRCODE_RES_MASK @@ -239,17 +223,14 @@ Resource RID_BASIC_START }; String SbERR_DDE_NOTPROCESSED & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Fremdapplikation kann DDE-Operation nicht ausf³hren : Fremdapplikation kann DDE-Operation nicht ausfhren */ Text [ en-US ] = "External application cannot execute DDE operation." ; }; String SbERR_DDE_TIMEOUT & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Zeit³berschreitung wõhrend des Wartens auf DDE-Antwort : Zeitberschreitung w§hrend des Wartens auf DDE-Antwort */ Text [ en-US ] = "Timeout while waiting for DDE response." ; }; String SbERR_DDE_USER_INTERRUPT & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Benutzer dr³ckte ESCAPE wõhrend der DDE-Operation : Benutzer drckte ESCAPE w§hrend der DDE-Operation */ Text [ en-US ] = "User pressed ESCAPE during DDE operation." ; }; String SbERR_DDE_BUSY & ERRCODE_RES_MASK @@ -270,7 +251,6 @@ Resource RID_BASIC_START }; String SbERR_DDE_CONV_CLOSED & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? DDE-Verbindung ist unterbrochen oder geõndert worden : DDE-Verbindung ist unterbrochen oder ge§ndert worden */ Text [ en-US ] = "DDE connection interrupted or modified." ; }; String SbERR_DDE_NO_CHANNEL & ERRCODE_RES_MASK @@ -279,7 +259,6 @@ Resource RID_BASIC_START }; String SbERR_DDE_INVALID_LINK & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Ung³ltiges DDE-Linkformat : Ungltiges DDE-Linkformat */ Text [ en-US ] = "Invalid DDE link format." ; }; String SbERR_DDE_QUEUE_OVERFLOW & ERRCODE_RES_MASK @@ -288,52 +267,42 @@ Resource RID_BASIC_START }; String SbERR_DDE_LINK_ALREADY_EST & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Paste Link bereits durchgef³hrt : Paste Link bereits durchgefhrt */ Text [ en-US ] = "Paste link already performed." ; }; String SbERR_DDE_LINK_INV_TOPIC & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? LinkMode kann wegen ung³ltigen Link-Topics nicht gesetzt werden : LinkMode kann wegen ungltigen Link-Topics nicht gesetzt werden */ Text [ en-US ] = "Link mode cannot be set due to invalid link topic." ; }; String SbERR_DDE_DLL_NOT_FOUND & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? F³r DDE wird DDEML.DLL ben÷tigt : Fr DDE wird DDEML.DLL ben”tigt */ Text [ en-US ] = "DDE requires the DDEML.DLL file." ; }; String SbERR_CANNOT_LOAD & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Das Modul kann nicht geladen werden, ung³ltiges Format : Das Modul kann nicht geladen werden, ungltiges Format */ Text [ en-US ] = "Module cannot be loaded; invalid format." ; }; String SbERR_BAD_INDEX & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Ung³ltiger Objektindex : Ungltiger Objektindex */ Text [ en-US ] = "Invalid object index." ; }; String SbERR_NO_ACTIVE_OBJECT & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Objekt ist nicht verf³gbar : Objekt ist nicht verfgbar */ Text [ en-US ] = "Object is not available." ; }; String SbERR_BAD_PROP_VALUE & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Falscher Wert f³r Eigenschaft : Falscher Wert fr Eigenschaft */ Text [ en-US ] = "Incorrect property value." ; }; String SbERR_PROP_READONLY & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Eigenschaft ist schreibgesch³tzt : Eigenschaft ist schreibgeschtzt */ Text [ en-US ] = "This property is read-only." ; }; String SbERR_PROP_WRITEONLY & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Eigenschaft ist lesegesch³tzt : Eigenschaft ist lesegeschtzt */ Text [ en-US ] = "This property is write only." ; }; String SbERR_INVALID_OBJECT & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Ung³ltige Objektreferenz : Ungltige Objektreferenz */ Text [ en-US ] = "Invalid object reference." ; }; String SbERR_NO_METHOD & ERRCODE_RES_MASK @@ -350,12 +319,10 @@ Resource RID_BASIC_START }; String SbERR_NO_OLE & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? OLE-Automatisierung wird von diesem Objekt nicht unterst³tzt : OLE-Automatisierung wird von diesem Objekt nicht untersttzt */ Text [ en-US ] = "OLE Automation is not supported by this object." ; }; String SbERR_BAD_METHOD & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Objekt unterst³tzt diese Eigenschaft oder Methode nicht : Objekt untersttzt diese Eigenschaft oder Methode nicht */ Text [ en-US ] = "This property or method is not supported by the object." ; }; String SbERR_OLE_ERROR & ERRCODE_RES_MASK @@ -364,17 +331,14 @@ Resource RID_BASIC_START }; String SbERR_BAD_ACTION & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Diese Aktion wird vom angegebenen Objekt nicht unterst³tzt : Diese Aktion wird vom angegebenen Objekt nicht untersttzt */ Text [ en-US ] = "This action is not supported by given object." ; }; String SbERR_NO_NAMED_ARGS & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Benannte Argumente werden vom angegebenen Objekt nicht unterst³tzt : Benannte Argumente werden vom angegebenen Objekt nicht untersttzt */ Text [ en-US ] = "Named arguments are not supported by given object." ; }; String SbERR_BAD_LOCALE & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Das aktuelle Gebietsschema wird vom angegebenen Objekt nicht unterst³tzt : Das aktuelle Gebietsschema wird vom angegebenen Objekt nicht untersttzt */ Text [ en-US ] = "The current locale setting is not supported by the given object." ; }; String SbERR_NAMED_NOT_FOUND & ERRCODE_RES_MASK @@ -395,7 +359,6 @@ Resource RID_BASIC_START }; String SbERR_BAD_ORDINAL & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Ordnungszahl ung³ltig : Ordnungszahl ungltig */ Text [ en-US ] = "Invalid ordinal number." ; }; String SbERR_DLLPROC_NOT_FOUND & ERRCODE_RES_MASK @@ -404,7 +367,6 @@ Resource RID_BASIC_START }; String SbERR_BAD_CLIPBD_FORMAT & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Ung³ltiges Clipboard-Format : Ungltiges Clipboard-Format */ Text [ en-US ] = "Invalid clipboard format." ; }; String SbERR_PROPERTY_NOT_FOUND & ERRCODE_RES_MASK @@ -421,12 +383,10 @@ Resource RID_BASIC_START }; String SbERR_BAD_NUMBER_OF_ARGS & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Ung³ltige Anzahl von Argumenten : Ungltige Anzahl von Argumenten */ Text [ en-US ] = "Invalid number of arguments." ; }; String SbERR_METHOD_FAILED & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Fehler in Ausf³hrung einer Methode : Fehler in Ausfhrung einer Methode */ Text [ en-US ] = "Error executing a method." ; }; String SbERR_SETPROP_FAILED & ERRCODE_RES_MASK @@ -516,12 +476,10 @@ Resource RID_BASIC_START }; String SbERR_BAD_CHAR_IN_NUMBER & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Ung³ltiges Zeichen in Zahl : Ungltiges Zeichen in Zahl */ Text [ en-US ] = "Invalid character in number." ; }; String SbERR_MUST_HAVE_DIMS & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Array mu˜ dimensioniert werden : Array muÿ dimensioniert werden */ Text [ en-US ] = "Array must be dimensioned." ; }; String SbERR_NO_IF & ERRCODE_RES_MASK @@ -530,12 +488,10 @@ Resource RID_BASIC_START }; String SbERR_NOT_IN_SUBR & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? $(ARG1) innerhalb einer Prozedur unzulõssig : $(ARG1) innerhalb einer Prozedur unzul§ssig */ Text [ en-US ] = "$(ARG1) not allowed within a procedure." ; }; String SbERR_NOT_IN_MAIN & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? $(ARG1) au˜erhalb einer Prozedur unzulõssig : $(ARG1) auÿerhalb einer Prozedur unzul§ssig */ Text [ en-US ] = "$(ARG1) not allowed outside a procedure." ; }; String SbERR_WRONG_DIMS & ERRCODE_RES_MASK @@ -552,12 +508,10 @@ Resource RID_BASIC_START }; String SbERR_PROG_TOO_LARGE & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Programm ist zu gro˜ : Programm ist zu groÿ */ Text [ en-US ] = "Program too large." ; }; String SbERR_NO_STRINGS_ARRAYS & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Strings oder Arrays unzulõssig : Strings oder Arrays unzul§ssig */ Text [ en-US ] = "Strings or arrays not permitted." ; }; String ERRCODE_BASIC_EXCEPTION & ERRCODE_RES_MASK @@ -604,26 +558,14 @@ String IDS_SBERR_STOREREF }; String ERRCODE_BASMGR_LIBLOAD & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Fehler beim Laden der Bibliothek '$(ARG1)' : Fehler beim Laden der Bibliothek ''$(ARG1)'' */ - /* ### ACHTUNG: Neuer Text in Resource? Fehler beim Laden der Bibliothek '$(ARG1)' : Fehler beim Laden der Bibliothek ''$(ARG1) */ - /* ### ACHTUNG: Neuer Text in Resource? Fehler beim Laden der Bibliothek '$(ARG1)' : Fehler beim Laden der Bibliothek ''$(ARG1) */ - /* ### ACHTUNG: Neuer Text in Resource? Fehler beim Laden der Bibliothek '$(ARG1)' : Fehler beim Laden der Bibliothek ''$(ARG1)'' */ Text [ en-US ] = "Error loading library '$(ARG1)'." ; }; String ERRCODE_BASMGR_LIBSAVE & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Fehler beim Speichern der Bibliothek: '$(ARG1)' : Fehler beim Speichern der Bibliothek: ''$(ARG1)'' */ - /* ### ACHTUNG: Neuer Text in Resource? Fehler beim Speichern der Bibliothek: '$(ARG1)' : Fehler beim Speichern der Bibliothek: ''$(ARG1) */ - /* ### ACHTUNG: Neuer Text in Resource? Fehler beim Speichern der Bibliothek: '$(ARG1)' : Fehler beim Speichern der Bibliothek: ''$(ARG1) */ - /* ### ACHTUNG: Neuer Text in Resource? Fehler beim Speichern der Bibliothek: '$(ARG1)' : Fehler beim Speichern der Bibliothek: ''$(ARG1)'' */ Text [ en-US ] = "Error saving library: '$(ARG1)'." ; }; String ERRCODE_BASMGR_MGROPEN & ERRCODE_RES_MASK { - /* ### ACHTUNG: Neuer Text in Resource? Das BASIC aus der Datei '$(ARG1)' konnte nicht initialisiert werden : Das BASIC aus der Datei ''$(ARG1)'' konnte nicht initialisiert werden */ - /* ### ACHTUNG: Neuer Text in Resource? Das BASIC aus der Datei '$(ARG1)' konnte nicht initialisiert werden : Das BASIC aus der Datei ''$(ARG1)'' konnte nicht initialisiert werden */ - /* ### ACHTUNG: Neuer Text in Resource? Das BASIC aus der Datei '$(ARG1)' konnte nicht initialisiert werden : Das BASIC aus der Datei ''$(ARG1)'' konnte nicht initialisiert werden */ - /* ### ACHTUNG: Neuer Text in Resource? Das BASIC aus der Datei '$(ARG1)' konnte nicht initialisiert werden : Das BASIC aus der Datei ''$(ARG1)'' konnte nicht initialisiert werden */ Text [ en-US ] = "The BASIC from the file '$(ARG1)' could not be initialized." ; }; String ERRCODE_BASMGR_MGRSAVE & ERRCODE_RES_MASK diff --git a/basic/source/classes/sbintern.cxx b/basic/source/classes/sbintern.cxx index 2b1f32e474d5..2f0a9fe93fee 100644 --- a/basic/source/classes/sbintern.cxx +++ b/basic/source/classes/sbintern.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -80,3 +81,4 @@ SbiGlobals::~SbiGlobals() delete pTransliterationWrapper; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 6f20a68a274f..cadaa0c43131 100755..100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -27,12 +28,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -//#include <stl_queue.h> -#include <vos/mutex.hxx> +#include <osl/mutex.hxx> #include <vcl/svapp.hxx> -#ifndef _TOOLERR_HXX //autogen #include <tools/errcode.hxx> -#endif #include <svl/hint.hxx> #include <cppuhelper/implbase1.hxx> @@ -64,6 +62,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/XDefaultMethod.hpp> #include <com/sun/star/script/XDirectInvocation.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XHierarchicalNameAccess.hpp> @@ -76,7 +75,7 @@ #include <com/sun/star/bridge/oleautomation/Decimal.hpp> #include <com/sun/star/bridge/oleautomation/Currency.hpp> #include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp> - +#include <com/sun/star/script/XAutomationInvocation.hpp> using com::sun::star::uno::Reference; using namespace com::sun::star::uno; @@ -99,7 +98,7 @@ using namespace cppu; #include<runtime.hxx> #include<math.h> -#include <hash_map> +#include <boost/unordered_map.hpp> #include <com/sun/star/reflection/XTypeDescriptionEnumerationAccess.hpp> #include <com/sun/star/reflection/XConstantsTypeDescription.hpp> @@ -113,7 +112,7 @@ TYPEINIT1(SbUnoSingleton,SbxObject) typedef WeakImplHelper1< XAllListener > BasicAllListenerHelper; -// Flag, um immer ueber Invocation zu gehen +// Flag to go via invocation //#define INVOCATION_ONLY @@ -129,14 +128,14 @@ static ::rtl::OUString defaultNameSpace( RTL_CONSTASCII_USTRINGPARAM("ooo.vba") // redirection built in. The property name specifies the name // of the default property. -bool SbUnoObject::getDefaultPropName( SbUnoObject* pUnoObj, String& sDfltProp ) +bool SbUnoObject::getDefaultPropName( SbUnoObject* pUnoObj, ::rtl::OUString& sDfltProp ) { bool result = false; Reference< XDefaultProperty> xDefaultProp( pUnoObj->maTmpUnoObj, UNO_QUERY ); if ( xDefaultProp.is() ) { sDfltProp = xDefaultProp->getDefaultPropertyName(); - if ( sDfltProp.Len() ) + if ( sDfltProp.getLength() ) result = true; } return result; @@ -162,11 +161,26 @@ SbxVariable* getDefaultProp( SbxVariable* pRef ) return pDefaultProp; } +void SetSbUnoObjectDfltPropName( SbxObject* pObj ) +{ + SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,(SbxObject*) pObj); + if ( pUnoObj ) + { + ::rtl::OUString sDfltPropName; + + if ( SbUnoObject::getDefaultPropName( pUnoObj, sDfltPropName ) ) + { + OSL_TRACE("SetSbUnoObjectDfltPropName setting dflt prop for %s", rtl::OUStringToOString( pObj->GetName(), RTL_TEXTENCODING_UTF8 ).getStr() ); + pUnoObj->SetDfltProperty( sDfltPropName ); + } + } +} + Reference< XComponentContext > getComponentContext_Impl( void ) { static Reference< XComponentContext > xContext; - // Haben wir schon CoreReflection, sonst besorgen + // Do we have already CoreReflection; if not obtain it if( !xContext.is() ) { Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); @@ -182,12 +196,12 @@ Reference< XComponentContext > getComponentContext_Impl( void ) return xContext; } -// CoreReflection statisch speichern +// save CoreReflection statically Reference< XIdlReflection > getCoreReflection_Impl( void ) { static Reference< XIdlReflection > xCoreReflection; - // Haben wir schon CoreReflection, sonst besorgen + // Do we have already CoreReflection; if not obtain it if( !xCoreReflection.is() ) { Reference< XComponentContext > xContext = getComponentContext_Impl(); @@ -208,7 +222,7 @@ Reference< XIdlReflection > getCoreReflection_Impl( void ) return xCoreReflection; } -// CoreReflection statisch speichern +// save CoreReflection statically Reference< XHierarchicalNameAccess > getCoreReflection_HierarchicalNameAccess_Impl( void ) { static Reference< XHierarchicalNameAccess > xCoreReflection_HierarchicalNameAccess; @@ -230,7 +244,7 @@ Reference< XHierarchicalNameAccess > getTypeProvider_Impl( void ) { static Reference< XHierarchicalNameAccess > xAccess; - // Haben wir schon CoreReflection, sonst besorgen + // Do we have already CoreReflection; if not obtain it if( !xAccess.is() ) { Reference< XComponentContext > xContext = getComponentContext_Impl(); @@ -257,7 +271,7 @@ Reference< XTypeConverter > getTypeConverter_Impl( void ) { static Reference< XTypeConverter > xTypeConverter; - // Haben wir schon CoreReflection, sonst besorgen + // Do we have already CoreReflection; if not obtain it if( !xTypeConverter.is() ) { Reference< XComponentContext > xContext = getComponentContext_Impl(); @@ -282,7 +296,7 @@ Reference< XTypeConverter > getTypeConverter_Impl( void ) // #111851 factory function to create an OLE object -SbUnoObject* createOLEObject_Impl( const String& aType ) +SbUnoObject* createOLEObject_Impl( const ::rtl::OUString& aType ) { static Reference< XMultiServiceFactory > xOLEFactory; static bool bNeedsInit = true; @@ -349,7 +363,7 @@ void implAppendExceptionMsg( ::rtl::OUStringBuffer& _inout_rBuffer, const Except } -// Fehlermeldungs-Message bei Exception zusammenbauen +// construct an error message for the exception ::rtl::OUString implGetExceptionMsg( const Exception& e, const ::rtl::OUString& aExceptionType_ ) { ::rtl::OUStringBuffer aMessageBuf; @@ -357,7 +371,7 @@ void implAppendExceptionMsg( ::rtl::OUStringBuffer& _inout_rBuffer, const Except return aMessageBuf.makeStringAndClear(); } -String implGetExceptionMsg( const Any& _rCaughtException ) +::rtl::OUString implGetExceptionMsg( const Any& _rCaughtException ) { OSL_PRECOND( _rCaughtException.getValueTypeClass() == TypeClass_EXCEPTION, "implGetExceptionMsg: illegal argument!" ); if ( _rCaughtException.getValueTypeClass() != TypeClass_EXCEPTION ) @@ -382,7 +396,7 @@ Any convertAny( const Any& rVal, const Type& aDestType ) } catch( CannotConvertException& e2 ) { - String aCannotConvertExceptionName + ::rtl::OUString aCannotConvertExceptionName ( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.IllegalArgumentException" ) ); StarBASIC::Error( ERRCODE_BASIC_EXCEPTION, implGetExceptionMsg( e2, aCannotConvertExceptionName ) ); @@ -396,10 +410,10 @@ Any convertAny( const Any& rVal, const Type& aDestType ) TYPEINIT1(SbUnoAnyObject,SbxObject) -// TODO: Spaeter auslagern +// TODO: source out later Reference<XIdlClass> TypeToIdlClass( const Type& rType ) { - // void als Default-Klasse eintragen + // register void as default class Reference<XIdlClass> xRetClass; typelib_TypeDescription * pTD = 0; rType.getDescription( &pTD ); @@ -415,15 +429,15 @@ Reference<XIdlClass> TypeToIdlClass( const Type& rType ) // Exception type unknown template< class EXCEPTION > -String implGetExceptionMsg( const EXCEPTION& e ) +::rtl::OUString implGetExceptionMsg( const EXCEPTION& e ) { return implGetExceptionMsg( e, ::getCppuType( &e ).getTypeName() ); } // Error-Message fuer WrappedTargetExceptions -String implGetWrappedMsg( const WrappedTargetException& e ) +::rtl::OUString implGetWrappedMsg( const WrappedTargetException& e ) { - String aMsg; + ::rtl::OUString aMsg; Any aWrappedAny = e.TargetException; Type aExceptionType = aWrappedAny.getValueType(); @@ -431,7 +445,7 @@ String implGetWrappedMsg( const WrappedTargetException& e ) if( aExceptionType.getTypeClass() == TypeClass_EXCEPTION ) { Exception& e_ = *( (Exception*)aWrappedAny.getValue() ); - aMsg = implGetExceptionMsg( e_, String( aExceptionType.getTypeName() ) ); + aMsg = implGetExceptionMsg( e_, ::rtl::OUString( aExceptionType.getTypeName() ) ); } // Otherwise use WrappedTargetException itself else @@ -463,6 +477,32 @@ void implHandleWrappedTargetException( const Any& _rWrappedTargetException ) SbError nError( ERRCODE_BASIC_EXCEPTION ); ::rtl::OUStringBuffer aMessageBuf; + // Add for VBA, to get the correct error code and message. + if ( SbiRuntime::isVBAEnabled() ) + { + if ( aExamine >>= aBasicError ) + { + if ( aBasicError.ErrorCode != 0 ) + { + nError = StarBASIC::GetSfxFromVBError( (sal_uInt16) aBasicError.ErrorCode ); + if ( nError == 0 ) + { + nError = (SbError) aBasicError.ErrorCode; + } + aMessageBuf.append( aBasicError.ErrorMessageArgument ); + aExamine.clear(); + } + } + + IndexOutOfBoundsException aIdxOutBndsExp; + if ( aExamine >>= aIdxOutBndsExp ) + { + nError = SbERR_OUT_OF_RANGE; + aExamine.clear(); + } + } + // End add + // strip any other WrappedTargetException instances, but this time preserve the error messages. WrappedTargetException aWrapped; sal_Int32 nLevel = 0; @@ -516,7 +556,6 @@ static void implHandleAnyException( const Any& _rCaughtException ) } } - // NativeObjectWrapper handling struct ObjectItem { @@ -554,7 +593,7 @@ SbxObject* lcl_getNativeObject( sal_uInt32 nIndex ) } -// Von Uno nach Sbx wandeln +// convert from Uno to Sbx SbxDataType unoToSbxType( TypeClass eType ) { SbxDataType eRetType = SbxVOID; @@ -566,22 +605,11 @@ SbxDataType unoToSbxType( TypeClass eType ) case TypeClass_STRUCT: case TypeClass_EXCEPTION: eRetType = SbxOBJECT; break; - /* folgende Typen lassen wir erstmal weg - case TypeClass_SERVICE: break; - case TypeClass_CLASS: break; - case TypeClass_TYPEDEF: break; - case TypeClass_UNION: break; - case TypeClass_ARRAY: break; - */ case TypeClass_ENUM: eRetType = SbxLONG; break; case TypeClass_SEQUENCE: eRetType = (SbxDataType) ( SbxOBJECT | SbxARRAY ); break; - /* - case TypeClass_VOID: break; - case TypeClass_UNKNOWN: break; - */ case TypeClass_ANY: eRetType = SbxVARIANT; break; case TypeClass_BOOLEAN: eRetType = SbxBOOL; break; @@ -589,18 +617,13 @@ SbxDataType unoToSbxType( TypeClass eType ) case TypeClass_STRING: eRetType = SbxSTRING; break; case TypeClass_FLOAT: eRetType = SbxSINGLE; break; case TypeClass_DOUBLE: eRetType = SbxDOUBLE; break; - //case TypeClass_OCTET: break; case TypeClass_BYTE: eRetType = SbxINTEGER; break; - //case TypeClass_INT: eRetType = SbxINT; break; case TypeClass_SHORT: eRetType = SbxINTEGER; break; case TypeClass_LONG: eRetType = SbxLONG; break; case TypeClass_HYPER: eRetType = SbxSALINT64; break; - //case TypeClass_UNSIGNED_OCTET: break; case TypeClass_UNSIGNED_SHORT: eRetType = SbxUSHORT; break; case TypeClass_UNSIGNED_LONG: eRetType = SbxULONG; break; case TypeClass_UNSIGNED_HYPER: eRetType = SbxSALUINT64;break; - //case TypeClass_UNSIGNED_INT: eRetType = SbxUINT; break; - //case TypeClass_UNSIGNED_BYTE: eRetType = SbxUSHORT; break; default: break; } return eRetType; @@ -622,7 +645,6 @@ static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int Type aType = aValue.getValueType(); TypeClass eTypeClass = aType.getTypeClass(); - sal_Int32 indicesIndex = indices.getLength() -1; sal_Int32 dimCopy = dimension; if ( eTypeClass == TypeClass_SEQUENCE ) @@ -647,7 +669,6 @@ static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int sizes.realloc( sizes.getLength() + 1 ); sizes[ sizes.getLength() - 1 ] = nLen; indices.realloc( indices.getLength() + 1 ); - indicesIndex = indices.getLength() - 1; } } @@ -716,12 +737,12 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) Any aClassAny; aClassAny <<= xClass; - // SbUnoObject instanzieren - String aName; + // instantiate SbUnoObject + ::rtl::OUString aName; SbUnoObject* pSbUnoObject = new SbUnoObject( aName, aClassAny ); SbxObjectRef xWrapper = (SbxObject*)pSbUnoObject; - // #51475 Wenn das Objekt ungueltig ist null liefern + // If the object is invalid deliver zero if( pSbUnoObject->getUnoAny().getValueType().getTypeClass() == TypeClass_VOID ) { pVar->PutObject( NULL ); @@ -732,7 +753,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) } } break; - // Interfaces und Structs muessen in ein SbUnoObject gewrappt werden + // Interfaces and Structs must be wrapped in a SbUnoObject case TypeClass_INTERFACE: case TypeClass_STRUCT: case TypeClass_EXCEPTION: @@ -796,13 +817,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) oleautomation::Currency aCurrency; if( (aValue >>= aCurrency) ) { - sal_Int64 nValue64 = aCurrency.Value; - SbxINT64 aInt64; - aInt64.nHigh = - sal::static_int_cast< sal_Int32 >( - nValue64 >> 32); - aInt64.nLow = (sal_uInt32)( nValue64 & 0xffffffff ); - pVar->PutCurrency( aInt64 ); + pVar->PutCurrency( aCurrency.Value ); break; } } @@ -810,8 +825,8 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) } } } - // SbUnoObject instanzieren - String aName; + // instantiate a SbUnoObject + ::rtl::OUString aName; SbUnoObject* pSbUnoObject = new SbUnoObject( aName, aValue ); //If this is called externally e.g. from the scripting //framework then there is no 'active' runtime the default property will not be set up @@ -819,14 +834,14 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) //test seems a bit of overkill //if ( SbiRuntime::isVBAEnabled() ) { - String sDfltPropName; + ::rtl::OUString sDfltPropName; if ( SbUnoObject::getDefaultPropName( pSbUnoObject, sDfltPropName ) ) pSbUnoObject->SetDfltProperty( sDfltPropName ); } SbxObjectRef xWrapper = (SbxObject*)pSbUnoObject; - // #51475 Wenn das Objekt ungueltig ist null liefern + // If the object is invalid deliver zero if( pSbUnoObject->getUnoAny().getValueType().getTypeClass() == TypeClass_VOID ) { pVar->PutObject( NULL ); @@ -838,14 +853,6 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) } break; - /* folgende Typen lassen wir erstmal weg - case TypeClass_SERVICE: break; - case TypeClass_CLASS: break; - case TypeClass_TYPEDEF: break; - case TypeClass_UNION: break; - case TypeClass_ENUM: break; - case TypeClass_ARRAY: break; - */ case TypeClass_ENUM: { @@ -867,7 +874,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) Type aElementType( ((typelib_IndirectTypeDescription *)pTD)->pType ); ::typelib_typedescription_release( pTD ); - // In Basic Array anlegen + // build an Array in Basic SbxDimArrayRef xArray; SbxDataType eSbxElementType = unoToSbxType( aElementType.getTypeClass() ); xArray = new SbxDimArray( eSbxElementType ); @@ -875,15 +882,15 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) { xArray->unoAddDim32( 0, nLen - 1 ); - // Elemente als Variablen eintragen + // register the elements as variables for( i = 0 ; i < nLen ; i++ ) { - // Elemente wandeln + // convert elements Any aElementAny = xIdlArray->get( aValue, (sal_uInt32)i ); SbxVariableRef xVar = new SbxVariable( eSbxElementType ); unoToSbxValue( (SbxVariable*)xVar, aElementAny ); - // Ins Array braten + // put into the Array xArray->Put32( (SbxVariable*)xVar, &i ); } } @@ -892,30 +899,15 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) xArray->unoAddDim( 0, -1 ); } - // Array zurueckliefern + // return the Array sal_uInt16 nFlags = pVar->GetFlags(); pVar->ResetFlag( SBX_FIXED ); pVar->PutObject( (SbxDimArray*)xArray ); pVar->SetFlags( nFlags ); - // #54548, Die Parameter duerfen hier nicht weggehauen werden - //pVar->SetParameters( NULL ); } break; - /* - case TypeClass_VOID: break; - case TypeClass_UNKNOWN: break; - - case TypeClass_ANY: - { - // Any rausholen und konvertieren - //Any* pAny = (Any*)aValue.get(); - //if( pAny ) - //unoToSbxValue( pVar, *pAny ); - } - break; - */ case TypeClass_BOOLEAN: pVar->PutBool( *(sal_Bool*)aValue.getValue() ); break; case TypeClass_CHAR: @@ -923,32 +915,26 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) pVar->PutChar( *(sal_Unicode*)aValue.getValue() ); break; } - case TypeClass_STRING: { ::rtl::OUString val; aValue >>= val; pVar->PutString( String( val ) ); } break; + case TypeClass_STRING: { ::rtl::OUString val; aValue >>= val; pVar->PutString( val ); } break; case TypeClass_FLOAT: { float val = 0; aValue >>= val; pVar->PutSingle( val ); } break; case TypeClass_DOUBLE: { double val = 0; aValue >>= val; pVar->PutDouble( val ); } break; - //case TypeClass_OCTET: break; case TypeClass_BYTE: { sal_Int8 val = 0; aValue >>= val; pVar->PutInteger( val ); } break; - //case TypeClass_INT: break; case TypeClass_SHORT: { sal_Int16 val = 0; aValue >>= val; pVar->PutInteger( val ); } break; case TypeClass_LONG: { sal_Int32 val = 0; aValue >>= val; pVar->PutLong( val ); } break; case TypeClass_HYPER: { sal_Int64 val = 0; aValue >>= val; pVar->PutInt64( val ); } break; - //case TypeClass_UNSIGNED_OCTET:break; case TypeClass_UNSIGNED_SHORT: { sal_uInt16 val = 0; aValue >>= val; pVar->PutUShort( val ); } break; case TypeClass_UNSIGNED_LONG: { sal_uInt32 val = 0; aValue >>= val; pVar->PutULong( val ); } break; case TypeClass_UNSIGNED_HYPER: { sal_uInt64 val = 0; aValue >>= val; pVar->PutUInt64( val ); } break; - //case TypeClass_UNSIGNED_INT: break; - //case TypeClass_UNSIGNED_BYTE: break; default: pVar->PutEmpty(); break; } } -// Reflection fuer Sbx-Typen liefern +// Deliver the reflection for Sbx types Type getUnoTypeForSbxBaseType( SbxDataType eType ) { Type aRetType = getCppuVoidType(); switch( eType ) { - //case SbxEMPTY: eRet = TypeClass_VOID; break; case SbxNULL: aRetType = ::getCppuType( (const Reference< XInterface > *)0 ); break; case SbxINTEGER: aRetType = ::getCppuType( (sal_Int16*)0 ); break; case SbxLONG: aRetType = ::getCppuType( (sal_Int32*)0 ); break; @@ -964,52 +950,35 @@ Type getUnoTypeForSbxBaseType( SbxDataType eType ) aRetType = ::getCppuType( (oleautomation::Date*)0 ); } break; - // case SbxDATE: aRetType = ::getCppuType( (double*)0 ); break; case SbxSTRING: aRetType = ::getCppuType( (::rtl::OUString*)0 ); break; - //case SbxOBJECT: break; - //case SbxERROR: break; case SbxBOOL: aRetType = ::getCppuType( (sal_Bool*)0 ); break; case SbxVARIANT: aRetType = ::getCppuType( (Any*)0 ); break; - //case SbxDATAOBJECT: break; case SbxCHAR: aRetType = ::getCppuType( (sal_Unicode*)0 ); break; case SbxBYTE: aRetType = ::getCppuType( (sal_Int8*)0 ); break; case SbxUSHORT: aRetType = ::getCppuType( (sal_uInt16*)0 ); break; case SbxULONG: aRetType = ::getCppuType( (sal_uInt32*)0 ); break; - //case SbxLONG64: break; - //case SbxULONG64: break; - // Maschinenabhaengige zur Sicherheit auf Hyper abbilden + // map machine-dependent ones on hyper for secureness case SbxINT: aRetType = ::getCppuType( (sal_Int32*)0 ); break; case SbxUINT: aRetType = ::getCppuType( (sal_uInt32*)0 ); break; - //case SbxVOID: break; - //case SbxHRESULT: break; - //case SbxPOINTER: break; - //case SbxDIMARRAY: break; - //case SbxCARRAY: break; - //case SbxUSERDEF: break; - //case SbxLPSTR: break; - //case SbxLPWSTR: break; - //case SbxCoreSTRING: break; default: break; } return aRetType; } -// Konvertierung von Sbx nach Uno ohne bekannte Zielklasse fuer TypeClass_ANY +// Converting of Sbx to Uno without a know target class for TypeClass_ANY Type getUnoTypeForSbxValue( SbxValue* pVal ) { Type aRetType = getCppuVoidType(); if( !pVal ) return aRetType; - // SbxType nach Uno wandeln + // convert SbxType to Uno SbxDataType eBaseType = pVal->SbxValue::GetType(); if( eBaseType == SbxOBJECT ) { SbxBaseRef xObj = (SbxBase*)pVal->GetObject(); if( !xObj ) { - // #109936 No error any more - // StarBASIC::Error( SbERR_INVALID_OBJECT ); aRetType = getCppuType( static_cast<Reference<XInterface> *>(0) ); return aRetType; } @@ -1029,8 +998,8 @@ Type getUnoTypeForSbxValue( SbxValue* pVal ) { if( eElementTypeClass == TypeClass_VOID || eElementTypeClass == TypeClass_ANY ) { - // Wenn alle Elemente des Arrays vom gleichen Typ sind, wird - // der genommen, sonst wird das ganze als Any-Sequence betrachtet + // If all elements of the arrays are from the same type, take + // this one - otherwise the whole will be considered as Any-Sequence sal_Bool bNeedsInit = sal_True; sal_Int32 nSize = nUpper - nLower + 1; @@ -1043,7 +1012,6 @@ Type getUnoTypeForSbxValue( SbxValue* pVal ) { if( aType.getTypeClass() == TypeClass_VOID ) { - // #88522 // if only first element is void: different types -> []any // if all elements are void: []void is not allowed -> []any aElementType = getCppuType( (Any*)0 ); @@ -1054,7 +1022,7 @@ Type getUnoTypeForSbxValue( SbxValue* pVal ) } else if( aElementType != aType ) { - // Verschiedene Typen -> AnySequence + // different types -> AnySequence aElementType = getCppuType( (Any*)0 ); break; } @@ -1092,7 +1060,7 @@ Type getUnoTypeForSbxValue( SbxValue* pVal ) } else if( aElementType != aType ) { - // Verschiedene Typen -> AnySequence + // different types -> AnySequence aElementType = getCppuType( (Any*)0 ); break; } @@ -1106,7 +1074,7 @@ Type getUnoTypeForSbxValue( SbxValue* pVal ) aRetType = Type( TypeClass_SEQUENCE, aSeqTypeName ); } } - // Kein Array, sondern... + // No array, but ... else if( xObj->ISA(SbUnoObject) ) { aRetType = ((SbUnoObject*)(SbxBase*)xObj)->getUnoAny().getValueType(); @@ -1116,9 +1084,9 @@ Type getUnoTypeForSbxValue( SbxValue* pVal ) { aRetType = ((SbUnoAnyObject*)(SbxBase*)xObj)->getValue().getValueType(); } - // Sonst ist es ein Nicht-Uno-Basic-Objekt -> default==void liefern + // Otherwise it is a No-Uno-Basic-Object -> default==deliver void } - // Kein Objekt, Basistyp konvertieren + // No object, convert basic type else { aRetType = getUnoTypeForSbxBaseType( eBaseType ); @@ -1126,10 +1094,10 @@ Type getUnoTypeForSbxValue( SbxValue* pVal ) return aRetType; } -// Deklaration Konvertierung von Sbx nach Uno mit bekannter Zielklasse +// Declaration converting of Sbx to Uno with known target class Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty = NULL ); -// Konvertierung von Sbx nach Uno ohne bekannte Zielklasse fuer TypeClass_ANY +// converting of Sbx to Uno without known target class for TypeClass_ANY Any sbxToUnoValueImpl( SbxVariable* pVar, bool bBlockConversionToSmallestType = false ) { SbxDataType eBaseType = pVar->SbxValue::GetType(); @@ -1221,6 +1189,7 @@ Any sbxToUnoValueImpl( SbxVariable* pVar, bool bBlockConversionToSmallestType = aType = ::getCppuType( (sal_uInt16*)0 ); break; } + // TODO: need to add hyper types ? default: break; } } @@ -1275,7 +1244,7 @@ static Any implRekMultiDimArrayToSequence( SbxDimArray* pArray, try { - // In die Sequence uebernehmen + // transfer to the sequence xArray->set( aRetVal, i, aElementVal ); } catch( const IllegalArgumentException& ) @@ -1297,7 +1266,6 @@ Any sbxToUnoValue( SbxVariable* pVar ) return sbxToUnoValueImpl( pVar ); } - // Funktion, um einen globalen Bezeichner im // UnoScope zu suchen und fuer Sbx zu wrappen static bool implGetTypeByName( const String& rName, Type& rRetType ) @@ -1321,7 +1289,7 @@ static bool implGetTypeByName( const String& rName, Type& rRetType ) } -// Konvertierung von Sbx nach Uno mit bekannter Zielklasse +// converting of Sbx to Uno with known target class Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty ) { Any aRetVal; @@ -1352,7 +1320,7 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty { Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( rType ); - // Null-Referenz? + // zero referenz? if( pVar->IsNull() && eType == TypeClass_INTERFACE ) { Reference< XInterface > xRef; @@ -1377,13 +1345,8 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty } else if( rType == ::getCppuType( (oleautomation::Currency*)0 ) ) { - SbxINT64 aInt64 = pVar->GetCurrency(); - oleautomation::Currency aCurrency; - sal_Int64& rnValue64 = aCurrency.Value; - rnValue64 = aInt64.nHigh; - rnValue64 <<= 32; - rnValue64 |= aInt64.nLow; - aRetVal <<= aCurrency; + // assumes per previous code that ole Currency is Int64 + aRetVal <<= (sal_Int64)( pVar->GetInt64() ); break; } else if( rType == ::getCppuType( (oleautomation::Date*)0 ) ) @@ -1403,7 +1366,7 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty } else { - // #109936 NULL object -> NULL XInterface + // zero object -> zero XInterface Reference<XInterface> xInt; aRetVal <<= xInt; } @@ -1444,16 +1407,7 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty } break; - /* folgende Typen lassen wir erstmal weg - case TypeClass_SERVICE: break; - case TypeClass_CLASS: break; - case TypeClass_TYPEDEF: break; - case TypeClass_UNION: break; - case TypeClass_ENUM: break; - case TypeClass_ARRAY: break; - */ - // Array -> Sequence case TypeClass_ENUM: { aRetVal = int2enum( pVar->GetLong(), rType ); @@ -1476,7 +1430,7 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty { sal_Int32 nSeqSize = nUpper - nLower + 1; - // Instanz der geforderten Sequence erzeugen + // create the instanz of the required sequence Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( rType ); xIdlTargetClass->createObject( aRetVal ); Reference< XIdlArray > xArray = xIdlTargetClass->getArray(); @@ -1488,20 +1442,19 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty typelib_typedescription_getByName( &pSeqTD, aClassName.pData ); OSL_ASSERT( pSeqTD ); Type aElemType( ((typelib_IndirectTypeDescription *)pSeqTD)->pType ); - // Reference< XIdlClass > xElementClass = TypeToIdlClass( aElemType ); - // Alle Array-Member umwandeln und eintragen + // convert all array member and register them sal_Int32 nIdx = nLower; for( sal_Int32 i = 0 ; i < nSeqSize ; i++,nIdx++ ) { SbxVariableRef xVar = pArray->Get32( &nIdx ); - // Wert von Sbx nach Uno wandeln + // Convert the value of Sbx to Uno Any aAnyValue = sbxToUnoValue( (SbxVariable*)xVar, aElemType ); try { - // In die Sequence uebernehmen + // take over to the sequence xArray->set( aRetVal, i, aAnyValue ); } catch( const IllegalArgumentException& ) @@ -1568,12 +1521,8 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty } break; - /* - case TypeClass_VOID: break; - case TypeClass_UNKNOWN: break; - */ - // Bei Any die Klassen-unabhaengige Konvertierungs-Routine nutzen + // Use for Any the class indipendent converting routine case TypeClass_ANY: { aRetVal = sbxToUnoValueImpl( pVar ); @@ -1595,7 +1544,6 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty case TypeClass_STRING: aRetVal <<= pVar->GetOUString(); break; case TypeClass_FLOAT: aRetVal <<= pVar->GetSingle(); break; case TypeClass_DOUBLE: aRetVal <<= pVar->GetDouble(); break; - //case TypeClass_OCTET: break; case TypeClass_BYTE: { @@ -1618,46 +1566,137 @@ Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty aRetVal <<= nByteVal; break; } - //case TypeClass_INT: break; case TypeClass_SHORT: aRetVal <<= (sal_Int16)( pVar->GetInteger() ); break; case TypeClass_LONG: aRetVal <<= (sal_Int32)( pVar->GetLong() ); break; case TypeClass_HYPER: aRetVal <<= (sal_Int64)( pVar->GetInt64() ); break; - //case TypeClass_UNSIGNED_OCTET:break; case TypeClass_UNSIGNED_SHORT: aRetVal <<= (sal_uInt16)( pVar->GetUShort() ); break; case TypeClass_UNSIGNED_LONG: aRetVal <<= (sal_uInt32)( pVar->GetULong() ); break; case TypeClass_UNSIGNED_HYPER: aRetVal <<= (sal_uInt64)( pVar->GetUInt64() ); break; - //case TypeClass_UNSIGNED_INT: break; - //case TypeClass_UNSIGNED_BYTE: break; default: break; } return aRetVal; } -// Dbg-Hilfsmethode zum Auslesen der in einem Object implementierten Interfaces -String Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Reference< XIdlClass >& xClass, sal_uInt16 nRekLevel ) +void processAutomationParams( SbxArray* pParams, Sequence< Any >& args, bool bOLEAutomation, sal_uInt32 nParamCount ) +{ + AutomationNamedArgsSbxArray* pArgNamesArray = NULL; + if( bOLEAutomation ) + pArgNamesArray = PTR_CAST(AutomationNamedArgsSbxArray,pParams); + + args.realloc( nParamCount ); + Any* pAnyArgs = args.getArray(); + bool bBlockConversionToSmallestType = pINST->IsCompatibility(); + sal_uInt32 i = 0; + if( pArgNamesArray ) + { + Sequence< ::rtl::OUString >& rNameSeq = pArgNamesArray->getNames(); + ::rtl::OUString* pNames = rNameSeq.getArray(); + Any aValAny; + for( i = 0 ; i < nParamCount ; i++ ) + { + sal_uInt16 iSbx = (sal_uInt16)(i+1); + + aValAny = sbxToUnoValueImpl( pParams->Get( iSbx ), + bBlockConversionToSmallestType ); + + ::rtl::OUString aParamName = pNames[iSbx]; + if( aParamName.getLength() ) + { + oleautomation::NamedArgument aNamedArgument; + aNamedArgument.Name = aParamName; + aNamedArgument.Value = aValAny; + pAnyArgs[i] <<= aNamedArgument; + } + else + { + pAnyArgs[i] = aValAny; + } + } + } + else + { + for( i = 0 ; i < nParamCount ; i++ ) + { + pAnyArgs[i] = sbxToUnoValueImpl( pParams->Get( (sal_uInt16)(i+1) ), + bBlockConversionToSmallestType ); + } + } + +} +enum INVOKETYPE +{ + GetProp = 0, + SetProp, + Func +}; +Any invokeAutomationMethod( const rtl::OUString& Name, Sequence< Any >& args, SbxArray* pParams, sal_uInt32 nParamCount, Reference< XInvocation >& rxInvocation, INVOKETYPE invokeType = Func ) +{ + Sequence< sal_Int16 > OutParamIndex; + Sequence< Any > OutParam; + + Any aRetAny; + switch( invokeType ) + { + case Func: + aRetAny = rxInvocation->invoke( Name, args, OutParamIndex, OutParam ); + break; + case GetProp: + { + Reference< XAutomationInvocation > xAutoInv( rxInvocation, UNO_QUERY ); + aRetAny = xAutoInv->invokeGetProperty( Name, args, OutParamIndex, OutParam ); + break; + } + case SetProp: + { + Reference< XAutomationInvocation > xAutoInv( rxInvocation, UNO_QUERY_THROW ); + aRetAny = xAutoInv->invokePutProperty( Name, args, OutParamIndex, OutParam ); + break; + } + default: + break; // should introduce an error here + + } + const sal_Int16* pIndices = OutParamIndex.getConstArray(); + sal_uInt32 nLen = OutParamIndex.getLength(); + if( nLen ) + { + const Any* pNewValues = OutParam.getConstArray(); + for( sal_uInt32 j = 0 ; j < nLen ; j++ ) + { + sal_Int16 iTarget = pIndices[ j ]; + if( iTarget >= (sal_Int16)nParamCount ) + break; + unoToSbxValue( (SbxVariable*)pParams->Get( (sal_uInt16)(j+1) ), pNewValues[ j ] ); + } + } + return aRetAny; +} + +// Debugging help method to readout the imlemented interfaces of an object +rtl::OUString Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Reference< XIdlClass >& xClass, sal_uInt16 nRekLevel ) { Type aIfaceType = ::getCppuType( (const Reference< XInterface > *)0 ); static Reference< XIdlClass > xIfaceClass = TypeToIdlClass( aIfaceType ); - String aRetStr; + rtl::OUStringBuffer aRetStr; for( sal_uInt16 i = 0 ; i < nRekLevel ; i++ ) - aRetStr.AppendAscii( " " ); - aRetStr += String( xClass->getName() ); + aRetStr.appendAscii( " " ); + aRetStr.append( xClass->getName() ); ::rtl::OUString aClassName = xClass->getName(); Type aClassType( xClass->getTypeClass(), aClassName.getStr() ); - // Pruefen, ob das Interface wirklich unterstuetzt wird + // checking if the interface is realy supported if( !x->queryInterface( aClassType ).hasValue() ) { - aRetStr.AppendAscii( " (ERROR: Not really supported!)\n" ); + aRetStr.appendAscii( " (ERROR: Not really supported!)\n" ); } - // Gibt es Super-Interfaces + // Are there super interfaces? else { - aRetStr.AppendAscii( "\n" ); + aRetStr.appendAscii( "\n" ); - // Super-Interfaces holen + // get the super interfaces Sequence< Reference< XIdlClass > > aSuperClassSeq = xClass->getSuperclasses(); const Reference< XIdlClass >* pClasses = aSuperClassSeq.getConstArray(); sal_uInt32 nSuperIfaceCount = aSuperClassSeq.getLength(); @@ -1665,19 +1704,19 @@ String Impl_GetInterfaceInfo( const Reference< XInterface >& x, const Reference< { const Reference< XIdlClass >& rxIfaceClass = pClasses[j]; if( !rxIfaceClass->equals( xIfaceClass ) ) - aRetStr += Impl_GetInterfaceInfo( x, rxIfaceClass, nRekLevel + 1 ); + aRetStr.append( Impl_GetInterfaceInfo( x, rxIfaceClass, nRekLevel + 1 ) ); } } - return aRetStr; + return aRetStr.makeStringAndClear(); } -String getDbgObjectNameImpl( SbUnoObject* pUnoObj ) +::rtl::OUString getDbgObjectNameImpl( SbUnoObject* pUnoObj ) { - String aName; + ::rtl::OUString aName; if( pUnoObj ) { aName = pUnoObj->GetClassName(); - if( !aName.Len() ) + if( !aName.getLength() ) { Any aToInspectObj = pUnoObj->getUnoAny(); TypeClass eType = aToInspectObj.getValueType().getTypeClass(); @@ -1695,24 +1734,24 @@ String getDbgObjectNameImpl( SbUnoObject* pUnoObj ) return aName; } -String getDbgObjectName( SbUnoObject* pUnoObj ) +::rtl::OUString getDbgObjectName( SbUnoObject* pUnoObj ) { - String aName = getDbgObjectNameImpl( pUnoObj ); - if( !aName.Len() ) - aName.AppendAscii( "Unknown" ); - - String aRet; - if( aName.Len() > 20 ) - aRet.AppendAscii( "\n" ); - aRet.AppendAscii( "\"" ); - aRet += aName; - aRet.AppendAscii( "\":" ); - return aRet; + ::rtl::OUString aName = getDbgObjectNameImpl( pUnoObj ); + if( !aName.getLength() ) + aName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Unknown")); + + ::rtl::OUStringBuffer aRet; + if( aName.getLength() > 20 ) + aRet.appendAscii( "\n" ); + aRet.appendAscii( "\"" ); + aRet.append( aName ); + aRet.appendAscii( "\":" ); + return aRet.makeStringAndClear(); } -String getBasicObjectTypeName( SbxObject* pObj ) +::rtl::OUString getBasicObjectTypeName( SbxObject* pObj ) { - String aName; + ::rtl::OUString aName; if( pObj ) { SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pObj); @@ -1764,7 +1803,7 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, const ::rtl::OUString& rClass ) Reference<XIdlClass> xClass = TypeToIdlClass( rType ); if( !xClass.is() ) { - DBG_ERROR("failed to get XIdlClass for type"); + OSL_FAIL("failed to get XIdlClass for type"); break; } ::rtl::OUString aInterfaceName = xClass->getName(); @@ -1799,35 +1838,34 @@ bool checkUnoObjectType( SbUnoObject* pUnoObj, const ::rtl::OUString& rClass ) return result; } -// Dbg-Hilfsmethode zum Auslesen der in einem Object implementierten Interfaces -String Impl_GetSupportedInterfaces( SbUnoObject* pUnoObj ) +// Debugging help method to readout the imlemented interfaces of an object +::rtl::OUString Impl_GetSupportedInterfaces( SbUnoObject* pUnoObj ) { Any aToInspectObj = pUnoObj->getUnoAny(); - // #54898: Nur TypeClass Interface zulasssen + // allow only TypeClass interface TypeClass eType = aToInspectObj.getValueType().getTypeClass(); - String aRet; + ::rtl::OUStringBuffer aRet; if( eType != TypeClass_INTERFACE ) { - aRet.AppendAscii( RTL_CONSTASCII_STRINGPARAM(ID_DBG_SUPPORTEDINTERFACES) ); - aRet.AppendAscii( " not available.\n(TypeClass is not TypeClass_INTERFACE)\n" ); + aRet.appendAscii( RTL_CONSTASCII_STRINGPARAM(ID_DBG_SUPPORTEDINTERFACES) ); + aRet.appendAscii( " not available.\n(TypeClass is not TypeClass_INTERFACE)\n" ); } else { - // Interface aus dem Any besorgen + // get the interface from the Any const Reference< XInterface > x = *(Reference< XInterface >*)aToInspectObj.getValue(); - // XIdlClassProvider-Interface ansprechen + // address the XIdlClassProvider-Interface Reference< XIdlClassProvider > xClassProvider( x, UNO_QUERY ); Reference< XTypeProvider > xTypeProvider( x, UNO_QUERY ); - aRet.AssignAscii( "Supported interfaces by object " ); - String aObjName = getDbgObjectName( pUnoObj ); - aRet += aObjName; - aRet.AppendAscii( "\n" ); + aRet.appendAscii( "Supported interfaces by object " ); + aRet.append( getDbgObjectName( pUnoObj ) ); + aRet.appendAscii( "\n" ); if( xTypeProvider.is() ) { - // Interfaces der Implementation holen + // get the interfaces of the implementation Sequence< Type > aTypeSeq = xTypeProvider->getTypes(); const Type* pTypeArray = aTypeSeq.getConstArray(); sal_uInt32 nIfaceCount = aTypeSeq.getLength(); @@ -1838,85 +1876,82 @@ String Impl_GetSupportedInterfaces( SbUnoObject* pUnoObj ) Reference<XIdlClass> xClass = TypeToIdlClass( rType ); if( xClass.is() ) { - aRet += Impl_GetInterfaceInfo( x, xClass, 1 ); + aRet.append( Impl_GetInterfaceInfo( x, xClass, 1 ) ); } else { typelib_TypeDescription * pTD = 0; rType.getDescription( &pTD ); - String TypeName( ::rtl::OUString( pTD->pTypeName ) ); - aRet.AppendAscii( "*** ERROR: No IdlClass for type \"" ); - aRet += TypeName; - aRet.AppendAscii( "\"\n*** Please check type library\n" ); + aRet.appendAscii( "*** ERROR: No IdlClass for type \"" ); + aRet.append( pTD->pTypeName ); + aRet.appendAscii( "\"\n*** Please check type library\n" ); } } } else if( xClassProvider.is() ) { - DBG_ERROR( "XClassProvider not supported in UNO3" ); + OSL_FAIL( "XClassProvider not supported in UNO3" ); } } - return aRet; + return aRet.makeStringAndClear(); } -// Dbg-Hilfsmethode SbxDataType -> String -String Dbg_SbxDataType2String( SbxDataType eType ) +// Debugging help method SbxDataType -> String +::rtl::OUString Dbg_SbxDataType2String( SbxDataType eType ) { - String aRet( RTL_CONSTASCII_USTRINGPARAM("Unknown Sbx-Type!") ); + ::rtl::OUStringBuffer aRet; switch( +eType ) { - case SbxEMPTY: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxEMPTY") ); break; - case SbxNULL: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxNULL") ); break; - case SbxINTEGER: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxINTEGER") ); break; - case SbxLONG: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxLONG") ); break; - case SbxSINGLE: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxSINGLE") ); break; - case SbxDOUBLE: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxDOUBLE") ); break; - case SbxCURRENCY: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxCURRENCY") ); break; - case SbxDECIMAL: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxDECIMAL") ); break; - case SbxDATE: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxDATE") ); break; - case SbxSTRING: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxSTRING") ); break; - case SbxOBJECT: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxOBJECT") ); break; - case SbxERROR: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxERROR") ); break; - case SbxBOOL: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxBOOL") ); break; - case SbxVARIANT: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxVARIANT") ); break; - case SbxDATAOBJECT: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxDATAOBJECT") ); break; - case SbxCHAR: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxCHAR") ); break; - case SbxBYTE: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxBYTE") ); break; - case SbxUSHORT: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxUSHORT") ); break; - case SbxULONG: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxULONG") ); break; - case SbxLONG64: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxLONG64") ); break; - case SbxULONG64: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxULONG64") ); break; - case SbxSALINT64: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxINT64") ); break; - case SbxSALUINT64: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxUINT64") ); break; - case SbxINT: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxINT") ); break; - case SbxUINT: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxUINT") ); break; - case SbxVOID: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxVOID") ); break; - case SbxHRESULT: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxHRESULT") ); break; - case SbxPOINTER: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxPOINTER") ); break; - case SbxDIMARRAY: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxDIMARRAY") ); break; - case SbxCARRAY: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxCARRAY") ); break; - case SbxUSERDEF: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxUSERDEF") ); break; - case SbxLPSTR: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxLPSTR") ); break; - case SbxLPWSTR: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxLPWSTR") ); break; - case SbxCoreSTRING: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxCoreSTRING" ) ); break; - case SbxOBJECT | SbxARRAY: aRet = String( RTL_CONSTASCII_USTRINGPARAM("SbxARRAY") ); break; - default: break; + case SbxEMPTY: aRet.appendAscii("SbxEMPTY"); break; + case SbxNULL: aRet.appendAscii("SbxNULL"); break; + case SbxINTEGER: aRet.appendAscii("SbxINTEGER"); break; + case SbxLONG: aRet.appendAscii("SbxLONG"); break; + case SbxSINGLE: aRet.appendAscii("SbxSINGLE"); break; + case SbxDOUBLE: aRet.appendAscii("SbxDOUBLE"); break; + case SbxCURRENCY: aRet.appendAscii("SbxCURRENCY"); break; + case SbxDECIMAL: aRet.appendAscii("SbxDECIMAL"); break; + case SbxDATE: aRet.appendAscii("SbxDATE"); break; + case SbxSTRING: aRet.appendAscii("SbxSTRING"); break; + case SbxOBJECT: aRet.appendAscii("SbxOBJECT"); break; + case SbxERROR: aRet.appendAscii("SbxERROR"); break; + case SbxBOOL: aRet.appendAscii("SbxBOOL"); break; + case SbxVARIANT: aRet.appendAscii("SbxVARIANT"); break; + case SbxDATAOBJECT: aRet.appendAscii("SbxDATAOBJECT"); break; + case SbxCHAR: aRet.appendAscii("SbxCHAR"); break; + case SbxBYTE: aRet.appendAscii("SbxBYTE"); break; + case SbxUSHORT: aRet.appendAscii("SbxUSHORT"); break; + case SbxULONG: aRet.appendAscii("SbxULONG"); break; + case SbxSALINT64: aRet.appendAscii("SbxINT64"); break; + case SbxSALUINT64: aRet.appendAscii("SbxUINT64"); break; + case SbxINT: aRet.appendAscii("SbxINT"); break; + case SbxUINT: aRet.appendAscii("SbxUINT"); break; + case SbxVOID: aRet.appendAscii("SbxVOID"); break; + case SbxHRESULT: aRet.appendAscii("SbxHRESULT"); break; + case SbxPOINTER: aRet.appendAscii("SbxPOINTER"); break; + case SbxDIMARRAY: aRet.appendAscii("SbxDIMARRAY"); break; + case SbxCARRAY: aRet.appendAscii("SbxCARRAY"); break; + case SbxUSERDEF: aRet.appendAscii("SbxUSERDEF"); break; + case SbxLPSTR: aRet.appendAscii("SbxLPSTR"); break; + case SbxLPWSTR: aRet.appendAscii("SbxLPWSTR"); break; + case SbxCoreSTRING: aRet.appendAscii("SbxCoreSTRING"); break; + case SbxOBJECT | SbxARRAY: aRet.appendAscii("SbxARRAY"); break; + default: aRet.appendAscii("Unknown Sbx-Type!");break; } - return aRet; + return aRet.makeStringAndClear(); } -// Dbg-Hilfsmethode zum Anzeigen der Properties eines SbUnoObjects -String Impl_DumpProperties( SbUnoObject* pUnoObj ) +// Debugging help method to display the properties of a SbUnoObjects +::rtl::OUString Impl_DumpProperties( SbUnoObject* pUnoObj ) { - String aRet( RTL_CONSTASCII_USTRINGPARAM("Properties of object ") ); - String aObjName = getDbgObjectName( pUnoObj ); - aRet += aObjName; + ::rtl::OUStringBuffer aRet; + aRet.appendAscii("Properties of object "); + aRet.append( getDbgObjectName( pUnoObj ) ); - // Uno-Infos auswerten, um Arrays zu erkennen + // analyse the Uno-Infos to recognise the arrays Reference< XIntrospectionAccess > xAccess = pUnoObj->getIntrospectionAccess(); if( !xAccess.is() ) { @@ -1926,8 +1961,8 @@ String Impl_DumpProperties( SbUnoObject* pUnoObj ) } if( !xAccess.is() ) { - aRet.AppendAscii( "\nUnknown, no introspection available\n" ); - return aRet; + aRet.appendAscii( "\nUnknown, no introspection available\n" ); + return aRet.makeStringAndClear(); } Sequence<Property> props = xAccess->getProperties( PropertyConcept::ALL - PropertyConcept::DANGEROUS ); @@ -1942,12 +1977,12 @@ String Impl_DumpProperties( SbUnoObject* pUnoObj ) SbxVariable* pVar = pProps->Get( i ); if( pVar ) { - String aPropStr; + ::rtl::OUStringBuffer aPropStr; if( (i % nPropsPerLine) == 0 ) - aPropStr.AppendAscii( "\n" ); + aPropStr.appendAscii( "\n" ); - // Typ und Namen ausgeben - // Ist es in Uno eine Sequence? + // output the type and name + // Is it in Uno a sequence? SbxDataType eType = pVar->GetFullType(); sal_Bool bMaybeVoid = sal_False; @@ -1955,8 +1990,8 @@ String Impl_DumpProperties( SbUnoObject* pUnoObj ) { const Property& rProp = pUnoProps[ i ]; - // #63133: Bei MAYBEVOID Typ aus Uno neu konvertieren, - // damit nicht immer nur SbxEMPTY ausgegben wird. + // By MAYBEVOID convert the type out of Uno newly, + // so that not only SbxEMPTY were outputed. if( rProp.Attributes & PropertyAttribute::MAYBEVOID ) { eType = unoToSbxType( rProp.Type.getTypeClass() ); @@ -1969,31 +2004,31 @@ String Impl_DumpProperties( SbUnoObject* pUnoObj ) eType = (SbxDataType) ( SbxOBJECT | SbxARRAY ); } } - aPropStr += Dbg_SbxDataType2String( eType ); + aPropStr.append( Dbg_SbxDataType2String( eType ) ); if( bMaybeVoid ) - aPropStr.AppendAscii( "/void" ); - aPropStr.AppendAscii( " " ); - aPropStr += pVar->GetName(); + aPropStr.appendAscii( "/void" ); + aPropStr.appendAscii( " " ); + aPropStr.append( pVar->GetName() ); if( i == nPropCount - 1 ) - aPropStr.AppendAscii( "\n" ); + aPropStr.appendAscii( "\n" ); else - aPropStr.AppendAscii( "; " ); + aPropStr.appendAscii( "; " ); - aRet += aPropStr; + aRet.append( aPropStr.makeStringAndClear() ); } } - return aRet; + return aRet.makeStringAndClear(); } -// Dbg-Hilfsmethode zum Anzeigen der Methoden eines SbUnoObjects -String Impl_DumpMethods( SbUnoObject* pUnoObj ) +// Debugging help method to display the methods of an SbUnoObjects +::rtl::OUString Impl_DumpMethods( SbUnoObject* pUnoObj ) { - String aRet( RTL_CONSTASCII_USTRINGPARAM("Methods of object ") ); - String aObjName = getDbgObjectName( pUnoObj ); - aRet += aObjName; + ::rtl::OUStringBuffer aRet; + aRet.appendAscii("Methods of object "); + aRet.append( getDbgObjectName( pUnoObj ) ); - // XIntrospectionAccess, um die Typen der Parameter auch ausgeben zu koennen + // XIntrospectionAccess, so that the types of the parameter could be outputed Reference< XIntrospectionAccess > xAccess = pUnoObj->getIntrospectionAccess(); if( !xAccess.is() ) { @@ -2003,8 +2038,8 @@ String Impl_DumpMethods( SbUnoObject* pUnoObj ) } if( !xAccess.is() ) { - aRet.AppendAscii( "\nUnknown, no introspection available\n" ); - return aRet; + aRet.appendAscii( "\nUnknown, no introspection available\n" ); + return aRet.makeStringAndClear(); } Sequence< Reference< XIdlMethod > > methods = xAccess->getMethods ( MethodConcept::ALL - MethodConcept::DANGEROUS ); @@ -2014,8 +2049,8 @@ String Impl_DumpMethods( SbUnoObject* pUnoObj ) sal_uInt16 nMethodCount = pMethods->Count(); if( !nMethodCount ) { - aRet.AppendAscii( "\nNo methods found\n" ); - return aRet; + aRet.appendAscii( "\nNo methods found\n" ); + return aRet.makeStringAndClear(); } sal_uInt16 nPropsPerLine = 1 + nMethodCount / 30; for( sal_uInt16 i = 0; i < nMethodCount; i++ ) @@ -2023,14 +2058,14 @@ String Impl_DumpMethods( SbUnoObject* pUnoObj ) SbxVariable* pVar = pMethods->Get( i ); if( pVar ) { - String aPropStr; + ::rtl::OUStringBuffer aPropStr; if( (i % nPropsPerLine) == 0 ) - aPropStr.AppendAscii( "\n" ); + aPropStr.appendAscii( "\n" ); - // Methode ansprechen + // address the method const Reference< XIdlMethod >& rxMethod = pUnoMethods[i]; - // Ist es in Uno eine Sequence? + // Is it in Uno a sequence? SbxDataType eType = pVar->GetFullType(); if( eType == SbxOBJECT ) { @@ -2038,13 +2073,13 @@ String Impl_DumpMethods( SbUnoObject* pUnoObj ) if( xClass.is() && xClass->getTypeClass() == TypeClass_SEQUENCE ) eType = (SbxDataType) ( SbxOBJECT | SbxARRAY ); } - // Name und Typ ausgeben - aPropStr += Dbg_SbxDataType2String( eType ); - aPropStr.AppendAscii( " " ); - aPropStr += pVar->GetName(); - aPropStr.AppendAscii( " ( " ); + // output the name and the type + aPropStr.append( Dbg_SbxDataType2String( eType ) ); + aPropStr.appendAscii( " " ); + aPropStr.append ( pVar->GetName() ); + aPropStr.appendAscii( " ( " ); - // get-Methode darf keinen Parameter haben + // the get-method mustn't have a parameter Sequence< Reference< XIdlClass > > aParamsSeq = rxMethod->getParameterTypes(); sal_uInt32 nParamCount = aParamsSeq.getLength(); const Reference< XIdlClass >* pParams = aParamsSeq.getConstArray(); @@ -2053,27 +2088,25 @@ String Impl_DumpMethods( SbUnoObject* pUnoObj ) { for( sal_uInt16 j = 0; j < nParamCount; j++ ) { - String aTypeStr = Dbg_SbxDataType2String( unoToSbxType( pParams[ j ] ) ); - aPropStr += aTypeStr; - + aPropStr.append ( Dbg_SbxDataType2String( unoToSbxType( pParams[ j ] ) ) ); if( j < nParamCount - 1 ) - aPropStr.AppendAscii( ", " ); + aPropStr.appendAscii( ", " ); } } else - aPropStr.AppendAscii( "void" ); + aPropStr.appendAscii( "void" ); - aPropStr.AppendAscii( " ) " ); + aPropStr.appendAscii( " ) " ); if( i == nMethodCount - 1 ) - aPropStr.AppendAscii( "\n" ); + aPropStr.appendAscii( "\n" ); else - aPropStr.AppendAscii( "; " ); + aPropStr.appendAscii( "; " ); - aRet += aPropStr; + aRet.append( aPropStr ); } } - return aRet; + return aRet.makeStringAndClear(); } TYPEINIT1(AutomationNamedArgsSbxArray,SbxArray) @@ -2101,26 +2134,26 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, sal_Int32 nId = pProp->nId; if( nId < 0 ) { - // Id == -1: Implementierte Interfaces gemaess ClassProvider anzeigen + // Id == -1: Display implemented interfaces according the ClassProvider if( nId == -1 ) // Property ID_DBG_SUPPORTEDINTERFACES" { - String aRetStr = Impl_GetSupportedInterfaces( this ); + ::rtl::OUString aRetStr = Impl_GetSupportedInterfaces( this ); pVar->PutString( aRetStr ); } - // Id == -2: Properties ausgeben + // Id == -2: output properties else if( nId == -2 ) // Property ID_DBG_PROPERTIES { - // Jetzt muessen alle Properties angelegt werden + // by now all properties must be established implCreateAll(); - String aRetStr = Impl_DumpProperties( this ); + ::rtl::OUString aRetStr = Impl_DumpProperties( this ); pVar->PutString( aRetStr ); } - // Id == -3: Methoden ausgeben + // Id == -3: output the methods else if( nId == -3 ) // Property ID_DBG_METHODS { - // Jetzt muessen alle Properties angelegt werden + // y now all properties must be established implCreateAll(); - String aRetStr = Impl_DumpMethods( this ); + ::rtl::OUString aRetStr = Impl_DumpMethods( this ); pVar->PutString( aRetStr ); } return; @@ -2130,14 +2163,14 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, { try { - // Wert holen + // get the value Reference< XPropertySet > xPropSet( mxUnoAccess->queryAdapter( ::getCppuType( (const Reference< XPropertySet > *)0 ) ), UNO_QUERY ); Any aRetAny = xPropSet->getPropertyValue( pProp->GetName() ); - // Die Nutzung von getPropertyValue (statt ueber den Index zu gehen) ist - // nicht optimal, aber die Umstellung auf XInvocation steht ja ohnehin an - // Ansonsten kann auch FastPropertySet genutzt werden + // The use of getPropertyValue (instead of using the index) is + // suboptimal, but the refactoring to XInvocation is already pending + // Otherwise it is posible to use FastPropertySet - // Wert von Uno nach Sbx uebernehmen + // take over the value from Uno to Sbx unoToSbxValue( pVar, aRetAny ); } catch( const Exception& ) @@ -2149,11 +2182,24 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, { try { - // Wert holen - Any aRetAny = mxInvocation->getValue( pProp->GetName() ); - - // Wert von Uno nach Sbx uebernehmen + sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0; + sal_Bool bCanBeConsideredAMethod = mxInvocation->hasMethod( pProp->GetName() ); + Any aRetAny; + if ( bCanBeConsideredAMethod && nParamCount ) + { + // Automation properties have methods, so.. we need to invoke this through + // XInvocation + Sequence<Any> args; + processAutomationParams( pParams, args, true, nParamCount ); + aRetAny = invokeAutomationMethod( pProp->GetName(), args, pParams, nParamCount, mxInvocation, GetProp ); + } + else + aRetAny = mxInvocation->getValue( pProp->GetName() ); + // take over the value from Uno to Sbx unoToSbxValue( pVar, aRetAny ); + if( pParams && bCanBeConsideredAMethod ) + pVar->SetParameters( NULL ); + } catch( const Exception& ) { @@ -2171,16 +2217,16 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, return; } - // Wert von Uno nach Sbx uebernehmen + // take over the value from Uno to Sbx Any aAnyValue = sbxToUnoValue( pVar, pProp->aUnoProp.Type, &pProp->aUnoProp ); try { - // Wert setzen + // set the value Reference< XPropertySet > xPropSet( mxUnoAccess->queryAdapter( ::getCppuType( (const Reference< XPropertySet > *)0 ) ), UNO_QUERY ); xPropSet->setPropertyValue( pProp->GetName(), aAnyValue ); - // Die Nutzung von getPropertyValue (statt ueber den Index zu gehen) ist - // nicht optimal, aber die Umstellung auf XInvocation steht ja ohnehin an - // Ansonsten kann auch FastPropertySet genutzt werden + // The use of getPropertyValue (instead of using the index) is + // suboptimal, but the refactoring to XInvocation is already pending + // Otherwise it is posible to use FastPropertySet } catch( const Exception& ) { @@ -2189,11 +2235,11 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, } else if( bInvocation && mxInvocation.is() ) { - // Wert von Uno nach Sbx uebernehmen + // take over the value from Uno to Sbx Any aAnyValue = sbxToUnoValueImpl( pVar ); try { - // Wert setzen + // set the value mxInvocation->setValue( pProp->GetName(), aAnyValue ); } catch( const Exception& ) @@ -2208,7 +2254,7 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, bool bInvocation = pMeth->isInvocationBased(); if( pHint->GetId() == SBX_HINT_DATAWANTED ) { - // Anzahl Parameter -1 wegen Param0 == this + // number of Parameter -1 because of Param0 == this sal_uInt32 nParamCount = pParams ? ((sal_uInt32)pParams->Count() - 1) : 0; Sequence<Any> args; sal_Bool bOutParams = sal_False; @@ -2216,13 +2262,13 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, if( !bInvocation && mxUnoAccess.is() ) { - // Infos holen + // get info const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos(); const ParamInfo* pParamInfos = rInfoSeq.getConstArray(); sal_uInt32 nUnoParamCount = rInfoSeq.getLength(); sal_uInt32 nAllocParamCount = nParamCount; - // Ueberschuessige Parameter ignorieren, Alternative: Error schmeissen + // ignore surplus parameter; alternative: throw an error if( nParamCount > nUnoParamCount ) { nParamCount = nUnoParamCount; @@ -2258,14 +2304,13 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, { const ParamInfo& rInfo = pParamInfos[i]; const Reference< XIdlClass >& rxClass = rInfo.aType; - //const XIdlClassRef& rxClass = pUnoParams[i]; com::sun::star::uno::Type aType( rxClass->getTypeClass(), rxClass->getName() ); - // ACHTUNG: Bei den Sbx-Parametern den Offset nicht vergessen! + // ATTENTION: Don't forget for Sbx-Parameter the offset! pAnyArgs[i] = sbxToUnoValue( pParams->Get( (sal_uInt16)(i+1) ), aType ); - // Wenn es nicht schon feststeht pruefen, ob Out-Parameter vorliegen + // If it is not certain check whether the out-parameter are available. if( !bOutParams ) { ParamMode aParamMode = rInfo.aMode; @@ -2278,55 +2323,10 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, else if( bInvocation && pParams && mxInvocation.is() ) { bool bOLEAutomation = true; - // TODO: bOLEAutomation = xOLEAutomation.is() - - AutomationNamedArgsSbxArray* pArgNamesArray = NULL; - if( bOLEAutomation ) - pArgNamesArray = PTR_CAST(AutomationNamedArgsSbxArray,pParams); - - args.realloc( nParamCount ); - Any* pAnyArgs = args.getArray(); - bool bBlockConversionToSmallestType = pINST->IsCompatibility(); - if( pArgNamesArray ) - { - Sequence< ::rtl::OUString >& rNameSeq = pArgNamesArray->getNames(); - ::rtl::OUString* pNames = rNameSeq.getArray(); - - Any aValAny; - for( i = 0 ; i < nParamCount ; i++ ) - { - sal_uInt16 iSbx = (sal_uInt16)(i+1); - - // ACHTUNG: Bei den Sbx-Parametern den Offset nicht vergessen! - aValAny = sbxToUnoValueImpl( pParams->Get( iSbx ), - bBlockConversionToSmallestType ); - - ::rtl::OUString aParamName = pNames[iSbx]; - if( aParamName.getLength() ) - { - oleautomation::NamedArgument aNamedArgument; - aNamedArgument.Name = aParamName; - aNamedArgument.Value = aValAny; - pAnyArgs[i] <<= aNamedArgument; - } - else - { - pAnyArgs[i] = aValAny; - } - } - } - else - { - for( i = 0 ; i < nParamCount ; i++ ) - { - // ACHTUNG: Bei den Sbx-Parametern den Offset nicht vergessen! - pAnyArgs[i] = sbxToUnoValueImpl( pParams->Get( (sal_uInt16)(i+1) ), - bBlockConversionToSmallestType ); - } - } + processAutomationParams( pParams, args, bOLEAutomation, nParamCount ); } - // Methode callen + // call the method GetSbData()->bBlockCompilerError = sal_True; // #106433 Block compiler errors for API calls try { @@ -2334,15 +2334,15 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, { Any aRetAny = pMeth->m_xUnoMethod->invoke( getUnoAny(), args ); - // Wert von Uno nach Sbx uebernehmen + // take over the value from Uno to Sbx unoToSbxValue( pVar, aRetAny ); - // Muessen wir Out-Parameter zurueckkopieren? + // Did we to copy back the Out-Parameter? if( bOutParams ) { const Any* pAnyArgs = args.getConstArray(); - // Infos holen + // get info const Sequence<ParamInfo>& rInfoSeq = pMeth->getParamInfos(); const ParamInfo* pParamInfos = rInfoSeq.getConstArray(); @@ -2358,40 +2358,12 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, } else if( bInvocation && mxInvocation.is() ) { - Reference< XDirectInvocation > xDirectInvoke; - if ( pMeth->needsDirectInvocation() ) - xDirectInvoke.set( mxInvocation, UNO_QUERY ); - - Any aRetAny; - if ( xDirectInvoke.is() ) - aRetAny = xDirectInvoke->directInvoke( pMeth->GetName(), args ); - else - { - Sequence< sal_Int16 > OutParamIndex; - Sequence< Any > OutParam; - aRetAny = mxInvocation->invoke( pMeth->GetName(), args, OutParamIndex, OutParam ); - - const sal_Int16* pIndices = OutParamIndex.getConstArray(); - sal_uInt32 nLen = OutParamIndex.getLength(); - if( nLen ) - { - const Any* pNewValues = OutParam.getConstArray(); - for( sal_uInt32 j = 0 ; j < nLen ; j++ ) - { - sal_Int16 iTarget = pIndices[ j ]; - if( iTarget >= (sal_Int16)nParamCount ) - break; - unoToSbxValue( (SbxVariable*)pParams->Get( (sal_uInt16)(j+1) ), pNewValues[ j ] ); - } - } - } - - // Wert von Uno nach Sbx uebernehmen + Any aRetAny = invokeAutomationMethod( pMeth->GetName(), args, pParams, nParamCount, mxInvocation ); unoToSbxValue( pVar, aRetAny ); - } + } - // #55460, Parameter hier weghauen, da das in unoToSbxValue() - // bei Arrays wegen #54548 nicht mehr gemacht wird + // remove parameter here, because this was not done anymore in unoToSbxValue() + // for arrays if( pParams ) pVar->SetParameters( NULL ); } @@ -2409,27 +2381,27 @@ void SbUnoObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, #ifdef INVOCATION_ONLY -// Aus USR +// From USR Reference< XInvocation > createDynamicInvocationFor( const Any& aAny ); #endif -SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ ) +SbUnoObject::SbUnoObject( const rtl::OUString& aName_, const Any& aUnoObj_ ) : SbxObject( aName_ ) , bNeedIntrospection( sal_True ) , bNativeCOMObject( sal_False ) { static Reference< XIntrospection > xIntrospection; - // Default-Properties von Sbx wieder rauspruegeln + // beat out again the default properties of Sbx Remove( XubString( RTL_CONSTASCII_USTRINGPARAM("Name") ), SbxCLASS_DONTCARE ); Remove( XubString( RTL_CONSTASCII_USTRINGPARAM("Parent") ), SbxCLASS_DONTCARE ); - // Typ des Objekts pruefen + // check the type of the ojekts TypeClass eType = aUnoObj_.getValueType().getTypeClass(); Reference< XInterface > x; if( eType == TypeClass_INTERFACE ) { - // Interface aus dem Any besorgen + // get the interface from the Any x = *(Reference< XInterface >*)aUnoObj_.getValue(); if( !x.is() ) return; @@ -2437,10 +2409,10 @@ SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ ) Reference< XTypeProvider > xTypeProvider; #ifdef INVOCATION_ONLY - // Invocation besorgen + // get the invocation mxInvocation = createDynamicInvocationFor( aUnoObj_ ); #else - // Hat das Object selbst eine Invocation? + // Did the object have an invocation itself? mxInvocation = Reference< XInvocation >( x, UNO_QUERY ); xTypeProvider = Reference< XTypeProvider >( x, UNO_QUERY ); @@ -2448,15 +2420,11 @@ SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ ) if( mxInvocation.is() ) { - // #94670: This is WRONG because then the MaterialHolder doesn't refer - // to the object implementing XInvocation but to the object passed to - // the invocation service!!! - // mxMaterialHolder = Reference< XMaterialHolder >::query( mxInvocation ); - // ExactName holen + // get the ExactName mxExactNameInvocation = Reference< XExactName >::query( mxInvocation ); - // Rest bezieht sich nur auf Introspection + // The remainder refers only to the introspection if( !xTypeProvider.is() ) { bNeedIntrospection = sal_False; @@ -2473,35 +2441,35 @@ SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ ) maTmpUnoObj = aUnoObj_; - //*** Namen bestimmen *** + //*** Define the name *** sal_Bool bFatalError = sal_True; - // Ist es ein Interface oder eine struct? + // Is it an interface or a struct? sal_Bool bSetClassName = sal_False; - String aClassName_; + rtl::OUString aClassName_; if( eType == TypeClass_STRUCT || eType == TypeClass_EXCEPTION ) { - // Struct ist Ok + // Struct is Ok bFatalError = sal_False; - // #67173 Echten Klassen-Namen eintragen - if( aName_.Len() == 0 ) + // insert the real name of the class + if( aName_.getLength() == 0 ) { - aClassName_ = String( aUnoObj_.getValueType().getTypeName() ); + aClassName_ = aUnoObj_.getValueType().getTypeName(); bSetClassName = sal_True; } } else if( eType == TypeClass_INTERFACE ) { - // #70197 Interface geht immer durch Typ im Any + // Interface works always through the type in the Any bFatalError = sal_False; - // Nach XIdlClassProvider-Interface fragen + // Ask for the XIdlClassProvider-Interface Reference< XIdlClassProvider > xClassProvider( x, UNO_QUERY ); if( xClassProvider.is() ) { - // #67173 Echten Klassen-Namen eintragen - if( aName_.Len() == 0 ) + // Insert the real name of the class + if( aName_.getLength() == 0 ) { Sequence< Reference< XIdlClass > > szClasses = xClassProvider->getIdlClasses(); sal_uInt32 nLen = szClasses.getLength(); @@ -2510,7 +2478,7 @@ SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ ) const Reference< XIdlClass > xImplClass = szClasses.getConstArray()[ 0 ]; if( xImplClass.is() ) { - aClassName_ = String( xImplClass->getName() ); + aClassName_ = xImplClass->getName(); bSetClassName = sal_True; } } @@ -2520,14 +2488,14 @@ SbUnoObject::SbUnoObject( const String& aName_, const Any& aUnoObj_ ) if( bSetClassName ) SetClassName( aClassName_ ); - // Weder Interface noch Struct -> FatalError + // Neither interface nor Struct -> FatalError if( bFatalError ) { StarBASIC::FatalError( ERRCODE_BASIC_EXCEPTION ); return; } - // #67781 Introspection erst on demand durchfuehren + // pass the introspection primal on demand } SbUnoObject::~SbUnoObject() @@ -2535,7 +2503,7 @@ SbUnoObject::~SbUnoObject() } -// #76470 Introspection on Demand durchfuehren +// pass the introspection on Demand void SbUnoObject::doIntrospection( void ) { static Reference< XIntrospection > xIntrospection; @@ -2546,14 +2514,13 @@ void SbUnoObject::doIntrospection( void ) if( !xIntrospection.is() ) { - // Introspection-Service holen + // get the introspection service Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() ); if ( xFactory.is() ) { - Reference< XInterface > xI = xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.beans.Introspection") ); + Reference< XInterface > xI = xFactory->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.beans.Introspection")) ); if (xI.is()) xIntrospection = Reference< XIntrospection >::query( xI ); - //xI->queryInterface( ::getCppuType( (const Reference< XIntrospection > *)0 ), xIntrospection ); } } if( !xIntrospection.is() ) @@ -2562,7 +2529,7 @@ void SbUnoObject::doIntrospection( void ) return; } - // Introspection durchfuehren + // pass the introspection try { mxUnoAccess = xIntrospection->inspect( maTmpUnoObj ); @@ -2574,21 +2541,21 @@ void SbUnoObject::doIntrospection( void ) if( !mxUnoAccess.is() ) { - // #51475 Ungueltiges Objekt kennzeichnen (kein mxMaterialHolder) + // #51475 mark an invalid objekt kennzeichnen (no mxMaterialHolder) return; } - // MaterialHolder vom Access holen + // get MaterialHolder from access mxMaterialHolder = Reference< XMaterialHolder >::query( mxUnoAccess ); - // ExactName vom Access holen + // get ExactName from access mxExactName = Reference< XExactName >::query( mxUnoAccess ); } -// #67781 Start einer Liste aller SbUnoMethod-Instanzen +// Start of a list of all SbUnoMethod-Instances static SbUnoMethod* pFirst = NULL; void clearUnoMethodsForBasic( StarBASIC* pBasic ) @@ -2645,7 +2612,7 @@ void clearUnoMethods( void ) SbUnoMethod::SbUnoMethod ( - const String& aName_, + const rtl::OUString& aName_, SbxDataType eSbxType, Reference< XIdlMethod > xUnoMethod_, bool bInvocation, @@ -2658,7 +2625,7 @@ SbUnoMethod::SbUnoMethod m_xUnoMethod = xUnoMethod_; pParamInfoSeq = NULL; - // #67781 Methode in Liste eintragen + // enregister the method in a list pNext = pFirst; pPrev = NULL; pFirst = this; @@ -2696,7 +2663,6 @@ SbxInfo* SbUnoMethod::GetInfo() const ParamInfo& rInfo = pParamInfos[i]; ::rtl::OUString aParamName = rInfo.aName; - // const Reference< XIdlClass >& rxClass = rInfo.aType; SbxDataType t = SbxVARIANT; sal_uInt16 nFlags_ = SBX_READ; pInfo->AddParam( aParamName, t, nFlags_ ); @@ -2718,7 +2684,7 @@ const Sequence<ParamInfo>& SbUnoMethod::getParamInfos( void ) SbUnoProperty::SbUnoProperty ( - const String& aName_, + const rtl::OUString& aName_, SbxDataType eSbxType, const Property& aUnoProp_, sal_Int32 nId_, @@ -2729,7 +2695,7 @@ SbUnoProperty::SbUnoProperty , nId( nId_ ) , mbInvocation( bInvocation ) { - // #54548, bei bedarf Dummy-Array einsetzen, damit SbiRuntime::CheckArray() geht + // as needed establish an dummy array so that SbiRuntime::CheckArray() works static SbxArrayRef xDummyArray = new SbxArray( SbxVARIANT ); if( eSbxType & SbxARRAY ) PutObject( xDummyArray ); @@ -2749,8 +2715,8 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t ) if( bNeedIntrospection ) doIntrospection(); - // Neu 4.3.1999: Properties on Demand anlegen, daher jetzt perIntrospectionAccess - // suchen, ob doch eine Property oder Methode des geforderten Namens existiert + // New 1999-03-04: Create properties on demand. Therefore search now perIntrospectionAccess, + // if a property or a method of the required name exist if( !pRes ) { ::rtl::OUString aUName( rName ); @@ -2767,14 +2733,14 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t ) const Property& rProp = mxUnoAccess-> getProperty( aUName, PropertyConcept::ALL - PropertyConcept::DANGEROUS ); - // #58455 Wenn die Property void sein kann, muss als Typ Variant gesetzt werden + // If the property could be void the type had to be set to Variant SbxDataType eSbxType; if( rProp.Attributes & PropertyAttribute::MAYBEVOID ) eSbxType = SbxVARIANT; else eSbxType = unoToSbxType( rProp.Type.getTypeClass() ); - // Property anlegen und reinbraten + // create the property and superimpose it SbxVariableRef xVarRef = new SbUnoProperty( rProp.Name, eSbxType, rProp, 0, false ); QuickInsert( (SbxVariable*)xVarRef ); pRes = xVarRef; @@ -2782,18 +2748,18 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t ) else if( mxUnoAccess->hasMethod( aUName, MethodConcept::ALL - MethodConcept::DANGEROUS ) ) { - // Methode ansprechen + // address the method const Reference< XIdlMethod >& rxMethod = mxUnoAccess-> getMethod( aUName, MethodConcept::ALL - MethodConcept::DANGEROUS ); - // SbUnoMethode anlegen und reinbraten + // create SbUnoMethod and superimpose it SbxVariableRef xMethRef = new SbUnoMethod( rxMethod->getName(), unoToSbxType( rxMethod->getReturnType() ), rxMethod, false ); QuickInsert( (SbxVariable*)xMethRef ); pRes = xMethRef; } - // Wenn immer noch nichts gefunden wurde, muss geprueft werden, ob NameAccess vorliegt + // Elsewise nothing would be found it had to be checked, if NameAccess is existent if( !pRes ) { try @@ -2805,13 +2771,13 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t ) { Any aAny = xNameAccess->getByName( aUName2 ); - // ACHTUNG: Die hier erzeugte Variable darf wegen bei XNameAccess + // ATTENTION: Die hier erzeugte Variable darf wegen bei XNameAccess // nicht als feste Property in das Object aufgenommen werden und // wird daher nirgendwo gehalten. - // Wenn das Probleme gibt, muss das kuenstlich gemacht werden oder - // es muss eine Klasse SbUnoNameAccessProperty geschaffen werden, - // bei der die Existenz staendig neu ueberprueft und die ggf. weg- - // geworfen wird, wenn der Name nicht mehr gefunden wird. + // If this leads to problems, it has to be created synthetically or + // a class SbUnoNameAccessProperty, whose existence had to be checked + // constantly and which were if necessary thrown away + // if the name was not found anymore. pRes = new SbxVariable( SbxVARIANT ); unoToSbxValue( pRes, aAny ); } @@ -2822,7 +2788,7 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t ) } catch( const Exception& ) { - // Anlegen, damit der Exception-Fehler nicht ueberschrieben wird + // Establish so that the exeption error will not be overwriten if( !pRes ) pRes = new SbxVariable( SbxVARIANT ); @@ -2843,14 +2809,14 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t ) { if( mxInvocation->hasProperty( aUName ) ) { - // Property anlegen und reinbraten + // create a property and superimpose it SbxVariableRef xVarRef = new SbUnoProperty( aUName, SbxVARIANT, aDummyProp, 0, true ); QuickInsert( (SbxVariable*)xVarRef ); pRes = xVarRef; } else if( mxInvocation->hasMethod( aUName ) ) { - // SbUnoMethode anlegen und reinbraten + // create SbUnoMethode and superimpose it SbxVariableRef xMethRef = new SbUnoMethod( aUName, SbxVARIANT, xDummyMethod, true ); QuickInsert( (SbxVariable*)xMethRef ); pRes = xMethRef; @@ -2869,7 +2835,7 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t ) } catch( RuntimeException& e ) { - // Anlegen, damit der Exception-Fehler nicht ueberschrieben wird + // Establish so that the exeption error will not be overwriten if( !pRes ) pRes = new SbxVariable( SbxVARIANT ); @@ -2878,7 +2844,7 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t ) } } - // Ganz am Schluss noch pruefen, ob die Dbg_-Properties gemeint sind + // At the very end checking if the Dbg_-Properties are meant if( !pRes ) { @@ -2886,10 +2852,10 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t ) rName.EqualsIgnoreCaseAscii( ID_DBG_PROPERTIES ) || rName.EqualsIgnoreCaseAscii( ID_DBG_METHODS ) ) { - // Anlegen + // Create implCreateDbgProperties(); - // Jetzt muessen sie regulaer gefunden werden + // Now they have to be found regular pRes = SbxObject::Find( rName, SbxCLASS_DONTCARE ); } } @@ -2897,33 +2863,33 @@ SbxVariable* SbUnoObject::Find( const String& rName, SbxClassType t ) } -// Hilfs-Methode zum Anlegen der dbg_-Properties +// help method to create the dbg_-Properties void SbUnoObject::implCreateDbgProperties( void ) { Property aProp; - // Id == -1: Implementierte Interfaces gemaess ClassProvider anzeigen - SbxVariableRef xVarRef = new SbUnoProperty( String(RTL_CONSTASCII_USTRINGPARAM(ID_DBG_SUPPORTEDINTERFACES)), SbxSTRING, aProp, -1, false ); + // Id == -1: display the implemented interfaces corresponding the ClassProvider + SbxVariableRef xVarRef = new SbUnoProperty( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ID_DBG_SUPPORTEDINTERFACES)), SbxSTRING, aProp, -1, false ); QuickInsert( (SbxVariable*)xVarRef ); - // Id == -2: Properties ausgeben - xVarRef = new SbUnoProperty( String(RTL_CONSTASCII_USTRINGPARAM(ID_DBG_PROPERTIES)), SbxSTRING, aProp, -2, false ); + // Id == -2: output the properties + xVarRef = new SbUnoProperty( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ID_DBG_PROPERTIES)), SbxSTRING, aProp, -2, false ); QuickInsert( (SbxVariable*)xVarRef ); - // Id == -3: Methoden ausgeben - xVarRef = new SbUnoProperty( String(RTL_CONSTASCII_USTRINGPARAM(ID_DBG_METHODS)), SbxSTRING, aProp, -3, false ); + // Id == -3: output the Methods + xVarRef = new SbUnoProperty( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(ID_DBG_METHODS)), SbxSTRING, aProp, -3, false ); QuickInsert( (SbxVariable*)xVarRef ); } void SbUnoObject::implCreateAll( void ) { - // Bestehende Methoden und Properties alle wieder wegwerfen + // throw away all existing methods and properties pMethods = new SbxArray; pProps = new SbxArray; if( bNeedIntrospection ) doIntrospection(); - // Instrospection besorgen + // get instrospection Reference< XIntrospectionAccess > xAccess = mxUnoAccess; if( !xAccess.is() || bNativeCOMObject ) { @@ -2935,7 +2901,7 @@ void SbUnoObject::implCreateAll( void ) if( !xAccess.is() ) return; - // Properties anlegen + // Establish properties Sequence<Property> props = xAccess->getProperties( PropertyConcept::ALL - PropertyConcept::DANGEROUS ); sal_uInt32 nPropCount = props.getLength(); const Property* pProps_ = props.getConstArray(); @@ -2945,32 +2911,32 @@ void SbUnoObject::implCreateAll( void ) { const Property& rProp = pProps_[ i ]; - // #58455 Wenn die Property void sein kann, muss als Typ Variant gesetzt werden + // If the property could be void the type had to be set to Variant SbxDataType eSbxType; if( rProp.Attributes & PropertyAttribute::MAYBEVOID ) eSbxType = SbxVARIANT; else eSbxType = unoToSbxType( rProp.Type.getTypeClass() ); - // Property anlegen und reinbraten + // Create property and superimpose it SbxVariableRef xVarRef = new SbUnoProperty( rProp.Name, eSbxType, rProp, i, false ); QuickInsert( (SbxVariable*)xVarRef ); } - // Dbg_-Properties anlegen + // Create Dbg_-Properties implCreateDbgProperties(); - // Methoden anlegen + // Create methods Sequence< Reference< XIdlMethod > > aMethodSeq = xAccess->getMethods ( MethodConcept::ALL - MethodConcept::DANGEROUS ); sal_uInt32 nMethCount = aMethodSeq.getLength(); const Reference< XIdlMethod >* pMethods_ = aMethodSeq.getConstArray(); for( i = 0 ; i < nMethCount ; i++ ) { - // Methode ansprechen + // address method const Reference< XIdlMethod >& rxMethod = pMethods_[i]; - // SbUnoMethode anlegen und reinbraten + // Create SbUnoMethod and superimpose it SbxVariableRef xMethRef = new SbUnoMethod ( rxMethod->getName(), unoToSbxType( rxMethod->getReturnType() ), rxMethod, false ); QuickInsert( (SbxVariable*)xMethRef ); @@ -2978,7 +2944,7 @@ void SbUnoObject::implCreateAll( void ) } -// Wert rausgeben +// output the value Any SbUnoObject::getUnoAny( void ) { Any aRetAny; @@ -2990,15 +2956,15 @@ Any SbUnoObject::getUnoAny( void ) return aRetAny; } -// Hilfsmethode zum Anlegen einer Uno-Struct per CoreReflection -SbUnoObject* Impl_CreateUnoStruct( const String& aClassName ) +// help method to create an Uno-Struct per CoreReflection +SbUnoObject* Impl_CreateUnoStruct( const ::rtl::OUString& aClassName ) { - // CoreReflection holen + // get CoreReflection Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl(); if( !xCoreReflection.is() ) return NULL; - // Klasse suchen + // search for the class Reference< XIdlClass > xClass; Reference< XHierarchicalNameAccess > xHarryName = getCoreReflection_HierarchicalNameAccess_Impl(); @@ -3007,25 +2973,25 @@ SbUnoObject* Impl_CreateUnoStruct( const String& aClassName ) if( !xClass.is() ) return NULL; - // Ist es ueberhaupt ein struct? + // Is it realy a struct? TypeClass eType = xClass->getTypeClass(); if ( ( eType != TypeClass_STRUCT ) && ( eType != TypeClass_EXCEPTION ) ) return NULL; - // Instanz erzeugen + // create an instance Any aNewAny; xClass->createObject( aNewAny ); - // SbUnoObject daraus basteln + // make a SbUnoObject out of it SbUnoObject* pUnoObj = new SbUnoObject( aClassName, aNewAny ); return pUnoObj; } -// Factory-Klasse fuer das Anlegen von Uno-Structs per DIM AS NEW +// Factory-Class to create Uno-Structs per DIM AS NEW SbxBase* SbUnoFactory::Create( sal_uInt16, sal_uInt32 ) { - // Ueber SbxId laeuft in Uno nix + // Via SbxId nothing works in Uno return NULL; } @@ -3035,9 +3001,9 @@ SbxObject* SbUnoFactory::CreateObject( const String& rClassName ) } -// Provisorische Schnittstelle fuer UNO-Anbindung -// Liefert ein SbxObject, das ein Uno-Interface wrappt -SbxObjectRef GetSbUnoObject( const String& aName, const Any& aUnoObj_ ) +// Provisional interface for the UNO-Connection +// Deliver a SbxObject, that wrap an Uno-Interface +SbxObjectRef GetSbUnoObject( const ::rtl::OUString& aName, const Any& aUnoObj_ ) { return new SbUnoObject( aName, aUnoObj_ ); } @@ -3061,22 +3027,22 @@ void RTL_Impl_CreateUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit (void)pBasic; (void)bWrite; - // Wir brauchen mindestens 1 Parameter + // We need 1 parameter minimum if ( rPar.Count() < 2 ) { StarBASIC::Error( SbERR_BAD_ARGUMENT ); return; } - // Klassen-Name der struct holen - String aClassName = rPar.Get(1)->GetString(); + // get the name of the class of the struct + ::rtl::OUString aClassName = rPar.Get(1)->GetString(); - // Versuchen, gleichnamige Struct zu erzeugen + // try to create Struct with the same name SbUnoObjectRef xUnoObj = Impl_CreateUnoStruct( aClassName ); if( !xUnoObj ) return; - // Objekt zurueckliefern + // return the objekt SbxVariableRef refVar = rPar.Get(0); refVar->PutObject( (SbUnoObject*)xUnoObj ); } @@ -3086,17 +3052,17 @@ void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWri (void)pBasic; (void)bWrite; - // Wir brauchen mindestens 1 Parameter + // We need 1 Parameter minimum if ( rPar.Count() < 2 ) { StarBASIC::Error( SbERR_BAD_ARGUMENT ); return; } - // Klassen-Name der struct holen - String aServiceName = rPar.Get(1)->GetString(); + // get the name of the class of the struct + ::rtl::OUString aServiceName = rPar.Get(1)->GetString(); - // Service suchen und instanzieren + // search for the service and instatiate it Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() ); Reference< XInterface > xInterface; if ( xFactory.is() ) @@ -3117,11 +3083,11 @@ void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWri Any aAny; aAny <<= xInterface; - // SbUnoObject daraus basteln und zurueckliefern + // Create a SbUnoObject out of it and return it SbUnoObjectRef xUnoObj = new SbUnoObject( aServiceName, aAny ); if( xUnoObj->getUnoAny().getValueType().getTypeClass() != TypeClass_VOID ) { - // Objekt zurueckliefern + // return the object refVar->PutObject( (SbUnoObject*)xUnoObj ); } else @@ -3140,21 +3106,21 @@ void RTL_Impl_CreateUnoServiceWithArguments( StarBASIC* pBasic, SbxArray& rPar, (void)pBasic; (void)bWrite; - // Wir brauchen mindestens 2 Parameter + // We need 2 parameter minimum if ( rPar.Count() < 3 ) { StarBASIC::Error( SbERR_BAD_ARGUMENT ); return; } - // Klassen-Name der struct holen - String aServiceName = rPar.Get(1)->GetString(); + // get the name of the class of the struct + ::rtl::OUString aServiceName = rPar.Get(1)->GetString(); Any aArgAsAny = sbxToUnoValue( rPar.Get(2), getCppuType( (Sequence<Any>*)0 ) ); Sequence< Any > aArgs; aArgAsAny >>= aArgs; - // Service suchen und instanzieren + // search for the service and instatiate it Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() ); Reference< XInterface > xInterface; if ( xFactory.is() ) @@ -3175,11 +3141,11 @@ void RTL_Impl_CreateUnoServiceWithArguments( StarBASIC* pBasic, SbxArray& rPar, Any aAny; aAny <<= xInterface; - // SbUnoObject daraus basteln und zurueckliefern + // Create a SbUnoObject out of it and return it SbUnoObjectRef xUnoObj = new SbUnoObject( aServiceName, aAny ); if( xUnoObj->getUnoAny().getValueType().getTypeClass() != TypeClass_VOID ) { - // Objekt zurueckliefern + // return the object refVar->PutObject( (SbUnoObject*)xUnoObj ); } else @@ -3200,15 +3166,15 @@ void RTL_Impl_GetProcessServiceManager( StarBASIC* pBasic, SbxArray& rPar, sal_B SbxVariableRef refVar = rPar.Get(0); - // Globalen Service-Manager holen + // get the global service manager Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() ); if( xFactory.is() ) { Any aAny; aAny <<= xFactory; - // SbUnoObject daraus basteln und zurueckliefern - SbUnoObjectRef xUnoObj = new SbUnoObject( String( RTL_CONSTASCII_USTRINGPARAM("ProcessServiceManager") ), aAny ); + // Create a SbUnoObject out of it and return it + SbUnoObjectRef xUnoObj = new SbUnoObject( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ProcessServiceManager") ), aAny ); refVar->PutObject( (SbUnoObject*)xUnoObj ); } else @@ -3222,7 +3188,7 @@ void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite (void)pBasic; (void)bWrite; - // Wir brauchen mindestens 2 Parameter + // We need 2 parameter minimum sal_uInt16 nParCount = rPar.Count(); if( nParCount < 3 ) { @@ -3230,11 +3196,11 @@ void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite return; } - // Variable fuer Rueckgabewert + // variable for the return value SbxVariableRef refVar = rPar.Get(0); refVar->PutBool( sal_False ); - // Uno-Objekt holen + // get the Uno-Object SbxBaseRef pObj = (SbxBase*)rPar.Get( 1 )->GetObject(); if( !(pObj && pObj->ISA(SbUnoObject)) ) return; @@ -3243,32 +3209,32 @@ void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite if( eType != TypeClass_INTERFACE ) return; - // Interface aus dem Any besorgen + // get the interface out of the Any Reference< XInterface > x = *(Reference< XInterface >*)aAny.getValue(); - // CoreReflection holen + // get CoreReflection Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl(); if( !xCoreReflection.is() ) return; for( sal_uInt16 i = 2 ; i < nParCount ; i++ ) { - // Interface-Name der struct holen - String aIfaceName = rPar.Get( i )->GetString(); + // get the name of the interface of the struct + rtl::OUString aIfaceName = rPar.Get( i )->GetString(); - // Klasse suchen + // search for the class Reference< XIdlClass > xClass = xCoreReflection->forName( aIfaceName ); if( !xClass.is() ) return; - // Pruefen, ob das Interface unterstuetzt wird + // check if the interface will be supported ::rtl::OUString aClassName = xClass->getName(); Type aClassType( xClass->getTypeClass(), aClassName.getStr() ); if( !x->queryInterface( aClassType ).hasValue() ) return; } - // Alles hat geklappt, dann sal_True liefern + // Every thing works; then return TRUE refVar->PutBool( sal_True ); } @@ -3277,18 +3243,18 @@ void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ) (void)pBasic; (void)bWrite; - // Wir brauchen mindestens 1 Parameter + // We need 1 parameter minimum if ( rPar.Count() < 2 ) { StarBASIC::Error( SbERR_BAD_ARGUMENT ); return; } - // Variable fuer Rueckgabewert + // variable for the return value SbxVariableRef refVar = rPar.Get(0); refVar->PutBool( sal_False ); - // Uno-Objekt holen + // get the Uno-Object SbxVariableRef xParam = rPar.Get( 1 ); if( !xParam->IsObject() ) return; @@ -3313,11 +3279,11 @@ void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit return; } - // Variable fuer Rueckgabewert + // variable for the return value SbxVariableRef refVar = rPar.Get(0); refVar->PutBool( sal_False ); - // Uno-Objekte holen + // get the Uno-Objects SbxVariableRef xParam1 = rPar.Get( 1 ); if( !xParam1->IsObject() ) return; @@ -3330,7 +3296,6 @@ void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit return; Reference< XInterface > x1; aAny1 >>= x1; - //XInterfaceRef x1 = *(XInterfaceRef*)aAny1.get(); SbxVariableRef xParam2 = rPar.Get( 2 ); if( !xParam2->IsObject() ) @@ -3344,13 +3309,12 @@ void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrit return; Reference< XInterface > x2; aAny2 >>= x2; - //XInterfaceRef x2 = *(XInterfaceRef*)aAny2.get(); if( x1 == x2 ) refVar->PutBool( sal_True ); } -typedef std::hash_map< ::rtl::OUString, std::vector< ::rtl::OUString >, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleHash; +typedef boost::unordered_map< ::rtl::OUString, std::vector< ::rtl::OUString >, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleHash; // helper wrapper function to interact with TypeProvider and @@ -3377,13 +3341,18 @@ getTypeDescriptorEnumeration( const ::rtl::OUString& sSearchRoot, return xEnum; } -typedef std::hash_map< ::rtl::OUString, Any, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > VBAConstantsHash; +typedef boost::unordered_map< ::rtl::OUString, Any, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > VBAConstantsHash; -SbxVariable* getVBAConstant( const String& rName ) +VBAConstantHelper& +VBAConstantHelper::instance() +{ + static VBAConstantHelper aHelper; + return aHelper; +} + +void +VBAConstantHelper::init() { - SbxVariable* pConst = NULL; - static VBAConstantsHash aConstCache; - static bool isInited = false; if ( !isInited ) { Sequence< TypeClass > types(1); @@ -3391,45 +3360,83 @@ SbxVariable* getVBAConstant( const String& rName ) Reference< XTypeDescriptionEnumeration > xEnum = getTypeDescriptorEnumeration( defaultNameSpace, types, TypeDescriptionSearchDepth_INFINITE ); if ( !xEnum.is() ) - return NULL; + return; //NULL; while ( xEnum->hasMoreElements() ) { Reference< XConstantsTypeDescription > xConstants( xEnum->nextElement(), UNO_QUERY ); if ( xConstants.is() ) { + // store constant group name + ::rtl::OUString sFullName = xConstants->getName(); + sal_Int32 indexLastDot = sFullName.lastIndexOf('.'); + ::rtl::OUString sLeafName( sFullName ); + if ( indexLastDot > -1 ) + sLeafName = sFullName.copy( indexLastDot + 1); + aConstCache.push_back( sLeafName ); // assume constant group names are unique Sequence< Reference< XConstantTypeDescription > > aConsts = xConstants->getConstants(); Reference< XConstantTypeDescription >* pSrc = aConsts.getArray(); sal_Int32 nLen = aConsts.getLength(); for ( sal_Int32 index =0; index<nLen; ++pSrc, ++index ) { + // store constant member name Reference< XConstantTypeDescription >& rXConst = *pSrc; - ::rtl::OUString sFullName = rXConst->getName(); - sal_Int32 indexLastDot = sFullName.lastIndexOf('.'); - ::rtl::OUString sLeafName; + sFullName = rXConst->getName(); + indexLastDot = sFullName.lastIndexOf('.'); + sLeafName = sFullName; if ( indexLastDot > -1 ) sLeafName = sFullName.copy( indexLastDot + 1); - aConstCache[ sLeafName.toAsciiLowerCase() ] = rXConst->getConstantValue(); + aConstHash[ sLeafName.toAsciiLowerCase() ] = rXConst->getConstantValue(); } } } isInited = true; } +} + +bool +VBAConstantHelper::isVBAConstantType( const ::rtl::OUString& rName ) +{ + init(); + bool bConstant = false; ::rtl::OUString sKey( rName ); - VBAConstantsHash::const_iterator it = aConstCache.find( sKey.toAsciiLowerCase() ); - if ( it != aConstCache.end() ) + VBAConstantsVector::const_iterator it = aConstCache.begin(); + + for( ; it != aConstCache.end(); ++it ) + { + if( sKey.equalsIgnoreAsciiCase( *it ) ) + { + bConstant = true; + break; + } + } + return bConstant; +} + +SbxVariable* +VBAConstantHelper::getVBAConstant( const ::rtl::OUString& rName ) +{ + SbxVariable* pConst = NULL; + init(); + + ::rtl::OUString sKey( rName ); + + VBAConstantsHash::const_iterator it = aConstHash.find( sKey.toAsciiLowerCase() ); + + if ( it != aConstHash.end() ) { pConst = new SbxVariable( SbxVARIANT ); pConst->SetName( rName ); unoToSbxValue( pConst, it->second ); } + return pConst; } -// Funktion, um einen globalen Bezeichner im -// UnoScope zu suchen und fuer Sbx zu wrappen -SbUnoClass* findUnoClass( const String& rName ) +// Function to search for a global identifier in the +// UnoScope and to wrap it for Sbx +SbUnoClass* findUnoClass( const ::rtl::OUString& rName ) { // #105550 Check if module exists SbUnoClass* pUnoClass = NULL; @@ -3457,13 +3464,13 @@ SbxVariable* SbUnoClass::Find( const XubString& rName, SbxClassType t ) SbxVariable* pRes = SbxObject::Find( rName, SbxCLASS_VARIABLE ); - // Wenn nichts gefunden wird, ist das Sub-Modul noch nicht bekannt + // If nothing were located the submodule isn't known yet if( !pRes ) { - // Wenn es schon eine Klasse ist, nach einen Feld fragen + // If it is already a class, ask for the field if( m_xClass.is() ) { - // Ist es ein Field + // Is it a field(?) ::rtl::OUString aUStr( rName ); Reference< XIdlField > xField = m_xClass->getField( aUStr ); Reference< XIdlClass > xClass; @@ -3474,7 +3481,7 @@ SbxVariable* SbUnoClass::Find( const XubString& rName, SbxClassType t ) Any aAny; aAny = xField->get( aAny ); - // Nach Sbx wandeln + // Convert to Sbx pRes = new SbxVariable( SbxVARIANT ); pRes->SetName( rName ); unoToSbxValue( pRes, aAny ); @@ -3487,16 +3494,16 @@ SbxVariable* SbUnoClass::Find( const XubString& rName, SbxClassType t ) } else { - // Vollqualifizierten Namen erweitern - String aNewName = GetName(); - aNewName.AppendAscii( "." ); + // expand fully qualified name + ::rtl::OUString aNewName = GetName(); + aNewName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".")); aNewName += rName; - // CoreReflection holen + // get CoreReflection Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl(); if( xCoreReflection.is() ) { - // Ist es eine Konstante? + // Is it a constant? Reference< XHierarchicalNameAccess > xHarryName( xCoreReflection, UNO_QUERY ); if( xHarryName.is() ) { @@ -3505,7 +3512,7 @@ SbxVariable* SbUnoClass::Find( const XubString& rName, SbxClassType t ) Any aValue = xHarryName->getByHierarchicalName( aNewName ); TypeClass eType = aValue.getValueType().getTypeClass(); - // Interface gefunden? Dann ist es eine Klasse + // Interface located? Then it is a class if( eType == TypeClass_INTERFACE ) { Reference< XInterface > xIface = *(Reference< XInterface >*)aValue.getValue(); @@ -3525,11 +3532,11 @@ SbxVariable* SbUnoClass::Find( const XubString& rName, SbxClassType t ) } catch( NoSuchElementException& e1 ) { - String aMsg = implGetExceptionMsg( e1 ); + ::rtl::OUString aMsg = implGetExceptionMsg( e1 ); } } - // Sonst wieder als Klasse annehmen + // Otherwise take it again as class if( !pRes ) { SbUnoClass* pNewClass = findUnoClass( aNewName ); @@ -3571,11 +3578,11 @@ SbxVariable* SbUnoClass::Find( const XubString& rName, SbxClassType t ) { pRes->SetName( rName ); - // Variable einfuegen, damit sie spaeter im Find gefunden wird + // Insert variable, so that it could be found later QuickInsert( pRes ); - // Uns selbst gleich wieder als Listener rausnehmen, - // die Werte sind alle konstant + // Take us out as listener at once, + // the values are all constant if( pRes->IsBroadcaster() ) EndListening( pRes->GetBroadcaster(), sal_True ); } @@ -3584,7 +3591,7 @@ SbxVariable* SbUnoClass::Find( const XubString& rName, SbxClassType t ) } -SbUnoService* findUnoService( const String& rName ) +SbUnoService* findUnoService( const ::rtl::OUString& rName ) { SbUnoService* pSbUnoService = NULL; @@ -3615,7 +3622,7 @@ SbxVariable* SbUnoService::Find( const String& rName, SbxClassType ) if( !pRes ) { - // Wenn es schon eine Klasse ist, nach einen Feld fragen + // If it is already a class ask for a field if( m_bNeedsInit && m_xServiceTypeDesc.is() ) { m_bNeedsInit = false; @@ -3627,14 +3634,14 @@ SbxVariable* SbUnoService::Find( const String& rName, SbxClassType ) { Reference< XServiceConstructorDescription > xCtor = pCtorSeq[i]; - String aName( xCtor->getName() ); - if( !aName.Len() ) + ::rtl::OUString aName( xCtor->getName() ); + if( !aName.getLength() ) { if( xCtor->isDefaultConstructor() ) - aName = String::CreateFromAscii( "create" ); + aName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("create")); } - if( aName.Len() ) + if( aName.getLength() ) { // Create and insert SbUnoServiceCtor SbxVariableRef xSbCtorRef = new SbUnoServiceCtor( aName, xCtor ); @@ -3776,7 +3783,7 @@ void SbUnoService::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, Any aRetAny; if( xServiceMgr.is() ) { - String aServiceName = GetName(); + ::rtl::OUString aServiceName = GetName(); Reference < XInterface > xRet; try { @@ -3826,7 +3833,7 @@ void clearUnoServiceCtors( void ) } } -SbUnoServiceCtor::SbUnoServiceCtor( const String& aName_, Reference< XServiceConstructorDescription > xServiceCtorDesc ) +SbUnoServiceCtor::SbUnoServiceCtor( const ::rtl::OUString& aName_, Reference< XServiceConstructorDescription > xServiceCtorDesc ) : SbxMethod( aName_, SbxOBJECT ) , m_xServiceCtorDesc( xServiceCtorDesc ) { @@ -3844,7 +3851,7 @@ SbxInfo* SbUnoServiceCtor::GetInfo() } -SbUnoSingleton* findUnoSingleton( const String& rName ) +SbUnoSingleton* findUnoSingleton( const ::rtl::OUString& rName ) { SbUnoSingleton* pSbUnoSingleton = NULL; @@ -3869,13 +3876,13 @@ SbUnoSingleton* findUnoSingleton( const String& rName ) return pSbUnoSingleton; } -SbUnoSingleton::SbUnoSingleton( const String& aName_, +SbUnoSingleton::SbUnoSingleton( const ::rtl::OUString& aName_, const Reference< XSingletonTypeDescription >& xSingletonTypeDesc ) : SbxObject( aName_ ) , m_xSingletonTypeDesc( xSingletonTypeDesc ) { SbxVariableRef xGetMethodRef = - new SbxMethod( String( RTL_CONSTASCII_USTRINGPARAM( "get" ) ), SbxOBJECT ); + new SbxMethod( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "get" ) ), SbxOBJECT ); QuickInsert( (SbxVariable*)xGetMethodRef ); } @@ -3916,7 +3923,7 @@ void SbUnoSingleton::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, Any aRetAny; if( xContextToUse.is() ) { - String aSingletonName( RTL_CONSTASCII_USTRINGPARAM("/singletons/") ); + ::rtl::OUString aSingletonName( RTL_CONSTASCII_USTRINGPARAM("/singletons/") ); aSingletonName += GetName(); Reference < XInterface > xRet; xContextToUse->getValueByName( aSingletonName ) >>= xRet; @@ -3930,11 +3937,9 @@ void SbUnoSingleton::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, //======================================================================== -//======================================================================== -//======================================================================== -// Implementation eines EventAttacher-bezogenen AllListeners, der -// nur einzelne Events an einen allgemeinen AllListener weiterleitet +// Implementation of an EventAttacher-drawn AllListener, which +// solely transmits several events to an general AllListener class BasicAllListener_Impl : public BasicAllListenerHelper { virtual void firing_impl(const AllEventObject& Event, Any* pRet); @@ -3946,14 +3951,11 @@ public: BasicAllListener_Impl( const ::rtl::OUString& aPrefixName ); ~BasicAllListener_Impl(); - // Methoden von XInterface - //virtual sal_Bool queryInterface( Uik aUik, Reference< XInterface > & rOut ); - - // Methoden von XAllListener + // Methods of XAllListener virtual void SAL_CALL firing(const AllEventObject& Event) throw ( RuntimeException ); virtual Any SAL_CALL approveFiring(const AllEventObject& Event) throw ( RuntimeException ); - // Methoden von XEventListener + // Methods of XEventListener virtual void SAL_CALL disposing(const EventObject& Source) throw ( RuntimeException ); }; @@ -3976,7 +3978,7 @@ BasicAllListener_Impl::~BasicAllListener_Impl() void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet ) { - vos::OGuard guard( Application::GetSolarMutex() ); + SolarMutexGuard guard; if( xSbxObj.Is() ) { @@ -3990,13 +3992,13 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet StarBASIC * pLib = PTR_CAST(StarBASIC,pP); if( pLib ) { - // In Basic Array anlegen + // Create in a Basic Array SbxArrayRef xSbxArray = new SbxArray( SbxVARIANT ); const Any * pArgs = Event.Arguments.getConstArray(); sal_Int32 nCount = Event.Arguments.getLength(); for( sal_Int32 i = 0; i < nCount; i++ ) { - // Elemente wandeln + // Convert elements SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); unoToSbxValue( (SbxVariable*)xVar, pArgs[i] ); xSbxArray->Put( xVar, sal::static_int_cast< sal_uInt16 >(i+1) ); @@ -4004,7 +4006,7 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet pLib->Call( aMethodName, xSbxArray ); - // Return-Wert aus dem Param-Array holen, wenn verlangt + // get the return value from the Param-Array, if requestet if( pRet ) { SbxVariable* pVar = xSbxArray->Get( 0 ); @@ -4024,7 +4026,7 @@ void BasicAllListener_Impl::firing_impl( const AllEventObject& Event, Any* pRet } -// Methoden von XAllListener +// Methods of Listener void BasicAllListener_Impl::firing( const AllEventObject& Event ) throw ( RuntimeException ) { firing_impl( Event, NULL ); @@ -4038,10 +4040,10 @@ Any BasicAllListener_Impl::approveFiring( const AllEventObject& Event ) throw ( } //======================================================================== -// Methoden von XEventListener +// Methods of XEventListener void BasicAllListener_Impl ::disposing(const EventObject& ) throw ( RuntimeException ) { - vos::OGuard guard( Application::GetSolarMutex() ); + SolarMutexGuard guard; xSbxObj.Clear(); } @@ -4204,42 +4206,42 @@ sal_Bool SAL_CALL InvocationToAllListenerMapper::hasProperty(const ::rtl::OUStri //======================================================================== // Uno-Service erzeugen -// 1. Parameter == Prefix-Name der Makros -// 2. Parameter == voll qualifizierter Name des Listeners +// 1. Parameter == Prefix-Name of the macro +// 2. Parameter == fully qualified name of the listener void SbRtl_CreateUnoListener( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ) //RTLFUNC(CreateUnoListener) { (void)bWrite; - // Wir brauchen 2 Parameter + // We need 2 parameters if ( rPar.Count() != 3 ) { StarBASIC::Error( SbERR_BAD_ARGUMENT ); return; } - // Klassen-Name der struct holen - String aPrefixName = rPar.Get(1)->GetString(); - String aListenerClassName = rPar.Get(2)->GetString(); + // get the name of the class of the struct + ::rtl::OUString aPrefixName = rPar.Get(1)->GetString(); + ::rtl::OUString aListenerClassName = rPar.Get(2)->GetString(); - // CoreReflection holen + // get the CoreReflection Reference< XIdlReflection > xCoreReflection = getCoreReflection_Impl(); if( !xCoreReflection.is() ) return; - // AllListenerAdapterService holen + // get the AllListenerAdapterService Reference< XMultiServiceFactory > xFactory( comphelper::getProcessServiceFactory() ); if( !xFactory.is() ) return; - // Klasse suchen + // search the class Reference< XIdlClass > xClass = xCoreReflection->forName( aListenerClassName ); if( !xClass.is() ) return; - // AB, 30.11.1999 InvocationAdapterFactory holen + // From 1999-11-30: get the InvocationAdapterFactory Reference< XInvocationAdapterFactory > xInvocationAdapterFactory = Reference< XInvocationAdapterFactory >( - xFactory->createInstance( rtl::OUString::createFromAscii("com.sun.star.script.InvocationAdapterFactory") ), UNO_QUERY ); + xFactory->createInstance( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.InvocationAdapterFactory")) ), UNO_QUERY ); BasicAllListener_Impl * p; Reference< XAllListener > xAllLst = p = new BasicAllListener_Impl( aPrefixName ); @@ -4262,7 +4264,7 @@ void SbRtl_CreateUnoListener( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite SbxArrayRef xBasicUnoListeners = pBasic->getUnoListeners(); xBasicUnoListeners->Insert( pUnoObj, xBasicUnoListeners->Count() ); - // Objekt zurueckliefern + // return the object SbxVariableRef refVar = rPar.Get(0); refVar->PutObject( p->xSbxObj ); } @@ -4282,10 +4284,10 @@ void RTL_Impl_GetDefaultContext( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWr if( xPSMPropertySet.is() ) { Any aContextAny = xPSMPropertySet->getPropertyValue( - String( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ); + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ); SbUnoObjectRef xUnoObj = new SbUnoObject - ( String( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ), + ( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ), aContextAny ); refVar->PutObject( (SbUnoObject*)xUnoObj ); } @@ -4303,7 +4305,7 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite (void)pBasic; (void)bWrite; - static String aTypeTypeString( RTL_CONSTASCII_USTRINGPARAM("type") ); + static rtl::OUString aTypeTypeString( RTL_CONSTASCII_USTRINGPARAM("type") ); // 2 parameters needed if ( rPar.Count() != 3 ) @@ -4312,8 +4314,8 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite return; } - // Klassen-Name der struct holen - String aTypeName = rPar.Get(1)->GetString(); + // get the name of the class of the struct + rtl::OUString aTypeName = rPar.Get(1)->GetString(); SbxVariable* pVal = rPar.Get(2); if( aTypeName == aTypeTypeString ) @@ -4360,7 +4362,7 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite } catch( NoSuchElementException& e1 ) { - String aNoSuchElementExceptionName + ::rtl::OUString aNoSuchElementExceptionName ( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.container.NoSuchElementException" ) ); StarBASIC::Error( ERRCODE_BASIC_EXCEPTION, implGetExceptionMsg( e1, aNoSuchElementExceptionName ) ); @@ -4376,28 +4378,6 @@ void RTL_Impl_CreateUnoValue( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite Any aVal = sbxToUnoValueImpl( pVal ); Any aConvertedVal = convertAny( aVal, aDestType ); - /* - // Convert - Reference< XTypeConverter > xConverter = getTypeConverter_Impl(); - try - { - aConvertedVal = xConverter->convertTo( aVal, aDestType ); - } - catch( IllegalArgumentException& e1 ) - { - StarBASIC::Error( ERRCODE_BASIC_EXCEPTION, - implGetExceptionMsg( ::cppu::getCaughtException() ) ); - return; - } - catch( CannotConvertException& e2 ) - { - String aCannotConvertExceptionName - ( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.IllegalArgumentException" ) ); - StarBASIC::Error( ERRCODE_BASIC_EXCEPTION, - implGetExceptionMsg( e2, aCannotConvertExceptionName ) ); - return; - } - */ SbxVariableRef refVar = rPar.Get(0); SbxObjectRef xUnoAnyObject = new SbUnoAnyObject( aConvertedVal ); @@ -4470,7 +4450,7 @@ void SAL_CALL ModuleInvocationProxy::setValue( const ::rtl::OUString& rProperty, if( !m_bProxyIsClassModuleObject ) throw UnknownPropertyException(); - vos::OGuard guard( Application::GetSolarMutex() ); + SolarMutexGuard guard; ::rtl::OUString aPropertyFunctionName( RTL_CONSTASCII_USTRINGPARAM( "Property Set ") ); aPropertyFunctionName += m_aPrefix; @@ -4495,14 +4475,11 @@ void SAL_CALL ModuleInvocationProxy::setValue( const ::rtl::OUString& rProperty, SbxVariableRef xValue = new SbxVariable; pMeth->SetParameters( xArray ); pMeth->Call( xValue ); - //aRet = sbxToUnoValue( xValue ); pMeth->SetParameters( NULL ); // TODO: OutParameter? - // throw InvocationTargetException(); - //return aRet; } @@ -4511,7 +4488,7 @@ Any SAL_CALL ModuleInvocationProxy::getValue( const ::rtl::OUString& rProperty ) if( !m_bProxyIsClassModuleObject ) throw UnknownPropertyException(); - vos::OGuard guard( Application::GetSolarMutex() ); + SolarMutexGuard guard; ::rtl::OUString aPropertyFunctionName( RTL_CONSTASCII_USTRINGPARAM( "Property Get ") ); aPropertyFunctionName += m_aPrefix; @@ -4549,7 +4526,7 @@ Any SAL_CALL ModuleInvocationProxy::invoke( const ::rtl::OUString& rFunction, Sequence< Any >& ) throw( CannotConvertException, InvocationTargetException ) { - vos::OGuard guard( Application::GetSolarMutex() ); + SolarMutexGuard guard; Any aRet; SbxObjectRef xScopeObj = m_xScopeObj; @@ -4862,3 +4839,4 @@ bool handleToStringForCOMObjects( SbxObject* pObj, SbxValue* pVal ) return bSuccess; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index 24b031e8f4e9..ba97917922a9 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,7 +31,6 @@ #include <list> -#include <vos/macros.hxx> #include <vcl/svapp.hxx> #include <tools/stream.hxx> #include <svl/brdcst.hxx> @@ -46,14 +46,11 @@ #include "runtime.hxx" #include "token.hxx" #include "sbunoobj.hxx" -#include "sbtrace.hxx" - -//#include <basic/hilight.hxx> #include <svtools/syntaxhighlight.hxx> #include <basic/basrdll.hxx> -#include <vos/mutex.hxx> +#include <osl/mutex.hxx> #include <basic/sbobjmod.hxx> #include <basic/vbahelper.hxx> #include <cppuhelper/implbase3.hxx> @@ -61,6 +58,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/script/ModuleType.hpp> #include <com/sun/star/script/vba/XVBACompatibility.hpp> +#include <com/sun/star/document/XVbaMethodParameter.hpp> #include <com/sun/star/script/vba/VBAScriptEventId.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/document/XEventBroadcaster.hpp> @@ -72,7 +70,7 @@ using namespace com::sun::star; #ifdef WNT #define CDECL _cdecl #endif -#if defined(UNX) || defined(OS2) +#if defined(UNX) #define CDECL #endif #ifdef UNX @@ -91,6 +89,7 @@ using namespace com::sun::star; #include <com/sun/star/uno/XAggregation.hpp> #include <com/sun/star/script/XInvocation.hpp> +using namespace ::com::sun::star; using namespace com::sun::star::lang; using namespace com::sun::star::reflection; using namespace com::sun::star::beans; @@ -185,7 +184,7 @@ DocObjectWrapper::DocObjectWrapper( SbModule* pVar ) : m_pMod( pVar ), mName( pV } catch( Exception& ) { - OSL_ENSURE( false, "DocObjectWrapper::DocObjectWrapper: Caught exception!" ); + OSL_FAIL( "DocObjectWrapper::DocObjectWrapper: Caught exception!" ); } } @@ -306,9 +305,8 @@ DocObjectWrapper::invoke( const ::rtl::OUString& aFunctionName, const Sequence< // call method SbxVariableRef xReturn = new SbxVariable; - ErrCode nErr = SbxERR_OK; - nErr = pMethod->Call( xReturn ); + pMethod->Call( xReturn ); Any aReturn; // get output parameters if ( xSbxParams.Is() ) @@ -513,10 +511,22 @@ IMPL_LINK( AsyncQuitHandler, OnAsyncQuit, void*, /*pNull*/ ) return 0L; } -///////////////////////////////////////////////////////////////////////////// +void VBAUnlockDocuments( StarBASIC* pBasic ) +{ + if ( pBasic && pBasic->IsDocBasic() ) + { + SbUnoObject* pGlobs = dynamic_cast< SbUnoObject* >( pBasic->Find( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ThisComponent" ) ), SbxCLASS_DONTCARE ) ); + if ( pGlobs ) + { + uno::Reference< frame::XModel > xModel( pGlobs->getUnoAny(), uno::UNO_QUERY ); + ::basic::vba::lockControllersOfAllDocuments( xModel, sal_False ); + ::basic::vba::enableContainerWindowsOfAllDocuments( xModel, sal_True ); + } + } +} -// Ein BASIC-Modul hat EXTSEARCH gesetzt, damit die im Modul enthaltenen -// Elemente von anderen Modulen aus gefunden werden koennen. +// A Basic module has set EXTSEARCH, so that the elements, that the modul contains, +// could be found from other module. SbModule::SbModule( const String& rName, sal_Bool bVBACompat ) : SbxObject( String( RTL_CONSTASCII_USTRINGPARAM("StarBASICModule") ) ), @@ -565,7 +575,7 @@ const SbxObject* SbModule::FindType( String aTypeName ) const } -// Aus dem Codegenerator: Loeschen des Images und Invalidieren der Entries +// From the code generator: deletion of images and the oposite of validation for entries void SbModule::StartDefinitions() { @@ -573,8 +583,8 @@ void SbModule::StartDefinitions() if( pClassData ) pClassData->clear(); - // Methoden und Properties bleiben erhalten, sind jedoch ungueltig - // schliesslich sind ja u.U. die Infos belegt + // methods and properties persist, but they are invalid; + // at least are the information under certain conditions clogged sal_uInt16 i; for( i = 0; i < pMethods->Count(); i++ ) { @@ -592,7 +602,7 @@ void SbModule::StartDefinitions() } } -// Methode anfordern/anlegen +// request/create method SbMethod* SbModule::GetMethod( const String& rName, SbxDataType t ) { @@ -608,8 +618,8 @@ SbMethod* SbModule::GetMethod( const String& rName, SbxDataType t ) pMethods->Put( pMeth, pMethods->Count() ); StartListening( pMeth->GetBroadcaster(), sal_True ); } - // Per Default ist die Methode GUELTIG, da sie auch vom Compiler - // (Codegenerator) erzeugt werden kann + // The method is per default valid, because it could be + // created from the compiler (code generator) as well. pMeth->bInvalid = sal_False; pMeth->ResetFlag( SBX_FIXED ); pMeth->SetFlag( SBX_WRITE ); @@ -620,7 +630,7 @@ SbMethod* SbModule::GetMethod( const String& rName, SbxDataType t ) return pMeth; } -// Property anfordern/anlegen +// request/create property SbProperty* SbModule::GetProperty( const String& rName, SbxDataType t ) { @@ -682,7 +692,7 @@ SbIfaceMapperMethod::~SbIfaceMapperMethod() TYPEINIT1(SbIfaceMapperMethod,SbMethod) -// Aus dem Codegenerator: Ungueltige Eintraege entfernen +// From the code generator: remove invalid entries void SbModule::EndDefinitions( sal_Bool bNewState ) { @@ -763,12 +773,10 @@ const String& SbModule::GetSource() const return aRetStr; } -// Parent und BASIC sind eins! +// Parent and BASIC are one! void SbModule::SetParent( SbxObject* p ) { - // #118083: Assertion is not valid any more - // DBG_ASSERT( !p || p->IsA( TYPE(StarBASIC) ), "SbModules nur in BASIC eintragen" ); pParent = p; } @@ -781,6 +789,82 @@ void SbModule::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, SbxVariable* pVar = pHint->GetVar(); SbProperty* pProp = PTR_CAST(SbProperty,pVar); SbMethod* pMeth = PTR_CAST(SbMethod,pVar); + SbProcedureProperty* pProcProperty = PTR_CAST( SbProcedureProperty, pVar ); + if( pProcProperty ) + { + + if( pHint->GetId() == SBX_HINT_DATAWANTED ) + { + String aProcName; + aProcName.AppendAscii( "Property Get " ); + aProcName += pProcProperty->GetName(); + + SbxVariable* pMethVar = Find( aProcName, SbxCLASS_METHOD ); + if( pMethVar ) + { + SbxValues aVals; + aVals.eType = SbxVARIANT; + + SbxArray* pArg = pVar->GetParameters(); + sal_uInt16 nVarParCount = (pArg != NULL) ? pArg->Count() : 0; + if( nVarParCount > 1 ) + { + SbxArrayRef xMethParameters = new SbxArray; + xMethParameters->Put( pMethVar, 0 ); // Method as parameter 0 + for( sal_uInt16 i = 1 ; i < nVarParCount ; ++i ) + { + SbxVariable* pPar = pArg->Get( i ); + xMethParameters->Put( pPar, i ); + } + + pMethVar->SetParameters( xMethParameters ); + pMethVar->Get( aVals ); + pMethVar->SetParameters( NULL ); + } + else + { + pMethVar->Get( aVals ); + } + + pVar->Put( aVals ); + } + } + else if( pHint->GetId() == SBX_HINT_DATACHANGED ) + { + SbxVariable* pMethVar = NULL; + + bool bSet = pProcProperty->isSet(); + if( bSet ) + { + pProcProperty->setSet( false ); + + String aProcName; + aProcName.AppendAscii( "Property Set " ); + aProcName += pProcProperty->GetName(); + pMethVar = Find( aProcName, SbxCLASS_METHOD ); + } + if( !pMethVar ) // Let + { + String aProcName; + aProcName.AppendAscii( "Property Let " ); + aProcName += pProcProperty->GetName(); + pMethVar = Find( aProcName, SbxCLASS_METHOD ); + } + + if( pMethVar ) + { + // Setup parameters + SbxArrayRef xArray = new SbxArray; + xArray->Put( pMethVar, 0 ); // Method as parameter 0 + xArray->Put( pVar, 1 ); + pMethVar->SetParameters( xArray ); + + SbxValues aVals; + pMethVar->Get( aVals ); + pMethVar->SetParameters( NULL ); + } + } + } if( pProp ) { if( pProp->GetModule() != this ) @@ -791,11 +875,11 @@ void SbModule::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, if( pHint->GetId() == SBX_HINT_DATAWANTED ) { if( pMeth->bInvalid && !Compile() ) - // Auto-Compile hat nicht geklappt! + // auto compile has not worked! StarBASIC::Error( SbERR_BAD_PROP_VALUE ); else { - // Aufruf eines Unterprogramms + // Call of a subprogram SbModule* pOld = pMOD; pMOD = this; Run( (SbMethod*) pVar ); @@ -820,8 +904,8 @@ void SbModule::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, } } -// Das Setzen der Source macht das Image ungueltig -// und scant die Methoden-Definitionen neu ein +// The setting of the source makes the image invalid +// and scans the method definitions newly in void SbModule::SetSource( const String& r ) { @@ -835,15 +919,16 @@ void SbModule::SetSource32( const ::rtl::OUString& r ) aOUSource = r; StartDefinitions(); SbiTokenizer aTok( r ); + aTok.SetCompatible( IsVBACompat() ); while( !aTok.IsEof() ) { SbiToken eEndTok = NIL; - // Suchen nach SUB oder FUNCTION + // Searching for SUB or FUNCTION SbiToken eLastTok = NIL; while( !aTok.IsEof() ) { - // #32385: Nicht bei declare + // #32385: not by declare SbiToken eCurTok = aTok.Next(); if( eLastTok != DECLARE ) { @@ -874,7 +959,7 @@ void SbModule::SetSource32( const ::rtl::OUString& r ) } eLastTok = eCurTok; } - // Definition der Methode + // Definition of the method SbMethod* pMeth = NULL; if( eEndTok != NIL ) { @@ -887,13 +972,13 @@ void SbModule::SetSource32( const ::rtl::OUString& r ) t = SbxVOID; pMeth = GetMethod( aName_, t ); pMeth->nLine1 = pMeth->nLine2 = nLine1; - // Die Methode ist erst mal GUELTIG + // The method is for a start VALID pMeth->bInvalid = sal_False; } else eEndTok = NIL; } - // Skip bis END SUB/END FUNCTION + // Skip up to END SUB/END FUNCTION if( eEndTok != NIL ) { while( !aTok.IsEof() ) @@ -931,14 +1016,14 @@ SbMethod* SbModule::GetFunctionForLine( sal_uInt16 nLine ) return NULL; } -// Ausstrahlen eines Hints an alle Basics +// Broadcast of a hint to all Basics static void _SendHint( SbxObject* pObj, sal_uIntPtr nId, SbMethod* p ) { - // Selbst ein BASIC? + // Self a BASIC? if( pObj->IsA( TYPE(StarBASIC) ) && pObj->IsBroadcaster() ) pObj->GetBroadcaster().Broadcast( SbxHint( nId, p ) ); - // Dann die Unterobjekte fragen + // Then ask for the subobjects SbxArray* pObjs = pObj->GetObjects(); for( sal_uInt16 i = 0; i < pObjs->Count(); i++ ) { @@ -955,35 +1040,35 @@ static void SendHint( SbxObject* pObj, sal_uIntPtr nId, SbMethod* p ) _SendHint( pObj, nId, p ); } -// #57841 Uno-Objekte, die in RTL-Funktionen gehalten werden, -// beim Programm-Ende freigeben, damit nichts gehalten wird. +// #57841 Clear Uno-Objects, which were helt in RTL functions, +// at the end of the program, so that nothing were helt. void ClearUnoObjectsInRTL_Impl_Rek( StarBASIC* pBasic ) { - // return-Wert von CreateUnoService loeschen + // delete the return value of CreateUnoService static String aName( RTL_CONSTASCII_USTRINGPARAM("CreateUnoService") ); SbxVariable* pVar = pBasic->GetRtl()->Find( aName, SbxCLASS_METHOD ); if( pVar ) pVar->SbxValue::Clear(); - // return-Wert von CreateUnoDialog loeschen + // delete the return value of CreateUnoDialog static String aName2( RTL_CONSTASCII_USTRINGPARAM("CreateUnoDialog") ); pVar = pBasic->GetRtl()->Find( aName2, SbxCLASS_METHOD ); if( pVar ) pVar->SbxValue::Clear(); - // return-Wert von CDec loeschen + // delete the return value of CDec static String aName3( RTL_CONSTASCII_USTRINGPARAM("CDec") ); pVar = pBasic->GetRtl()->Find( aName3, SbxCLASS_METHOD ); if( pVar ) pVar->SbxValue::Clear(); - // return-Wert von CreateObject loeschen + // delete return value of CreateObject static String aName4( RTL_CONSTASCII_USTRINGPARAM("CreateObject") ); pVar = pBasic->GetRtl()->Find( aName4, SbxCLASS_METHOD ); if( pVar ) pVar->SbxValue::Clear(); - // Ueber alle Sub-Basics gehen + // Go over all Sub-Basics SbxArray* pObjs = pBasic->GetObjects(); sal_uInt16 nCount = pObjs->Count(); for( sal_uInt16 i = 0 ; i < nCount ; i++ ) @@ -997,13 +1082,13 @@ void ClearUnoObjectsInRTL_Impl_Rek( StarBASIC* pBasic ) void ClearUnoObjectsInRTL_Impl( StarBASIC* pBasic ) { - // #67781 Rueckgabewerte der Uno-Methoden loeschen + // #67781 Delete return values of the Uno-methods clearUnoMethods(); clearUnoServiceCtors(); ClearUnoObjectsInRTL_Impl_Rek( pBasic ); - // Oberstes Basic suchen + // Search for the topmost Basic SbxObject* p = pBasic; while( p->GetParent() ) p = p->GetParent(); @@ -1019,24 +1104,23 @@ void SbModule::SetVBACompat( sal_Bool bCompat ) { mbVBACompat = bCompat; } -// Ausfuehren eines BASIC-Unterprogramms +// Run a Basic-subprogram sal_uInt16 SbModule::Run( SbMethod* pMeth ) { + OSL_TRACE("About to run %s, vba compatmode is %d", rtl::OUStringToOString( pMeth->GetName(), RTL_TEXTENCODING_UTF8 ).getStr(), mbVBACompat ); static sal_uInt16 nMaxCallLevel = 0; static String aMSOMacroRuntimeLibName = String::CreateFromAscii( "Launcher" ); static String aMSOMacroRuntimeAppSymbol = String::CreateFromAscii( "Application" ); sal_uInt16 nRes = 0; sal_Bool bDelInst = sal_Bool( pINST == NULL ); + bool bQuit = false; StarBASICRef xBasic; uno::Reference< frame::XModel > xModel; uno::Reference< script::vba::XVBACompatibility > xVBACompat; if( bDelInst ) { -#ifdef DBG_TRACE_BASIC - dbg_InitTrace(); -#endif - // #32779: Basic waehrend der Ausfuehrung festhalten + // #32779: Hold Basic during the execution xBasic = (StarBASIC*) GetParent(); pINST = new SbiInstance( (StarBASIC*) GetParent() ); @@ -1081,7 +1165,7 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) } } - // Error-Stack loeschen + // Delete the Error-Stack SbErrorStack*& rErrStack = GetSbData()->pErrStack; delete rErrStack; rErrStack = NULL; @@ -1091,7 +1175,6 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) #ifdef UNX struct rlimit rl; getrlimit ( RLIMIT_STACK, &rl ); - // printf( "RLIMIT_STACK = %ld\n", rl.rlim_cur ); #endif #if defined LINUX // Empiric value, 900 = needed bytes/Basic call level @@ -1109,22 +1192,22 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) } } - // Rekursion zu tief? + // Recursion to deep? if( ++pINST->nCallLvl <= nMaxCallLevel ) { - // Globale Variable in allen Mods definieren + // Define a globale variable in all Mods GlobalRunInit( /* bBasicStart = */ bDelInst ); - // Trat ein Compiler-Fehler auf? Dann starten wir nicht + // Appeared a compiler error? Then we don't launch if( GetSbData()->bGlobalInitErr == sal_False ) { if( bDelInst ) { SendHint( GetParent(), SBX_HINT_BASICSTART, pMeth ); - // 16.10.96: #31460 Neues Konzept fuer StepInto/Over/Out - // Erklaerung siehe runtime.cxx bei SbiInstance::CalcBreakCallLevel() - // BreakCallLevel ermitteln + // 1996-10-16: #31460 New concept for StepInto/Over/Out + // For an explanation see runtime.cxx at SbiInstance::CalcBreakCallLevel() + // Identify the BreakCallLevel pINST->CalcBreakCallLevel( pMeth->GetDebugFlags() ); } @@ -1132,10 +1215,6 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) pMOD = this; SbiRuntime* pRt = new SbiRuntime( this, pMeth, pMeth->nStart ); -#ifdef DBG_TRACE_BASIC - dbg_traceNotifyCall( this, pMeth, pINST->nCallLvl ); -#endif - pRt->pNext = pINST->pRun; if( pRt->pNext ) pRt->pNext->block(); @@ -1148,31 +1227,26 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) if( pRt->pNext ) pRt->pNext->unblock(); -#ifdef DBG_TRACE_BASIC - bool bLeave = true; - dbg_traceNotifyCall( this, pMeth, pINST->nCallLvl, bLeave ); -#endif - - // #63710 Durch ein anderes Thread-Handling bei Events kann es passieren, - // dass show-Aufruf an einem Dialog zurueckkehrt (durch schliessen des - // Dialogs per UI), BEVOR ein per Event ausgeloester weitergehender Call, - // der in Basic weiter oben im Stack steht und auf einen Basic-Breakpoint - // gelaufen ist, zurueckkehrt. Dann wird unten die Instanz zerstoert und - // wenn das noch im Call stehende Basic weiterlaeuft, gibt es einen GPF. - // Daher muss hier gewartet werden, bis andere Call zurueckkehrt. + // #63710 It can happen by an another thread handling at events, + // that the show call returns to an dialog (by closing the + // dialog per UI), before a by an event triggered further call returned, + // which stands in Basic more top in the stack and that had been run on + // a Basic-Breakpoint. Then would the instance below destroyed. And if the Basic, + // that stand still in the call, further runs, there is a GPF. + // Thus here had to be wait until the other call comes back. if( bDelInst ) { - // Hier mit 1 statt 0 vergleichen, da vor nCallLvl-- + // Compare here with 1 instead of 0, because before nCallLvl-- while( pINST->nCallLvl != 1 ) GetpApp()->Yield(); } nRes = sal_True; pINST->pRun = pRt->pNext; - pINST->nCallLvl--; // Call-Level wieder runter + pINST->nCallLvl--; // Call-Level down again - // Gibt es eine uebergeordnete Runtime-Instanz? - // Dann SbDEBUG_BREAK uebernehmen, wenn gesetzt + // Exist an higher-ranking runtime instance? + // Then take over SbDEBUG_BREAK, if set SbiRuntime* pRtNext = pRt->pNext; if( pRtNext && (pRt->GetDebugFlags() & SbDEBUG_BREAK) ) pRtNext->SetDebugFlags( SbDEBUG_BREAK ); @@ -1181,8 +1255,8 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) pMOD = pOldMod; if( bDelInst ) { - // #57841 Uno-Objekte, die in RTL-Funktionen gehalten werden, - // beim Programm-Ende freigeben, damit nichts gehalten wird. + // #57841 Clear Uno-Objects, which were helt in RTL functions, + // at the end of the program, so that nothing were helt. ClearUnoObjectsInRTL_Impl( xBasic ); clearNativeObjectWrapperVector(); @@ -1191,7 +1265,7 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) delete pINST, pINST = NULL, bDelInst = sal_False; // #i30690 - vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + SolarMutexGuard aSolarGuard; SendHint( GetParent(), SBX_HINT_BASICSTOP, pMeth ); GlobalRunDeInit(); @@ -1221,25 +1295,27 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) } } else - pINST->nCallLvl--; // Call-Level wieder runter + pINST->nCallLvl--; // Call-Level down again } else { - pINST->nCallLvl--; // Call-Level wieder runter + pINST->nCallLvl--; // Call-Level down again StarBASIC::FatalError( SbERR_STACK_OVERFLOW ); } StarBASIC* pBasic = PTR_CAST(StarBASIC,GetParent()); if( bDelInst ) { - // #57841 Uno-Objekte, die in RTL-Funktionen gehalten werden, - // beim Programm-Ende freigeben, damit nichts gehalten wird. + // #57841 Clear Uno-Objects, which were helt in RTL functions, + // the end of the program, so that nothing were helt. ClearUnoObjectsInRTL_Impl( xBasic ); delete pINST; pINST = NULL; } if ( pBasic && pBasic->IsDocBasic() && pBasic->IsQuitApplication() && !pINST ) + bQuit = true; + if ( bQuit ) { Application::PostUserEvent( LINK( &AsyncQuitHandler::instance(), AsyncQuitHandler, OnAsyncQuit ), NULL ); } @@ -1247,8 +1323,8 @@ sal_uInt16 SbModule::Run( SbMethod* pMeth ) return nRes; } -// Ausfuehren der Init-Methode eines Moduls nach dem Laden -// oder der Compilation +// Execute of the init method of a module after the loading +// or the compilation void SbModule::RunInit() { @@ -1256,44 +1332,30 @@ void SbModule::RunInit() && !pImage->bInit && pImage->GetFlag( SBIMG_INITCODE ) ) { - // Flag setzen, dass RunInit aktiv ist (Testtool) + // Set flag, so that RunInit get activ (Testtool) GetSbData()->bRunInit = sal_True; - // sal_Bool bDelInst = sal_Bool( pINST == NULL ); - // if( bDelInst ) - // pINST = new SbiInstance( (StarBASIC*) GetParent() ); SbModule* pOldMod = pMOD; pMOD = this; - // Der Init-Code beginnt immer hier + // The init code starts always here SbiRuntime* pRt = new SbiRuntime( this, NULL, 0 ); -#ifdef DBG_TRACE_BASIC - dbg_traceNotifyCall( this, NULL, 0 ); -#endif - pRt->pNext = pINST->pRun; pINST->pRun = pRt; while( pRt->Step() ) {} -#ifdef DBG_TRACE_BASIC - bool bLeave = true; - dbg_traceNotifyCall( this, NULL, 0, bLeave ); -#endif - pINST->pRun = pRt->pNext; delete pRt; pMOD = pOldMod; - // if( bDelInst ) - // delete pINST, pINST = NULL; pImage->bInit = sal_True; pImage->bFirstInit = sal_False; - // RunInit ist nicht mehr aktiv + // RunInit is not activ anymore GetSbData()->bRunInit = sal_False; } } -// Mit private/dim deklarierte Variablen loeschen +// Delete with private/dim declared variables void SbModule::AddVarName( const String& aName ) { @@ -1328,7 +1390,7 @@ void SbModule::ClearPrivateVars() SbProperty* p = PTR_CAST(SbProperty,pProps->Get( i ) ); if( p ) { - // Arrays nicht loeschen, sondern nur deren Inhalt + // Delete not the arrays, only their content if( p->GetType() & SbxARRAY ) { SbxArray* pArray = PTR_CAST(SbxArray,p->GetObject()); @@ -1338,24 +1400,12 @@ void SbModule::ClearPrivateVars() { SbxVariable* pj = PTR_CAST(SbxVariable,pArray->Get( j )); pj->SbxValue::Clear(); - /* - sal_uInt16 nFlags = pj->GetFlags(); - pj->SetFlags( (nFlags | SBX_WRITE) & (~SBX_FIXED) ); - pj->PutEmpty(); - pj->SetFlags( nFlags ); - */ } } } else { p->SbxValue::Clear(); - /* - sal_uInt16 nFlags = p->GetFlags(); - p->SetFlags( (nFlags | SBX_WRITE) & (~SBX_FIXED) ); - p->PutEmpty(); - p->SetFlags( nFlags ); - */ } } } @@ -1416,47 +1466,34 @@ void SbModule::ClearVarsDependingOnDeletedBasic( StarBASIC* pDeletedBasic ) } } -// Zunaechst in dieses Modul, um 358-faehig zu bleiben -// (Branch in sb.cxx vermeiden) void StarBASIC::ClearAllModuleVars( void ) { - // Eigene Module initialisieren + // Initialise the own module for ( sal_uInt16 nMod = 0; nMod < pModules->Count(); nMod++ ) { SbModule* pModule = (SbModule*)pModules->Get( nMod ); - // Nur initialisieren, wenn der Startcode schon ausgefuehrt wurde + // Initialise only, if the startcode was already executed if( pModule->pImage && pModule->pImage->bInit && !pModule->isProxyModule() && !pModule->ISA(SbObjModule) ) pModule->ClearPrivateVars(); } - /* #88042 This code can delete already used public vars during runtime! - // Alle Objekte ueberpruefen, ob es sich um ein Basic handelt - // Wenn ja, auch dort initialisieren - for ( sal_uInt16 nObj = 0; nObj < pObjs->Count(); nObj++ ) - { - SbxVariable* pVar = pObjs->Get( nObj ); - StarBASIC* pBasic = PTR_CAST(StarBASIC,pVar); - if( pBasic ) - pBasic->ClearAllModuleVars(); - } - */ } -// Ausfuehren des Init-Codes aller Module +// Execution of the init-code of all module void SbModule::GlobalRunInit( sal_Bool bBasicStart ) { - // Wenn kein Basic-Start, nur initialisieren, wenn Modul uninitialisiert + // If no Basic-Start, only initialise, if the module is not initialised if( !bBasicStart ) if( !(pImage && !pImage->bInit) ) return; - // GlobalInitErr-Flag fuer Compiler-Error initialisieren - // Anhand dieses Flags kann in SbModule::Run() nach dem Aufruf - // von GlobalRunInit festgestellt werden, ob beim initialisieren - // der Module ein Fehler auftrat. Dann wird nicht gestartet. + // Initialise GlobalInitErr-Flag for Compiler-Error + // With the help of this flags could be located in SbModule::Run() after the call of + // GlobalRunInit, if at the intialising of the module + // an error occurred. Then it will not be launched. GetSbData()->bGlobalInitErr = sal_False; - // Parent vom Modul ist ein Basic + // Parent of the module is a Basic StarBASIC *pBasic = PTR_CAST(StarBASIC,GetParent()); if( pBasic ) { @@ -1498,8 +1535,8 @@ void SbModule::GlobalRunDeInit( void ) } } -// Suche nach dem naechsten STMNT-Befehl im Code. Wird vom STMNT- -// Opcode verwendet, um die Endspalte zu setzen. +// Search for the next STMNT-Command in the code. This was used from the STMNT- +// Opcode to set the endcolumn. const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine, sal_uInt16& nCol ) const { @@ -1544,7 +1581,7 @@ const sal_uInt8* SbModule::FindNextStmnt( const sal_uInt8* p, sal_uInt16& nLine, return NULL; } -// Testen, ob eine Zeile STMNT-Opcodes enthaelt +// Test, if a line contains STMNT-Opcodes sal_Bool SbModule::IsBreakable( sal_uInt16 nLine ) const { @@ -1604,7 +1641,7 @@ sal_Bool SbModule::SetBP( sal_uInt16 nLine ) } pBreaks->insert( pBreaks->begin() + i, nLine ); - // #38568: Zur Laufzeit auch hier SbDEBUG_BREAK setzen + // #38568: Set during runtime as well here SbDEBUG_BREAK if( pINST && pINST->pRun ) pINST->pRun->SetDebugFlags( SbDEBUG_BREAK ); @@ -1665,7 +1702,7 @@ sal_Bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer ) Clear(); if( !SbxObject::LoadData( rStrm, 1 ) ) return sal_False; - // Precaution... + // As a precaution... SetFlag( SBX_EXTSEARCH | SBX_GBLSEARCH ); sal_uInt8 bImage; rStrm >> bImage; @@ -1690,7 +1727,7 @@ sal_Bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer ) if( p->GetCodeSize() ) { aOUSource = p->aOUSource; - // Alte Version: Image weg + // Old version: image away if( nVer == 1 ) { SetSource32( p->aOUSource ); @@ -1753,6 +1790,52 @@ sal_Bool SbModule::ExceedsLegacyModuleSize() return false; } +class ErrorHdlResetter +{ + Link mErrHandler; + bool mbError; + public: + ErrorHdlResetter() : mbError( false ) + { + // save error handler + mErrHandler = StarBASIC::GetGlobalErrorHdl(); + // set new error handler + StarBASIC::SetGlobalErrorHdl( LINK( this, ErrorHdlResetter, BasicErrorHdl ) ); + } + ~ErrorHdlResetter() + { + // restore error handler + StarBASIC::SetGlobalErrorHdl(mErrHandler); + } + DECL_LINK( BasicErrorHdl, StarBASIC * ); + bool HasError() { return mbError; } +}; +IMPL_LINK( ErrorHdlResetter, BasicErrorHdl, StarBASIC *, /*pBasic*/) +{ + mbError = true; + return 0; +} + +bool SbModule::HasExeCode() +{ + // And empty Image always has the Global Chain set up + static const unsigned char pEmptyImage[] = { 0x45, 0x0 , 0x0, 0x0, 0x0 }; + // lets be stricter for the moment than VBA + + if (!IsCompiled()) + { + ErrorHdlResetter aGblErrHdl; + Compile(); + if (aGblErrHdl.HasError()) //assume unsafe on compile error + return true; + } + + bool bRes = false; + if (pImage && !(pImage->GetCodeSize() == 5 && (memcmp(pImage->GetCode(), pEmptyImage, pImage->GetCodeSize()) == 0 ))) + bRes = true; + + return bRes; +} // Store only image, no source sal_Bool SbModule::StoreBinaryData( SvStream& rStrm ) @@ -1791,7 +1874,6 @@ sal_Bool SbModule::StoreBinaryData( SvStream& rStrm, sal_uInt16 nVer ) } // Called for >= OO 1.0 passwd protected libraries only -// sal_Bool SbModule::LoadBinaryData( SvStream& rStrm ) { @@ -1802,7 +1884,6 @@ sal_Bool SbModule::LoadBinaryData( SvStream& rStrm ) return bRet; } - sal_Bool SbModule::LoadCompleted() { SbxArray* p = GetMethods(); @@ -1915,7 +1996,6 @@ void SbModule::handleProcedureProperties( SfxBroadcaster& rBC, const SfxHint& rH } -///////////////////////////////////////////////////////////////////////// // Implementation SbJScriptModule (Basic-Modul fuer JavaScript-Sourcen) SbJScriptModule::SbJScriptModule( const String& rName ) :SbModule( rName ) @@ -1930,11 +2010,10 @@ sal_Bool SbJScriptModule::LoadData( SvStream& rStrm, sal_uInt16 nVer ) if( !SbxObject::LoadData( rStrm, 1 ) ) return sal_False; - // Source-String holen + // Get the source string String aTmp; rStrm.ReadByteString( aTmp, gsl_getSystemTextEncoding() ); aOUSource = aTmp; - //rStrm >> aSource; return sal_True; } @@ -1943,10 +2022,9 @@ sal_Bool SbJScriptModule::StoreData( SvStream& rStrm ) const if( !SbxObject::StoreData( rStrm ) ) return sal_False; - // Source-String schreiben + // Write the source string String aTmp = aOUSource; rStrm.WriteByteString( aTmp, gsl_getSystemTextEncoding() ); - //rStrm << aSource; return sal_True; } @@ -1962,7 +2040,8 @@ SbMethod::SbMethod( const String& r, SbxDataType t, SbModule* p ) nLine1 = nLine2 = 0; refStatics = new SbxArray; - // AB: 2.7.1996: HACK wegen 'Referenz kann nicht gesichert werden' + mCaller = 0; + // HACK due to 'Referenz could not be saved' SetFlag( SBX_NO_MODIFY ); } @@ -1976,6 +2055,7 @@ SbMethod::SbMethod( const SbMethod& r ) nLine1 = r.nLine1; nLine2 = r.nLine2; refStatics = r.refStatics; + mCaller = r.mCaller; SetFlag( SBX_NO_MODIFY ); } @@ -2008,10 +2088,9 @@ sal_Bool SbMethod::LoadData( SvStream& rStrm, sal_uInt16 nVer ) sal_Int16 n; rStrm >> n; sal_Int16 nTempStart = (sal_Int16)nStart; - // nDebugFlags = n; // AB 16.1.96: Nicht mehr uebernehmen if( nVer == 2 ) rStrm >> nLine1 >> nLine2 >> nTempStart >> bInvalid; - // AB: 2.7.1996: HACK wegen 'Referenz kann nicht gesichert werden' + // HACK ue to 'Referenz could not be saved' SetFlag( SBX_NO_MODIFY ); nStart = nTempStart; return sal_True; @@ -2034,27 +2113,32 @@ void SbMethod::GetLineRange( sal_uInt16& l1, sal_uInt16& l2 ) l1 = nLine1; l2 = nLine2; } -// Kann spaeter mal weg +// Could later be deleted SbxInfo* SbMethod::GetInfo() { return pInfo; } -// Schnittstelle zum Ausfuehren einer Methode aus den Applikationen -// #34191# Mit speziellem RefCounting, damit das Basic nicht durch CloseDocument() -// abgeschossen werden kann. Rueckgabewert wird als String geliefert. -ErrCode SbMethod::Call( SbxValue* pRet ) +// Interface to execute a method of the applications +// With special RefCounting, so that the Basic was not fired of by CloseDocument() +// The return value will be delivered as string. +ErrCode SbMethod::Call( SbxValue* pRet, SbxVariable* pCaller ) { + if ( pCaller ) + { + OSL_TRACE("SbMethod::Call Have been passed a caller 0x%x", pCaller ); + mCaller = pCaller; + } // RefCount vom Modul hochzaehlen SbModule* pMod_ = (SbModule*)GetParent(); pMod_->AddRef(); - // RefCount vom Basic hochzaehlen + // Increment the RefCount of the Basic StarBASIC* pBasic = (StarBASIC*)pMod_->GetParent(); pBasic->AddRef(); - // Values anlegen, um Return-Wert zu erhalten + // Establish the values to get the return value SbxValues aVals; aVals.eType = SbxVARIANT; @@ -2066,14 +2150,14 @@ ErrCode SbMethod::Call( SbxValue* pRet ) if ( pRet ) pRet->Put( aVals ); - // Gab es einen Error + // Was there an error ErrCode nErr = SbxBase::GetError(); SbxBase::ResetError(); - // Objekte freigeben + // Release objects pMod_->ReleaseRef(); pBasic->ReleaseRef(); - + mCaller = 0; return nErr; } @@ -2083,8 +2167,8 @@ void SbMethod::Broadcast( sal_uIntPtr nHintId ) { if( pCst && !IsSet( SBX_NO_BROADCAST ) && StaticIsEnabledBroadcasting() ) { - // Da die Methode von aussen aufrufbar ist, hier noch einmal - // die Berechtigung testen + // Because the method could be called from outside, test here once again + // the authorisation if( nHintId & SBX_HINT_DATAWANTED ) if( !CanRead() ) return; @@ -2102,7 +2186,7 @@ void SbMethod::Broadcast( sal_uIntPtr nHintId ) SbMethodRef xHolder = pThisCopy; if( mpPar.Is() ) { - // this, als Element 0 eintragen, aber den Parent nicht umsetzen! + // Enrigister this as element 0, but don't reset the parent! if( GetType() != SbxVOID ) mpPar->PutDirect( pThisCopy, 0 ); SetParameters( NULL ); @@ -2120,9 +2204,8 @@ void SbMethod::Broadcast( sal_uIntPtr nHintId ) } } -///////////////////////////////////////////////////////////////////////// -// Implementation SbJScriptMethod (Method-Klasse als Wrapper fuer JavaScript-Funktionen) +// Implementation of SbJScriptMethod (method class as a wrapper for JavaScript-functions) SbJScriptMethod::SbJScriptMethod( const String& r, SbxDataType t, SbModule* p ) : SbMethod( r, t, p ) @@ -2133,14 +2216,13 @@ SbJScriptMethod::~SbJScriptMethod() {} -///////////////////////////////////////////////////////////////////////// SbObjModule::SbObjModule( const String& rName, const com::sun::star::script::ModuleInfo& mInfo, bool bIsVbaCompatible ) : SbModule( rName, bIsVbaCompatible ) { SetModuleType( mInfo.ModuleType ); if ( mInfo.ModuleType == script::ModuleType::FORM ) { - SetClassName( rtl::OUString::createFromAscii( "Form" ) ); + SetClassName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Form" )) ); } else if ( mInfo.ModuleObject.is() ) SetUnoObject( uno::makeAny( mInfo.ModuleObject ) ); @@ -2159,13 +2241,13 @@ SbObjModule::SetUnoObject( const uno::Any& aObj ) throw ( uno::RuntimeException pDocObject = new SbUnoObject( GetName(), uno::makeAny( aObj ) ); com::sun::star::uno::Reference< com::sun::star::lang::XServiceInfo > xServiceInfo( aObj, com::sun::star::uno::UNO_QUERY_THROW ); - if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "ooo.vba.excel.Worksheet" ) ) ) + if( xServiceInfo->supportsService( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Worksheet" )) ) ) { - SetClassName( rtl::OUString::createFromAscii( "Worksheet" ) ); + SetClassName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Worksheet" )) ); } - else if( xServiceInfo->supportsService( rtl::OUString::createFromAscii( "ooo.vba.excel.Workbook" ) ) ) + else if( xServiceInfo->supportsService( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.excel.Workbook" )) ) ) { - SetClassName( rtl::OUString::createFromAscii( "Workbook" ) ); + SetClassName( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "Workbook" )) ); } } @@ -2177,7 +2259,6 @@ SbObjModule::GetObject() SbxVariable* SbObjModule::Find( const XubString& rName, SbxClassType t ) { - //OSL_TRACE("SbObjectModule find for %s", rtl::OUStringToOString( rName, RTL_TEXTENCODING_UTF8 ).getStr() ); SbxVariable* pVar = NULL; if ( pDocObject) pVar = pDocObject->Find( rName, t ); @@ -2291,10 +2372,9 @@ public: } } - //liuchen 2009-7-21, support Excel VBA Form_QueryClose event - virtual void SAL_CALL windowClosing( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) + + virtual void SAL_CALL windowClosing( const lang::EventObject& e ) throw (uno::RuntimeException) { -#if IN_THE_FUTURE uno::Reference< awt::XDialog > xDialog( e.Source, uno::UNO_QUERY ); if ( xDialog.is() ) { @@ -2304,7 +2384,6 @@ public: uno::Reference< document::XVbaMethodParameter > xVbaMethodParameter( xControl->getPeer(), uno::UNO_QUERY ); if ( xVbaMethodParameter.is() ) { -#endif sal_Int8 nCancel = 0; sal_Int8 nCloseMode = ::ooo::vba::VbQueryClose::vbFormControlMenu; @@ -2315,16 +2394,16 @@ public: mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ), aParams); -#if IN_THE_FUTURE xVbaMethodParameter->setVbaMethodParameter( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Cancel")), aParams[0]); return; } } } -#endif + + mpUserForm->triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ) ); } - //liuchen 2009-7-21 + virtual void SAL_CALL windowClosed( const lang::EventObject& /*e*/ ) throw (uno::RuntimeException) { @@ -2551,7 +2630,7 @@ void SbUserFormModule::Load() InitObject(); } -//liuchen 2009-7-21 change to accmordate VBA's beheavior + void SbUserFormModule::Unload() { OSL_TRACE("** Unload() "); @@ -2567,7 +2646,10 @@ void SbUserFormModule::Unload() triggerMethod( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Userform_QueryClose") ), aParams); aParams[0] >>= nCancel; - if (nCancel != 0) // Basic returns -1 for "True" + // basic boolean ( and what the user might use ) can be ambiguous ( e.g. basic true = -1 ) + // test agains 0 ( false ) and assume anything else is true + // ( Note: ) this used to work ( something changes somewhere ) + if (nCancel != 0) { return; } @@ -2598,7 +2680,7 @@ void SbUserFormModule::Unload() OSL_TRACE("UnloadObject completed ( we hope )"); } } -//liuchen + void registerComponentToBeDisposedForBasic( Reference< XComponent > xComponent, StarBASIC* pBasic ); @@ -2620,8 +2702,15 @@ void SbUserFormModule::InitObject() aArgs[ 0 ] <<= m_xModel; rtl::OUString sDialogUrl( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.script:" ) ); rtl::OUString sProjectName( RTL_CONSTASCII_USTRINGPARAM("Standard") ); - if ( this->GetParent()->GetName().Len() ) - sProjectName = this->GetParent()->GetName(); + + try + { + Reference< beans::XPropertySet > xProps( m_xModel, UNO_QUERY_THROW ); + uno::Reference< script::vba::XVBACompatibility > xVBAMode( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("BasicLibraries") ) ), uno::UNO_QUERY_THROW ); + sProjectName = xVBAMode->getProjectName(); + } + catch( Exception& /*e*/) {} + sDialogUrl = sDialogUrl.concat( sProjectName ).concat( rtl::OUString( '.') ).concat( GetName() ).concat( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("?location=document") ) ); uno::Reference< awt::XDialogProvider > xProvider( xFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.DialogProvider")), aArgs ), uno::UNO_QUERY_THROW ); @@ -2632,7 +2721,7 @@ void SbUserFormModule::InitObject() aArgs[ 0 ] = uno::Any(); aArgs[ 1 ] <<= m_xDialog; aArgs[ 2 ] <<= m_xModel; - aArgs[ 3 ] <<= rtl::OUString( GetParent()->GetName() ); + aArgs[ 3 ] <<= sProjectName; pDocObject = new SbUnoObject( GetName(), uno::makeAny( xVBAFactory->createInstanceWithArguments( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ooo.vba.msforms.UserForm")), aArgs ) ) ); uno::Reference< lang::XComponent > xComponent( m_xDialog, uno::UNO_QUERY_THROW ); @@ -2672,7 +2761,6 @@ SbUserFormModule::Find( const XubString& rName, SbxClassType t ) InitObject(); return SbObjModule::Find( rName, t ); } -///////////////////////////////////////////////////////////////////////// SbProperty::SbProperty( const String& r, SbxDataType t, SbModule* p ) : SbxProperty( r, t ), pMod( p ) @@ -2683,8 +2771,8 @@ SbProperty::SbProperty( const String& r, SbxDataType t, SbModule* p ) SbProperty::~SbProperty() {} -///////////////////////////////////////////////////////////////////////// SbProcedureProperty::~SbProcedureProperty() {} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/buffer.cxx b/basic/source/comp/buffer.cxx index 46df47cbd665..2e0fb542d3c2 100644 --- a/basic/source/comp/buffer.cxx +++ b/basic/source/comp/buffer.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,9 +35,9 @@ const static sal_uInt32 UP_LIMIT=0xFFFFFF00L; -// Der SbiBuffer wird in Inkrements von mindestens 16 Bytes erweitert. -// Dies ist notwendig, da viele Klassen von einer Pufferlaenge -// von x*16 Bytes ausgehen. +// The SbiBuffer will be expanded in increments of at least 16 Bytes. +// This is necessary, because many classes emanate from a buffer length +// of x*16 Bytes. SbiBuffer::SbiBuffer( SbiParser* p, short n ) { @@ -55,8 +56,8 @@ SbiBuffer::~SbiBuffer() delete[] pBuf; } -// Rausreichen des Puffers -// Dies fuehrt zur Loeschung des Puffers! +// Reach out the buffer +// This lead to the deletion of the buffer! char* SbiBuffer::GetBuffer() { @@ -66,8 +67,8 @@ char* SbiBuffer::GetBuffer() return p; } -// Test, ob der Puffer n Bytes aufnehmen kann. -// Im Zweifelsfall wird er vergroessert +// Test, if the buffer can contain n Bytes. +// In case of doubt it will be enlarged sal_Bool SbiBuffer::Check( sal_uInt16 n ) { @@ -100,7 +101,7 @@ sal_Bool SbiBuffer::Check( sal_uInt16 n ) return sal_True; } -// Angleich des Puffers auf die uebergebene Byte-Grenze +// Conditioning of the buffer onto the passed Byte limit void SbiBuffer::Align( sal_Int32 n ) { @@ -119,7 +120,7 @@ void SbiBuffer::Align( sal_Int32 n ) } } -// Patch einer Location +// Patch of a Location void SbiBuffer::Patch( sal_uInt32 off, sal_uInt32 val ) { @@ -135,9 +136,9 @@ void SbiBuffer::Patch( sal_uInt32 off, sal_uInt32 val ) } } -// Forward References auf Labels und Prozeduren -// bauen eine Kette auf. Der Anfang der Kette ist beim uebergebenen -// Parameter, das Ende der Kette ist 0. +// Forward References upon label und procedures +// establish a linkage. The beginning of the linkage is at the passed parameter, +// the end of the linkage is 0. void SbiBuffer::Chain( sal_uInt32 off ) { @@ -248,3 +249,4 @@ sal_Bool SbiBuffer::Add( const void* p, sal_uInt16 len ) +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index f59edfbb12e9..f5d820ecc51e 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,9 +33,10 @@ #include "sbcomp.hxx" #include "image.hxx" #include <limits> +#include <algorithm> #include <com/sun/star/script/ModuleType.hpp> -// nInc ist die Inkrementgroesse der Puffer +// nInc is the increment size of the buffers SbiCodeGen::SbiCodeGen( SbModule& r, SbiParser* p, short nInc ) : rMod( r ), aCode( p, nInc ) @@ -51,7 +53,7 @@ sal_uInt32 SbiCodeGen::GetPC() return aCode.GetSize(); } -// Statement merken +// memorize the statement void SbiCodeGen::Statement() { @@ -60,12 +62,12 @@ void SbiCodeGen::Statement() nLine = pParser->GetLine(); nCol = pParser->GetCol1(); - // #29955 Information der for-Schleifen-Ebene - // in oberen Byte der Spalte speichern + // #29955 Store the information of the for-loop-layer + // in the uppper Byte of the column nCol = (nCol & 0xff) + 0x100 * nForLevel; } -// Anfang eines Statements markieren +// Mark the beginning of a statement void SbiCodeGen::GenStmnt() { @@ -76,8 +78,8 @@ void SbiCodeGen::GenStmnt() } } -// Die Gen-Routinen returnen den Offset des 1. Operanden, -// damit Jumps dort ihr Backchain versenken koennen +// The Gen-Routines return the offset of the 1. operand, +// so that jumps can sink their backchain there. sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode ) { @@ -117,15 +119,15 @@ sal_uInt32 SbiCodeGen::Gen( SbiOpcode eOpcode, sal_uInt32 nOpnd1, sal_uInt32 nOp return n; } -// Abspeichern des erzeugten Images im Modul +// Storing of the created image in the module void SbiCodeGen::Save() { SbiImage* p = new SbiImage; rMod.StartDefinitions(); - // OPTION BASE-Wert: + // OPTION BASE-Value: p->nDimBase = pParser->nBase; - // OPTION EXPLICIT-Flag uebernehmen + // OPTION take over the EXPLICIT-Flag if( pParser->bExplicit ) p->SetFlag( SBIMG_EXPLICIT ); @@ -163,8 +165,6 @@ void SbiCodeGen::Save() rMod.bIsProxyModule = false; } - if( pParser->bText ) - p->SetFlag( SBIMG_COMPARETEXT ); // GlobalCode-Flag if( pParser->HasGlobalCode() ) p->SetFlag( SBIMG_INITCODE ); @@ -237,25 +237,24 @@ void SbiCodeGen::Save() ePropType = SbxOBJECT; break; case PROPERTY_MODE_NONE: - DBG_ERROR( "Illegal PropertyMode PROPERTY_MODE_NONE" ); + OSL_FAIL( "Illegal PropertyMode PROPERTY_MODE_NONE" ); break; } String aPropName = pProc->GetPropName(); if( nPass == 1 ) aPropName = aPropName.Copy( aIfaceName.Len() + 1 ); - SbProcedureProperty* pProcedureProperty = NULL; - pProcedureProperty = rMod.GetProcedureProperty( aPropName, ePropType ); + OSL_TRACE("*** getProcedureProperty for thing %s", + rtl::OUStringToOString( aPropName,RTL_TEXTENCODING_UTF8 ).getStr() ); + rMod.GetProcedureProperty( aPropName, ePropType ); } if( nPass == 1 ) { - SbIfaceMapperMethod* pMapperMeth = NULL; - pMapperMeth = rMod.GetIfaceMapperMethod( aProcName, pMeth ); + rMod.GetIfaceMapperMethod( aProcName, pMeth ); } else { pMeth = rMod.GetMethod( aProcName, pProc->GetType() ); - // #110004 if( !pProc->IsPublic() ) pMeth->SetFlag( SBX_PRIVATE ); @@ -266,22 +265,22 @@ void SbiCodeGen::Save() pMeth->nStart = pProc->GetAddr(); pMeth->nLine1 = pProc->GetLine1(); pMeth->nLine2 = pProc->GetLine2(); - // Die Parameter: + // The parameter: SbxInfo* pInfo = pMeth->GetInfo(); String aHelpFile, aComment; sal_uIntPtr nHelpId = 0; if( pInfo ) { - // Die Zusatzdaten retten + // Rescue the additional data aHelpFile = pInfo->GetHelpFile(); aComment = pInfo->GetComment(); nHelpId = pInfo->GetHelpId(); } - // Und die Parameterliste neu aufbauen + // And reestablish the parameter list pInfo = new SbxInfo( aHelpFile, nHelpId ); pInfo->SetComment( aComment ); SbiSymPool* pPool = &pProc->GetParams(); - // Das erste Element ist immer der Funktionswert! + // The first element is always the value of the function! for( sal_uInt16 i = 1; i < pPool->GetSize(); i++ ) { SbiSymDef* pPar = pPool->Get( i ); @@ -290,7 +289,7 @@ void SbiCodeGen::Save() t = (SbxDataType) ( t | SbxBYREF ); if( pPar->GetDims() ) t = (SbxDataType) ( t | SbxARRAY ); - // #33677 Optional-Info durchreichen + // #33677 hand-over an Optional-Info sal_uInt16 nFlags = SBX_READ; if( pPar->IsOptional() ) nFlags |= SBX_OPTIONAL; @@ -317,10 +316,10 @@ void SbiCodeGen::Save() } // for( iPass... } } - // Der Code + // The code p->AddCode( aCode.GetBuffer(), aCode.GetSize() ); - // Der globale StringPool. 0 ist nicht belegt. + // The global StringPool. 0 is not occupied. SbiStringPool* pPool = &pParser->aGblStrings; sal_uInt16 nSize = pPool->GetSize(); p->MakeStrings( nSize ); @@ -328,7 +327,7 @@ void SbiCodeGen::Save() for( i = 1; i <= nSize; i++ ) p->AddString( pPool->Find( i ) ); - // Typen einfuegen + // Insert types sal_uInt16 nCount = pParser->rTypeArray->Count(); for (i = 0; i < nCount; i++) p->AddType((SbxObject *)pParser->rTypeArray->Get(i)); @@ -438,10 +437,7 @@ public: T result = 0 ; static const S max = std::numeric_limits< S >::max(); result = m_nNumOp0 + ( ( sizeof(S) + 1 ) * m_nNumSingleParams ) + ( (( sizeof(S) * 2 )+ 1 ) * m_nNumDoubleParams ); - if ( result > max ) - return max; - - return static_cast<S>(result); + return std::min(static_cast<T>(max), result); } virtual bool processParams(){ return false; } }; @@ -539,3 +535,5 @@ PCodeBuffConvertor<T,S>::convert() template class PCodeBuffConvertor< sal_uInt16, sal_uInt32 >; template class PCodeBuffConvertor< sal_uInt32, sal_uInt16 >; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx index 03c4845569a7..e1e56101e937 100644 --- a/basic/source/comp/dim.cxx +++ b/basic/source/comp/dim.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,13 +30,15 @@ #include "precompiled_basic.hxx" #include <basic/sbx.hxx> #include "sbcomp.hxx" +#include "sbunoobj.hxx" + SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj ); -// Deklaration einer Variablen -// Bei Fehlern wird bis zum Komma oder Newline geparst. -// Returnwert: eine neue Instanz, die eingefuegt und dann geloescht wird. -// Array-Indexe werden als SbiDimList zurueckgegeben +// Declaration of a variable +// If there are errors it will be parsed up to the comma or the newline. +// Return-value: a new instance, which were inserted and then deleted. +// Array-Indexex were returned as SbiDimList SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, sal_Bool bStatic, sal_Bool bConst ) { @@ -49,7 +52,7 @@ SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, sal_Bool bStatic, sal_Bool bC SbxDataType t = eScanType; SbiSymDef* pDef = bConst ? new SbiConstDef( aSym ) : new SbiSymDef( aSym ); SbiDimList* pDim = NULL; - // Klammern? + // Brackets? if( Peek() == LPAREN ) { pDim = new SbiDimList( this ); @@ -73,15 +76,15 @@ SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, sal_Bool bStatic, sal_Bool bC return pDef; } -// Aufloesen einer AS-Typdeklaration -// Der Datentyp wird in die uebergebene Variable eingetragen +// Resolving of a AS-Type-Declaration +// The data type were inserted into the handed over variable void SbiParser::TypeDecl( SbiSymDef& rDef, sal_Bool bAsNewAlreadyParsed ) { SbxDataType eType = rDef.GetType(); - short nSize = 0; if( bAsNewAlreadyParsed || Peek() == AS ) { + short nSize = 0; if( !bAsNewAlreadyParsed ) Next(); rDef.SetDefinedAs(); @@ -128,14 +131,14 @@ void SbiParser::TypeDecl( SbiSymDef& rDef, sal_Bool bAsNewAlreadyParsed ) } } break; - case SYMBOL: // kann nur ein TYPE oder eine Objektklasse sein! + case SYMBOL: // can only be a TYPE or a object class! if( eScanType != SbxVARIANT ) Error( SbERR_SYNTAX ); else { String aCompleteName = aSym; - // #52709 DIM AS NEW fuer Uno mit voll-qualifizierten Namen + // #52709 DIM AS NEW for Uno with full-qualified name if( Peek() == DOT ) { String aDotStr( '.' ); @@ -157,13 +160,13 @@ void SbiParser::TypeDecl( SbiSymDef& rDef, sal_Bool bAsNewAlreadyParsed ) } } } - else if( rEnumArray->Find( aCompleteName, SbxCLASS_OBJECT ) ) + else if( rEnumArray->Find( aCompleteName, SbxCLASS_OBJECT ) || ( IsVBASupportOn() && VBAConstantHelper::instance().isVBAConstantType( aCompleteName ) ) ) { eType = SbxLONG; break; } - // In den String-Pool uebernehmen + // Take over in the String pool rDef.SetTypeId( aGblStrings.Add( aCompleteName ) ); if( rDef.IsNew() && pProc == NULL ) @@ -179,7 +182,7 @@ void SbiParser::TypeDecl( SbiSymDef& rDef, sal_Bool bAsNewAlreadyParsed ) Error( SbERR_UNEXPECTED, eTok ); Next(); } - // Die Variable koennte mit Suffix deklariert sein + // The variable could have been declared with a suffix if( rDef.GetType() != SbxVARIANT ) { if( rDef.GetType() != eType ) @@ -192,7 +195,7 @@ void SbiParser::TypeDecl( SbiSymDef& rDef, sal_Bool bAsNewAlreadyParsed ) } } -// Hier werden Variable, Arrays und Strukturen definiert. +// Here variables, arrays and structures were definied. // DIM/PRIVATE/PUBLIC/GLOBAL void SbiParser::Dim() @@ -210,7 +213,7 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) Error( SbERR_NOT_IN_SUBR, eCurTok ); if( eCurTok == PUBLIC || eCurTok == GLOBAL ) { - bSwitchPool = sal_True; // im richtigen Moment auf globalen Pool schalten + bSwitchPool = sal_True; // at the right moment switch to the global pool if( eCurTok == GLOBAL ) bPersistantGlobal = sal_True; } @@ -218,7 +221,7 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) // tied to the document. e.g. a module scope variable is global if( GetBasic()->IsDocBasic() && bVBASupportOn && !pProc ) bPersistantGlobal = sal_True; - // PRIVATE ist Synonym fuer DIM + // PRIVATE is a synonymous for DIM // _CONST_? sal_Bool bConst = sal_False; if( eCurTok == _CONST_ ) @@ -276,13 +279,13 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) #define tmpSHARED #undef SHARED #endif - // SHARED wird ignoriert + // SHARED were ignored if( Peek() == SHARED ) Next(); #ifdef tmpSHARED #define SHARED #undef tmpSHARED #endif - // PRESERVE nur bei REDIM + // PRESERVE only at REDIM if( Peek() == PRESERVE ) { Next(); @@ -294,23 +297,23 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) SbiSymDef* pDef; SbiDimList* pDim; - // AB 9.7.97, #40689, Statics -> Modul-Initialisierung, in Sub ueberspringen + // #40689, Statics -> Modul-Initialising, skip in Sub sal_uInt32 nEndOfStaticLbl = 0; if( !bVBASupportOn && bStatic ) { nEndOfStaticLbl = aGen.Gen( _JUMP, 0 ); - aGen.Statement(); // bei static hier nachholen + aGen.Statement(); // catch up on static here } sal_Bool bDefined = sal_False; while( ( pDef = VarDecl( &pDim, bStatic, bConst ) ) != NULL ) { EnableErrors(); - // Variable suchen: + // search variable: if( bSwitchPool ) pPool = &aGlobals; SbiSymDef* pOld = pPool->Find( pDef->GetName() ); - // AB 31.3.1996, #25651#, auch in Runtime-Library suchen + // search also in the Runtime-Library sal_Bool bRtlSym = sal_False; if( !pOld ) { @@ -326,10 +329,10 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) if( pOld ) { bDefined = sal_True; - // Bei RTL-Symbol immer Fehler + // always an error at a RTL-S if( !bRtlSym && (eOp == _REDIM || eOp == _REDIMP) ) { - // Bei REDIM die Attribute vergleichen + // compare the attributes at a REDIM SbxDataType eDefType; bool bError_ = false; if( pOld->IsStatic() ) @@ -351,19 +354,19 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) else pPool->Add( pDef ); - // #36374: Variable vor Unterscheidung IsNew() anlegen - // Sonst Error bei Dim Identifier As New Type und option explicit + // #36374: Create the variable in front of the distinction IsNew() + // Otherwise error at Dim Identifier As New Type and option explicit if( !bDefined && !(eOp == _REDIM || eOp == _REDIMP) && ( !bConst || pDef->GetScope() == SbGLOBAL ) ) { - // Variable oder globale Konstante deklarieren + // Declare variable or global constant SbiOpcode eOp2; switch ( pDef->GetScope() ) { case SbGLOBAL: eOp2 = bPersistantGlobal ? _GLOBAL_P : _GLOBAL; goto global; case SbPUBLIC: eOp2 = bPersistantGlobal ? _PUBLIC_P : _PUBLIC; - // AB 9.7.97, #40689, kein eigener Opcode mehr + // #40689, no own Opcode anymore if( bVBASupportOn && bStatic ) { eOp2 = _STATIC; @@ -392,8 +395,8 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) aGen.Gen( eOp2, pDef->GetId(), nOpnd2 ); } - // Initialisierung fuer selbstdefinierte Datentypen - // und per NEW angelegte Variable + // Initialising for self-defined daty types + // and per NEW created variable if( pDef->GetType() == SbxOBJECT && pDef->GetTypeId() ) { @@ -436,14 +439,17 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) aExpr.Gen(); SbiOpcode eOp_ = pDef->IsNew() ? _CREATE : _TCREATE; aGen.Gen( eOp_, pDef->GetId(), pDef->GetTypeId() ); - aGen.Gen( _SET ); + if ( bVBASupportOn ) + aGen.Gen( _VBASET ); + else + aGen.Gen( _SET ); } } else { if( bConst ) { - // Konstanten-Definition + // Definition of the constants if( pDim ) { Error( SbERR_SYNTAX ); @@ -451,13 +457,13 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) } SbiExpression aVar( this, *pDef ); if( !TestToken( EQ ) ) - goto MyBreak; // AB 24.6.1996 (s.u.) + goto MyBreak; // (see below) SbiConstExpression aExpr( this ); if( !bDefined && aExpr.IsValid() ) { if( pDef->GetScope() == SbGLOBAL ) { - // Nur Code fuer globale Konstante erzeugen! + // Create code only for the global constant! aVar.Gen(); aExpr.Gen(); aGen.Gen( _PUTC ); @@ -471,8 +477,8 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) } else if( pDim ) { - // Die Variable dimensionieren - // Bei REDIM die Var vorher loeschen + // Dimension the variable + // Delete the var at REDIM beforehand if( eOp == _REDIM ) { SbiExpression aExpr( this, *pDef, NULL ); @@ -502,36 +508,34 @@ void SbiParser::DefVar( SbiOpcode eOp, sal_Bool bStatic ) } } if( !TestComma() ) - goto MyBreak; // AB 24.6.1996 (s.u.) - - // #27963# AB, 24.6.1996 - // Einfuehrung bSwitchPool (s.o.): pPool darf beim VarDecl-Aufruf - // noch nicht auf &aGlobals gesetzt sein. - // Ansonsten soll das Verhalten aber absolut identisch bleiben, - // d.h. pPool muss immer am Schleifen-Ende zurueckgesetzt werden. - // auch bei break + goto MyBreak; + + // Implementation of bSwitchPool (see above): pPool must not be set to &aGlobals + // at the VarDecl-Call. + // Apart from that the behavior should be absolutely identical, + // i.e., pPool had to be reset always at the end of the loop. + // also at a break pPool = pOldPool; - continue; // MyBreak überspingen + continue; // Skip MyBreak MyBreak: pPool = pOldPool; break; } - // AB 9.7.97, #40689, Sprung ueber Statics-Deklaration abschliessen + // #40689, finalize the jump over statics declarations if( !bVBASupportOn && bStatic ) { - // globalen Chain pflegen + // maintain the global chain nGblChain = aGen.Gen( _JUMP, 0 ); bGblDefs = bNewGblDefs = sal_True; - // fuer Sub Sprung auf Ende der statics eintragen + // Register for Sub a jump to the end of statics aGen.BackChain( nEndOfStaticLbl ); } - //pPool = pOldPool; } -// Hier werden Arrays redimensioniert. +// Here were Arrays redimensioned. void SbiParser::ReDim() { @@ -551,7 +555,7 @@ void SbiParser::Erase() } } -// Deklaration eines Datentyps +// Declaration of a data type void SbiParser::Type() { @@ -563,7 +567,7 @@ void SbiParser::DefType( sal_Bool bPrivate ) // TODO: Use bPrivate (void)bPrivate; - // Neues Token lesen, es muss ein Symbol sein + // Read the new Token lesen. It had to be a symbol if (!TestSymbol()) return; @@ -596,10 +600,9 @@ void SbiParser::DefType( sal_Bool bPrivate ) break; default: - pDim = NULL; pElem = VarDecl(&pDim,sal_False,sal_False); if( !pElem ) - bDone = sal_True; // Error occured + bDone = sal_True; // Error occurred } if( pElem ) { @@ -662,9 +665,9 @@ void SbiParser::DefType( sal_Bool bPrivate ) } } } - delete pDim; pTypeMembers->Insert( pTypeElem, pTypeMembers->Count() ); } + delete pDim, pDim = NULL; delete pElem; } } @@ -685,7 +688,7 @@ void SbiParser::Enum() void SbiParser::DefEnum( sal_Bool bPrivate ) { - // Neues Token lesen, es muss ein Symbol sein + // Read a the new Token. It had to be a symbol if (!TestSymbol()) return; @@ -731,14 +734,14 @@ void SbiParser::DefEnum( sal_Bool bPrivate ) pElem = VarDecl( &pDim, sal_False, sal_True ); if( !pElem ) { - bDone = sal_True; // Error occured + bDone = sal_True; // Error occurred break; } else if( pDim ) { delete pDim; Error( SbERR_SYNTAX ); - bDone = sal_True; // Error occured + bDone = sal_True; // Error occurred break; } @@ -768,7 +771,7 @@ void SbiParser::DefEnum( sal_Bool bPrivate ) if( pOld ) { Error( SbERR_VAR_DEFINED, pElem->GetName() ); - bDone = sal_True; // Error occured + bDone = sal_True; // Error occurred break; } @@ -812,8 +815,8 @@ void SbiParser::DefEnum( sal_Bool bPrivate ) } -// Prozedur-Deklaration -// das erste Token ist bereits eingelesen (SUB/FUNCTION) +// Procedure-Declaration +// the first Token is already read in (SUB/FUNCTION) // xxx Name [LIB "name"[ALIAS "name"]][(Parameter)][AS TYPE] SbiProcDef* SbiParser::ProcDecl( sal_Bool bDecl ) @@ -847,7 +850,7 @@ SbiProcDef* SbiParser::ProcDecl( sal_Bool bDecl ) } if( !bDecl ) { - // CDECL, LIB und ALIAS sind unzulaessig + // CDECL, LIB and ALIAS are invalid if( pDef->GetLib().Len() ) Error( SbERR_UNEXPECTED, LIB ); if( pDef->GetAlias().Len() ) @@ -860,7 +863,7 @@ SbiProcDef* SbiParser::ProcDecl( sal_Bool bDecl ) } else if( !pDef->GetLib().Len() ) { - // ALIAS und CDECL nur zusammen mit LIB + // ALIAS and CDECL only together with LIB if( pDef->GetAlias().Len() ) Error( SbERR_UNEXPECTED, ALIAS ); if( pDef->IsCdecl() ) @@ -868,7 +871,7 @@ SbiProcDef* SbiParser::ProcDecl( sal_Bool bDecl ) pDef->SetCdecl( sal_False ); pDef->GetAlias().Erase(); } - // Klammern? + // Brackets? if( Peek() == LPAREN ) { Next(); @@ -937,9 +940,6 @@ SbiProcDef* SbiParser::ProcDecl( sal_Bool bDecl ) TypeDecl( *pDef ); if( eType != SbxVARIANT && pDef->GetType() != eType ) Error( SbERR_BAD_DECLARATION, aName ); -// if( pDef->GetType() == SbxOBJECT ) -// pDef->SetType( SbxVARIANT ), -// Error( SbERR_SYNTAX ); if( pDef->GetType() == SbxVARIANT && !( bFunc || bProp ) ) pDef->SetType( SbxEMPTY ); return pDef; @@ -966,14 +966,14 @@ void SbiParser::DefDeclare( sal_Bool bPrivate ) { if( !pDef->GetLib().Len() ) Error( SbERR_EXPECTED, LIB ); - // gibts den schon? + // Is it already there? SbiSymDef* pOld = aPublics.Find( pDef->GetName() ); if( pOld ) { SbiProcDef* p = pOld->GetProcDef(); if( !p ) { - // Als Variable deklariert + // Declared as a variable Error( SbERR_BAD_DECLARATION, pDef->GetName() ); delete pDef; pDef = NULL; @@ -1053,11 +1053,27 @@ void SbiParser::DefDeclare( sal_Bool bPrivate ) } } -// Aufruf einer SUB oder FUNCTION +void SbiParser::Attribute() +{ + // TODO: Need to implement the method as an attributed object. + while( Next() != EQ ) + { + if( Next() != DOT) + break; + } + + if( eCurTok != EQ ) + Error( SbERR_SYNTAX ); + else + SbiExpression aValue( this ); + + // Don't generate any code - just discard it. +} + +// Call of a SUB or a FUNCTION void SbiParser::Call() { - String aName( aSym ); SbiExpression aVar( this, SbSYMBOL ); aVar.Gen( FORCE_CALL ); aGen.Gen( _GET ); @@ -1070,7 +1086,7 @@ void SbiParser::SubFunc() DefProc( sal_False, sal_False ); } -// Einlesen einer Prozedur +// Read in of a procedure sal_Bool runsInSetup( void ); @@ -1099,7 +1115,7 @@ void SbiParser::DefProc( sal_Bool bStatic, sal_Bool bPrivate ) return; pDef->setPropertyMode( ePropertyMode ); - // Ist die Proc bereits deklariert? + // Is the Proc already declared? SbiSymDef* pOld = aPublics.Find( pDef->GetName() ); if( pOld ) { @@ -1108,7 +1124,7 @@ void SbiParser::DefProc( sal_Bool bStatic, sal_Bool bPrivate ) pProc = pOld->GetProcDef(); if( !pProc ) { - // Als Variable deklariert + // Declared as a variable Error( SbERR_BAD_DECLARATION, pDef->GetName() ); delete pDef; pProc = NULL; @@ -1141,8 +1157,8 @@ void SbiParser::DefProc( sal_Bool bStatic, sal_Bool bPrivate ) return; pProc->SetPublic( !bPrivate ); - // Nun setzen wir die Suchhierarchie fuer Symbole sowie die aktuelle - // Prozedur. + // Now we set the search hierarchy for symbols as well as the + // current procedure. aPublics.SetProcId( pProc->GetId() ); pProc->GetParams().SetParent( &aPublics ); if( bStatic ) @@ -1156,7 +1172,7 @@ void SbiParser::DefProc( sal_Bool bStatic, sal_Bool bPrivate ) { pProc->SetStatic( sal_False ); } - // Normalfall: Lokale Variable->Parameter->Globale Variable + // Normal case: Local variable->parameter->global variable pProc->GetLocals().SetParent( &pProc->GetParams() ); pPool = &pProc->GetLocals(); @@ -1168,7 +1184,7 @@ void SbiParser::DefProc( sal_Bool bStatic, sal_Bool bPrivate ) pProc->SetLine2( l2 ); pPool = &aPublics; aPublics.SetProcId( 0 ); - // Offene Labels? + // Open labels? pProc->GetLabels().CheckRefs(); CloseBlock(); aGen.Gen( _LEAVE ); @@ -1202,8 +1218,8 @@ void SbiParser::DefStatic( sal_Bool bPrivate ) default: { if( !pProc ) Error( SbERR_NOT_IN_SUBR ); - // Pool umsetzen, damit STATIC-Deklarationen im globalen - // Pool landen + // Reset the Pool, so that STATIC-Declarations go into the + // global Pool SbiSymPool* p = pPool; pPool = &aPublics; DefVar( _STATIC, sal_True ); pPool = p; @@ -1211,3 +1227,4 @@ void SbiParser::DefStatic( sal_Bool bPrivate ) } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/exprgen.cxx b/basic/source/comp/exprgen.cxx index c77123493916..214653f501d7 100644 --- a/basic/source/comp/exprgen.cxx +++ b/basic/source/comp/exprgen.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -31,7 +32,7 @@ #include "sbcomp.hxx" #include "expr.hxx" -// Umsetztabelle fuer Token-Operatoren und Opcodes +// Transform table for token operators and opcodes typedef struct { SbiToken eTok; // Token @@ -64,7 +65,7 @@ static OpTable aOpTable [] = { { IS, _IS }, { NIL, _NOP }}; -// Ausgabe eines Elements +// Output of an element void SbiExprNode::Gen( RecursiveMode eRecMode ) { if( IsConstant() ) @@ -108,10 +109,10 @@ void SbiExprNode::Gen( RecursiveMode eRecMode ) eOp = aVar.pDef->IsGlobal() ? _FIND_G : _FIND; } } - // AB: 17.12.1995, Spezialbehandlung fuer WITH + // special treatment for WITH else if( (pWithParent_ = GetWithParent()) != NULL ) { - eOp = _ELEM; // .-Ausdruck in WITH + eOp = _ELEM; // .-Term in in WITH } else { @@ -162,7 +163,7 @@ void SbiExprNode::Gen( RecursiveMode eRecMode ) } } -// Ausgabe eines Operanden-Elements +// Output of an operand element void SbiExprNode::GenElement( SbiOpcode eOp ) { @@ -171,11 +172,11 @@ void SbiExprNode::GenElement( SbiOpcode eOp ) pGen->GetParser()->Error( SbERR_INTERNAL_ERROR, "Opcode" ); #endif SbiSymDef* pDef = aVar.pDef; - // Das ID ist entweder die Position oder das String-ID - // Falls das Bit 0x8000 gesetzt ist, hat die Variable - // eine Parameterliste. + // The ID is either the position or the String-ID + // If the bit Bit 0x8000 is set, the variable have + // a parameter list. sal_uInt16 nId = ( eOp == _PARAM ) ? pDef->GetPos() : pDef->GetId(); - // Parameterliste aufbauen + // Build a parameter list if( aVar.pPar && aVar.pPar->GetSize() ) { nId |= 0x8000; @@ -197,18 +198,18 @@ void SbiExprNode::GenElement( SbiOpcode eOp ) } } -// Erzeugen einer Argv-Tabelle -// Das erste Element bleibt immer frei fuer Returnwerte etc. -// Siehe auch SbiProcDef::SbiProcDef() in symtbl.cxx +// Create an Argv-Table +// The first element remain available for return value etc. +// See as well SbiProcDef::SbiProcDef() in symtbl.cxx void SbiExprList::Gen() { if( pFirst ) { pParser->aGen.Gen( _ARGC ); - // AB 10.1.96: Typ-Anpassung bei DECLARE - sal_uInt16 nCount = 1 /*, nParAnz = 0*/; -// SbiSymPool* pPool = NULL; + // Type adjustment at DECLARE + sal_uInt16 nCount = 1; + for( SbiExpression* pExpr = pFirst; pExpr; pExpr = pExpr->pNext,nCount++ ) { pExpr->Gen(); @@ -219,13 +220,13 @@ void SbiExprList::Gen() pParser->aGen.Gen( _ARGN, nSid ); /* TODO: Check after Declare concept change - // AB 10.1.96: Typanpassung bei named -> passenden Parameter suchen + // From 1996-01-10: Type adjustment at named -> search suitable parameter if( pProc ) { - // Vorerst: Error ausloesen + // For the present: trigger an error pParser->Error( SbERR_NO_NAMED_ARGS ); - // Spaeter, wenn Named Args bei DECLARE moeglich + // Later, if Named Args at DECLARE is posible //for( sal_uInt16 i = 1 ; i < nParAnz ; i++ ) //{ // SbiSymDef* pDef = pPool->Get( i ); @@ -253,8 +254,8 @@ void SbiExprList::Gen() void SbiExpression::Gen( RecursiveMode eRecMode ) { - // AB: 17.12.1995, Spezialbehandlung fuer WITH - // Wenn pExpr == .-Ausdruck in With, zunaechst Gen fuer Basis-Objekt + // special treatment for WITH + // If pExpr == .-term in With, approximately Gen for Basis-Object pExpr->Gen( eRecMode ); if( bByVal ) pParser->aGen.Gen( _BYVAL ); @@ -268,3 +269,4 @@ void SbiExpression::Gen( RecursiveMode eRecMode ) } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx index f516513d7589..5c7bb0b51a88 100644 --- a/basic/source/comp/exprnode.cxx +++ b/basic/source/comp/exprnode.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,7 +35,6 @@ #include "sbcomp.hxx" #include "expr.hxx" -////////////////////////////////////////////////////////////////////////// SbiExprNode::SbiExprNode( void ) { @@ -51,7 +51,7 @@ SbiExprNode::SbiExprNode( SbiParser* p, SbiExprNode* l, SbiToken t, SbiExprNode* pRight = r; eTok = t; nVal = 0; - eType = SbxVARIANT; // Nodes sind immer Variant + eType = SbxVARIANT; // Nodes are always Variant eNodeType = SbxNODE; bComposite= sal_True; } @@ -85,7 +85,7 @@ SbiExprNode::SbiExprNode( SbiParser* p, const SbiSymDef& r, SbxDataType t, SbiEx aVar.pvMorePar = NULL; aVar.pNext= NULL; - // Funktionsergebnisse sind nie starr + // Results of functions are at no time fixed bComposite= sal_Bool( aVar.pDef->GetProcDef() != NULL ); } @@ -110,7 +110,7 @@ SbiExprNode::SbiExprNode( SbiParser* p, sal_uInt16 nId ) nTypeStrId = nId; } -// AB: 17.12.95, Hilfsfunktion fuer Ctor fuer einheitliche Initialisierung +// From 1995-12-17, auxiliary function for Ctor for the uniform initialisation void SbiExprNode::BaseInit( SbiParser* p ) { pGen = &p->aGen; @@ -158,7 +158,7 @@ SbiSymDef* SbiExprNode::GetRealVar() return NULL; } -// AB: 18.12.95 +// From 1995-12-18 SbiExprNode* SbiExprNode::GetRealNode() { if( eNodeType == SbxVARVAL ) @@ -172,7 +172,7 @@ SbiExprNode* SbiExprNode::GetRealNode() return NULL; } -// Diese Methode setzt den Typ um, falls er in den Integer-Bereich hineinpasst +// This method transform the type, if it fits into the Integer range sal_Bool SbiExprNode::IsIntConst() { @@ -212,7 +212,7 @@ sal_Bool SbiExprNode::IsLvalue() return IsVariable(); } -// Ermitteln der Tiefe eines Baumes +// Identify of the depth of a tree short SbiExprNode::GetDepth() { @@ -226,11 +226,11 @@ short SbiExprNode::GetDepth() } -// Abgleich eines Baumes: +// Adjustment of a tree: // 1. Constant Folding -// 2. Typabgleich -// 3. Umwandlung der Operanden in Strings -// 4. Hochziehen der Composite- und Error-Bits +// 2. Type-Adjustment +// 3. Conversion of the operans into Strings +// 4. Lifting of the composite- and error-bits void SbiExprNode::Optimize() { @@ -238,7 +238,7 @@ void SbiExprNode::Optimize() CollectBits(); } -// Hochziehen der Composite- und Fehlerbits +// Lifting of the composite- and error-bits void SbiExprNode::CollectBits() { @@ -256,8 +256,8 @@ void SbiExprNode::CollectBits() } } -// Kann ein Zweig umgeformt werden, wird sal_True zurueckgeliefert. In diesem -// Fall ist das Ergebnis im linken Zweig. +// If a twig can be converted, True will be returned. In this case +// the result is in the left twig. void SbiExprNode::FoldConstants() { @@ -272,10 +272,10 @@ void SbiExprNode::FoldConstants() { CollectBits(); if( eTok == CAT ) - // CAT verbindet auch zwei Zahlen miteinander! + // CAT affiliate also two numbers! eType = SbxSTRING; if( pLeft->eType == SbxSTRING ) - // Kein Type Mismatch! + // No Type Mismatch! eType = SbxSTRING; if( eType == SbxSTRING ) { @@ -287,7 +287,7 @@ void SbiExprNode::FoldConstants() if( eTok == PLUS || eTok == CAT ) { eTok = CAT; - // Verkettung: + // Linking: aStrVal = rl; aStrVal += rr; eType = SbxSTRING; @@ -333,7 +333,7 @@ void SbiExprNode::FoldConstants() if( ( eTok >= AND && eTok <= IMP ) || eTok == IDIV || eTok == MOD ) { - // Integer-Operationen + // Integer operations sal_Bool err = sal_False; if( nl > SbxMAXLNG ) err = sal_True, nl = SbxMAXLNG; else @@ -427,12 +427,11 @@ void SbiExprNode::FoldConstants() if( !::rtl::math::isFinite( nVal ) ) pGen->GetParser()->Error( SbERR_MATH_OVERFLOW ); - // Den Datentyp wiederherstellen, um Rundungsfehler - // zu killen + // Recover the data type to kill rounding error if( bCheckType && bBothInt && nVal >= SbxMINLNG && nVal <= SbxMAXLNG ) { - // NK-Stellen weg + // Decimal place away long n = (long) nVal; nVal = n; eType = ( n >= SbxMININT && n <= SbxMAXINT ) @@ -454,7 +453,7 @@ void SbiExprNode::FoldConstants() case NEG: nVal = -nVal; break; case NOT: { - // Integer-Operation! + // Integer operation! sal_Bool err = sal_False; if( nVal > SbxMAXLNG ) err = sal_True, nVal = SbxMAXLNG; else @@ -472,7 +471,7 @@ void SbiExprNode::FoldConstants() } if( eNodeType == SbxNUMVAL ) { - // Evtl auf INTEGER falten (wg. besserem Opcode)? + // Potentially convolve in INTEGER (because of better opcode)? if( eType == SbxSINGLE || eType == SbxDOUBLE ) { double x; @@ -486,3 +485,4 @@ void SbiExprNode::FoldConstants() } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/exprtree.cxx b/basic/source/comp/exprtree.cxx index 42b4bfa06aaf..31d285f89148 100644 --- a/basic/source/comp/exprtree.cxx +++ b/basic/source/comp/exprtree.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -252,7 +253,7 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo ) pvMoreParLcl = new SbiExprListVector(); SbiParameters* pAddPar = new SbiParameters( pParser ); pvMoreParLcl->push_back( pAddPar ); - bError |= !pPar->IsValid(); + bError |= !pAddPar->IsValid(); eTok = pParser->Peek(); } } @@ -373,8 +374,12 @@ SbiExprNode* SbiExpression::Term( const KeywordSymbolInfo* pKeywordSymbolInfo ) // Typ SbxOBJECT sein if( pDef->GetType() != SbxOBJECT && pDef->GetType() != SbxVARIANT ) { - pParser->Error( SbERR_BAD_DECLARATION, aSym ); - bError = sal_True; + // defer error until runtime if in vba mode + if ( !pParser->IsVBASupportOn() ) + { + pParser->Error( SbERR_BAD_DECLARATION, aSym ); + bError = sal_True; + } } if( !bError ) pNd->aVar.pNext = ObjTerm( *pDef ); @@ -402,13 +407,7 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj ) bError = sal_True; } } - /* #118410 Allow type for Class methods and RTL object, e.g. RTL.Chr$(97) - else - { - if( pParser->GetType() != SbxVARIANT ) - pParser->Error( SbERR_SYNTAX ), bError = sal_True; - } - */ + if( bError ) return NULL; @@ -468,7 +467,6 @@ SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj ) // Falls wir etwas mit Punkt einscannen, muss der // Typ SbxOBJECT sein - // AB, 3.1.96 // Es kann sein, dass pDef ein Objekt beschreibt, das bisher // nur als SbxVARIANT erkannt wurde, dann Typ von pDef aendern if( pDef->GetType() == SbxVARIANT ) @@ -735,6 +733,7 @@ SbiExprNode* SbiExpression::Comp() return pNd; } + SbiExprNode* SbiExpression::VBA_Not() { SbiExprNode* pNd = NULL; @@ -752,6 +751,93 @@ SbiExprNode* SbiExpression::VBA_Not() return pNd; } +SbiExprNode* SbiExpression::VBA_And() +{ + SbiExprNode* pNd = VBA_Not(); + if( m_eMode != EXPRMODE_EMPTY_PAREN ) + { + for( ;; ) + { + SbiToken eTok = pParser->Peek(); + if( eTok != AND ) + break; + eTok = pParser->Next(); + pNd = new SbiExprNode( pParser, pNd, eTok, VBA_Not() ); + } + } + return pNd; +} + +SbiExprNode* SbiExpression::VBA_Or() +{ + SbiExprNode* pNd = VBA_And(); + if( m_eMode != EXPRMODE_EMPTY_PAREN ) + { + for( ;; ) + { + SbiToken eTok = pParser->Peek(); + if( eTok != OR ) + break; + eTok = pParser->Next(); + pNd = new SbiExprNode( pParser, pNd, eTok, VBA_And() ); + } + } + return pNd; +} + +SbiExprNode* SbiExpression::VBA_Xor() +{ + SbiExprNode* pNd = VBA_Or(); + if( m_eMode != EXPRMODE_EMPTY_PAREN ) + { + for( ;; ) + { + SbiToken eTok = pParser->Peek(); + if( eTok != XOR ) + break; + eTok = pParser->Next(); + pNd = new SbiExprNode( pParser, pNd, eTok, VBA_Or() ); + } + } + return pNd; + +} + +SbiExprNode* SbiExpression::VBA_Eqv() +{ + SbiExprNode* pNd = VBA_Xor(); + if( m_eMode != EXPRMODE_EMPTY_PAREN ) + { + for( ;; ) + { + SbiToken eTok = pParser->Peek(); + if( eTok != EQV ) + break; + eTok = pParser->Next(); + pNd = new SbiExprNode( pParser, pNd, eTok, VBA_Xor() ); + } + } + return pNd; +} + +SbiExprNode* SbiExpression::VBA_Imp() +{ + SbiExprNode* pNd = VBA_Eqv(); + if( m_eMode != EXPRMODE_EMPTY_PAREN ) + { + for( ;; ) + { + SbiToken eTok = pParser->Peek(); + if( eTok != IMP ) + break; + eTok = pParser->Next(); + pNd = new SbiExprNode( pParser, pNd, eTok, VBA_Eqv() ); + } + } + return pNd; + +} + SbiExprNode* SbiExpression::Like() { SbiExprNode* pNd = pParser->IsVBASupportOn() ? VBA_Not() : Comp(); @@ -763,7 +849,7 @@ SbiExprNode* SbiExpression::Like() pNd = new SbiExprNode( pParser, pNd, eTok, Comp() ), nCount++; } // Mehrere Operatoren hintereinander gehen nicht - if( nCount > 1 ) + if( nCount > 1 && !pParser->IsVBASupportOn() ) { pParser->Error( SbERR_SYNTAX ); bError = sal_True; @@ -825,7 +911,6 @@ SbiConstExpression::SbiConstExpression( SbiParser* p ) : SbiExpression( p ) // Ist es eine sal_Bool-Konstante? sal_Bool bBoolVal = sal_False; if( pVarDef->GetName().EqualsIgnoreCaseAscii( "true" ) ) - //if( pVarDef->GetName().ICompare( "true" ) == COMPARE_EQUAL ) { bIsBool = sal_True; bBoolVal = sal_True; @@ -981,8 +1066,6 @@ SbiParameters::SbiParameters( SbiParser* p, sal_Bool bStandaloneExpression, sal_ if( eTok == COMMA ) { pExpr = new SbiExpression( pParser, 0, SbxEMPTY ); - //if( bConst ) - // pParser->Error( SbERR_SYNTAX ), bError = sal_True; } // Benannte Argumente: entweder .name= oder name:= else @@ -1029,8 +1112,6 @@ SbiParameters::SbiParameters( SbiParser* p, sal_Bool bStandaloneExpression, sal_ if( bByVal && pExpr->IsLvalue() ) pExpr->SetByVal(); - //pExpr = bConst ? new SbiConstExpression( pParser ) - // : new SbiExpression( pParser ); if( !bAssumeArrayMode ) { if( pParser->Peek() == ASSIGN ) @@ -1041,8 +1122,6 @@ SbiParameters::SbiParameters( SbiParser* p, sal_Bool bStandaloneExpression, sal_ delete pExpr; pParser->Next(); pExpr = new SbiExpression( pParser ); - //if( bConst ) - // pParser->Error( SbERR_SYNTAX ), bError = sal_True; } pExpr->GetName() = aName; } @@ -1161,3 +1240,4 @@ SbiDimList::SbiDimList( SbiParser* p ) : SbiExprList( p ) else pParser->Next(); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/io.cxx b/basic/source/comp/io.cxx index 958b34ee57ff..bc458e54305f 100644 --- a/basic/source/comp/io.cxx +++ b/basic/source/comp/io.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -144,27 +145,7 @@ void SbiParser::Line() void SbiParser::LineInput() { Channel( sal_True ); - // sal_Bool bChan = Channel( sal_True ); SbiExpression* pExpr = new SbiExpression( this, SbOPERAND ); - /* AB 15.1.96: Keinen allgemeinen Ausdruck mehr zulassen - SbiExpression* pExpr = new SbiExpression( this ); - if( !pExpr->IsVariable() ) - { - SbiToken eTok = Peek(); - if( eTok == COMMA || eTok == SEMICOLON ) Next(); - else Error( SbERR_EXPECTED, COMMA ); - // mit Prompt - if( !bChan ) - { - pExpr->Gen(); - aGen.Gen( _PROMPT ); - } - else - Error( SbERR_VAR_EXPECTED ); - delete pExpr; - pExpr = new SbiExpression( this, SbOPERAND ); - } - */ if( !pExpr->IsVariable() ) Error( SbERR_VAR_EXPECTED ); if( pExpr->GetType() != SbxVARIANT && pExpr->GetType() != SbxSTRING ) @@ -181,13 +162,7 @@ void SbiParser::Input() { aGen.Gen( _RESTART ); Channel( sal_True ); - // sal_Bool bChan = Channel( sal_True ); SbiExpression* pExpr = new SbiExpression( this, SbOPERAND ); - /* ALT: Jetzt keinen allgemeinen Ausdruck mehr zulassen - SbiExpression* pExpr = new SbiExpression( this ); - ... - siehe LineInput - */ while( !bAbort ) { if( !pExpr->IsVariable() ) @@ -234,7 +209,7 @@ void SbiParser::Open() { Next(); eTok = Next(); - // #27964# Nur STREAM_READ,STREAM_WRITE-Flags in nMode beeinflussen + // Nur STREAM_READ,STREAM_WRITE-Flags in nMode beeinflussen nMode &= ~(STREAM_READ | STREAM_WRITE); // loeschen if( eTok == READ ) { @@ -356,3 +331,4 @@ void SbiParser::Close() } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/loops.cxx b/basic/source/comp/loops.cxx index 02feb685c11f..c3e9159dac3b 100644 --- a/basic/source/comp/loops.cxx +++ b/basic/source/comp/loops.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -42,7 +43,7 @@ void SbiParser::If() TestToken( THEN ); if( IsEoln( Next() ) ) { - // AB 13.5.1996: #27720# Am Ende jeden Blocks muss ein Jump zu ENDIF + // Am Ende jeden Blocks muss ein Jump zu ENDIF // eingefuegt werden, damit bei ELSEIF nicht erneut die Bedingung // ausgewertet wird. Die Tabelle nimmt alle Absprungstellen auf. #define JMP_TABLE_SIZE 100 @@ -61,10 +62,9 @@ void SbiParser::If() Error( SbERR_BAD_BLOCK, IF ); bAbort = sal_True; return; } } - // ELSEIF? while( eTok == ELSEIF ) { - // #27720# Bei erfolgreichem IF/ELSEIF auf ENDIF springen + // Bei erfolgreichem IF/ELSEIF auf ENDIF springen if( iJmp >= JMP_TABLE_SIZE ) { Error( SbERR_PROG_TOO_LARGE ); bAbort = sal_True; return; @@ -104,7 +104,7 @@ void SbiParser::If() else if( eTok == ENDIF ) Next(); - // #27720# Jmp-Tabelle abarbeiten + // Jmp-Tabelle abarbeiten while( iJmp > 0 ) { iJmp--; @@ -316,8 +316,7 @@ void SbiParser::OnGoto() sal_uInt32 nLbl = 0; do { - SbiToken eTok2 = NIL; - eTok2 = Next(); // Label holen + Next(); // Label holen if( MayBeLabel() ) { sal_uInt32 nOff = pProc->GetLabels().Reference( aSym ); @@ -473,7 +472,6 @@ void SbiParser::On() SbiToken eTok = Peek(); String aString = SbiTokenizer::Symbol(eTok); if (aString.EqualsIgnoreCaseAscii("ERROR")) - //if (!aString.ICompare("ERROR")) eTok = _ERROR_; // Error kommt als SYMBOL if( eTok != _ERROR_ && eTok != LOCAL ) OnGoto(); else @@ -556,3 +554,4 @@ void SbiParser::Resume() } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/makefile.mk b/basic/source/comp/makefile.mk index 1e17b35cde61..146c832df97e 100644..100755 --- a/basic/source/comp/makefile.mk +++ b/basic/source/comp/makefile.mk @@ -35,17 +35,12 @@ TARGET=comp .INCLUDE : settings.mk SLOFILES= \ - $(SLO)$/buffer.obj \ - $(SLO)$/codegen.obj \ - $(SLO)$/dim.obj \ + $(EXCEPTIONSFILES) \ + $(SLO)$/buffer.obj \ $(SLO)$/exprgen.obj \ $(SLO)$/exprnode.obj \ - $(SLO)$/exprtree.obj \ - $(SLO)$/io.obj \ + $(SLO)$/io.obj \ $(SLO)$/loops.obj \ - $(SLO)$/parser.obj \ - $(SLO)$/sbcomp.obj \ - $(SLO)$/scanner.obj \ $(SLO)$/symtbl.obj \ $(SLO)$/token.obj @@ -54,6 +49,7 @@ EXCEPTIONSFILES= \ $(SLO)$/dim.obj \ $(SLO)$/exprtree.obj \ $(SLO)$/parser.obj \ + $(SLO)$/scanner.obj \ $(SLO)$/sbcomp.obj # --- Targets -------------------------------------------------------------- diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx index 670ca7384767..2ea78357882f 100644 --- a/basic/source/comp/parser.cxx +++ b/basic/source/comp/parser.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -49,6 +50,7 @@ struct SbiStatement { #define N sal_False static SbiStatement StmntTable [] = { +{ ATTRIBUTE, &SbiParser::Attribute, Y, Y, }, // ATTRIBUTE { CALL, &SbiParser::Call, N, Y, }, // CALL { CLOSE, &SbiParser::Close, N, Y, }, // CLOSE { _CONST_, &SbiParser::Dim, Y, Y, }, // CONST @@ -193,7 +195,6 @@ sal_Bool SbiParser::HasGlobalCode() { aGen.BackChain( nGblChain ); aGen.Gen( _LEAVE ); - // aGen.Gen( _STOP ); nGblChain = 0; } return bGblDefs; @@ -387,6 +388,18 @@ sal_Bool SbiParser::Parse() Next(); return sal_True; } + // In vba it's possible to do Error.foobar ( even if it results in + // a runtime error + if ( eCurTok == _ERROR_ && IsVBASupportOn() ) // we probably need to define a subset of keywords where this madness applies e.g. if ( IsVBASupportOn() && SymbolCanBeRedined( eCurTok ) ) + { + SbiTokenizer tokens( *(SbiTokenizer*)this ); + tokens.Next(); + if ( tokens.Peek() == DOT ) + { + eCurTok = SYMBOL; + ePush = eCurTok; + } + } // Kommt ein Symbol, ist es entweder eine Variable( LET ) // oder eine SUB-Prozedur( CALL ohne Klammern ) // DOT fuer Zuweisungen im WITH-Block: .A=5 @@ -501,7 +514,6 @@ void SbiParser::Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo ) if( aRtlName.EqualsIgnoreCaseAscii("Mid") ) { SbiExprNode* pExprNode = aVar.GetExprNode(); - // SbiNodeType eNodeType; if( pExprNode && pExprNode->GetNodeType() == SbxVARVAL ) { SbiExprList* pPar = pExprNode->GetParameters(); @@ -535,7 +547,6 @@ void SbiParser::Symbol( const KeywordSymbolInfo* pKeywordSymbolInfo ) SbiExpression aExpr( this ); aExpr.Gen(); SbiOpcode eOp = _PUT; - // SbiSymDef* pDef = aVar.GetRealVar(); if( pDef ) { if( pDef->GetConstDef() ) @@ -598,7 +609,6 @@ void SbiParser::Set() TypeDecl( *pTypeDef, sal_True ); aLvalue.Gen(); - // aGen.Gen( _CLASS, pDef->GetTypeId() | 0x8000 ); aGen.Gen( _CREATE, pDef->GetId(), pTypeDef->GetTypeId() ); aGen.Gen( _SETCLASS, pDef->GetTypeId() ); } @@ -627,7 +637,6 @@ void SbiParser::Set() aGen.Gen( _SET ); } } - // aGen.Gen( _SET ); } // JSM 07.10.95 @@ -681,7 +690,6 @@ void SbiParser::DefXXX() else { ch2 = aSym.ToUpperAscii().GetBuffer()[0]; - //ch2 = aSym.Upper(); if( ch2 < ch1 ) Error( SbERR_SYNTAX ), ch2 = 0; } } @@ -795,7 +803,7 @@ void SbiParser::Option() bClassModule = sal_True; aGen.GetModule().SetModuleType( com::sun::star::script::ModuleType::CLASS ); break; - case VBASUPPORT: + case VBASUPPORT: // Option VBASupport used to override the module mode ( in fact this must reset the mode if( Next() == NUMBER ) { if ( nVal == 1 || nVal == 0 ) @@ -861,3 +869,4 @@ void SbiParser::ErrorStmnt() aGen.Gen( _ERROR ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/sbcomp.cxx b/basic/source/comp/sbcomp.cxx index 1b3395b70526..86557db46699 100755..100644 --- a/basic/source/comp/sbcomp.cxx +++ b/basic/source/comp/sbcomp.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -31,24 +32,17 @@ #include <basic/sbx.hxx> #include "sbcomp.hxx" #include "image.hxx" -#include "sbtrace.hxx" #include <basic/sbobjmod.hxx> #include <stdio.h> -//========================================================================== -// Tracing, for debugging only - // To activate tracing enable in sbtrace.hxx #ifdef DBG_TRACE_BASIC -#include <hash_map> - // Trace ini file (set NULL to ignore) // can be overridden with the environment variable OOO_BASICTRACEINI static char GpTraceIniFile[] = "~/BasicTrace.ini"; //static char* GpTraceIniFile = NULL; - // Trace Settings, used if no ini file / not found in ini file static char GpTraceFileNameDefault[] = "~/BasicTrace.txt"; static char* GpTraceFileName = GpTraceFileNameDefault; @@ -909,75 +903,6 @@ void RTL_Impl_TraceCommand( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite ) #endif - -//========================================================================== -// For debugging only -//#define DBG_SAVE_DISASSEMBLY - -#ifdef DBG_SAVE_DISASSEMBLY -static bool dbg_bDisassemble = true; -#include <comphelper/processfactory.hxx> - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/ucb/XSimpleFileAccess3.hpp> -#include <com/sun/star/io/XTextOutputStream.hpp> -#include <com/sun/star/io/XActiveDataSource.hpp> - -using namespace comphelper; -using namespace rtl; -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::ucb; -using namespace com::sun::star::io; - -void dbg_SaveDisassembly( SbModule* pModule ) -{ - bool bDisassemble = dbg_bDisassemble; - if( bDisassemble ) - { - Reference< XSimpleFileAccess3 > xSFI; - Reference< XTextOutputStream > xTextOut; - Reference< XOutputStream > xOut; - Reference< XMultiServiceFactory > xSMgr = getProcessServiceFactory(); - if( xSMgr.is() ) - { - Reference< XSimpleFileAccess3 > xSFI = Reference< XSimpleFileAccess3 >( xSMgr->createInstance - ( OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY ); - if( xSFI.is() ) - { - String aFile( RTL_CONSTASCII_USTRINGPARAM("file:///d:/zBasic.Asm/Asm_") ); - StarBASIC* pBasic = (StarBASIC*)pModule->GetParent(); - if( pBasic ) - { - aFile += pBasic->GetName(); - aFile.AppendAscii( "_" ); - } - aFile += pModule->GetName(); - aFile.AppendAscii( ".txt" ); - - // String aFile( RTL_CONSTASCII_USTRINGPARAM("file:///d:/BasicAsm.txt") ); - if( xSFI->exists( aFile ) ) - xSFI->kill( aFile ); - xOut = xSFI->openFileWrite( aFile ); - Reference< XInterface > x = xSMgr->createInstance( OUString::createFromAscii( "com.sun.star.io.TextOutputStream" ) ); - Reference< XActiveDataSource > xADS( x, UNO_QUERY ); - xADS->setOutputStream( xOut ); - xTextOut = Reference< XTextOutputStream >( x, UNO_QUERY ); - } - } - - if( xTextOut.is() ) - { - String aDisassemblyStr; - pModule->Disassemble( aDisassemblyStr ); - xTextOut->writeString( aDisassemblyStr ); - } - xOut->closeOutput(); - } -} -#endif - - // Diese Routine ist hier definiert, damit der Compiler als eigenes Segment // geladen werden kann. @@ -1031,14 +956,6 @@ sal_Bool SbModule::Compile() } } -#ifdef DBG_SAVE_DISASSEMBLY - dbg_SaveDisassembly( this ); -#endif - -#ifdef DBG_TRACE_BASIC - lcl_PrepareTraceForModule( this ); -#endif - return bRet; } @@ -1054,3 +971,4 @@ void StarBASIC::Highlight( const String& rSrc, SbTextPortions& rList ) aTok.Hilite( rList ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx index ad94bbe842c8..11c081d1b4b2 100644 --- a/basic/source/comp/scanner.cxx +++ b/basic/source/comp/scanner.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -318,8 +319,6 @@ sal_Bool SbiScanner::NextSym() { pLine++; nCol++; continue; } -// if( toupper( *pLine ) == 'D' ) -// eScanType = SbxDOUBLE; *p++ = 'E'; pLine++; nCol++; // Vorzeichen hinter Exponent? if( *pLine == '+' ) @@ -344,7 +343,6 @@ sal_Bool SbiScanner::NextSym() // #57844 Lokalisierte Funktion benutzen nVal = rtl_math_uStringToDouble( buf, buf+(p-buf), '.', ',', NULL, NULL ); - // ALT: nVal = atof( buf ); ndig = ndig - comma; if( !comma && !exp ) @@ -357,12 +355,6 @@ sal_Bool SbiScanner::NextSym() } if( bBufOverflow ) GenError( SbERR_MATH_OVERFLOW ); - // zu viele Zahlen fuer SINGLE? -// if (ndig > 15 || ncdig > 6) -// eScanType = SbxDOUBLE; -// else -// if( nVal > SbxMAXSNG || nVal < SbxMINSNG ) -// eScanType = SbxDOUBLE; // Typkennung? SbxDataType t = GetSuffixType( *pLine ); @@ -381,7 +373,6 @@ sal_Bool SbiScanner::NextSym() sal_Unicode cmp1[] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F', 0 }; sal_Unicode cmp2[] = { '0', '1', '2', '3', '4', '5', '6', '7', 0 }; sal_Unicode *cmp = cmp1; - //char *cmp = "0123456789ABCDEF"; sal_Unicode base = 16; sal_Unicode ndig = 8; sal_Unicode xch = *pLine++ & 0xFF; nCol++; @@ -389,7 +380,6 @@ sal_Bool SbiScanner::NextSym() { case 'O': cmp = cmp2; base = 8; ndig = 11; break; - //cmp = "01234567"; base = 8; ndig = 11; break; case 'H': break; default : @@ -618,3 +608,5 @@ bool LetterTable::isLetterUnicode( sal_Unicode c ) bool bRet = pCharClass->isLetter( aStr, 0 ); return bRet; } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx index cc6dc04fde65..128c4acf52fc 100644 --- a/basic/source/comp/symtbl.cxx +++ b/basic/source/comp/symtbl.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -400,7 +401,6 @@ SbiSymScope SbiSymDef::GetScope() const return pIn ? pIn->GetScope() : SbLOCAL; } -//////////////////////////////////////////////////////////////////////////// // Die Prozedur-Definition hat drei Pools: // 1) aParams: wird durch die Definition gefuellt. Enthaelt die Namen @@ -501,7 +501,7 @@ void SbiProcDef::setPropertyMode( PropertyMode ePropMode ) case PROPERTY_MODE_LET: aCompleteProcName.AppendAscii( "Let " ); break; case PROPERTY_MODE_SET: aCompleteProcName.AppendAscii( "Set " ); break; case PROPERTY_MODE_NONE: - DBG_ERROR( "Illegal PropertyMode PROPERTY_MODE_NONE" ); + OSL_FAIL( "Illegal PropertyMode PROPERTY_MODE_NONE" ); break; } aCompleteProcName += aName; @@ -510,7 +510,6 @@ void SbiProcDef::setPropertyMode( PropertyMode ePropMode ) } -////////////////////////////////////////////////////////////////////////// SbiConstDef::SbiConstDef( const String& rName ) : SbiSymDef( rName ) @@ -536,3 +535,4 @@ SbiConstDef* SbiConstDef::GetConstDef() return this; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/comp/token.cxx b/basic/source/comp/token.cxx index 28c90ff0bd87..df387eabc102 100644 --- a/basic/source/comp/token.cxx +++ b/basic/source/comp/token.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -58,6 +59,7 @@ static TokenTable aTokTable_Basic [] = { // Token-Tabelle: { ANY, "Any" }, { APPEND, "Append" }, { AS, "As" }, + { ATTRIBUTE,"Attribute" }, { BASE, "Base" }, { BINARY, "Binary" }, { TBOOLEAN, "Boolean" }, @@ -191,168 +193,6 @@ static TokenTable aTokTable_Basic [] = { // Token-Tabelle: { NIL, "" } }; -/* -TokenTable aTokTable_Java [] = { // Token-Tabelle: - - { JS_LOG_NOT, "!" }, - { JS_NE, "!=" }, - { JS_MOD, "%" }, - { JS_ASS_MOD, "%=" }, - { JS_BIT_AND, "&" }, - { JS_LOG_AND, "&&" }, - { JS_ASS_AND, "&=" }, - { JS_LPAREN, "(" }, - { JS_RPAREN, ")" }, - { JS_MUL, "*" }, - { JS_ASS_MUL, "*=" }, - { JS_PLUS, "+" }, - { JS_INC, "++" }, - { JS_ASS_PLUS, "+=" }, - { JS_COMMA, "," }, - { JS_MINUS, "-" }, - { JS_DEC, "--" }, - { JS_ASS_MINUS, "-=" }, - { JS_DIV, "/" }, - { JS_ASS_DIV, "/=" }, - { JS_COND_SEL, ":" }, - { JS_LT, "<" }, - { JS_LSHIFT, "<<" }, - { JS_ASS_LSHIFT,"<<=" }, - { JS_LE, "<=" }, - { JS_NE, "<>" }, - { JS_ASSIGNMENT,"=" }, - { JS_EQ, "==" }, - { JS_GT, ">" }, - { JS_RSHIFT, ">>" }, - { JS_ASS_RSHIFT,">>=" }, - { JS_RSHIFT_Z, ">>>" }, - { JS_ASS_RSHIFT_Z,">>>=" }, - { JS_GE, ">=" }, - { JS_COND_QUEST,"?" }, - { ACCESS, "Access" }, - { ALIAS, "Alias" }, - { AND, "And" }, - { ANY, "Any" }, - { APPEND, "Append" }, - { AS, "As" }, - { BASE, "Base" }, - { BINARY, "Binary" }, - { TBOOLEAN, "Boolean" }, - { BYVAL, "ByVal", }, - { CALL, "Call" }, - { CASE, "Case" }, - { _CDECL_, "Cdecl" }, - { CLOSE, "Close" }, - { COMPARE, "Compare" }, - { _CONST_, "Const" }, - { TCURRENCY,"Currency" }, - { TDATE, "Date" }, - { DECLARE, "Declare" }, - { DEFBOOL, "DefBool" }, - { DEFCUR, "DefCur" }, - { DEFDATE, "DefDate" }, - { DEFDBL, "DefDbl" }, - { DEFERR, "DefErr" }, - { DEFINT, "DefInt" }, - { DEFLNG, "DefLng" }, - { DEFOBJ, "DefObj" }, - { DEFSNG, "DefSng" }, - { DEFSTR, "DefStr" }, - { DEFVAR, "DefVar" }, - { DIM, "Dim" }, - { DO, "Do" }, - { TDOUBLE, "Double" }, - { EACH, "Each" }, - { ELSE, "Else" }, - { ELSEIF, "ElseIf" }, - { END, "End" }, - { ENDFUNC, "End Function" }, - { ENDIF, "End If" }, - { ENDSELECT,"End Select" }, - { ENDSUB, "End Sub" }, - { ENDTYPE, "End Type" }, - { ENDIF, "EndIf" }, - { EQV, "Eqv" }, - { ERASE, "Erase" }, - { _ERROR_, "Error" }, - { EXIT, "Exit" }, - { EXPLICIT, "Explicit" }, - { FOR, "For" }, - { FUNCTION, "Function" }, - { GLOBAL, "Global" }, - { GOSUB, "GoSub" }, - { GOTO, "GoTo" }, - { IF, "If" }, - { IMP, "Imp" }, - { _IN_, "In" }, - { INPUT, "Input" }, // auch INPUT # - { TINTEGER, "Integer" }, - { IS, "Is" }, - { LET, "Let" }, - { LIB, "Lib" }, - { LINE, "Line" }, - { LINEINPUT,"Line Input" }, - { LOCAL, "Local" }, - { LOCK, "Lock" }, - { TLONG, "Long" }, - { LOOP, "Loop" }, - { LPRINT, "LPrint" }, - { LSET, "LSet" }, // JSM - { MOD, "Mod" }, - { NAME, "Name" }, - { NEW, "New" }, - { NEXT, "Next" }, - { NOT, "Not" }, - { TOBJECT, "Object" }, - { ON, "On" }, - { OPEN, "Open" }, - { OPTION, "Option" }, - { _OPTIONAL_, "Optional" }, - { OR, "Or" }, - { OUTPUT, "Output" }, - { PRESERVE, "Preserve" }, - { PRINT, "Print" }, - { PRIVATE, "Private" }, - { PUBLIC, "Public" }, - { RANDOM, "Random" }, - { READ, "Read" }, - { REDIM, "ReDim" }, - { REM, "Rem" }, - { RESUME, "Resume" }, - { RETURN, "Return" }, - { RSET, "RSet" }, // JSM - { SELECT, "Select" }, - { SET, "Set" }, - { SHARED, "Shared" }, - { TSINGLE, "Single" }, - { STATIC, "Static" }, - { STEP, "Step" }, - { STOP, "Stop" }, - { TSTRING, "String" }, - { SUB, "Sub" }, - { STOP, "System" }, - { TEXT, "Text" }, - { THEN, "Then" }, - { TO, "To", }, - { TYPE, "Type" }, - { UNTIL, "Until" }, - { TVARIANT, "Variant" }, - { WEND, "Wend" }, - { WHILE, "While" }, - { WITH, "With" }, - { WRITE, "Write" }, // auch WRITE # - { XOR, "Xor" }, - { JS_LINDEX, "[" }, - { JS_RINDEX, "]" }, - { JS_BIT_XOR, "^" }, - { JS_ASS_XOR, "^=" }, - { JS_BIT_OR, "|" }, - { JS_ASS_OR, "|=" }, - { JS_LOG_OR, "||" }, - { JS_BIT_NOT, "~" }, - { NIL } -}; -*/ // #i109076 TokenLabelInfo::TokenLabelInfo( void ) @@ -383,8 +223,6 @@ SbiTokenizer::SbiTokenizer( const ::rtl::OUString& rSrc, StarBASIC* pb ) : SbiScanner( rSrc, pb ) { pTokTable = aTokTable_Basic; - //if( StarBASIC::GetGlobalLanguageMode() == SB_LANG_JAVASCRIPT ) - // pTokTable = aTokTable_Java; TokenTable *tp; bEof = bAs = sal_False; eCurTok = NIL; @@ -716,3 +554,4 @@ void SbiTokenizer::Hilite( SbTextPortions& rList ) bUsedForHilite = sal_False; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/buffer.hxx b/basic/source/inc/buffer.hxx index 4c14cac05791..24c4bc002f60 100644 --- a/basic/source/inc/buffer.hxx +++ b/basic/source/inc/buffer.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -61,3 +62,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx index 9ba99e7ceae8..0f5699803945 100644 --- a/basic/source/inc/codegen.hxx +++ b/basic/source/inc/codegen.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -91,3 +92,5 @@ public: #define PARAM_INFO_WITHBRACKETS 0x0020000 #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/collelem.hxx b/basic/source/inc/collelem.hxx index cd1787d6ff01..2c39e711f993 100644 --- a/basic/source/inc/collelem.hxx +++ b/basic/source/inc/collelem.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -45,3 +46,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/disas.hxx b/basic/source/inc/disas.hxx index 2d85dc5d1365..1756d36bfacf 100644 --- a/basic/source/inc/disas.hxx +++ b/basic/source/inc/disas.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -70,3 +71,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/dlgcont.hxx b/basic/source/inc/dlgcont.hxx index 2c927a8286f4..94c10ca86b2e 100644 --- a/basic/source/inc/dlgcont.hxx +++ b/basic/source/inc/dlgcont.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,9 +31,7 @@ #include "namecont.hxx" -#ifndef _COM_SUN_STAR_AWT_XSTRINGRESOURCESUPPLIER_HPP_ #include <com/sun/star/resource/XStringResourceSupplier.hpp> -#endif #include "com/sun/star/resource/XStringResourcePersistence.hpp" #include <cppuhelper/implbase1.hxx> @@ -96,7 +95,9 @@ public: throw (::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); - + // XLibraryQueryExecutable + virtual sal_Bool SAL_CALL HasExecutableCode(const rtl::OUString&) + throw (::com::sun::star::uno::RuntimeException); // Service static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_static(); static ::rtl::OUString getImplementationName_static(); @@ -173,3 +174,4 @@ protected: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/errobject.hxx b/basic/source/inc/errobject.hxx index 39e6e319caae..1e94a3927e93 100644 --- a/basic/source/inc/errobject.hxx +++ b/basic/source/inc/errobject.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -50,3 +51,5 @@ public: throw (com::sun::star::uno::RuntimeException); }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/expr.hxx b/basic/source/inc/expr.hxx index 28a84094d918..0ae218d14c18 100644 --- a/basic/source/inc/expr.hxx +++ b/basic/source/inc/expr.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -189,6 +190,11 @@ protected: SbiExprNode* Cat(); SbiExprNode* Like(); SbiExprNode* VBA_Not(); + SbiExprNode* VBA_And(); + SbiExprNode* VBA_Or(); + SbiExprNode* VBA_Xor(); + SbiExprNode* VBA_Eqv(); + SbiExprNode* VBA_Imp(); SbiExprNode* Comp(); SbiExprNode* Boolean(); public: @@ -265,3 +271,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/filefmt.hxx b/basic/source/inc/filefmt.hxx index 2b3b3eafbf65..caf6131aa9dd 100644 --- a/basic/source/inc/filefmt.hxx +++ b/basic/source/inc/filefmt.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -167,7 +168,6 @@ class SvStream; // sal_uInt16 Anzahl Objekte // .... Objektdaten -//////////////////////////////////////////////////////////////////////////// // Service-Routinen (in IMAGE.CXX) @@ -176,3 +176,5 @@ sal_uIntPtr SbOpenRecord( SvStream&, sal_uInt16 nSignature, sal_uInt16 nElem ); void SbCloseRecord( SvStream&, sal_uIntPtr ); #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/image.hxx b/basic/source/inc/image.hxx index b2d863acc52b..0f0ffdf7df9a 100644 --- a/basic/source/inc/image.hxx +++ b/basic/source/inc/image.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,7 @@ #define _SBIMAGE_HXX #include "sbintern.hxx" -#ifndef _RTL_USTRING_HXX #include <rtl/ustring.hxx> -#endif #include <filefmt.hxx> // Diese Klasse liest das vom Compiler erzeugte Image ein und verwaltet @@ -88,7 +87,6 @@ public: ::rtl::OUString& GetSource32() { return aOUSource; } sal_uInt16 GetBase() const { return nDimBase; } String GetString( short nId ) const; - //const char* GetString( short nId ) const; const SbxObject* FindType (String aTypeName) const; SbxArrayRef GetEnums() { return rEnums; } @@ -108,3 +106,5 @@ public: #define SBIMG_CLASSMODULE 0x0008 // OPTION ClassModule is active #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/iosys.hxx b/basic/source/inc/iosys.hxx index 1308e0289b9f..48d6ce39d506 100644 --- a/basic/source/inc/iosys.hxx +++ b/basic/source/inc/iosys.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,7 @@ #define _SBIOSYS_HXX #include <tools/stream.hxx> -#ifndef _SBERRORS_HXX #include <basic/sberrors.hxx> -#endif class SvStream; @@ -111,3 +110,4 @@ public: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx index c0e8191be307..c05890b8cd90 100644 --- a/basic/source/inc/namecont.hxx +++ b/basic/source/inc/namecont.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,14 +29,14 @@ #ifndef BASIC_NAMECONTAINER_HXX #define BASIC_NAMECONTAINER_HXX -#include <hash_map> - +#include <boost/unordered_map.hpp> #include <com/sun/star/lang/XSingleServiceFactory.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp> #include <com/sun/star/script/XLibraryContainerPassword.hpp> #include <com/sun/star/script/XLibraryContainerExport.hpp> +#include <com/sun/star/script/XLibraryQueryExecutable.hpp> #include <com/sun/star/script/XLibraryContainer3.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XContainer.hpp> @@ -65,22 +66,43 @@ #include <sot/storage.hxx> #include <comphelper/listenernotification.hxx> #include <xmlscript/xmllib_imexp.hxx> +#include <com/sun/star/deployment/XPackage.hpp> + +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/compbase8.hxx> +#include <cppuhelper/compbase9.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <com/sun/star/script/vba/XVBACompatibility.hpp> class BasicManager; namespace basic { -//============================================================================ +typedef ::cppu::WeakComponentImplHelper9< + ::com::sun::star::lang::XInitialization, + ::com::sun::star::script::XStorageBasedLibraryContainer, + ::com::sun::star::script::XLibraryContainerPassword, + ::com::sun::star::script::XLibraryContainerExport, + ::com::sun::star::script::XLibraryContainer3, + ::com::sun::star::container::XContainer, + ::com::sun::star::script::XLibraryQueryExecutable, + ::com::sun::star::script::vba::XVBACompatibility, + ::com::sun::star::lang::XServiceInfo > LibraryContainerHelper; + +typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer, + ::com::sun::star::container::XContainer > NameContainerHelper; typedef ::cppu::WeakImplHelper3< ::com::sun::star::container::XNameContainer, ::com::sun::star::container::XContainer, ::com::sun::star::util::XChangesNotifier > NameContainer_BASE; +//============================================================================ + class NameContainer : public ::cppu::BaseMutex, public NameContainer_BASE { - typedef std::hash_map< ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > NameContainerNameMap; + typedef boost::unordered_map < ::rtl::OUString, sal_Int32, ::rtl::OUStringHash > NameContainerNameMap; NameContainerNameMap mHashMap; ::com::sun::star::uno::Sequence< ::rtl::OUString > mNames; @@ -224,6 +246,7 @@ class SfxLibraryContainer : public SfxLibraryContainer_BASE, public ::utl::OEven VBAScriptListenerContainer maVBAScriptListeners; sal_Int32 mnRunningVBAScripts; sal_Bool mbVBACompat; + rtl::OUString msProjectName; protected: ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > mxSFI; @@ -518,10 +541,10 @@ public: virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0; // Methods XVBACompatibility - virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() - throw (::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) - throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Bool SAL_CALL getVBACompatibilityMode() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setVBACompatibilityMode( ::sal_Bool _vbacompatmodeon ) throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getProjectName() throw (::com::sun::star::uno::RuntimeException) { return msProjectName; } + virtual void SAL_CALL setProjectName( const ::rtl::OUString& _projectname ) throw (::com::sun::star::uno::RuntimeException); virtual sal_Int32 SAL_CALL getRunningVBAScripts() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addVBAScriptListener( @@ -794,3 +817,4 @@ protected: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/object.hxx b/basic/source/inc/object.hxx index aa39eba72ef3..52af24b2b994 100644 --- a/basic/source/inc/object.hxx +++ b/basic/source/inc/object.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,7 @@ #define _SAMPLE_OBJECT_HXX #include <basic/sbxfac.hxx> -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif #include <basic/sbxobj.hxx> // 1) Properties: @@ -56,12 +55,12 @@ using SbxVariable::GetInfo; // Definition eines Tabelleneintrags. Dies wird hier gemacht, // da dadurch die Methoden und Properties als private deklariert // werden koennen. -#if defined ( ICC ) || defined ( HPUX ) || defined ( C50 ) || defined ( C52 ) +#if defined ( ICC ) || defined ( C50 ) public: #endif typedef void( SampleObject::*pMeth ) ( SbxVariable* pThis, SbxArray* pArgs, sal_Bool bWrite ); -#if defined ( ICC ) || defined ( HPUX ) +#if defined ( ICC ) private: #endif @@ -98,3 +97,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/opcodes.hxx b/basic/source/inc/opcodes.hxx index ff7eff027f83..156ef8bd625a 100644 --- a/basic/source/inc/opcodes.hxx +++ b/basic/source/inc/opcodes.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,10 +31,6 @@ #include "sbintern.hxx" -#ifdef MTW -#undef _NUMBER -#endif - // Ein Opcode ist entweder 1, 3 oder 5 Bytes lang, je nach numerischen // Wert des Opcodes (s.u.). @@ -94,7 +91,8 @@ enum SbiOpcode { _ERASE_CLEAR, // Erase array and clear variable _ARRAYACCESS, // Assign parameters to TOS and get value, used for array of arrays _BYVAL, // byref -> byval for lvalue parameter passed in call - SbOP0_END, + + SbOP0_END = _BYVAL, // Alle Opcodes mit einem Operanden @@ -128,7 +126,8 @@ enum SbiOpcode { // Typanpassung im Argv _ARGTYP, // Letzten Parameter in Argv konvertieren (+Typ) _VBASETCLASS, // VBA-like Set - SbOP1_END, + + SbOP1_END = _VBASETCLASS, // Alle Opcodes mit zwei Operanden @@ -163,10 +162,9 @@ enum SbiOpcode { _PUBLIC_P, // Module global Variable (persisted between calls)(+StringID+Typ) _FIND_STATIC, // local static var lookup (+StringID+Typ) - SbOP2_END - + SbOP2_END = _FIND_STATIC }; - - #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/parser.hxx b/basic/source/inc/parser.hxx index 62f7da1b4303..1b58e5d39f0b 100644 --- a/basic/source/inc/parser.hxx +++ b/basic/source/inc/parser.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -107,6 +108,7 @@ public: void BadSyntax(); // Falsches SbiToken void NoIf(); // ELSE/ELSE IF ohne IF void Assign(); // LET + void Attribute(); // Attribute void Call(); // CALL void Close(); // CLOSE void Declare(); // DECLARE @@ -151,3 +153,5 @@ public: #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/propacc.hxx b/basic/source/inc/propacc.hxx index 262a2cf8935d..1497bbc0df9d 100644 --- a/basic/source/inc/propacc.hxx +++ b/basic/source/inc/propacc.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,21 +29,11 @@ #define _SFX_PROPBAG_HXX #include <svl/svarray.hxx> -#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HXX_ #include <com/sun/star/beans/PropertyValue.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HXX_ #include <com/sun/star/beans/XPropertySet.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HXX_ #include <com/sun/star/beans/XPropertySetInfo.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HXX_ #include <com/sun/star/beans/XPropertyAccess.hpp> -#endif -#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HXX_ #include <com/sun/star/beans/XPropertyContainer.hpp> -#endif #include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase2.hxx> @@ -201,3 +192,4 @@ void RTL_Impl_CreatePropertySet( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWr #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index 406bd487034c..855af7fa1eb7 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,16 +29,10 @@ #ifndef _SBRUNTIME_HXX #define _SBRUNTIME_HXX -#ifndef _SBX_HXX #include <basic/sbx.hxx> -#endif #include "sb.hxx" -// Define activates class UCBStream in iosys.cxx -#define _USE_UNO - -#ifdef _USE_UNO #include <rtl/ustring.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <osl/file.hxx> @@ -54,16 +49,6 @@ using namespace com::sun::star::lang; using namespace com::sun::star::container; -// Define activates old file implementation -// (only in non UCB case) -// #define _OLD_FILE_IMPL - - -//#include <sal/types.h> -//#include <rtl/byteseq.hxx> -//#include <rtl/ustring> - - namespace basicEncoder { @@ -72,16 +57,10 @@ class AsciiEncoder { public: static ::rtl::OUString decodeUnoUrlParamValue(const rtl::OUString & rSource); - //static ::rtl::OUString encodeUnoUrlParamValue(const rtl::OUString & rSource); - //static ::rtl::ByteSequence decode(const ::rtl::OUString & string); - //static ::rtl::OUString encode(const ::rtl::ByteSequence & bytes); - //static void test(); }; } -#endif /* _USE_UNO */ - class SbiInstance; // aktiver StarBASIC-Prozess class SbiRuntime; // aktive StarBASIC-Prozedur-Instanz @@ -151,20 +130,14 @@ class SbiRTLData { public: -#ifdef _OLD_FILE_IMPL - Dir* pDir; -#else ::osl::Directory* pDir; -#endif sal_Int16 nDirFlags; short nCurDirPos; String sFullNameToBeChecked; WildCard* pWildCard; -#ifdef _USE_UNO Sequence< ::rtl::OUString > aDirSeq; -#endif /* _USE_UNO */ SbiRTLData(); ~SbiRTLData(); @@ -203,7 +176,6 @@ class SbiInstance sal_Bool bCompatibility; // Flag: sal_True = VBA runtime compatibility mode ComponentVector_t ComponentVector; - public: SbiRuntime* pRun; // Call-Stack SbiInstance* pNext; // Instanzen-Chain @@ -251,7 +223,7 @@ public: sal_uInt32 GetStdTimeIdx() const { return nStdTimeIdx; } sal_uInt32 GetStdDateTimeIdx() const { return nStdDateTimeIdx; } - // #39629# NumberFormatter auch statisch anbieten + // NumberFormatter auch statisch anbieten static void PrepareNumberFormatter( SvNumberFormatter*& rpNumberFormatter, sal_uInt32 &rnStdDateIdx, sal_uInt32 &rnStdTimeIdx, sal_uInt32 &rnStdDateTimeIdx, LanguageType* peFormatterLangType=NULL, DateFormat* peFormatterDateFormat=NULL ); @@ -294,7 +266,9 @@ class SbiRuntime SbxArrayRef refExprStk; // expression stack SbxArrayRef refCaseStk; // CASE expression stack SbxArrayRef refRedimpArray; // Array saved to use for REDIM PRESERVE + SbxVariableRef refRedim; // Array saved to use for REDIM SbxVariableRef xDummyVar; // Ersatz fuer nicht gefundene Variablen + SbxVariable* mpExtCaller; // Caller ( external - e.g. button name, shape, range object etc. - only in vba mode ) SbiArgvStack* pArgvStk; // ARGV-Stack SbiGosubStack* pGosubStk; // GOSUB stack SbiForStack* pForStk; // FOR/NEXT-Stack @@ -311,8 +285,7 @@ class SbiRuntime SbxArrayRef refParams; // aktuelle Prozedur-Parameter SbxArrayRef refLocals; // lokale Variable SbxArrayRef refArgv; // aktueller Argv - // AB, 28.3.2000 #74254, Ein refSaveObj reicht nicht! Neu: pRefSaveList (s.u.) - //SbxVariableRef refSaveObj; // #56368 Bei StepElem Referenz sichern + // #74254, Ein refSaveObj reicht nicht! Neu: pRefSaveList (s.u.) short nArgc; // aktueller Argc sal_Bool bRun; // sal_True: Programm ist aktiv sal_Bool bError; // sal_True: Fehler behandeln @@ -385,8 +358,7 @@ class SbiRuntime // #56204 DIM-Funktionalitaet in Hilfsmethode auslagern (step0.cxx) void DimImpl( SbxVariableRef refVar ); - // #115829 - bool implIsClass( SbxObject* pObj, const String& aClass ); + bool implIsClass( SbxObject* pObj, const ::rtl::OUString& aClass ); void StepSETCLASS_impl( sal_uInt32 nOp1, bool bHandleDflt = false ); @@ -418,7 +390,7 @@ class SbiRuntime void StepGOSUB( sal_uInt32 ), StepRETURN( sal_uInt32 ); void StepTESTFOR( sal_uInt32 ), StepCASETO( sal_uInt32 ), StepERRHDL( sal_uInt32 ); void StepRESUME( sal_uInt32 ), StepSETCLASS( sal_uInt32 ), StepVBASETCLASS( sal_uInt32 ), StepTESTCLASS( sal_uInt32 ), StepLIB( sal_uInt32 ); - bool checkClass_Impl( const SbxVariableRef& refVal, const String& aClass, bool bRaiseErrors, bool bDefault = true ); + bool checkClass_Impl( const SbxVariableRef& refVal, const ::rtl::OUString& aClass, bool bRaiseErrors, bool bDefault = true ); void StepCLOSE( sal_uInt32 ), StepPRCHAR( sal_uInt32 ), StepARGTYP( sal_uInt32 ); // Alle Opcodes mit zwei Operanden void StepRTL( sal_uInt32, sal_uInt32 ), StepPUBLIC( sal_uInt32, sal_uInt32 ), StepPUBLIC_P( sal_uInt32, sal_uInt32 ); @@ -464,6 +436,7 @@ public: SbMethod* GetCaller(); SbxArray* GetLocals(); SbxArray* GetParams(); + SbxVariable* GetExternalCaller(){ return mpExtCaller; } SbiForStack* FindForStackItemForCollection( class BasicCollection* pCollection ); @@ -532,3 +505,4 @@ bool IsBaseIndexOne(); #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbcomp.hxx b/basic/source/inc/sbcomp.hxx index 6335a55da62f..2918e67880f0 100644 --- a/basic/source/inc/sbcomp.hxx +++ b/basic/source/inc/sbcomp.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -36,3 +37,5 @@ #include "codegen.hxx" // Code-Generator #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbintern.hxx b/basic/source/inc/sbintern.hxx index 41296e865032..34d08f6e8c21 100644 --- a/basic/source/inc/sbintern.hxx +++ b/basic/source/inc/sbintern.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -148,3 +149,4 @@ SbiGlobals* GetSbData(); #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbjsmeth.hxx b/basic/source/inc/sbjsmeth.hxx index 80c301821884..f2cc8a3d3865 100644 --- a/basic/source/inc/sbjsmeth.hxx +++ b/basic/source/inc/sbjsmeth.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -51,3 +52,5 @@ SV_DECL_IMPL_REF(SbJScriptMethod) #endif #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbjsmod.hxx b/basic/source/inc/sbjsmod.hxx index b4f680231f93..55091dc681c5 100644 --- a/basic/source/inc/sbjsmod.hxx +++ b/basic/source/inc/sbjsmod.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -48,3 +49,4 @@ public: +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/sbtrace.hxx b/basic/source/inc/sbtrace.hxx index 6ab27050d263..1f450d542b5d 100755..100644 --- a/basic/source/inc/sbtrace.hxx +++ b/basic/source/inc/sbtrace.hxx @@ -46,12 +46,12 @@ #ifdef DBG_TRACE_BASIC void dbg_InitTrace( void ); void dbg_DeInitTrace( void ); -void dbg_traceStep( SbModule* pModule, sal_uInt32 nPC, sal_Int32 nCallLvl ); -void dbg_traceNotifyCall( SbModule* pModule, SbMethod* pMethod, sal_Int32 nCallLvl, bool bLeave = false ); -void dbg_traceNotifyError( SbError nTraceErr, const String& aTraceErrMsg, bool bTraceErrHandled, sal_Int32 nCallLvl ); -void dbg_RegisterTraceTextForPC( SbModule* pModule, sal_uInt32 nPC, +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, sal_Bool bWrite ); +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 5c9d58e8ce55..cc0f03903f17 100644 --- a/basic/source/inc/sbunoobj.hxx +++ b/basic/source/inc/sbunoobj.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -31,9 +32,7 @@ #include <basic/sbxmeth.hxx> #include <basic/sbxprop.hxx> #include <basic/sbxfac.hxx> -#ifndef __SBX_SBX_HXX //autogen #include <basic/sbx.hxx> -#endif #include <com/sun/star/beans/XMaterialHolder.hpp> #include <com/sun/star/beans/XExactName.hpp> #include <com/sun/star/beans/XIntrospectionAccess.hpp> @@ -43,6 +42,8 @@ #include <com/sun/star/reflection/XServiceTypeDescription2.hpp> #include <com/sun/star/reflection/XSingletonTypeDescription.hpp> #include <rtl/ustring.hxx> +#include <boost/unordered_map.hpp> +#include <vector> class SbUnoObject: public SbxObject { @@ -63,9 +64,9 @@ class SbUnoObject: public SbxObject void implCreateAll( void ); public: - static bool getDefaultPropName( SbUnoObject* pUnoObj, String& sDfltProp ); + static bool getDefaultPropName( SbUnoObject* pUnoObj, ::rtl::OUString& sDfltProp ); TYPEINFO(); - SbUnoObject( const String& aName_, const ::com::sun::star::uno::Any& aUnoObj_ ); + SbUnoObject( const ::rtl::OUString& aName_, const ::com::sun::star::uno::Any& aUnoObj_ ); ~SbUnoObject(); // #76470 Introspection on Demand durchfuehren @@ -114,7 +115,7 @@ class SbUnoMethod : public SbxMethod public: TYPEINFO(); - SbUnoMethod( const String& aName_, SbxDataType eSbxType, ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlMethod > xUnoMethod_, + SbUnoMethod( const rtl::OUString& aName_, SbxDataType eSbxType, ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlMethod > xUnoMethod_, bool bInvocation, bool bDirect = false ); virtual ~SbUnoMethod(); @@ -142,7 +143,7 @@ class SbUnoProperty : public SbxProperty virtual ~SbUnoProperty(); public: TYPEINFO(); - SbUnoProperty( const String& aName_, SbxDataType eSbxType, + SbUnoProperty( const rtl::OUString& aName_, SbxDataType eSbxType, const ::com::sun::star::beans::Property& aUnoProp_, sal_Int32 nId_, bool bInvocation ); bool isInvocationBased( void ) @@ -171,7 +172,6 @@ public: : SbxObject( aName_ ) , m_xClass( xClass_ ) {} - //~SbUnoClass(); // Find ueberladen, um Elemente on Demand anzulegen virtual SbxVariable* Find( const String&, SbxClassType ); @@ -179,14 +179,13 @@ public: // Wert rausgeben const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XIdlClass >& getUnoClass( void ) { return m_xClass; } - //void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); }; SV_DECL_IMPL_REF(SbUnoClass); // Funktion, um einen globalen Bezeichner im // UnoScope zu suchen und fuer Sbx zu wrappen -SbUnoClass* findUnoClass( const String& rName ); +SbUnoClass* findUnoClass( const ::rtl::OUString& rName ); // Wrapper for UNO Service @@ -210,7 +209,7 @@ public: }; SV_DECL_IMPL_REF(SbUnoService); -SbUnoService* findUnoService( const String& rName ); +SbUnoService* findUnoService( const ::rtl::OUString& rName ); void clearUnoServiceCtors( void ); @@ -228,7 +227,7 @@ class SbUnoServiceCtor : public SbxMethod public: TYPEINFO(); - SbUnoServiceCtor( const String& aName_, ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceConstructorDescription > xServiceCtorDesc ); + SbUnoServiceCtor( const::rtl::OUString& aName_, ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XServiceConstructorDescription > xServiceCtorDesc ); virtual ~SbUnoServiceCtor(); virtual SbxInfo* GetInfo(); @@ -244,14 +243,14 @@ class SbUnoSingleton : public SbxObject public: TYPEINFO(); - SbUnoSingleton( const String& aName_, + SbUnoSingleton( const ::rtl::OUString& aName_, const ::com::sun::star::uno::Reference< ::com::sun::star::reflection::XSingletonTypeDescription >& xSingletonTypeDesc ); void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& ); }; SV_DECL_IMPL_REF(SbUnoSingleton); -SbUnoSingleton* findUnoSingleton( const String& rName ); +SbUnoSingleton* findUnoSingleton( const ::rtl::OUString& rName ); // #105565 Special Object to wrap a strongly typed Uno Any @@ -333,6 +332,27 @@ public: virtual void Clear(); }; +typedef boost::unordered_map< ::rtl::OUString, ::com::sun::star::uno::Any, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > VBAConstantsHash; + +typedef std::vector< rtl::OUString > VBAConstantsVector; + +class VBAConstantHelper +{ +private: + + VBAConstantsVector aConstCache; + VBAConstantsHash aConstHash; + bool isInited; + VBAConstantHelper():isInited( false ) {} + VBAConstantHelper(const VBAConstantHelper&); + void init(); +public: + static VBAConstantHelper& instance(); + SbxVariable* getVBAConstant( const ::rtl::OUString& rName ); + bool isVBAConstantType( const ::rtl::OUString& rName ); +}; + #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/scanner.hxx b/basic/source/inc/scanner.hxx index 0c2c27f72b2f..5abfc1efdd3c 100644 --- a/basic/source/inc/scanner.hxx +++ b/basic/source/inc/scanner.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,7 @@ #define _SCANNER_HXX #include <tools/string.hxx> -#ifndef _SBERRORS_HXX #include <basic/sberrors.hxx> -#endif // Der Scanner ist stand-alone, d.h. er kann von ueberallher verwendet // werden. Eine BASIC-Instanz ist fuer Fehlermeldungen notwendig. Ohne @@ -144,3 +143,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/scriptcont.hxx b/basic/source/inc/scriptcont.hxx index 9ef4c41c6ce3..89e4f7f648df 100644 --- a/basic/source/inc/scriptcont.hxx +++ b/basic/source/inc/scriptcont.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -123,7 +124,9 @@ public: throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); - + // XLibraryQueryExecutable + virtual sal_Bool SAL_CALL HasExecutableCode(const rtl::OUString&) + throw (::com::sun::star::uno::RuntimeException); // Methods XServiceInfo virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); @@ -140,6 +143,7 @@ public: }; //============================================================================ +typedef boost::unordered_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > ModuleInfoMap; typedef ::cppu::ImplHelper1< ::com::sun::star::script::vba::XVBAModuleInfo > SfxScriptLibrary_BASE; @@ -147,7 +151,7 @@ class SfxScriptLibrary : public SfxLibrary, public SfxScriptLibrary_BASE { friend class SfxScriptLibraryContainer; - typedef std::hash_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash > ModuleInfoMap; + typedef boost::unordered_map< ::rtl::OUString, ::com::sun::star::script::ModuleInfo, ::rtl::OUStringHash > ModuleInfoMap; sal_Bool mbLoadedSource; sal_Bool mbLoadedBinary; @@ -199,3 +203,4 @@ protected: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/stdobj.hxx b/basic/source/inc/stdobj.hxx index cdf3209624fb..7abaf47492f1 100644 --- a/basic/source/inc/stdobj.hxx +++ b/basic/source/inc/stdobj.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -49,3 +50,5 @@ public: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx index 576639dc5a45..a52d8c499a07 100644 --- a/basic/source/inc/symtbl.hxx +++ b/basic/source/inc/symtbl.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -44,7 +45,6 @@ class SbiParser; enum SbiSymScope { SbLOCAL, SbPARAM, SbPUBLIC, SbGLOBAL, SbRTL }; -/////////////////////////////////////////////////////////////////////////// // Der String-Pool nimmt String-Eintraege auf und sorgt dafuer, // dass sie nicht doppelt vorkommen. @@ -67,7 +67,6 @@ public: SbiParser* GetParser() { return pParser; } }; -/////////////////////////////////////////////////////////////////////////// SV_DECL_PTRARR_DEL(SbiSymbols,SbiSymDef*,5,5) @@ -108,7 +107,6 @@ public: void CheckRefs(); // offene Referenzen suchen }; -/////////////////////////////////////////////////////////////////////////// class SbiSymDef { // Allgemeiner Symboleintrag friend class SbiSymPool; @@ -251,3 +249,4 @@ public: #endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/inc/token.hxx b/basic/source/inc/token.hxx index 3af2e235c077..deb6764f2e2c 100644 --- a/basic/source/inc/token.hxx +++ b/basic/source/inc/token.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,9 +30,7 @@ #define _TOKEN_HXX #include "scanner.hxx" -#ifndef _SBDEF_HXX #include <basic/sbdef.hxx> -#endif #if defined( SHARED ) #define SbiTokenSHAREDTMPUNDEF @@ -72,7 +71,7 @@ enum SbiToken { IF, _IN_, INPUT, LET, LINE, LINEINPUT, LOCAL, LOOP, LPRINT, LSET, NAME, NEW, NEXT, - ON, OPEN, OPTION, IMPLEMENTS, + ON, OPEN, OPTION, ATTRIBUTE, IMPLEMENTS, PRINT, PRIVATE, PROPERTY, PUBLIC, REDIM, REM, RESUME, RETURN, RSET, SELECT, SET, SHARED, STATIC, STEP, STOP, SUB, @@ -181,3 +180,5 @@ public: #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/basrdll.cxx b/basic/source/runtime/basrdll.cxx index 0cf81e30d9a6..910ecce98f72 100644 --- a/basic/source/runtime/basrdll.cxx +++ b/basic/source/runtime/basrdll.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -102,3 +103,4 @@ void BasicDLL::BasicBreak() } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/ddectrl.cxx b/basic/source/runtime/ddectrl.cxx index 5e8775159c38..75fcd7f4d725 100644 --- a/basic/source/runtime/ddectrl.cxx +++ b/basic/source/runtime/ddectrl.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,9 +31,7 @@ #include <tools/errcode.hxx> #include <svl/svdde.hxx> #include "ddectrl.hxx" -#ifndef _SBERRORS_HXX #include <basic/sberrors.hxx> -#endif #define DDE_FREECHANNEL ((DdeConnection*)0xffffffff) @@ -82,32 +81,26 @@ IMPL_LINK_INLINE( SbiDdeControl,Data , DdeData*, pData, SbiDdeControl::SbiDdeControl() { - pConvList = new DdeConnections; - DdeConnection* pPtr = DDE_FREECHANNEL; - pConvList->Insert( pPtr ); } SbiDdeControl::~SbiDdeControl() { TerminateAll(); - delete pConvList; } sal_Int16 SbiDdeControl::GetFreeChannel() { - sal_Int16 nListSize = (sal_Int16)pConvList->Count(); - DdeConnection* pPtr = pConvList->First(); - pPtr = pConvList->Next(); // nullten eintrag ueberspringen - sal_Int16 nChannel; - for( nChannel = 1; nChannel < nListSize; nChannel++ ) + sal_Int16 nChannel = 0; + sal_Int16 nListSize = static_cast<sal_Int16>(aConvList.size()); + + for (; nChannel < nListSize; ++nChannel) { - if( pPtr == DDE_FREECHANNEL ) - return nChannel; - pPtr = pConvList->Next(); + if (aConvList[nChannel] == DDE_FREECHANNEL) + return nChannel+1; } - pPtr = DDE_FREECHANNEL; - pConvList->Insert( pPtr, LIST_APPEND ); - return nChannel; + + aConvList.push_back(DDE_FREECHANNEL); + return nChannel+1; } SbError SbiDdeControl::Initiate( const String& rService, const String& rTopic, @@ -124,42 +117,52 @@ SbError SbiDdeControl::Initiate( const String& rService, const String& rTopic, else { sal_Int16 nChannel = GetFreeChannel(); - pConvList->Replace( pConv, (sal_uIntPtr)nChannel ); + aConvList[nChannel-1] = pConv; rnHandle = nChannel; } return 0; } -SbError SbiDdeControl::Terminate( sal_Int16 nChannel ) +SbError SbiDdeControl::Terminate( sal_uInt16 nChannel ) { - DdeConnection* pConv = pConvList->GetObject( (sal_uIntPtr)nChannel ); - if( !nChannel || !pConv || pConv == DDE_FREECHANNEL ) + if (!nChannel || nChannel > aConvList.size()) + return SbERR_DDE_NO_CHANNEL; + + DdeConnection* pConv = aConvList[nChannel-1]; + + if( pConv == DDE_FREECHANNEL ) return SbERR_DDE_NO_CHANNEL; - pConvList->Replace( DDE_FREECHANNEL, (sal_uIntPtr)nChannel ); + delete pConv; + pConv = DDE_FREECHANNEL; + return 0L; } SbError SbiDdeControl::TerminateAll() { - sal_Int16 nChannel = (sal_Int16)pConvList->Count(); - while( nChannel ) + DdeConnection *conv; + for (sal_uInt16 nChannel = 0; nChannel < aConvList.size(); ++nChannel) { - nChannel--; - Terminate( nChannel ); + conv = aConvList[nChannel]; + + if (conv != DDE_FREECHANNEL) + delete conv; } - pConvList->Clear(); - DdeConnection* pPtr = DDE_FREECHANNEL; - pConvList->Insert( pPtr ); + aConvList.clear(); return 0; } -SbError SbiDdeControl::Request( sal_Int16 nChannel, const String& rItem, String& rResult ) +SbError SbiDdeControl::Request( sal_uInt16 nChannel, const String& rItem, String& rResult ) { - DdeConnection* pConv = pConvList->GetObject( (sal_uIntPtr)nChannel ); - if( !nChannel || !pConv || pConv == DDE_FREECHANNEL ) + if (!nChannel || nChannel > aConvList.size()) + return SbERR_DDE_NO_CHANNEL; + + DdeConnection* pConv = aConvList[nChannel-1]; + + if( pConv == DDE_FREECHANNEL ) return SbERR_DDE_NO_CHANNEL; DdeRequest aRequest( *pConv, rItem, 30000 ); @@ -169,24 +172,35 @@ SbError SbiDdeControl::Request( sal_Int16 nChannel, const String& rItem, String& return GetLastErr( pConv ); } -SbError SbiDdeControl::Execute( sal_Int16 nChannel, const String& rCommand ) +SbError SbiDdeControl::Execute( sal_uInt16 nChannel, const String& rCommand ) { - DdeConnection* pConv = pConvList->GetObject( (sal_uIntPtr)nChannel ); - if( !nChannel || !pConv || pConv == DDE_FREECHANNEL ) + if (!nChannel || nChannel > aConvList.size()) return SbERR_DDE_NO_CHANNEL; + + DdeConnection* pConv = aConvList[nChannel-1]; + + if( pConv == DDE_FREECHANNEL ) + return SbERR_DDE_NO_CHANNEL; + DdeExecute aRequest( *pConv, rCommand, 30000 ); aRequest.Execute(); return GetLastErr( pConv ); } -SbError SbiDdeControl::Poke( sal_Int16 nChannel, const String& rItem, const String& rData ) +SbError SbiDdeControl::Poke( sal_uInt16 nChannel, const String& rItem, const String& rData ) { - DdeConnection* pConv = pConvList->GetObject( (sal_uIntPtr)nChannel ); - if( !nChannel || !pConv || pConv == DDE_FREECHANNEL ) + if (!nChannel || nChannel > aConvList.size()) return SbERR_DDE_NO_CHANNEL; + + DdeConnection* pConv = aConvList[nChannel-1]; + + if( pConv == DDE_FREECHANNEL ) + return SbERR_DDE_NO_CHANNEL; + DdePoke aRequest( *pConv, rItem, DdeData(rData), 30000 ); aRequest.Execute(); return GetLastErr( pConv ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/ddectrl.hxx b/basic/source/runtime/ddectrl.hxx index a99575308fa8..c71611e8c32d 100644 --- a/basic/source/runtime/ddectrl.hxx +++ b/basic/source/runtime/ddectrl.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,13 +30,10 @@ #define _DDECTRL_HXX #include <tools/link.hxx> -#ifndef _SBERRORS_HXX #include <basic/sberrors.hxx> -#endif #include <tools/string.hxx> class DdeConnection; -class DdeConnections; class DdeData; class SbiDdeControl @@ -44,7 +42,7 @@ private: DECL_LINK( Data, DdeData* ); SbError GetLastErr( DdeConnection* ); sal_Int16 GetFreeChannel(); - DdeConnections* pConvList; + std::vector<DdeConnection*> aConvList; String aData; public: @@ -54,11 +52,13 @@ public: SbError Initiate( const String& rService, const String& rTopic, sal_Int16& rnHandle ); - SbError Terminate( sal_Int16 nChannel ); + SbError Terminate( sal_uInt16 nChannel ); SbError TerminateAll(); - SbError Request( sal_Int16 nChannel, const String& rItem, String& rResult ); - SbError Execute( sal_Int16 nChannel, const String& rCommand ); - SbError Poke( sal_Int16 nChannel, const String& rItem, const String& rData ); + SbError Request( sal_uInt16 nChannel, const String& rItem, String& rResult ); + SbError Execute( sal_uInt16 nChannel, const String& rCommand ); + SbError Poke( sal_uInt16 nChannel, const String& rItem, const String& rData ); }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/workben/basmgr.src b/basic/source/runtime/dllmgr-none.cxx index f89c719c2399..bde3db062116 100644 --- a/basic/workben/basmgr.src +++ b/basic/source/runtime/dllmgr-none.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -24,8 +25,44 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#pragma CHARSET_IBMPC -String 300 { - Text = "Dummy"; -}; +#include "precompiled_basic.hxx" +#include "sal/config.h" + +#if defined(WNT) +#include <windows.h> +#undef GetObject +#endif + +#include <algorithm> +#include <cstddef> +#include <list> +#include <map> +#include <vector> + +#include "basic/sbx.hxx" +#include "basic/sbxvar.hxx" +#include "osl/thread.h" +#include "rtl/ref.hxx" +#include "rtl/string.hxx" +#include "rtl/ustring.hxx" +#include "salhelper/simplereferenceobject.hxx" + +#include "dllmgr.hxx" + +struct SbiDllMgr::Impl {}; + +SbError SbiDllMgr::Call( + rtl::OUString const &, rtl::OUString const &, SbxArray *, SbxVariable &, + bool) +{ + return ERRCODE_BASIC_NOT_IMPLEMENTED; +} + +void SbiDllMgr::FreeDll(rtl::OUString const &) {} + +SbiDllMgr::SbiDllMgr(): impl_(new Impl) {} + +SbiDllMgr::~SbiDllMgr() {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/dllmgr-x64.cxx b/basic/source/runtime/dllmgr-x64.cxx new file mode 100644 index 000000000000..f38e587a3fa0 --- /dev/null +++ b/basic/source/runtime/dllmgr-x64.cxx @@ -0,0 +1,776 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * 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 "sal/config.h" + +#if defined(WNT) +#include <windows.h> +#undef GetObject +#endif + +#include <algorithm> +#include <cstddef> +#include <list> +#include <map> +#include <vector> + +#include "basic/sbx.hxx" +#include "basic/sbxvar.hxx" +#include "osl/thread.h" +#include "rtl/ref.hxx" +#include "rtl/string.hxx" +#include "rtl/ustring.hxx" +#include "salhelper/simplereferenceobject.hxx" + +#undef max + +#include "dllmgr.hxx" + +/* Open issues: + + Missing support for functions returning structs (see TODO in call()). + + Missing support for additional data types (64 bit integers, Any, ...; would + trigger OSL_ASSERT(false) in various switches). + + It is assumed that the variables passed into SbiDllMgr::Call to represent + the arguments and return value have types that exactly match the Declare + statement; it would be better if this code had access to the function + signature from the Declare statement, so that it could convert the passed + variables accordingly. +*/ + +namespace { + +char * address(std::vector< char > & blob) { + return blob.empty() ? 0 : &blob[0]; +} + +SbError convert(rtl::OUString const & source, rtl::OString * target) { + return + source.convertToString( + target, osl_getThreadTextEncoding(), + (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | + RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)) + ? ERRCODE_NONE : ERRCODE_BASIC_BAD_ARGUMENT; + //TODO: more specific errcode? +} + +SbError convert(char const * source, sal_Int32 length, rtl::OUString * target) { + return + rtl_convertStringToUString( + &target->pData, source, length, osl_getThreadTextEncoding(), + (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)) + ? ERRCODE_NONE : ERRCODE_BASIC_BAD_ARGUMENT; + //TODO: more specific errcode? +} + +struct UnmarshalData { + UnmarshalData(SbxVariable * theVariable, void * theBuffer): + variable(theVariable), buffer(theBuffer) {} + + SbxVariable * variable; + void * buffer; +}; + +struct StringData: public UnmarshalData { + StringData(SbxVariable * theVariable, void * theBuffer, bool theSpecial): + UnmarshalData(theVariable, theBuffer), special(theSpecial) {} + + bool special; +}; + +class MarshalData: private boost::noncopyable { +public: + std::vector< char > * newBlob() { + blobs_.push_front(std::vector< char >()); + return &blobs_.front(); + } + + std::vector< UnmarshalData > unmarshal; + + std::vector< StringData > unmarshalStrings; + +private: + std::list< std::vector< char > > blobs_; +}; + +std::size_t align(std::size_t address, std::size_t alignment) { + // alignment = 2^k for some k >= 0 + return (address + (alignment - 1)) & ~(alignment - 1); +} + +char * align( + std::vector< char > & blob, std::size_t alignment, std::size_t offset, + std::size_t add) +{ + std::vector< char >::size_type n = blob.size(); + n = align(n - offset, alignment) + offset; //TODO: overflow in align() + blob.resize(n + add); //TODO: overflow + return address(blob) + n; +} + +template< typename T > void add( + std::vector< char > & blob, T const & data, std::size_t alignment, + std::size_t offset) +{ + *reinterpret_cast< T * >(align(blob, alignment, offset, sizeof (T))) = data; +} + +std::size_t alignment(SbxVariable * variable) { + OSL_ASSERT(variable != 0); + if ((variable->GetType() & SbxARRAY) == 0) { + switch (variable->GetType()) { + case SbxINTEGER: + return 2; + case SbxLONG: + case SbxSINGLE: + case SbxSTRING: + return 4; + case SbxDOUBLE: + return 8; + case SbxOBJECT: + { + std::size_t n = 1; + SbxArray * props = PTR_CAST(SbxObject, variable->GetObject())-> + GetProperties(); + for (sal_uInt16 i = 0; i < props->Count(); ++i) { + n = std::max(n, alignment(props->Get(i))); + } + return n; + } + case SbxBOOL: + case SbxBYTE: + return 1; + default: + OSL_ASSERT(false); + return 1; + } + } else { + SbxDimArray * arr = PTR_CAST(SbxDimArray, variable->GetObject()); + int dims = arr->GetDims(); + std::vector< sal_Int32 > low(dims); + for (int i = 0; i < dims; ++i) { + sal_Int32 up; + arr->GetDim32(i + 1, low[i], up); + } + return alignment(arr->Get32(&low[0])); + } +} + +SbError marshal( + bool outer, SbxVariable * variable, bool special, + std::vector< char > & blob, std::size_t offset, MarshalData & data); + +SbError marshalString( + SbxVariable * variable, bool special, MarshalData & data, void ** buffer) +{ + OSL_ASSERT(variable != 0 && buffer != 0); + rtl::OString str; + SbError e = convert(variable->GetString(), &str); + if (e != ERRCODE_NONE) { + return e; + } + std::vector< char > * blob = data.newBlob(); + blob->insert(blob->begin(), str.getStr(), str.getStr() + str.getLength() + 1); + *buffer = address(*blob); + data.unmarshalStrings.push_back(StringData(variable, *buffer, special)); + return ERRCODE_NONE; +} + +SbError marshalStruct( + SbxVariable * variable, std::vector< char > & blob, std::size_t offset, + MarshalData & data) +{ + OSL_ASSERT(variable != 0); + SbxArray * props = PTR_CAST(SbxObject, variable->GetObject())-> + GetProperties(); + for (sal_uInt16 i = 0; i < props->Count(); ++i) { + SbError e = marshal(false, props->Get(i), false, blob, offset, data); + if (e != ERRCODE_NONE) { + return e; + } + } + return ERRCODE_NONE; +} + +SbError marshalArray( + SbxVariable * variable, std::vector< char > & blob, std::size_t offset, + MarshalData & data) +{ + OSL_ASSERT(variable != 0); + SbxDimArray * arr = PTR_CAST(SbxDimArray, variable->GetObject()); + int dims = arr->GetDims(); + std::vector< sal_Int32 > low(dims); + std::vector< sal_Int32 > up(dims); + for (int i = 0; i < dims; ++i) { + arr->GetDim32(i + 1, low[i], up[i]); + } + for (std::vector< sal_Int32 > idx = low;;) { + SbError e = marshal( + false, arr->Get32(&idx[0]), false, blob, offset, data); + if (e != ERRCODE_NONE) { + return e; + } + int i = dims - 1; + while (idx[i] == up[i]) { + idx[i] = low[i]; + if (i == 0) { + return ERRCODE_NONE; + } + --i; + } + ++idx[i]; + } +} + +// 8-aligned structs are only 4-aligned on stack, so alignment of members in +// such structs must take that into account via "offset" +SbError marshal( + bool outer, SbxVariable * variable, bool special, + std::vector< char > & blob, std::size_t offset, MarshalData & data) +{ + OSL_ASSERT(variable != 0); + if ((variable->GetFlags() & SBX_REFERENCE) == 0) { + if ((variable->GetType() & SbxARRAY) == 0) { + switch (variable->GetType()) { + case SbxINTEGER: + add(blob, variable->GetInteger(), outer ? 8 : 2, offset); + break; + case SbxLONG: + add(blob, variable->GetLong(), outer ? 8 : 4, offset); + break; + case SbxSINGLE: + add(blob, variable->GetSingle(), outer ? 8 : 4, offset); + break; + case SbxDOUBLE: + add(blob, variable->GetDouble(), 8, offset); + break; + case SbxSTRING: + { + void * p; + SbError e = marshalString(variable, special, data, &p); + if (e != ERRCODE_NONE) { + return e; + } + add(blob, p, 8, offset); + break; + } + case SbxOBJECT: + { + align(blob, outer ? 8 : alignment(variable), offset, 0); + SbError e = marshalStruct(variable, blob, offset, data); + if (e != ERRCODE_NONE) { + return e; + } + break; + } + case SbxBOOL: + add(blob, variable->GetBool(), outer ? 8 : 1, offset); + break; + case SbxBYTE: + add(blob, variable->GetByte(), outer ? 8 : 1, offset); + break; + default: + OSL_ASSERT(false); + break; + } + } else { + SbError e = marshalArray(variable, blob, offset, data); + if (e != ERRCODE_NONE) { + return e; + } + } + } else { + if ((variable->GetType() & SbxARRAY) == 0) { + switch (variable->GetType()) { + case SbxINTEGER: + case SbxLONG: + case SbxSINGLE: + case SbxDOUBLE: + case SbxBOOL: + case SbxBYTE: + add(blob, variable->data(), 8, offset); + break; + case SbxSTRING: + { + std::vector< char > * blob2 = data.newBlob(); + void * p; + SbError e = marshalString(variable, special, data, &p); + if (e != ERRCODE_NONE) { + return e; + } + add(*blob2, p, 8, 0); + add(blob, address(*blob2), 8, offset); + break; + } + case SbxOBJECT: + { + std::vector< char > * blob2 = data.newBlob(); + SbError e = marshalStruct(variable, *blob2, 0, data); + if (e != ERRCODE_NONE) { + return e; + } + void * p = address(*blob2); + if (outer) { + data.unmarshal.push_back(UnmarshalData(variable, p)); + } + add(blob, p, 8, offset); + break; + } + default: + OSL_ASSERT(false); + break; + } + } else { + std::vector< char > * blob2 = data.newBlob(); + SbError e = marshalArray(variable, *blob2, 0, data); + if (e != ERRCODE_NONE) { + return e; + } + void * p = address(*blob2); + if (outer) { + data.unmarshal.push_back(UnmarshalData(variable, p)); + } + add(blob, p, 8, offset); + } + } + return ERRCODE_NONE; +} + +template< typename T > T read(void const ** pointer) { + T const * p = static_cast< T const * >(*pointer); + *pointer = static_cast< void const * >(p + 1); + return *p; +} + +void const * unmarshal(SbxVariable * variable, void const * data) { + OSL_ASSERT(variable != 0); + if ((variable->GetType() & SbxARRAY) == 0) { + switch (variable->GetType()) { + case SbxINTEGER: + variable->PutInteger(read< sal_Int16 >(&data)); + break; + case SbxLONG: + variable->PutLong(read< sal_Int32 >(&data)); + break; + case SbxSINGLE: + variable->PutSingle(read< float >(&data)); + break; + case SbxDOUBLE: + variable->PutDouble(read< double >(&data)); + break; + case SbxSTRING: + read< char * >(&data); // handled by unmarshalString + break; + case SbxOBJECT: + { + data = reinterpret_cast< void const * >( + align( + reinterpret_cast< sal_uIntPtr >(data), + alignment(variable))); + SbxArray * props = PTR_CAST(SbxObject, variable->GetObject())-> + GetProperties(); + for (sal_uInt16 i = 0; i < props->Count(); ++i) { + data = unmarshal(props->Get(i), data); + } + break; + } + case SbxBOOL: + variable->PutBool(read< sal_Bool >(&data)); + break; + case SbxBYTE: + variable->PutByte(read< sal_uInt8 >(&data)); + break; + default: + OSL_ASSERT(false); + break; + } + } else { + SbxDimArray * arr = PTR_CAST(SbxDimArray, variable->GetObject()); + int dims = arr->GetDims(); + std::vector< sal_Int32 > low(dims); + std::vector< sal_Int32 > up(dims); + for (int i = 0; i < dims; ++i) { + arr->GetDim32(i + 1, low[i], up[i]); + } + for (std::vector< sal_Int32 > idx = low;;) { + data = unmarshal(arr->Get32(&idx[0]), data); + int i = dims - 1; + while (idx[i] == up[i]) { + idx[i] = low[i]; + if (i == 0) { + goto done; + } + --i; + } + ++idx[i]; + } + done:; + } + return data; +} + +SbError unmarshalString(StringData const & data, SbxVariable & result) { + rtl::OUString str; + if (data.buffer != 0) { + char const * p = static_cast< char const * >(data.buffer); + sal_Int32 len; + if (data.special) { + len = static_cast< sal_Int32 >(result.GetULong()); + if (len < 0) { // i.e., DWORD result >= 2^31 + return ERRCODE_BASIC_BAD_ARGUMENT; + //TODO: more specific errcode? + } + } else { + len = rtl_str_getLength(p); + } + SbError e = convert(p, len, &str); + if (e != ERRCODE_NONE) { + return e; + } + } + data.variable->PutString(String(str)); + return ERRCODE_NONE; +} + +struct ProcData { + rtl::OString name; + FARPROC proc; +}; + +SbError call( + rtl::OUString const & dll, ProcData const & proc, SbxArray * arguments, + SbxVariable & result) +{ + if (arguments->Count() > 20) + return ERRCODE_BASIC_NOT_IMPLEMENTED; + + std::vector< char > stack; + MarshalData data; + + // For DWORD GetLogicalDriveStringsA(DWORD nBufferLength, LPSTR lpBuffer) + // from kernel32, upon return, filled lpBuffer length is result DWORD, which + // requires special handling in unmarshalString; other functions might + // require similar treatment, too: + bool special = + dll.equalsIgnoreAsciiCaseAsciiL( + RTL_CONSTASCII_STRINGPARAM("KERNEL32.DLL")) && + (proc.name == + rtl::OString(RTL_CONSTASCII_STRINGPARAM("GetLogicalDriveStringsA"))); + for (int i = 1; i < (arguments == 0 ? 0 : arguments->Count()); ++i) { + SbError e = marshal( + true, arguments->Get(i), special && i == 2, stack, stack.size(), + data); + if (e != ERRCODE_NONE) { + return e; + } + align(stack, 8, 0, 0); + } + + stack.resize(20*8); + + // We fake all calls as being to a varargs function, + // as this means any floating-point argument among the first four + // ones will end up in a XMM register where the callee expects it. + sal_Int32 (*proc_i)(double d, ...) = (sal_Int32 (*)(double, ...)) proc.proc; + double (*proc_d)(double d, ...) = (double (*)(double, ...)) proc.proc; + + sal_Int64 iRetVal; + double dRetVal; + + switch (result.GetType()) { + case SbxEMPTY: + case SbxINTEGER: + case SbxLONG: + case SbxSTRING: + case SbxOBJECT: + case SbxBOOL: + case SbxBYTE: + iRetVal = + proc_i(*(double *)&stack[0*8], + *(double *)&stack[1*8], + *(double *)&stack[2*8], + *(double *)&stack[3*8], + *(sal_uInt64 *)&stack[4*8], + *(sal_uInt64 *)&stack[5*8], + *(sal_uInt64 *)&stack[6*8], + *(sal_uInt64 *)&stack[7*8], + *(sal_uInt64 *)&stack[8*8], + *(sal_uInt64 *)&stack[9*8], + *(sal_uInt64 *)&stack[10*8], + *(sal_uInt64 *)&stack[11*8], + *(sal_uInt64 *)&stack[12*8], + *(sal_uInt64 *)&stack[13*8], + *(sal_uInt64 *)&stack[14*8], + *(sal_uInt64 *)&stack[15*8], + *(sal_uInt64 *)&stack[16*8], + *(sal_uInt64 *)&stack[17*8], + *(sal_uInt64 *)&stack[18*8], + *(sal_uInt64 *)&stack[19*8]); + break; + case SbxSINGLE: + case SbxDOUBLE: + dRetVal = + proc_d(*(double *)&stack[0*8], + *(double *)&stack[1*8], + *(double *)&stack[2*8], + *(double *)&stack[3*8], + *(sal_uInt64 *)&stack[4*8], + *(sal_uInt64 *)&stack[5*8], + *(sal_uInt64 *)&stack[6*8], + *(sal_uInt64 *)&stack[7*8], + *(sal_uInt64 *)&stack[8*8], + *(sal_uInt64 *)&stack[9*8], + *(sal_uInt64 *)&stack[10*8], + *(sal_uInt64 *)&stack[11*8], + *(sal_uInt64 *)&stack[12*8], + *(sal_uInt64 *)&stack[13*8], + *(sal_uInt64 *)&stack[14*8], + *(sal_uInt64 *)&stack[15*8], + *(sal_uInt64 *)&stack[16*8], + *(sal_uInt64 *)&stack[17*8], + *(sal_uInt64 *)&stack[18*8], + *(sal_uInt64 *)&stack[19*8]); + } + + switch (result.GetType()) { + case SbxEMPTY: + break; + case SbxINTEGER: + result.PutInteger(static_cast< sal_Int16 >(iRetVal)); + break; + case SbxLONG: + result.PutLong(static_cast< sal_Int32 >(iRetVal)); + break; + case SbxSINGLE: + result.PutSingle(static_cast< float >(dRetVal)); + break; + case SbxDOUBLE: + result.PutDouble(dRetVal); + break; + case SbxSTRING: + { + char const * s1 = reinterpret_cast< char const * >(iRetVal); + rtl::OUString s2; + SbError e = convert(s1, rtl_str_getLength(s1), &s2); + if (e != ERRCODE_NONE) { + return e; + } + result.PutString(String(s2)); + break; + } + case SbxOBJECT: + //TODO + break; + case SbxBOOL: + result.PutBool(static_cast< sal_Bool >(iRetVal)); + break; + case SbxBYTE: + result.PutByte(static_cast< sal_uInt8 >(iRetVal)); + break; + default: + OSL_ASSERT(false); + break; + } + for (int i = 1; i < (arguments == 0 ? 0 : arguments->Count()); ++i) { + arguments->Get(i)->ResetFlag(SBX_REFERENCE); + //TODO: skipped for errors?!? + } + for (std::vector< UnmarshalData >::iterator i(data.unmarshal.begin()); + i != data.unmarshal.end(); ++i) + { + unmarshal(i->variable, i->buffer); + } + for (std::vector< StringData >::iterator i(data.unmarshalStrings.begin()); + i != data.unmarshalStrings.end(); ++i) + { + SbError e = unmarshalString(*i, result); + if (e != ERRCODE_NONE) { + return e; + } + } + return ERRCODE_NONE; +} + +SbError getProcData(HMODULE handle, rtl::OUString const & name, ProcData * proc) +{ + OSL_ASSERT(proc != 0); + if (name.getLength() != 0 && name[0] == '@') { //TODO: "@" vs. "#"??? + sal_Int32 n = name.copy(1).toInt32(); //TODO: handle bad input + if (n <= 0 || n > 0xFFFF) { + return ERRCODE_BASIC_BAD_ARGUMENT; //TODO: more specific errcode? + } + FARPROC p = GetProcAddress(handle, reinterpret_cast< LPCSTR >(n)); + if (p != 0) { + proc->name = rtl::OString(RTL_CONSTASCII_STRINGPARAM("#")) + + rtl::OString::valueOf(n); + proc->proc = p; + return ERRCODE_NONE; + } + } else { + rtl::OString name8; + SbError e = convert(name, &name8); + if (e != ERRCODE_NONE) { + return e; + } + FARPROC p = GetProcAddress(handle, name8.getStr()); + if (p != 0) { + proc->name = name8; + proc->proc = p; + return ERRCODE_NONE; + } + sal_Int32 i = name8.indexOf('#'); + if (i != -1) { + name8 = name8.copy(0, i); + p = GetProcAddress(handle, name8.getStr()); + if (p != 0) { + proc->name = name8; + proc->proc = p; + return ERRCODE_NONE; + } + } + rtl::OString real( + rtl::OString(RTL_CONSTASCII_STRINGPARAM("_")) + name8); + p = GetProcAddress(handle, real.getStr()); + if (p != 0) { + proc->name = real; + proc->proc = p; + return ERRCODE_NONE; + } + real = name8 + rtl::OString(RTL_CONSTASCII_STRINGPARAM("A")); + p = GetProcAddress(handle, real.getStr()); + if (p != 0) { + proc->name = real; + proc->proc = p; + return ERRCODE_NONE; + } + } + return ERRCODE_BASIC_PROC_UNDEFINED; +} + +struct Dll: public salhelper::SimpleReferenceObject { +private: + typedef std::map< rtl::OUString, ProcData > Procs; + + virtual ~Dll(); + +public: + Dll(): handle(0) {} + + SbError getProc(rtl::OUString const & name, ProcData * proc); + + HMODULE handle; + Procs procs; +}; + +Dll::~Dll() { + if (handle != 0 && !FreeLibrary(handle)) { + OSL_TRACE("FreeLibrary(%p) failed with %u", handle, GetLastError()); + } +} + +SbError Dll::getProc(rtl::OUString const & name, ProcData * proc) { + Procs::iterator i(procs.find(name)); + if (i != procs.end()) { + *proc = i->second; + return ERRCODE_NONE; + } + SbError e = getProcData(handle, name, proc); + if (e == ERRCODE_NONE) { + procs.insert(Procs::value_type(name, *proc)); + } + return e; +} + +rtl::OUString fullDllName(rtl::OUString const & name) { + rtl::OUString full(name); + if (full.indexOf('.') == -1) { + full += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".DLL")); + } + return full; +} + +} + +struct SbiDllMgr::Impl: private boost::noncopyable { +private: + typedef std::map< rtl::OUString, rtl::Reference< Dll > > Dlls; + +public: + Dll * getDll(rtl::OUString const & name); + + Dlls dlls; +}; + +Dll * SbiDllMgr::Impl::getDll(rtl::OUString const & name) { + Dlls::iterator i(dlls.find(name)); + if (i == dlls.end()) { + i = dlls.insert(Dlls::value_type(name, new Dll)).first; + HMODULE h = LoadLibraryW(reinterpret_cast<LPCWSTR>(name.getStr())); + if (h == 0) { + dlls.erase(i); + return 0; + } + i->second->handle = h; + } + return i->second.get(); +} + +SbError SbiDllMgr::Call( + rtl::OUString const & function, rtl::OUString const & library, + SbxArray * arguments, SbxVariable & result, bool cdeclConvention) +{ + if (cdeclConvention) { + return ERRCODE_BASIC_NOT_IMPLEMENTED; + } + rtl::OUString dllName(fullDllName(library)); + Dll * dll = impl_->getDll(dllName); + if (dll == 0) { + return ERRCODE_BASIC_BAD_DLL_LOAD; + } + ProcData proc; + SbError e = dll->getProc(function, &proc); + if (e != ERRCODE_NONE) { + return e; + } + return call(dllName, proc, arguments, result); +} + +void SbiDllMgr::FreeDll(rtl::OUString const & library) { + impl_->dlls.erase(library); +} + +SbiDllMgr::SbiDllMgr(): impl_(new Impl) {} + +SbiDllMgr::~SbiDllMgr() {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/dllmgr.cxx b/basic/source/runtime/dllmgr-x86.cxx index 8baf819372ba..5b47511db11e 100644 --- a/basic/source/runtime/dllmgr.cxx +++ b/basic/source/runtime/dllmgr-x86.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,6 +29,11 @@ #include "precompiled_basic.hxx" #include "sal/config.h" +#if defined(WNT) +#include <windows.h> +#undef GetObject +#endif + #include <algorithm> #include <cstddef> #include <list> @@ -42,7 +48,6 @@ #include "rtl/string.hxx" #include "rtl/ustring.hxx" #include "salhelper/simplereferenceobject.hxx" -#include "tools/svwin.h" #undef max @@ -50,8 +55,6 @@ /* Open issues: - Only 32-bit Windows for now. - Missing support for functions returning structs (see TODO in call()). Missing support for additional data types (64 bit integers, Any, ...; would @@ -64,8 +67,6 @@ variables accordingly. */ -#if defined WNT // only 32-bit Windows, actually - extern "C" { int __stdcall DllMgr_call32(FARPROC, void const * stack, std::size_t size); @@ -726,21 +727,8 @@ void SbiDllMgr::FreeDll(rtl::OUString const & library) { impl_->dlls.erase(library); } -#else - -struct SbiDllMgr::Impl {}; - -SbError SbiDllMgr::Call( - rtl::OUString const &, rtl::OUString const &, SbxArray *, SbxVariable &, - bool) -{ - return ERRCODE_BASIC_NOT_IMPLEMENTED; -} - -void SbiDllMgr::FreeDll(rtl::OUString const &) {} - -#endif - SbiDllMgr::SbiDllMgr(): impl_(new Impl) {} SbiDllMgr::~SbiDllMgr() {} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/dllmgr.hxx b/basic/source/runtime/dllmgr.hxx index fdff8c2849be..1507ffe7f94f 100644 --- a/basic/source/runtime/dllmgr.hxx +++ b/basic/source/runtime/dllmgr.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -58,3 +59,5 @@ private: }; #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/inputbox.cxx b/basic/source/runtime/inputbox.cxx index c43519a9b2de..c14afa075155 100644 --- a/basic/source/runtime/inputbox.cxx +++ b/basic/source/runtime/inputbox.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,9 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#ifndef _SV_BUTTON_HXX //autogen #include <vcl/button.hxx> -#endif #include <vcl/fixed.hxx> #include <vcl/edit.hxx> #include <vcl/dialog.hxx> @@ -153,7 +152,6 @@ IMPL_LINK_INLINE_END( SvRTLInputBox, CancelHdl, Button *, pButton ) // ********************************************************************* // ********************************************************************* -// ********************************************************************* // Syntax: String InputBox( Prompt, [Title], [Default] [, nXpos, nYpos ] ) @@ -195,3 +193,4 @@ RTLFUNC(InputBox) +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/iosys.cxx b/basic/source/runtime/iosys.cxx index 06faa7c0aba5..b71558b0fb7e 100644 --- a/basic/source/runtime/iosys.cxx +++ b/basic/source/runtime/iosys.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,21 +30,16 @@ #include "precompiled_basic.hxx" #include <vcl/dialog.hxx> #include <vcl/edit.hxx> -#ifndef _SV_BUTTON_HXX //autogen #include <vcl/button.hxx> -#endif #include <vcl/msgbox.hxx> #include <vcl/svapp.hxx> #include <osl/security.h> #include <osl/file.hxx> #include <tools/urlobj.hxx> -#include <vos/mutex.hxx> +#include <osl/mutex.hxx> #include "runtime.hxx" -#ifdef _USE_UNO - -// <-- encoding #include <sal/alloca.h> #include <ctype.h> @@ -52,7 +48,7 @@ #include <rtl/ustrbuf.hxx> #include <rtl/textenc.h> #include <rtl/ustrbuf.hxx> -// encoding --> + #include <comphelper/processfactory.hxx> #include <com/sun/star/uno/Sequence.hxx> @@ -68,15 +64,12 @@ #include <com/sun/star/bridge/XBridgeFactory.hpp> using namespace comphelper; -using namespace osl; using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::ucb; using namespace com::sun::star::io; using namespace com::sun::star::bridge; -#endif /* _USE_UNO */ - #include "iosys.hxx" #include "sbintern.hxx" @@ -141,7 +134,6 @@ IMPL_LINK_INLINE_START( SbiInputDialog, Cancel, Window *, pWindow ) } IMPL_LINK_INLINE_END( SbiInputDialog, Cancel, Window *, pWindow ) -////////////////////////////////////////////////////////////////////////// SbiStream::SbiStream() : pStrm( 0 ) @@ -179,8 +171,6 @@ void SbiStream::MapError() } } -#ifdef _USE_UNO - // TODO: Code is copied from daemons2/source/uno/asciiEncoder.cxx ::rtl::OUString findUserInDescription( const ::rtl::OUString& aDescription ) @@ -213,15 +203,11 @@ void SbiStream::MapError() return user; } -#endif - - // Hack for #83750 sal_Bool runsInSetup( void ); sal_Bool needSecurityRestrictions( void ) { -#ifdef _USE_UNO static sal_Bool bNeedInit = sal_True; static sal_Bool bRetVal = sal_True; @@ -252,7 +238,7 @@ sal_Bool needSecurityRestrictions( void ) if( !xSMgr.is() ) return sal_True; Reference< XBridgeFactory > xBridgeFac( xSMgr->createInstance - ( ::rtl::OUString::createFromAscii( "com.sun.star.bridge.BridgeFactory" ) ), UNO_QUERY ); + ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.bridge.BridgeFactory" )) ), UNO_QUERY ); Sequence< Reference< XBridge > > aBridgeSeq; sal_Int32 nBridgeCount = 0; @@ -298,9 +284,6 @@ sal_Bool needSecurityRestrictions( void ) } return bRetVal; -#else - return sal_False; -#endif } // Returns sal_True if UNO is available, otherwise the old file @@ -308,7 +291,6 @@ sal_Bool needSecurityRestrictions( void ) // #89378 New semantic: Don't just ask for UNO but for UCB sal_Bool hasUno( void ) { -#ifdef _USE_UNO static sal_Bool bNeedInit = sal_True; static sal_Bool bRetVal = sal_True; @@ -323,10 +305,10 @@ sal_Bool hasUno( void ) } else { - Reference< XContentProviderManager > xManager( xSMgr->createInstance( ::rtl::OUString::createFromAscii - ( "com.sun.star.ucb.UniversalContentBroker" ) ), UNO_QUERY ); + Reference< XContentProviderManager > xManager( xSMgr->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM + ( "com.sun.star.ucb.UniversalContentBroker" )) ), UNO_QUERY ); - if ( !( xManager.is() && xManager->queryContentProvider( ::rtl::OUString::createFromAscii( "file:///" ) ).is() ) ) + if ( !( xManager.is() && xManager->queryContentProvider( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "file:///" )) ).is() ) ) { // No UCB bRetVal = sal_False; @@ -334,18 +316,13 @@ sal_Bool hasUno( void ) } } return bRetVal; -#else - return sal_False; -#endif } -#ifndef _OLD_FILE_IMPL - class OslStream : public SvStream { - File maFile; + osl::File maFile; short mnStrmMode; public: @@ -366,25 +343,25 @@ OslStream::OslStream( const String& rName, short nStrmMode ) if( (nStrmMode & (STREAM_READ | STREAM_WRITE)) == (STREAM_READ | STREAM_WRITE) ) { - nFlags = OpenFlag_Read | OpenFlag_Write; + nFlags = osl_File_OpenFlag_Read | osl_File_OpenFlag_Write; } else if( nStrmMode & STREAM_WRITE ) { - nFlags = OpenFlag_Write; + nFlags = osl_File_OpenFlag_Write; } else //if( nStrmMode & STREAM_READ ) { - nFlags = OpenFlag_Read; + nFlags = osl_File_OpenFlag_Read; } - FileBase::RC nRet = maFile.open( nFlags ); - if( nRet == FileBase::E_NOENT && nFlags != OpenFlag_Read ) + osl::FileBase::RC nRet = maFile.open( nFlags ); + if( nRet == osl::FileBase::E_NOENT && nFlags != osl_File_OpenFlag_Read ) { - nFlags |= OpenFlag_Create; + nFlags |= osl_File_OpenFlag_Create; nRet = maFile.open( nFlags ); } - if( nRet != FileBase::E_None ) + if( nRet != osl::FileBase::E_None ) { SetError( ERRCODE_IO_GENERAL ); } @@ -399,32 +376,25 @@ OslStream::~OslStream() sal_uIntPtr OslStream::GetData( void* pData, sal_uIntPtr nSize ) { sal_uInt64 nBytesRead = nSize; - FileBase::RC nRet = FileBase::E_None; - nRet = maFile.read( pData, nBytesRead, nBytesRead ); + maFile.read( pData, nBytesRead, nBytesRead ); return (sal_uIntPtr)nBytesRead; } sal_uIntPtr OslStream::PutData( const void* pData, sal_uIntPtr nSize ) { sal_uInt64 nBytesWritten; - FileBase::RC nRet = FileBase::E_None; - nRet = maFile.write( pData, (sal_uInt64)nSize, nBytesWritten ); + maFile.write( pData, (sal_uInt64)nSize, nBytesWritten ); return (sal_uIntPtr)nBytesWritten; } sal_uIntPtr OslStream::SeekPos( sal_uIntPtr nPos ) { - FileBase::RC nRet; if( nPos == STREAM_SEEK_TO_END ) - { - nRet = maFile.setPos( Pos_End, 0 ); - } + maFile.setPos( osl_Pos_End, 0 ); else - { - nRet = maFile.setPos( Pos_Absolut, (sal_uInt64)nPos ); - } - sal_uInt64 nRealPos; - nRet = maFile.getPos( nRealPos ); + maFile.setPos( osl_Pos_Absolut, (sal_uInt64)nPos ); + sal_uInt64 nRealPos(0); + maFile.getPos( nRealPos ); return sal::static_int_cast<sal_uIntPtr>(nRealPos); } @@ -434,14 +404,9 @@ void OslStream::FlushData() void OslStream::SetSize( sal_uIntPtr nSize ) { - FileBase::RC nRet = FileBase::E_None; - nRet = maFile.setSize( (sal_uInt64)nSize ); + maFile.setSize( (sal_uInt64)nSize ); } -#endif - - -#ifdef _USE_UNO class UCBStream : public SvStream { @@ -461,40 +426,6 @@ public: virtual void SetSize( sal_uIntPtr nSize ); }; -/* -sal_uIntPtr UCBErrorToSvStramError( ucb::IOErrorCode nError ) -{ - sal_uIntPtr eReturn = ERRCODE_IO_GENERAL; - switch( nError ) - { - case ucb::IOErrorCode_ABORT: eReturn = SVSTREAM_GENERALERROR; break; - case ucb::IOErrorCode_NOT_EXISTING: eReturn = SVSTREAM_FILE_NOT_FOUND; break; - case ucb::IOErrorCode_NOT_EXISTING_PATH: eReturn = SVSTREAM_PATH_NOT_FOUND; break; - case ucb::IOErrorCode_OUT_OF_FILE_HANDLES: eReturn = SVSTREAM_TOO_MANY_OPEN_FILES; break; - case ucb::IOErrorCode_ACCESS_DENIED: eReturn = SVSTREAM_ACCESS_DENIED; break; - case ucb::IOErrorCode_LOCKING_VIOLATION: eReturn = SVSTREAM_SHARING_VIOLATION; break; - - case ucb::IOErrorCode_INVALID_ACCESS: eReturn = SVSTREAM_INVALID_ACCESS; break; - case ucb::IOErrorCode_CANT_CREATE: eReturn = SVSTREAM_CANNOT_MAKE; break; - case ucb::IOErrorCode_INVALID_PARAMETER: eReturn = SVSTREAM_INVALID_PARAMETER; break; - - case ucb::IOErrorCode_CANT_READ: eReturn = SVSTREAM_READ_ERROR; break; - case ucb::IOErrorCode_CANT_WRITE: eReturn = SVSTREAM_WRITE_ERROR; break; - case ucb::IOErrorCode_CANT_SEEK: eReturn = SVSTREAM_SEEK_ERROR; break; - case ucb::IOErrorCode_CANT_TELL: eReturn = SVSTREAM_TELL_ERROR; break; - - case ucb::IOErrorCode_OUT_OF_MEMORY: eReturn = SVSTREAM_OUTOFMEMORY; break; - - case SVSTREAM_FILEFORMAT_ERROR: eReturn = SVSTREAM_FILEFORMAT_ERROR; break; - case ucb::IOErrorCode_WRONG_VERSION: eReturn = SVSTREAM_WRONGVERSION; - case ucb::IOErrorCode_OUT_OF_DISK_SPACE: eReturn = SVSTREAM_DISK_FULL; break; - - case ucb::IOErrorCode_BAD_CRC: eReturn = ERRCODE_IO_BADCRC; break; - } - return eReturn; -} -*/ - UCBStream::UCBStream( Reference< XInputStream > & rStm ) : xIS( rStm ) , xSeek( rStm, UNO_QUERY ) @@ -635,12 +566,10 @@ void UCBStream::SetSize( sal_uIntPtr nSize ) { (void)nSize; - DBG_ERROR( "not allowed to call from basic" ); + OSL_FAIL( "not allowed to call from basic" ); SetError( ERRCODE_IO_GENERAL ); } -#endif - // Oeffnen eines Streams SbError SbiStream::Open ( short nCh, const ByteString& rName, short nStrmMode, short nFlags, short nL ) @@ -655,14 +584,13 @@ SbError SbiStream::Open String aStr( rName, gsl_getSystemTextEncoding() ); String aNameStr = getFullPath( aStr ); -#ifdef _USE_UNO if( hasUno() ) { Reference< XMultiServiceFactory > xSMgr = getProcessServiceFactory(); if( xSMgr.is() ) { Reference< XSimpleFileAccess > - xSFI( xSMgr->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY ); + xSFI( xSMgr->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" )) ), UNO_QUERY ); if( xSFI.is() ) { try @@ -684,9 +612,6 @@ SbError SbiStream::Open { Reference< XStream > xIS = xSFI->openFileReadWrite( aNameStr ); pStrm = new UCBStream( xIS ); - // Open for writing is not implemented in ucb yet!!! - //Reference< XOutputStream > xIS = xSFI->openFileWrite( aNameStr ); - //pStrm = new UCBStream( xIS ); } else //if( nStrmMode & STREAM_READ ) { @@ -703,14 +628,9 @@ SbError SbiStream::Open } } -#endif if( !pStrm ) { -#ifdef _OLD_FILE_IMPL - pStrm = new SvFileStream( aNameStr, nStrmMode ); -#else pStrm = new OslStream( aNameStr, nStrmMode ); -#endif } if( IsAppend() ) pStrm->Seek( STREAM_SEEK_TO_END ); @@ -724,12 +644,6 @@ SbError SbiStream::Close() { if( pStrm ) { - if( !hasUno() ) - { -#ifdef _OLD_FILE_IMPL - ((SvFileStream *)pStrm)->Close(); -#endif - } MapError(); delete pStrm; pStrm = NULL; @@ -825,7 +739,6 @@ SbError SbiStream::Write( const ByteString& rBuf, sal_uInt16 n ) return nError; } -////////////////////////////////////////////////////////////////////////// // Zugriff auf das aktuelle I/O-System: @@ -835,7 +748,6 @@ SbiIoSystem* SbGetIoSystem() return pInst ? pInst->GetIoSystem() : NULL; } -////////////////////////////////////////////////////////////////////////// SbiIoSystem::SbiIoSystem() { @@ -1037,7 +949,7 @@ void SbiIoSystem::WriteCon( const ByteString& rText ) aOut.Erase( 0, 1 ); String aStr( s, gsl_getSystemTextEncoding() ); { - vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + SolarMutexGuard aSolarGuard; if( !MessBox( GetpApp()->GetDefDialogParent(), WinBits( WB_OK_CANCEL | WB_DEF_OK ), String(), aStr ).Execute() ) @@ -1046,3 +958,4 @@ void SbiIoSystem::WriteCon( const ByteString& rText ) } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/makefile.mk b/basic/source/runtime/makefile.mk index 329448c67e75..80066425e3c1 100644..100755 --- a/basic/source/runtime/makefile.mk +++ b/basic/source/runtime/makefile.mk @@ -42,7 +42,7 @@ ENABLE_EXCEPTIONS = TRUE SLOFILES= \ $(SLO)$/basrdll.obj \ $(SLO)$/comenumwrapper.obj \ - $(SLO)$/inputbox.obj \ + $(SLO)$/inputbox.obj\ $(SLO)$/runtime.obj \ $(SLO)$/step0.obj \ $(SLO)$/step1.obj \ @@ -51,16 +51,27 @@ SLOFILES= \ $(SLO)$/stdobj.obj \ $(SLO)$/stdobj1.obj \ $(SLO)$/methods.obj \ - $(SLO)$/methods1.obj \ + $(SLO)$/methods1.obj\ $(SLO)$/props.obj \ - $(SLO)$/ddectrl.obj \ - $(SLO)$/dllmgr.obj \ + $(SLO)$/ddectrl.obj \ $(SLO)$/sbdiagnose.obj +.IF "$(GUI)$(CPU)" == "WNTI" +SLOFILES+= \ + $(SLO)$/dllmgr-x86.obj +.ELIF "$(GUI)$(CPU)" == "WNTX" +SLOFILES+= \ + $(SLO)$/dllmgr-x64.obj +.ELSE +SLOFILES+= \ + $(SLO)$/dllmgr-none.obj +.ENDIF .IF "$(GUI)$(COM)$(CPU)" == "WNTMSCI" -SLOFILES+= $(SLO)$/wnt.obj +SLOFILES+= \ + $(SLO)$/wnt-x86.obj .ELIF "$(GUI)$(COM)$(CPU)" == "WNTGCCI" -SLOFILES+= $(SLO)$/wnt-mingw.obj +SLOFILES+= \ + $(SLO)$/wnt-mingw.obj .ENDIF # --- Targets ------------------------------------------------------------- diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 640dd7e8bcbe..f7920a11d1a9 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -31,9 +32,7 @@ #include <tools/date.hxx> #include <basic/sbxvar.hxx> -#ifndef _VOS_PROCESS_HXX -#include <vos/process.hxx> -#endif +#include <osl/process.h> #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <vcl/sound.hxx> @@ -48,22 +47,17 @@ #include <unotools/ucbstreamhelper.hxx> #include <tools/wldcrd.hxx> #include <i18npool/lang.h> +#include <rtl/string.hxx> #include "runtime.hxx" #include "sbunoobj.hxx" #ifdef WNT -#include <tools/prewin.h> -#include "winbase.h" -#include <tools/postwin.h> -#ifndef _FSYS_HXX //autogen #include <tools/fsys.hxx> -#endif #else #include <osl/file.hxx> #endif #include "errobject.hxx" -#ifdef _USE_UNO #include <comphelper/processfactory.hxx> #include <com/sun/star/uno/Sequence.hxx> @@ -75,19 +69,18 @@ #include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/io/XStream.hpp> #include <com/sun/star/io/XSeekable.hpp> - +#include <com/sun/star/script/XErrorQuery.hpp> +#include <ooo/vba/XHelperInterface.hpp> +#include <com/sun/star/bridge/oleautomation/XAutomationObject.hpp> using namespace comphelper; using namespace osl; using namespace com::sun::star::uno; using namespace com::sun::star::lang; using namespace com::sun::star::ucb; using namespace com::sun::star::io; +using namespace com::sun::star::script; using namespace com::sun::star::frame; -#endif /* _USE_UNO */ - -//#define _ENABLE_CUR_DIR - #include "stdobj.hxx" #include <basic/sbstdobj.hxx> #include "rtlproto.hxx" @@ -105,7 +98,9 @@ using namespace com::sun::star::frame; #include <stdlib.h> #include <ctype.h> -#if defined (WNT) || defined (OS2) +SbxVariable* getDefaultProp( SbxVariable* pRef ); + +#if defined (WNT) #include <direct.h> // _getdcwd get current work directory, _chdrive #endif @@ -114,12 +109,16 @@ using namespace com::sun::star::frame; #include <unistd.h> #endif +#include <basic/sbobjmod.hxx> + #ifdef WNT +#define GradientStyle_RECT BLA_GradientStyle_RECT +#include <windows.h> #include <io.h> +#undef GetObject +#undef GradientSyle_RECT #endif -#include <basic/sbobjmod.hxx> - // from source/classes/sbxmod.cxx Reference< XModel > getDocumentModel( StarBASIC* ); @@ -217,7 +216,7 @@ static com::sun::star::uno::Reference< XSimpleFileAccess3 > getFileAccess( void if( xSMgr.is() ) { xSFI = com::sun::star::uno::Reference< XSimpleFileAccess3 >( xSMgr->createInstance - ( ::rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY ); + ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ucb.SimpleFileAccess" )) ), UNO_QUERY ); } } return xSFI; @@ -445,8 +444,7 @@ RTLFUNC(CurDir) // DirEntry-Funktionalitaet keine Moeglichkeit besteht, das aktuelle so // zu ermitteln, dass eine virtuelle URL geliefert werden koennte. -// rPar.Get(0)->PutEmpty(); -#if defined (WNT) || defined (OS2) +#if defined (WNT) int nCurDir = 0; // Current dir // JSM if ( rPar.Count() == 2 ) { @@ -469,10 +467,6 @@ RTLFUNC(CurDir) } } char* pBuffer = new char[ _MAX_PATH ]; -#ifdef OS2 - if( !nCurDir ) - nCurDir = _getdrive(); -#endif if ( _getdcwd( nCurDir, pBuffer, _MAX_PATH ) != 0 ) rPar.Get(0)->PutString( String::CreateFromAscii( pBuffer ) ); else @@ -510,30 +504,13 @@ RTLFUNC(CurDir) #endif } -RTLFUNC(ChDir) // JSM +RTLFUNC(ChDir) { (void)bWrite; rPar.Get(0)->PutEmpty(); if (rPar.Count() == 2) { -#ifdef _ENABLE_CUR_DIR - String aPath = rPar.Get(1)->GetString(); - sal_Bool bError = sal_False; -#ifdef WNT - // #55997 Laut MI hilft es bei File-URLs einen DirEntry zwischenzuschalten - // #40996 Harmoniert bei Verwendung der WIN32-Funktion nicht mit getdir - DirEntry aEntry( aPath ); - ByteString aFullPath( aEntry.GetFull(), gsl_getSystemTextEncoding() ); - if( chdir( aFullPath.GetBuffer()) ) - bError = sal_True; -#else - if (!DirEntry(aPath).SetCWD()) - bError = sal_True; -#endif - if( bError ) - StarBASIC::Error( SbERR_PATH_NOT_FOUND ); -#endif // VBA: track current directory per document type (separately for Writer, Calc, Impress, etc.) if( SbiRuntime::isVBAEnabled() ) ::basic::vba::registerCurrentDirectory( getDocumentModel( pBasic ), rPar.Get(1)->GetString() ); @@ -542,40 +519,13 @@ RTLFUNC(ChDir) // JSM StarBASIC::Error( SbERR_BAD_ARGUMENT ); } -RTLFUNC(ChDrive) // JSM +RTLFUNC(ChDrive) { (void)pBasic; (void)bWrite; rPar.Get(0)->PutEmpty(); - if (rPar.Count() == 2) - { -#ifdef _ENABLE_CUR_DIR - // Keine Laufwerke in Unix -#ifndef UNX - String aPar1 = rPar.Get(1)->GetString(); - -#if defined (WNT) || defined (OS2) - if (aPar1.Len() > 0) - { - int nCurDrive = (int)aPar1.GetBuffer()[0]; ; - if ( !isalpha( nCurDrive ) ) - { - StarBASIC::Error( SbERR_BAD_ARGUMENT ); - return; - } - else - nCurDrive -= ( 'A' - 1 ); - if (_chdrive(nCurDrive)) - StarBASIC::Error( SbERR_NO_DEVICE ); - } -#endif - -#endif - // #ifndef UNX -#endif - } - else + if (rPar.Count() != 2) StarBASIC::Error( SbERR_BAD_ARGUMENT ); } @@ -618,7 +568,7 @@ void implStepRenameOSL( const String& aSource, const String& aDest ) } } -RTLFUNC(FileCopy) // JSM +RTLFUNC(FileCopy) { (void)pBasic; (void)bWrite; @@ -628,7 +578,6 @@ RTLFUNC(FileCopy) // JSM { String aSource = rPar.Get(1)->GetString(); String aDest = rPar.Get(2)->GetString(); - // <-- UCB if( hasUno() ) { com::sun::star::uno::Reference< XSimpleFileAccess3 > xSFI = getFileAccess(); @@ -645,31 +594,19 @@ RTLFUNC(FileCopy) // JSM } } else - // --> UCB { -#ifdef _OLD_FILE_IMPL - DirEntry aSourceDirEntry(aSource); - if (aSourceDirEntry.Exists()) - { - if (aSourceDirEntry.CopyTo(DirEntry(aDest),FSYS_ACTION_COPYFILE) != FSYS_ERR_OK) - StarBASIC::Error( SbERR_PATH_NOT_FOUND ); - } - else - StarBASIC::Error( SbERR_PATH_NOT_FOUND ); -#else FileBase::RC nRet = File::copy( getFullPathUNC( aSource ), getFullPathUNC( aDest ) ); if( nRet != FileBase::E_None ) { StarBASIC::Error( SbERR_PATH_NOT_FOUND ); } -#endif } } else StarBASIC::Error( SbERR_BAD_ARGUMENT ); } -RTLFUNC(Kill) // JSM +RTLFUNC(Kill) { (void)pBasic; (void)bWrite; @@ -679,7 +616,6 @@ RTLFUNC(Kill) // JSM { String aFileSpec = rPar.Get(1)->GetString(); - // <-- UCB if( hasUno() ) { com::sun::star::uno::Reference< XSimpleFileAccess3 > xSFI = getFileAccess(); @@ -702,21 +638,15 @@ RTLFUNC(Kill) // JSM } } else - // --> UCB { -#ifdef _OLD_FILE_IMPL - if(DirEntry(aFileSpec).Kill() != FSYS_ERR_OK) - StarBASIC::Error( SbERR_PATH_NOT_FOUND ); -#else File::remove( getFullPathUNC( aFileSpec ) ); -#endif } } else StarBASIC::Error( SbERR_BAD_ARGUMENT ); } -RTLFUNC(MkDir) // JSM +RTLFUNC(MkDir) { (void)pBasic; (void)bWrite; @@ -726,7 +656,6 @@ RTLFUNC(MkDir) // JSM { String aPath = rPar.Get(1)->GetString(); - // <-- UCB if( hasUno() ) { com::sun::star::uno::Reference< XSimpleFileAccess3 > xSFI = getFileAccess(); @@ -734,6 +663,36 @@ RTLFUNC(MkDir) // JSM { try { + if ( SbiRuntime::isVBAEnabled() ) + { + // If aPath is the folder name, not a path, then create the folder under current directory. + INetURLObject aTryPathURL( aPath ); + ::rtl::OUString sPathURL = aTryPathURL.GetMainURL( INetURLObject::NO_DECODE ); + if ( !sPathURL.getLength() ) + { + File::getFileURLFromSystemPath( aPath, sPathURL ); + } + INetURLObject aPathURL( sPathURL ); + if ( !aPathURL.GetPath().getLength() ) + { + ::rtl::OUString sCurDirURL; + SbxArrayRef pPar = new SbxArray; + SbxVariableRef pVar = new SbxVariable(); + pPar->Put( pVar, 0 ); + SbRtl_CurDir( pBasic, *pPar, sal_False ); + String aCurPath = pPar->Get(0)->GetString(); + + File::getFileURLFromSystemPath( aCurPath, sCurDirURL ); + INetURLObject aDirURL( sCurDirURL ); + aDirURL.Append( aPath ); + ::rtl::OUString aTmpPath = aDirURL.GetMainURL( INetURLObject::NO_DECODE ); + if ( aTmpPath.getLength() > 0 ) + { + aPath = aTmpPath; + } + } + } + xSFI->createFolder( getFullPath( aPath ) ); } catch( Exception & ) @@ -743,14 +702,8 @@ RTLFUNC(MkDir) // JSM } } else - // --> UCB { -#ifdef _OLD_FILE_IMPL - if (!DirEntry(aPath).MakeDir()) - StarBASIC::Error( SbERR_PATH_NOT_FOUND ); -#else Directory::create( getFullPathUNC( aPath ) ); -#endif } } else @@ -758,8 +711,6 @@ RTLFUNC(MkDir) // JSM } -#ifndef _OLD_FILE_IMPL - // In OSL only empty directories can be deleted // so we have to delete all files recursively void implRemoveDirRecursive( const String& aDirPath ) @@ -768,7 +719,7 @@ void implRemoveDirRecursive( const String& aDirPath ) FileBase::RC nRet = DirectoryItem::get( aDirPath, aItem ); sal_Bool bExists = (nRet == FileBase::E_None); - FileStatus aFileStatus( FileStatusMask_Type ); + FileStatus aFileStatus( osl_FileStatus_Mask_Type ); nRet = aItem.getFileStatus( aFileStatus ); FileStatus::Type aType = aFileStatus.getFileType(); sal_Bool bFolder = isFolder( aType ); @@ -795,7 +746,7 @@ void implRemoveDirRecursive( const String& aDirPath ) break; // Handle flags - FileStatus aFileStatus2( FileStatusMask_Type | FileStatusMask_FileURL ); + FileStatus aFileStatus2( osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileURL ); nRet = aItem2.getFileStatus( aFileStatus2 ); ::rtl::OUString aPath = aFileStatus2.getFileURL(); @@ -815,10 +766,9 @@ void implRemoveDirRecursive( const String& aDirPath ) nRet = Directory::remove( aDirPath ); } -#endif -RTLFUNC(RmDir) // JSM +RTLFUNC(RmDir) { (void)pBasic; (void)bWrite; @@ -827,7 +777,6 @@ RTLFUNC(RmDir) // JSM if (rPar.Count() == 2) { String aPath = rPar.Get(1)->GetString(); - // <-- UCB if( hasUno() ) { com::sun::star::uno::Reference< XSimpleFileAccess3 > xSFI = getFileAccess(); @@ -862,22 +811,15 @@ RTLFUNC(RmDir) // JSM } } else - // --> UCB { -#ifdef _OLD_FILE_IMPL - DirEntry aDirEntry(aPath); - if (aDirEntry.Kill() != FSYS_ERR_OK) - StarBASIC::Error( SbERR_PATH_NOT_FOUND ); -#else implRemoveDirRecursive( getFullPathUNC( aPath ) ); -#endif } } else StarBASIC::Error( SbERR_BAD_ARGUMENT ); } -RTLFUNC(SendKeys) // JSM +RTLFUNC(SendKeys) { (void)pBasic; (void)bWrite; @@ -914,7 +856,6 @@ RTLFUNC(FileLen) SbxVariableRef pArg = rPar.Get( 1 ); String aStr( pArg->GetString() ); sal_Int32 nLen = 0; - // <-- UCB if( hasUno() ) { com::sun::star::uno::Reference< XSimpleFileAccess3 > xSFI = getFileAccess(); @@ -931,18 +872,12 @@ RTLFUNC(FileLen) } } else - // --> UCB { -#ifdef _OLD_FILE_IMPL - FileStat aStat = DirEntry( aStr ); - nLen = aStat.GetSize(); -#else DirectoryItem aItem; - FileBase::RC nRet = DirectoryItem::get( getFullPathUNC( aStr ), aItem ); - FileStatus aFileStatus( FileStatusMask_FileSize ); - nRet = aItem.getFileStatus( aFileStatus ); + DirectoryItem::get( getFullPathUNC( aStr ), aItem ); + FileStatus aFileStatus( osl_FileStatus_Mask_FileSize ); + aItem.getFileStatus( aFileStatus ); nLen = (sal_Int32)aFileStatus.getFileSize(); -#endif } rPar.Get(0)->PutLong( (long)nLen ); } @@ -968,6 +903,26 @@ RTLFUNC(Hex) } } +RTLFUNC(FuncCaller) +{ + (void)pBasic; + (void)bWrite; + if ( SbiRuntime::isVBAEnabled() && pINST && pINST->pRun ) + { + if ( pINST->pRun->GetExternalCaller() ) + *rPar.Get(0) = *pINST->pRun->GetExternalCaller(); + else + { + SbxVariableRef pVar = new SbxVariable(SbxVARIANT); + *rPar.Get(0) = *pVar; + } + } + else + { + StarBASIC::Error( SbERR_NOT_IMPLEMENTED ); + } + +} // InStr( [start],string,string,[compare] ) RTLFUNC(InStr) @@ -1760,9 +1715,6 @@ RTLFUNC(Val) char* pEndPtr; String aStr( rPar.Get(1)->GetString() ); -// lt. Mikkysoft bei Kommas abbrechen! -// for( sal_uInt16 n=0; n < aStr.Len(); n++ ) -// if( aStr[n] == ',' ) aStr[n] = '.'; FilterWhiteSpace( aStr ); if ( aStr.GetBuffer()[0] == '&' && aStr.Len() > 1 ) @@ -1785,7 +1737,6 @@ RTLFUNC(Val) // #57844 Lokalisierte Funktion benutzen nResult = ::rtl::math::stringToDouble( aStr, '.', ',', NULL, NULL ); checkArithmeticOverflow( nResult ); - // ATL: nResult = strtod( aStr.GetStr(), &pEndPtr ); } rPar.Get(0)->PutDouble( nResult ); @@ -2033,8 +1984,7 @@ RTLFUNC(DateValue) else fResult = ceil( fResult ); } - // fResult += 2.0; // Anpassung StarCalcFormatter - rPar.Get(0)->PutDate( fResult ); // JSM + rPar.Get(0)->PutDate( fResult ); } else StarBASIC::Error( SbERR_CONVERSION ); @@ -2074,7 +2024,7 @@ RTLFUNC(TimeValue) if ( nType == NUMBERFORMAT_DATETIME ) // Tage abschneiden fResult = fmod( fResult, 1 ); - rPar.Get(0)->PutDate( fResult ); // JSM + rPar.Get(0)->PutDate( fResult ); } else StarBASIC::Error( SbERR_CONVERSION ); @@ -2439,7 +2389,18 @@ RTLFUNC(IsEmpty) if ( rPar.Count() < 2 ) StarBASIC::Error( SbERR_BAD_ARGUMENT ); else - rPar.Get( 0 )->PutBool( rPar.Get(1)->IsEmpty() ); + { + SbxVariable* pVar = NULL; + if( SbiRuntime::isVBAEnabled() ) + pVar = getDefaultProp( rPar.Get(1) ); + if ( pVar ) + { + pVar->Broadcast( SBX_HINT_DATAWANTED ); + rPar.Get( 0 )->PutBool( pVar->IsEmpty() ); + } + else + rPar.Get( 0 )->PutBool( rPar.Get(1)->IsEmpty() ); + } } RTLFUNC(IsError) @@ -2450,7 +2411,22 @@ RTLFUNC(IsError) if ( rPar.Count() < 2 ) StarBASIC::Error( SbERR_BAD_ARGUMENT ); else - rPar.Get( 0 )->PutBool( rPar.Get(1)->IsErr() ); + { + SbxVariable* pVar =rPar.Get( 1 ); + SbUnoObject* pObj = PTR_CAST(SbUnoObject,pVar ); + if ( !pObj ) + { + if ( SbxBase* pBaseObj = pVar->GetObject() ) + pObj = PTR_CAST(SbUnoObject, pBaseObj ); + } + Reference< XErrorQuery > xError; + if ( pObj ) + xError.set( pObj->getUnoAny(), UNO_QUERY ); + if ( xError.is() ) + rPar.Get( 0 )->PutBool( xError->hasError() ); + else + rPar.Get( 0 )->PutBool( rPar.Get(1)->IsErr() ); + } } RTLFUNC(IsNull) @@ -2501,39 +2477,6 @@ RTLFUNC(IsMissing) rPar.Get( 0 )->PutBool( rPar.Get(1)->IsErr() ); } -// Dir( [Maske] [,Attrs] ) -// ToDo: Library-globaler Datenbereich fuer Dir-Objekt und Flags - - -String getDirectoryPath( String aPathStr ) -{ - String aRetStr; - - DirectoryItem aItem; - FileBase::RC nRet = DirectoryItem::get( aPathStr, aItem ); - if( nRet == FileBase::E_None ) - { - FileStatus aFileStatus( FileStatusMask_Type ); - nRet = aItem.getFileStatus( aFileStatus ); - if( nRet == FileBase::E_None ) - { - FileStatus::Type aType = aFileStatus.getFileType(); - if( isFolder( aType ) ) - { - aRetStr = aPathStr; - } - else if( aType == FileStatus::Link ) - { - FileStatus aFileStatus2( FileStatusMask_LinkTargetURL ); - nRet = aItem.getFileStatus( aFileStatus2 ); - if( nRet == FileBase::E_None ) - aRetStr = getDirectoryPath( aFileStatus2.getLinkTargetURL() ); - } - } - } - return aRetStr; -} - // Function looks for wildcards, removes them and always returns the pure path String implSetupWildcard( const String& rFileParam, SbiRTLData* pRTLData ) { @@ -2657,7 +2600,6 @@ RTLFUNC(Dir) if( !pRTLData ) return; - // <-- UCB if( hasUno() ) { com::sun::star::uno::Reference< XSimpleFileAccess3 > xSFI = getFileAccess(); @@ -2728,7 +2670,6 @@ RTLFUNC(Dir) } catch( Exception & ) { - //StarBASIC::Error( ERRCODE_IO_GENERAL ); } } @@ -2745,11 +2686,11 @@ RTLFUNC(Dir) { if( pRTLData->nCurDirPos == -2 ) { - aPath = ::rtl::OUString::createFromAscii( "." ); + aPath = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "." )); } else if( pRTLData->nCurDirPos == -1 ) { - aPath = ::rtl::OUString::createFromAscii( ".." ); + aPath = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ".." )); } pRTLData->nCurDirPos++; } @@ -2799,62 +2740,7 @@ RTLFUNC(Dir) } } else - // --> UCB { -#ifdef _OLD_FILE_IMPL - if ( nParCount >= 2 ) - { - delete pRTLData->pDir; - pRTLData->pDir = 0; // wg. Sonderbehandlung Sb_ATTR_VOLUME - DirEntry aEntry( rPar.Get(1)->GetString() ); - FileStat aStat( aEntry ); - if(!aStat.GetError() && (aStat.GetKind() & FSYS_KIND_FILE)) - { - // ah ja, ist nur ein dateiname - // Pfad abschneiden (wg. VB4) - rPar.Get(0)->PutString( aEntry.GetName() ); - return; - } - sal_uInt16 nFlags = 0; - if ( nParCount > 2 ) - pRTLData->nDirFlags = nFlags = rPar.Get(2)->GetInteger(); - else - pRTLData->nDirFlags = 0; - - // Sb_ATTR_VOLUME wird getrennt gehandelt - if( pRTLData->nDirFlags & Sb_ATTR_VOLUME ) - aPath = aEntry.GetVolume(); - else - { - // Die richtige Auswahl treffen - sal_uInt16 nMode = FSYS_KIND_FILE; - if( nFlags & Sb_ATTR_DIRECTORY ) - nMode |= FSYS_KIND_DIR; - if( nFlags == Sb_ATTR_DIRECTORY ) - nMode = FSYS_KIND_DIR; - pRTLData->pDir = new Dir( aEntry, (DirEntryKind) nMode ); - pRTLData->nCurDirPos = 0; - } - } - - if( pRTLData->pDir ) - { - for( ;; ) - { - if( pRTLData->nCurDirPos >= pRTLData->pDir->Count() ) - { - delete pRTLData->pDir; - pRTLData->pDir = 0; - aPath.Erase(); - break; - } - DirEntry aNextEntry=(*(pRTLData->pDir))[pRTLData->nCurDirPos++]; - aPath = aNextEntry.GetName(); //Full(); - break; - } - } - rPar.Get(0)->PutString( aPath ); -#else // TODO: OSL if ( nParCount >= 2 ) { @@ -2907,11 +2793,11 @@ RTLFUNC(Dir) { if( pRTLData->nCurDirPos == -2 ) { - aPath = ::rtl::OUString::createFromAscii( "." ); + aPath = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "." )); } else if( pRTLData->nCurDirPos == -1 ) { - aPath = ::rtl::OUString::createFromAscii( ".." ); + aPath = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( ".." )); } pRTLData->nCurDirPos++; } @@ -2928,7 +2814,7 @@ RTLFUNC(Dir) } // Handle flags - FileStatus aFileStatus( FileStatusMask_Type | FileStatusMask_FileName ); + FileStatus aFileStatus( osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName ); nRet = aItem.getFileStatus( aFileStatus ); // Only directories? @@ -2951,7 +2837,6 @@ RTLFUNC(Dir) } } rPar.Get(0)->PutString( aPath ); -#endif } } } @@ -2992,7 +2877,6 @@ RTLFUNC(GetAttr) } #endif - // <-- UCB if( hasUno() ) { com::sun::star::uno::Reference< XSimpleFileAccess3 > xSFI = getFileAccess(); @@ -3027,14 +2911,13 @@ RTLFUNC(GetAttr) } } else - // --> UCB { DirectoryItem aItem; - FileBase::RC nRet = DirectoryItem::get( getFullPathUNC( rPar.Get(1)->GetString() ), aItem ); - FileStatus aFileStatus( FileStatusMask_Attributes | FileStatusMask_Type ); - nRet = aItem.getFileStatus( aFileStatus ); + DirectoryItem::get( getFullPathUNC( rPar.Get(1)->GetString() ), aItem ); + FileStatus aFileStatus( osl_FileStatus_Mask_Attributes | osl_FileStatus_Mask_Type ); + aItem.getFileStatus( aFileStatus ); sal_uInt64 nAttributes = aFileStatus.getAttributes(); - sal_Bool bReadOnly = (nAttributes & Attribute_ReadOnly) != 0; + sal_Bool bReadOnly = (nAttributes & osl_File_Attribute_ReadOnly) != 0; FileStatus::Type aType = aFileStatus.getFileType(); sal_Bool bDirectory = isFolder( aType ); @@ -3059,7 +2942,6 @@ RTLFUNC(FileDateTime) StarBASIC::Error( SbERR_BAD_ARGUMENT ); else { - // <-- UCB String aPath = rPar.Get(1)->GetString(); Time aTime; Date aDate; @@ -3081,25 +2963,17 @@ RTLFUNC(FileDateTime) } } else - // --> UCB { -#ifdef _OLD_FILE_IMPL - DirEntry aEntry( aPath ); - FileStat aStat( aEntry ); - aTime = Time( aStat.TimeModified() ); - aDate = Date( aStat.DateModified() ); -#else DirectoryItem aItem; - FileBase::RC nRet = DirectoryItem::get( getFullPathUNC( aPath ), aItem ); - FileStatus aFileStatus( FileStatusMask_ModifyTime ); - nRet = aItem.getFileStatus( aFileStatus ); + DirectoryItem::get( getFullPathUNC( aPath ), aItem ); + FileStatus aFileStatus( osl_FileStatus_Mask_ModifyTime ); + aItem.getFileStatus( aFileStatus ); TimeValue aTimeVal = aFileStatus.getModifyTime(); oslDateTime aDT; osl_getDateTimeFromTimeValue( &aTimeVal, &aDT ); aTime = Time( aDT.Hours, aDT.Minutes, aDT.Seconds, 10000000*aDT.NanoSeconds ); aDate = Date( aDT.Day, aDT.Month, aDT.Year ); -#endif } double fSerial = (double)GetDayDiff( aDate ); @@ -3142,13 +3016,12 @@ RTLFUNC(EOF) (void)pBasic; (void)bWrite; - // AB 08/16/2000: No changes for UCB + // No changes for UCB if ( rPar.Count() != 2 ) StarBASIC::Error( SbERR_BAD_ARGUMENT ); else { sal_Int16 nChannel = rPar.Get(1)->GetInteger(); - // nChannel--; // macht MD beim Oeffnen auch nicht SbiIoSystem* pIO = pINST->GetIoSystem(); SbiStream* pSbStrm = pIO->GetStream( nChannel ); if ( !pSbStrm ) @@ -3177,8 +3050,7 @@ RTLFUNC(FileAttr) (void)pBasic; (void)bWrite; - // AB 08/16/2000: No changes for UCB - + // No changes for UCB // #57064 Obwohl diese Funktion nicht mit DirEntry arbeitet, ist sie von // der Anpassung an virtuelle URLs nich betroffen, da sie nur auf bereits // geoeffneten Dateien arbeitet und der Name hier keine Rolle spielt. @@ -3188,7 +3060,6 @@ RTLFUNC(FileAttr) else { sal_Int16 nChannel = rPar.Get(1)->GetInteger(); -// nChannel--; SbiIoSystem* pIO = pINST->GetIoSystem(); SbiStream* pSbStrm = pIO->GetStream( nChannel ); if ( !pSbStrm ) @@ -3210,7 +3081,7 @@ RTLFUNC(Loc) (void)pBasic; (void)bWrite; - // AB 08/16/2000: No changes for UCB + // No changes for UCB if ( rPar.Count() != 2 ) StarBASIC::Error( SbERR_BAD_ARGUMENT ); else @@ -3248,7 +3119,7 @@ RTLFUNC(Lof) (void)pBasic; (void)bWrite; - // AB 08/16/2000: No changes for UCB + // No changes for UCB if ( rPar.Count() != 2 ) StarBASIC::Error( SbERR_BAD_ARGUMENT ); else @@ -3275,7 +3146,7 @@ RTLFUNC(Seek) (void)pBasic; (void)bWrite; - // AB 08/16/2000: No changes for UCB + // No changes for UCB int nArgs = (int)rPar.Count(); if ( nArgs < 2 || nArgs > 3 ) { @@ -3283,7 +3154,6 @@ RTLFUNC(Seek) return; } sal_Int16 nChannel = rPar.Get(1)->GetInteger(); -// nChannel--; SbiIoSystem* pIO = pINST->GetIoSystem(); SbiStream* pSbStrm = pIO->GetStream( nChannel ); if ( !pSbStrm ) @@ -3365,23 +3235,19 @@ RTLFUNC(Rnd) else { double nRand = (double)rand(); - nRand = ( nRand / (double)RAND_MAX ); + nRand = ( nRand / ((double)RAND_MAX + 1.0)); rPar.Get(0)->PutDouble( nRand ); } } -// // Syntax: Shell("Path",[ Window-Style,[ "Params", [ bSync = sal_False ]]]) -// // WindowStyles (VBA-kompatibel): // 2 == Minimized // 3 == Maximized // 10 == Full-Screen (Textmodus-Anwendungen OS/2, WIN95, WNT) -// // !!!HACK der WindowStyle wird im Creator an Application::StartApp // uebergeben. Format: "xxxx2" -// RTLFUNC(Shell) @@ -3404,8 +3270,8 @@ RTLFUNC(Shell) } else { - sal_uInt16 nOptions = vos::OProcess::TOption_SearchPath| - vos::OProcess::TOption_Detached; + oslProcessOption nOptions = osl_Process_SEARCHPATH | osl_Process_DETACHED; + String aCmdLine = rPar.Get(1)->GetString(); // Zusaetzliche Parameter anhaengen, es muss eh alles geparsed werden if( nArgCount >= 4 ) @@ -3482,81 +3348,80 @@ RTLFUNC(Shell) nWinStyle = rPar.Get(2)->GetInteger(); switch( nWinStyle ) { - case 2: - nOptions |= vos::OProcess::TOption_Minimized; - break; - case 3: - nOptions |= vos::OProcess::TOption_Maximized; - break; - case 10: - nOptions |= vos::OProcess::TOption_FullScreen; - break; + case 2: + nOptions |= osl_Process_MINIMIZED; + break; + case 3: + nOptions |= osl_Process_MAXIMIZED; + break; + case 10: + nOptions |= osl_Process_FULLSCREEN; + break; } sal_Bool bSync = sal_False; if( nArgCount >= 5 ) bSync = rPar.Get(4)->GetBool(); if( bSync ) - nOptions |= vos::OProcess::TOption_Wait; + nOptions |= osl_Process_WAIT; } - vos::OProcess::TProcessOption eOptions = - (vos::OProcess::TProcessOption)nOptions; - // #72471 Parameter aufbereiten std::list<String>::const_iterator iter = aTokenList.begin(); const String& rStr = *iter; ::rtl::OUString aOUStrProg( rStr.GetBuffer(), rStr.Len() ); - String aOUStrProgUNC = getFullPathUNC( aOUStrProg ); + ::rtl::OUString aOUStrProgUNC = getFullPathUNC( aOUStrProg ); - iter++; + ++iter; sal_uInt16 nParamCount = sal::static_int_cast< sal_uInt16 >( aTokenList.size() - 1 ); - ::rtl::OUString* pArgumentList = NULL; - //const char** pParamList = NULL; + rtl_uString** pParamList = NULL; if( nParamCount ) { - pArgumentList = new ::rtl::OUString[ nParamCount ]; - //pParamList = new const char*[ nParamCount ]; - sal_uInt16 iList = 0; - while( iter != aTokenList.end() ) + pParamList = new rtl_uString*[nParamCount]; + for(int iList = 0; iter != aTokenList.end(); ++iList, ++iter) { const String& rParamStr = (*iter); - pArgumentList[iList++] = ::rtl::OUString( rParamStr.GetBuffer(), rParamStr.Len() ); - //pParamList[iList++] = (*iter).GetStr(); - iter++; + const ::rtl::OUString aTempStr( rParamStr.GetBuffer(), rParamStr.Len()); + pParamList[iList] = NULL; + rtl_uString_assign(&(pParamList[iList]), aTempStr.pData); } } - //const char* pParams = aParams.Len() ? aParams.GetStr() : 0; - vos::OProcess* pApp; - pApp = new vos::OProcess( aOUStrProgUNC ); - sal_Bool bSucc; - if( nParamCount == 0 ) + oslProcess pApp; + sal_Bool bSucc = osl_executeProcess( + aOUStrProgUNC.pData, + pParamList, + nParamCount, + nOptions, + NULL, + NULL, + NULL, 0, + &pApp ) == osl_Process_E_None; + + osl_freeProcessHandle( pApp ); + + for(int j = 0; i < nParamCount; i++) { - bSucc = pApp->execute( eOptions ) == vos::OProcess::E_None; + rtl_uString_release(pParamList[j]); + pParamList[j] = NULL; } - else + + long nResult = 0; + // We should return the identifier of the executing process when is running VBA, because method Shell(...) returns it in Excel. + if ( bSucc && SbiRuntime::isVBAEnabled()) { - vos::OArgumentList aArgList( pArgumentList, nParamCount ); - bSucc = pApp->execute( eOptions, aArgList ) == vos::OProcess::E_None; + oslProcessInfo aInfo; + aInfo.Size = sizeof(oslProcessInfo); + osl_getProcessInfo( pApp, osl_Process_IDENTIFIER, &aInfo ); + nResult = aInfo.Ident; } - /* - if( nParamCount == 0 ) - pApp = new vos::OProcess( pProg ); - else - pApp = new vos::OProcess( pProg, pParamList, nParamCount ); - sal_Bool bSucc = pApp->execute( eOptions ) == vos::OProcess::E_None; - */ - - delete pApp; - delete[] pArgumentList; if( !bSucc ) StarBASIC::Error( SbERR_FILE_NOT_FOUND ); else - rPar.Get(0)->PutLong( 0 ); + rPar.Get(0)->PutLong( nResult ); } } @@ -3627,6 +3492,65 @@ String getBasicTypeName( SbxDataType eType ) return aRetStr; } +String getObjectTypeName( SbxVariable* pVar ) +{ + rtl::OUString sRet( RTL_CONSTASCII_USTRINGPARAM("Object") ); + if ( pVar ) + { + SbxBase* pObj = pVar->GetObject(); + if( !pObj ) + sRet = String( RTL_CONSTASCII_USTRINGPARAM("Nothing") ); + else + { + SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pVar ); + if ( !pUnoObj ) + { + if ( SbxBase* pBaseObj = pVar->GetObject() ) + pUnoObj = PTR_CAST(SbUnoObject, pBaseObj ); + } + if ( pUnoObj ) + { + Any aObj = pUnoObj->getUnoAny(); + // For upstreaming unless we start to build oovbaapi by default + // we need to get detect the vba-ness of the object in some + // other way + // note: Automation objects do not support XServiceInfo + Reference< XServiceInfo > xServInfo( aObj, UNO_QUERY ); + if ( xServInfo.is() ) + { + // is this a VBA object ? + Reference< ooo::vba::XHelperInterface > xVBA( aObj, UNO_QUERY ); + Sequence< rtl::OUString > sServices = xServInfo->getSupportedServiceNames(); + if ( sServices.getLength() ) + sRet = sServices[ 0 ]; + } + else + { + Reference< com::sun::star::bridge::oleautomation::XAutomationObject > xAutoMation( aObj, UNO_QUERY ); + if ( xAutoMation.is() ) + { + Reference< XInvocation > xInv( aObj, UNO_QUERY ); + if ( xInv.is() ) + { + try + { + xInv->getValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("$GetTypeName") ) ) >>= sRet; + } + catch( Exception& ) + { + } + } + } + } + sal_Int32 nDot = sRet.lastIndexOf( '.' ); + if ( nDot != -1 && nDot < sRet.getLength() ) + sRet = sRet.copy( nDot + 1 ); + } + } + } + return sRet; +} + RTLFUNC(TypeName) { (void)pBasic; @@ -3638,7 +3562,12 @@ RTLFUNC(TypeName) { SbxDataType eType = rPar.Get(1)->GetType(); sal_Bool bIsArray = ( ( eType & SbxARRAY ) != 0 ); - String aRetStr = getBasicTypeName( eType ); + + String aRetStr; + if ( SbiRuntime::isVBAEnabled() && eType == SbxOBJECT ) + aRetStr = getObjectTypeName( rPar.Get(1) ); + else + aRetStr = getBasicTypeName( eType ); if( bIsArray ) aRetStr.AppendAscii( "()" ); rPar.Get(0)->PutString( aRetStr ); @@ -3992,11 +3921,6 @@ RTLFUNC(StrConv) sal_Int32 nConversion = rPar.Get(2)->GetLong(); sal_uInt16 nLanguage = LANGUAGE_SYSTEM; - if( nArgCount == 3 ) - { - // LCID not supported now - //nLanguage = rPar.Get(3)->GetInteger(); - } sal_uInt16 nOldLen = aOldStr.Len(); if( nOldLen == 0 ) @@ -4051,6 +3975,7 @@ RTLFUNC(StrConv) } pChar[nSize] = '\0'; ::rtl::OString aOStr(pChar); + delete[] pChar; // there is no concept about default codepage in unix. so it is incorrectly in unix ::rtl::OUString aOUStr = ::rtl::OStringToOUString(aOStr, osl_getThreadTextEncoding()); @@ -4343,7 +4268,7 @@ RTLFUNC(MsgBox) delete pBox; } -RTLFUNC(SetAttr) // JSM +RTLFUNC(SetAttr) { (void)pBasic; (void)bWrite; @@ -4354,7 +4279,6 @@ RTLFUNC(SetAttr) // JSM String aStr = rPar.Get(1)->GetString(); sal_Int16 nFlags = rPar.Get(2)->GetInteger(); - // <-- UCB if( hasUno() ) { com::sun::star::uno::Reference< XSimpleFileAccess3 > xSFI = getFileAccess(); @@ -4373,46 +4297,12 @@ RTLFUNC(SetAttr) // JSM } } } - else - // --> UCB - { -#ifdef _OLD_FILE_IMPL - // #57064 Bei virtuellen URLs den Real-Path extrahieren - DirEntry aEntry( aStr ); - String aFile = aEntry.GetFull(); - ByteString aByteFile( aFile, gsl_getSystemTextEncoding() ); - #ifdef WNT - if (!SetFileAttributes (aByteFile.GetBuffer(),(DWORD)nFlags)) - StarBASIC::Error(SbERR_FILE_NOT_FOUND); - #endif - #ifdef OS2 - FILESTATUS3 aFileStatus; - APIRET rc = DosQueryPathInfo(aByteFile.GetBuffer(),1, - &aFileStatus,sizeof(FILESTATUS3)); - if (!rc) - { - if (aFileStatus.attrFile != nFlags) - { - aFileStatus.attrFile = nFlags; - rc = DosSetPathInfo(aFile.GetStr(),1, - &aFileStatus,sizeof(FILESTATUS3),0); - if (rc) - StarBASIC::Error( SbERR_FILE_NOT_FOUND ); - } - } - else - StarBASIC::Error( SbERR_FILE_NOT_FOUND ); - #endif -#else - // Not implemented -#endif - } } else StarBASIC::Error( SbERR_BAD_ARGUMENT ); } -RTLFUNC(Reset) // JSM +RTLFUNC(Reset) { (void)pBasic; (void)bWrite; @@ -4458,7 +4348,6 @@ RTLFUNC(FileExists) String aStr = rPar.Get(1)->GetString(); sal_Bool bExists = sal_False; - // <-- UCB if( hasUno() ) { com::sun::star::uno::Reference< XSimpleFileAccess3 > xSFI = getFileAccess(); @@ -4475,16 +4364,10 @@ RTLFUNC(FileExists) } } else - // --> UCB { -#ifdef _OLD_FILE_IMPL - DirEntry aEntry( aStr ); - bExists = aEntry.Exists(); -#else DirectoryItem aItem; FileBase::RC nRet = DirectoryItem::get( getFullPathUNC( aStr ), aItem ); bExists = (nRet == FileBase::E_None); -#endif } rPar.Get(0)->PutBool( bExists ); } @@ -4571,3 +4454,5 @@ RTLFUNC(Partition) aRetStr.append( aUpperValue ); rPar.Get(0)->PutString( String(aRetStr.makeStringAndClear()) ); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/methods1.cxx b/basic/source/runtime/methods1.cxx index 20eca1f985ff..56b22cd69a5e 100644 --- a/basic/source/runtime/methods1.cxx +++ b/basic/source/runtime/methods1.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,20 +35,12 @@ #include <vcl/wrkwin.hxx> #include <vcl/timer.hxx> #include <basic/sbxvar.hxx> -#ifndef _SBX_HXX #include <basic/sbx.hxx> -#endif #include <svl/zforlist.hxx> #include <tools/fsys.hxx> #include <tools/urlobj.hxx> #include <osl/file.hxx> -#ifdef OS2 -#define INCL_DOS -#define INCL_DOSPROCESS -#include <svpm.h> -#endif - #ifndef CLK_TCK #define CLK_TCK CLOCKS_PER_SEC #endif @@ -70,11 +63,15 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/i18n/XCalendar.hpp> +#include <com/sun/star/sheet/XFunctionAccess.hpp> using namespace comphelper; +using namespace com::sun::star::sheet; using namespace com::sun::star::uno; using namespace com::sun::star::i18n; +void unoToSbxValue( SbxVariable* pVar, const Any& aValue ); +Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, com::sun::star::beans::Property* pUnoProperty = NULL ); static Reference< XCalendar > getLocaleCalendar( void ) { @@ -85,7 +82,7 @@ static Reference< XCalendar > getLocaleCalendar( void ) if( xSMgr.is() ) { xCalendar = Reference< XCalendar >( xSMgr->createInstance - ( ::rtl::OUString::createFromAscii( "com.sun.star.i18n.LocaleCalendar" ) ), UNO_QUERY ); + ( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.i18n.LocaleCalendar" )) ), UNO_QUERY ); } } @@ -267,12 +264,12 @@ RTLFUNC(CByte) // JSM rPar.Get(0)->PutByte(nByte); } -RTLFUNC(CCur) // JSM +RTLFUNC(CCur) { (void)pBasic; (void)bWrite; - SbxINT64 nCur; + sal_Int64 nCur = 0; if ( rPar.Count() == 2 ) { SbxVariable *pSbxVariable = rPar.Get(1); @@ -284,7 +281,7 @@ RTLFUNC(CCur) // JSM rPar.Get(0)->PutCurrency( nCur ); } -RTLFUNC(CDec) // JSM +RTLFUNC(CDec) { (void)pBasic; (void)bWrite; @@ -506,8 +503,6 @@ RTLFUNC(GetGUIType) // 17.7.2000 Make simple solution for testtool / fat office #if defined (WNT) rPar.Get(0)->PutInteger( 1 ); -#elif defined OS2 - rPar.Get(0)->PutInteger( 2 ); #elif defined UNX rPar.Get(0)->PutInteger( 4 ); #else @@ -640,13 +635,11 @@ RTLFUNC(DoEvents) (void)pBasic; (void)bWrite; (void)rPar; - // Dummy implementation as the following code leads - // to performance problems for unknown reasons - //Timer aTimer; - //aTimer.SetTimeout( 1 ); - //aTimer.Start(); - //while ( aTimer.IsActive() ) - // Application::Reschedule(); +// don't undstand what upstream are up to +// we already process application events etc. in between +// basic runtime pcode ( on a timed basis ) + // always return 0 + rPar.Get(0)->PutInteger( 0 ); Application::Reschedule( true ); } @@ -894,13 +887,6 @@ RTLFUNC(FindObject) SbxObject* pFindObj = NULL; if( pFind ) pFindObj = PTR_CAST(SbxObject,pFind); - /* - if( !pFindObj ) - { - StarBASIC::Error( SbERR_VAR_UNDEFINED ); - return; - } - */ // Objekt zurueckliefern SbxVariableRef refVar = rPar.Get(0); @@ -932,13 +918,6 @@ RTLFUNC(FindPropertyObject) SbxBase* pObjVarObj = ((SbxVariable*)pObjVar)->GetObject(); pObj = PTR_CAST(SbxObject,pObjVarObj); } - /* - if( !pObj ) - { - StarBASIC::Error( SbERR_VAR_UNDEFINED ); - return; - } - */ // 2. Parameter ist der Name String aNameStr = rPar.Get(2)->GetString(); @@ -993,13 +972,16 @@ sal_Bool lcl_WriteSbxVariable( const SbxVariable& rVar, SvStream* pStrm, case SbxLONG: case SbxULONG: - case SbxLONG64: - case SbxULONG64: if( bIsVariant ) *pStrm << (sal_uInt16)SbxLONG; // VarType Id *pStrm << rVar.GetLong(); break; - + case SbxSALINT64: + case SbxSALUINT64: + if( bIsVariant ) + *pStrm << (sal_uInt16)SbxSALINT64; // VarType Id + *pStrm << (sal_uInt64)rVar.GetInt64(); + break; case SbxSINGLE: if( bIsVariant ) *pStrm << (sal_uInt16)eType; // VarType Id @@ -1023,7 +1005,6 @@ sal_Bool lcl_WriteSbxVariable( const SbxVariable& rVar, SvStream* pStrm, if( bIsVariant ) *pStrm << (sal_uInt16)SbxSTRING; pStrm->WriteByteString( rStr, gsl_getSystemTextEncoding() ); - //*pStrm << rStr; } else { @@ -1031,7 +1012,6 @@ sal_Bool lcl_WriteSbxVariable( const SbxVariable& rVar, SvStream* pStrm, // What does that mean for Unicode?! Choosing conversion to ByteString... ByteString aByteStr( rStr, gsl_getSystemTextEncoding() ); *pStrm << (const char*)aByteStr.GetBuffer(); - //*pStrm << (const char*)rStr.GetStr(); } } break; @@ -1099,15 +1079,20 @@ sal_Bool lcl_ReadSbxVariable( SbxVariable& rVar, SvStream* pStrm, case SbxLONG: case SbxULONG: - case SbxLONG64: - case SbxULONG64: { sal_Int32 aInt; *pStrm >> aInt; rVar.PutLong( aInt ); } break; - + case SbxSALINT64: + case SbxSALUINT64: + { + sal_uInt32 aInt; + *pStrm >> aInt; + rVar.PutInt64( (sal_Int64)aInt ); + } + break; case SbxSINGLE: { float nS; @@ -1394,8 +1379,6 @@ RTLFUNC(ResolvePath) { String aStr = rPar.Get(1)->GetString(); DirEntry aEntry( aStr ); - //if( aEntry.IsVirtual() ) - //aStr = aEntry.GetRealPathFromVirtualURL(); rPar.Get(0)->PutString( aStr ); } else @@ -1446,8 +1429,8 @@ RTLFUNC(TypeLen) case SbxDOUBLE: case SbxCURRENCY: case SbxDATE: - case SbxLONG64: - case SbxULONG64: + case SbxSALINT64: + case SbxSALUINT64: nLen = 8; break; @@ -2536,7 +2519,6 @@ RTLFUNC(FormatDateTime) // ShortDate: Display a date using the short date format specified // in your computer's regional settings. - // 12/21/2004 // 21.12.2004 case 2: pSbxVar->PutDate( floor(dDate) ); @@ -2617,6 +2599,546 @@ RTLFUNC(Round) rPar.Get(0)->PutDouble( dRes ); } +void CallFunctionAccessFunction( const Sequence< Any >& aArgs, const rtl::OUString& sFuncName, SbxVariable* pRet ) +{ + static Reference< XFunctionAccess > xFunc; + Any aRes; + try + { + if ( !xFunc.is() ) + { + Reference< XMultiServiceFactory > xFactory( getProcessServiceFactory() ); + if( xFactory.is() ) + { + xFunc.set( xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.FunctionAccess"))), UNO_QUERY_THROW); + } + } + Any aRet = xFunc->callFunction( sFuncName, aArgs ); + + unoToSbxValue( pRet, aRet ); + + } + catch( Exception& ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + } +} + +RTLFUNC(SYD) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 4 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + + // retrieve non-optional params + + Sequence< Any > aParams( 4 ); + aParams[ 0 ] <<= makeAny( rPar.Get(1)->GetDouble() ); + aParams[ 1 ] <<= makeAny( rPar.Get(2)->GetDouble() ); + aParams[ 2 ] <<= makeAny( rPar.Get(3)->GetDouble() ); + aParams[ 3 ] <<= makeAny( rPar.Get(4)->GetDouble() ); + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYD") ), rPar.Get( 0 ) ); +} + +RTLFUNC(SLN) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 3 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + + // retrieve non-optional params + + Sequence< Any > aParams( 3 ); + aParams[ 0 ] <<= makeAny( rPar.Get(1)->GetDouble() ); + aParams[ 1 ] <<= makeAny( rPar.Get(2)->GetDouble() ); + aParams[ 2 ] <<= makeAny( rPar.Get(3)->GetDouble() ); + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SLN") ), rPar.Get( 0 ) ); +} + +RTLFUNC(Pmt) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 3 || nArgCount > 5 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + // retrieve non-optional params + + double rate = rPar.Get(1)->GetDouble(); + double nper = rPar.Get(2)->GetDouble(); + double pmt = rPar.Get(3)->GetDouble(); + + // set default values for Optional args + double fv = 0; + double type = 0; + + // fv + if ( nArgCount >= 4 ) + { + if( rPar.Get(4)->GetType() != SbxEMPTY ) + fv = rPar.Get(4)->GetDouble(); + } + // type + if ( nArgCount >= 5 ) + { + if( rPar.Get(5)->GetType() != SbxEMPTY ) + type = rPar.Get(5)->GetDouble(); + } + + Sequence< Any > aParams( 5 ); + aParams[ 0 ] <<= rate; + aParams[ 1 ] <<= nper; + aParams[ 2 ] <<= pmt; + aParams[ 3 ] <<= fv; + aParams[ 4 ] <<= type; + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Pmt") ), rPar.Get( 0 ) ); +} + +RTLFUNC(PPmt) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 4 || nArgCount > 6 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + // retrieve non-optional params + + double rate = rPar.Get(1)->GetDouble(); + double per = rPar.Get(2)->GetDouble(); + double nper = rPar.Get(3)->GetDouble(); + double pv = rPar.Get(4)->GetDouble(); + + // set default values for Optional args + double fv = 0; + double type = 0; + + // fv + if ( nArgCount >= 5 ) + { + if( rPar.Get(5)->GetType() != SbxEMPTY ) + fv = rPar.Get(5)->GetDouble(); + } + // type + if ( nArgCount >= 6 ) + { + if( rPar.Get(6)->GetType() != SbxEMPTY ) + type = rPar.Get(6)->GetDouble(); + } + + Sequence< Any > aParams( 6 ); + aParams[ 0 ] <<= rate; + aParams[ 1 ] <<= per; + aParams[ 2 ] <<= nper; + aParams[ 3 ] <<= pv; + aParams[ 4 ] <<= fv; + aParams[ 5 ] <<= type; + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PPmt") ), rPar.Get( 0 ) ); +} + +RTLFUNC(PV) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 3 || nArgCount > 5 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + // retrieve non-optional params + + double rate = rPar.Get(1)->GetDouble(); + double nper = rPar.Get(2)->GetDouble(); + double pmt = rPar.Get(3)->GetDouble(); + + // set default values for Optional args + double fv = 0; + double type = 0; + + // fv + if ( nArgCount >= 4 ) + { + if( rPar.Get(4)->GetType() != SbxEMPTY ) + fv = rPar.Get(4)->GetDouble(); + } + // type + if ( nArgCount >= 5 ) + { + if( rPar.Get(5)->GetType() != SbxEMPTY ) + type = rPar.Get(5)->GetDouble(); + } + + Sequence< Any > aParams( 5 ); + aParams[ 0 ] <<= rate; + aParams[ 1 ] <<= nper; + aParams[ 2 ] <<= pmt; + aParams[ 3 ] <<= fv; + aParams[ 4 ] <<= type; + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PV") ), rPar.Get( 0 ) ); +} + +RTLFUNC(NPV) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 1 || nArgCount > 2 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + + Sequence< Any > aParams( 2 ); + aParams[ 0 ] <<= makeAny( rPar.Get(1)->GetDouble() ); + Any aValues = sbxToUnoValue( rPar.Get(2), + getCppuType( (Sequence<double>*)0 ) ); + + // convert for calc functions + Sequence< Sequence< double > > sValues(1); + aValues >>= sValues[ 0 ]; + aValues <<= sValues; + + aParams[ 1 ] <<= aValues; + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NPV") ), rPar.Get( 0 ) ); +} + +RTLFUNC(NPer) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 3 || nArgCount > 5 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + // retrieve non-optional params + + double rate = rPar.Get(1)->GetDouble(); + double pmt = rPar.Get(2)->GetDouble(); + double pv = rPar.Get(3)->GetDouble(); + + // set default values for Optional args + double fv = 0; + double type = 0; + + // fv + if ( nArgCount >= 4 ) + { + if( rPar.Get(4)->GetType() != SbxEMPTY ) + fv = rPar.Get(4)->GetDouble(); + } + // type + if ( nArgCount >= 5 ) + { + if( rPar.Get(5)->GetType() != SbxEMPTY ) + type = rPar.Get(5)->GetDouble(); + } + + Sequence< Any > aParams( 5 ); + aParams[ 0 ] <<= rate; + aParams[ 1 ] <<= pmt; + aParams[ 2 ] <<= pv; + aParams[ 3 ] <<= fv; + aParams[ 4 ] <<= type; + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NPer") ), rPar.Get( 0 ) ); +} + +RTLFUNC(MIRR) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 3 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + + // retrieve non-optional params + + Sequence< Any > aParams( 3 ); + Any aValues = sbxToUnoValue( rPar.Get(1), + getCppuType( (Sequence<double>*)0 ) ); + + // convert for calc functions + Sequence< Sequence< double > > sValues(1); + aValues >>= sValues[ 0 ]; + aValues <<= sValues; + + aParams[ 0 ] <<= aValues; + aParams[ 1 ] <<= makeAny( rPar.Get(2)->GetDouble() ); + aParams[ 2 ] <<= makeAny( rPar.Get(3)->GetDouble() ); + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("MIRR") ), rPar.Get( 0 ) ); +} + +RTLFUNC(IRR) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 1 || nArgCount > 2 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + // retrieve non-optional params + Any aValues = sbxToUnoValue( rPar.Get(1), + getCppuType( (Sequence<double>*)0 ) ); + + // convert for calc functions + Sequence< Sequence< double > > sValues(1); + aValues >>= sValues[ 0 ]; + aValues <<= sValues; + + // set default values for Optional args + double guess = 0.1; + // guess + if ( nArgCount >= 2 ) + { + if( rPar.Get(2)->GetType() != SbxEMPTY ) + guess = rPar.Get(2)->GetDouble(); + } + + Sequence< Any > aParams( 2 ); + aParams[ 0 ] <<= aValues; + aParams[ 1 ] <<= guess; + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IRR") ), rPar.Get( 0 ) ); +} + +RTLFUNC(IPmt) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 4 || nArgCount > 6 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + // retrieve non-optional params + + double rate = rPar.Get(1)->GetDouble(); + double per = rPar.Get(2)->GetInteger(); + double nper = rPar.Get(3)->GetDouble(); + double pv = rPar.Get(4)->GetDouble(); + + // set default values for Optional args + double fv = 0; + double type = 0; + + // fv + if ( nArgCount >= 5 ) + { + if( rPar.Get(5)->GetType() != SbxEMPTY ) + fv = rPar.Get(5)->GetDouble(); + } + // type + if ( nArgCount >= 6 ) + { + if( rPar.Get(6)->GetType() != SbxEMPTY ) + type = rPar.Get(6)->GetDouble(); + } + + Sequence< Any > aParams( 6 ); + aParams[ 0 ] <<= rate; + aParams[ 1 ] <<= per; + aParams[ 2 ] <<= nper; + aParams[ 3 ] <<= pv; + aParams[ 4 ] <<= fv; + aParams[ 5 ] <<= type; + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("IPmt") ), rPar.Get( 0 ) ); +} + +RTLFUNC(FV) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 3 || nArgCount > 5 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + // retrieve non-optional params + + double rate = rPar.Get(1)->GetDouble(); + double nper = rPar.Get(2)->GetDouble(); + double pmt = rPar.Get(3)->GetDouble(); + + // set default values for Optional args + double pv = 0; + double type = 0; + + // pv + if ( nArgCount >= 4 ) + { + if( rPar.Get(4)->GetType() != SbxEMPTY ) + pv = rPar.Get(4)->GetDouble(); + } + // type + if ( nArgCount >= 5 ) + { + if( rPar.Get(5)->GetType() != SbxEMPTY ) + type = rPar.Get(5)->GetDouble(); + } + + Sequence< Any > aParams( 5 ); + aParams[ 0 ] <<= rate; + aParams[ 1 ] <<= nper; + aParams[ 2 ] <<= pmt; + aParams[ 3 ] <<= pv; + aParams[ 4 ] <<= type; + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("FV") ), rPar.Get( 0 ) ); +} + +RTLFUNC(DDB) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 4 || nArgCount > 5 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + // retrieve non-optional params + + double cost = rPar.Get(1)->GetDouble(); + double salvage = rPar.Get(2)->GetDouble(); + double life = rPar.Get(3)->GetDouble(); + double period = rPar.Get(4)->GetDouble(); + + // set default values for Optional args + double factor = 2; + + // factor + if ( nArgCount >= 5 ) + { + if( rPar.Get(5)->GetType() != SbxEMPTY ) + factor = rPar.Get(5)->GetDouble(); + } + + Sequence< Any > aParams( 5 ); + aParams[ 0 ] <<= cost; + aParams[ 1 ] <<= salvage; + aParams[ 2 ] <<= life; + aParams[ 3 ] <<= period; + aParams[ 4 ] <<= factor; + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DDB") ), rPar.Get( 0 ) ); +} + +RTLFUNC(Rate) +{ + (void)pBasic; + (void)bWrite; + + sal_uLong nArgCount = rPar.Count()-1; + + if ( nArgCount < 3 || nArgCount > 6 ) + { + StarBASIC::Error( SbERR_BAD_ARGUMENT ); + return; + } + // retrieve non-optional params + + double nper = 0; + double pmt = 0; + double pv = 0; + + nper = rPar.Get(1)->GetDouble(); + pmt = rPar.Get(2)->GetDouble(); + pv = rPar.Get(3)->GetDouble(); + + // set default values for Optional args + double fv = 0; + double type = 0; + double guess = 0.1; + + // fv + if ( nArgCount >= 4 ) + { + if( rPar.Get(4)->GetType() != SbxEMPTY ) + fv = rPar.Get(4)->GetDouble(); + } + + // type + if ( nArgCount >= 5 ) + { + if( rPar.Get(5)->GetType() != SbxEMPTY ) + type = rPar.Get(5)->GetDouble(); + } + + // guess + if ( nArgCount >= 6 ) + { + if( rPar.Get(6)->GetType() != SbxEMPTY ) + type = rPar.Get(6)->GetDouble(); + } + + Sequence< Any > aParams( 6 ); + aParams[ 0 ] <<= nper; + aParams[ 1 ] <<= pmt; + aParams[ 2 ] <<= pv; + aParams[ 3 ] <<= fv; + aParams[ 4 ] <<= type; + aParams[ 5 ] <<= guess; + + CallFunctionAccessFunction( aParams, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Rate") ), rPar.Get( 0 ) ); +} + RTLFUNC(StrReverse) { (void)pBasic; @@ -2697,7 +3219,6 @@ RTLFUNC(Input) rPar.Get(0)->PutString( String( aByteBuffer, gsl_getSystemTextEncoding() ) ); } -// #115824 RTLFUNC(Me) { (void)pBasic; @@ -2718,3 +3239,4 @@ RTLFUNC(Me) refVar->PutObject( pClassModuleObject ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/props.cxx b/basic/source/runtime/props.cxx index 032b687b987b..1c6723904e08 100644 --- a/basic/source/runtime/props.cxx +++ b/basic/source/runtime/props.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,6 +33,7 @@ #include "stdobj.hxx" #include "rtlproto.hxx" #include "errobject.hxx" +#include "basegfx/numeric/ftools.hxx" // Properties und Methoden legen beim Get (bWrite = sal_False) den Returnwert @@ -774,3 +776,4 @@ RTLFUNC(TYP_JUMPEDITFLD) } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/rtlproto.hxx b/basic/source/runtime/rtlproto.hxx index 8594382bd733..469cd0f0afe6 100644 --- a/basic/source/runtime/rtlproto.hxx +++ b/basic/source/runtime/rtlproto.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -167,29 +168,41 @@ extern RTLFUNC(Kill); // JSM extern RTLFUNC(MkDir); // JSM extern RTLFUNC(RmDir); // JSM extern RTLFUNC(SendKeys); // JSM +extern RTLFUNC(DDB); extern RTLFUNC(DimArray); extern RTLFUNC(Dir); extern RTLFUNC(DoEvents); extern RTLFUNC(Exp); extern RTLFUNC(FileLen); extern RTLFUNC(Fix); +extern RTLFUNC(FV); extern RTLFUNC(Hex); extern RTLFUNC(Input); extern RTLFUNC(InStr); extern RTLFUNC(InStrRev); extern RTLFUNC(Int); +extern RTLFUNC(IPmt); +extern RTLFUNC(IRR); extern RTLFUNC(Join); extern RTLFUNC(LCase); extern RTLFUNC(Left); extern RTLFUNC(Log); extern RTLFUNC(LTrim); extern RTLFUNC(Mid); +extern RTLFUNC(MIRR); +extern RTLFUNC(NPer); +extern RTLFUNC(NPV); extern RTLFUNC(Oct); +extern RTLFUNC(Pmt); +extern RTLFUNC(PPmt); +extern RTLFUNC(PV); +extern RTLFUNC(Rate); extern RTLFUNC(Replace); extern RTLFUNC(Right); extern RTLFUNC(RTrim); extern RTLFUNC(RTL); extern RTLFUNC(Sgn); +extern RTLFUNC(SLN); extern RTLFUNC(Space); extern RTLFUNC(Split); extern RTLFUNC(Sqr); @@ -197,6 +210,7 @@ extern RTLFUNC(Str); extern RTLFUNC(StrComp); extern RTLFUNC(String); extern RTLFUNC(StrReverse); +extern RTLFUNC(SYD); extern RTLFUNC(Tan); extern RTLFUNC(UCase); extern RTLFUNC(Val); @@ -300,6 +314,7 @@ extern RTLFUNC(Switch); extern RTLFUNC(Wait); //i#64882# add new WaitUntil extern RTLFUNC(WaitUntil); +extern RTLFUNC(FuncCaller); extern RTLFUNC(GetGUIVersion); extern RTLFUNC(Choose); @@ -355,3 +370,5 @@ extern RTLFUNC(TraceCommand); extern double Now_Impl(); extern void Wait_Impl( bool bDurationBased, SbxArray& rPar ); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 1a83a323931d..8e6299b6203f 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -44,9 +45,11 @@ #include <com/sun/star/container/XEnumerationAccess.hpp> #include "sbunoobj.hxx" #include "errobject.hxx" -#include "sbtrace.hxx" + #include "comenumwrapper.hxx" +SbxVariable* getDefaultProp( SbxVariable* pRef ); + using namespace ::com::sun::star; bool SbiRuntime::isVBAEnabled() @@ -220,9 +223,7 @@ SbiRuntime::pStep2 SbiRuntime::aStep2[] = {// Alle Opcodes mit zwei Operanden }; -////////////////////////////////////////////////////////////////////////// // SbiRTLData // -////////////////////////////////////////////////////////////////////////// SbiRTLData::SbiRTLData() { @@ -239,9 +240,7 @@ SbiRTLData::~SbiRTLData() delete pWildCard; } -////////////////////////////////////////////////////////////////////////// // SbiInstance // -////////////////////////////////////////////////////////////////////////// // 16.10.96: #31460 Neues Konzept fuer StepInto/Over/Out // Die Entscheidung, ob StepPoint aufgerufen werden soll, wird anhand des @@ -323,7 +322,7 @@ SbiInstance::~SbiInstance() } catch( const Exception& ) { - DBG_ERROR( "SbiInstance::~SbiInstance: caught an exception while disposing the components!" ); + OSL_FAIL( "SbiInstance::~SbiInstance: caught an exception while disposing the components!" ); } ComponentVector.clear(); @@ -537,15 +536,13 @@ SbxArray* SbiInstance::GetLocals( SbMethod* pMeth ) return NULL; } -////////////////////////////////////////////////////////////////////////// // SbiInstance // -////////////////////////////////////////////////////////////////////////// // Achtung: pMeth kann auch NULL sein (beim Aufruf des Init-Codes) SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart ) : rBasic( *(StarBASIC*)pm->pParent ), pInst( pINST ), - pMod( pm ), pMeth( pe ), pImg( pMod->pImage ), m_nLastTime(0) + pMod( pm ), pMeth( pe ), pImg( pMod->pImage ), mpExtCaller(0), m_nLastTime(0) { nFlags = pe ? pe->GetDebugFlags() : 0; pIosys = pInst->pIosys; @@ -602,6 +599,13 @@ SbiRuntime::~SbiRuntime() void SbiRuntime::SetVBAEnabled(bool bEnabled ) { bVBAEnabled = bEnabled; + if ( bVBAEnabled ) + { + if ( pMeth ) + mpExtCaller = pMeth->mCaller; + } + else + mpExtCaller = 0; } // Aufbau der Parameterliste. Alle ByRef-Parameter werden direkt @@ -728,11 +732,6 @@ sal_Bool SbiRuntime::Step() Application::Reschedule(); } -#ifdef DBG_TRACE_BASIC - sal_uInt32 nPC = ( pCode - (const sal_uInt8* )pImg->GetCode() ); - dbg_traceStep( pMod, nPC, pINST->nCallLvl ); -#endif - SbiOpcode eOp = (SbiOpcode ) ( *pCode++ ); sal_uInt32 nOp1, nOp2; if( eOp <= SbOP0_END ) @@ -769,11 +768,6 @@ sal_Bool SbiRuntime::Step() // (insbesondere nicht nach Compiler-Fehlern zur Laufzeit) if( nError && bRun ) { -#ifdef DBG_TRACE_BASIC - SbError nTraceErr = nError; - String aTraceErrMsg = GetSbData()->aErrMsg; - bool bTraceErrHandled = true; -#endif SbError err = nError; ClearExprStack(); nError = 0; @@ -781,7 +775,7 @@ sal_Bool SbiRuntime::Step() pInst->nErl = nLine; pErrCode = pCode; pErrStmnt = pStmnt; - // An error occured in an error handler + // An error occurred in an error handler // force parent handler ( if there is one ) // to handle the error bool bLetParentHandleThis = false; @@ -854,19 +848,10 @@ sal_Bool SbiRuntime::Step() // Kein Error-Hdl gefunden -> altes Vorgehen else { -#ifdef DBG_TRACE_BASIC - bTraceErrHandled = false; -#endif pInst->Abort(); } - // ALT: Nur - // pInst->Abort(); } - -#ifdef DBG_TRACE_BASIC - dbg_traceNotifyError( nTraceErr, aTraceErrMsg, bTraceErrHandled, pINST->nCallLvl ); -#endif } } return bRun; @@ -948,11 +933,7 @@ sal_Int32 SbiRuntime::translateErrorToVba( SbError nError, String& rMsg ) return nVBAErrorNumber; } -////////////////////////////////////////////////////////////////////////// -// // Parameter, Locals, Caller -// -////////////////////////////////////////////////////////////////////////// SbMethod* SbiRuntime::GetCaller() { @@ -969,11 +950,7 @@ SbxArray* SbiRuntime::GetParams() return refParams; } -////////////////////////////////////////////////////////////////////////// -// // Stacks -// -////////////////////////////////////////////////////////////////////////// // Der Expression-Stack steht fuer die laufende Auswertung von Expressions // zur Verfuegung. @@ -996,7 +973,7 @@ SbxVariableRef SbiRuntime::PopVar() SbxVariableRef xVar = refExprStk->Get( --nExprLvl ); #ifdef DBG_UTIL if ( xVar->GetName().EqualsAscii( "Cells" ) ) - DBG_TRACE( "" ); + OSL_TRACE( "" ); #endif // Methods halten im 0.Parameter sich selbst, also weghauen if( xVar->IsA( TYPE(SbxMethod) ) ) @@ -1036,7 +1013,24 @@ SbxVariable* SbiRuntime::GetTOS( short n ) void SbiRuntime::TOSMakeTemp() { SbxVariable* p = refExprStk->Get( nExprLvl - 1 ); - if( p->GetRefCount() != 1 ) + if ( p->GetType() == SbxEMPTY ) + p->Broadcast( SBX_HINT_DATAWANTED ); + + SbxVariable* pDflt = NULL; + if ( bVBAEnabled && ( p->GetType() == SbxOBJECT || p->GetType() == SbxVARIANT ) && ((pDflt = getDefaultProp(p)) != NULL) ) + { + pDflt->Broadcast( SBX_HINT_DATAWANTED ); + // replacing new p on stack causes object pointed by + // pDft->pParent to be deleted, when p2->Compute() is + // called below pParent is accessed ( but its deleted ) + // so set it to NULL now + pDflt->SetParent( NULL ); + p = new SbxVariable( *pDflt ); + p->SetFlag( SBX_READWRITE ); + refExprStk->Put( p, nExprLvl - 1 ); + } + + else if( p->GetRefCount() != 1 ) { SbxVariable* pNew = new SbxVariable( *p ); pNew->SetFlag( SBX_READWRITE ); @@ -1045,7 +1039,6 @@ void SbiRuntime::TOSMakeTemp() } // Der GOSUB-Stack nimmt Returnadressen fuer GOSUBs auf - void SbiRuntime::PushGosub( const sal_uInt8* pc ) { if( ++nGosubLvl > MAXRECURSION ) @@ -1244,29 +1237,23 @@ void SbiRuntime::ClearForStack() SbiForStack* SbiRuntime::FindForStackItemForCollection( class BasicCollection* pCollection ) { - SbiForStack* pRet = NULL; - - SbiForStack* p = pForStk; - while( p ) + for (SbiForStack *p = pForStk; p; p = p->pNext) { SbxVariable* pVar = p->refEnd.Is() ? (SbxVariable*)p->refEnd : NULL; if( p->eForType == FOR_EACH_COLLECTION && pVar != NULL && - (pCollection = PTR_CAST(BasicCollection,pVar)) == pCollection ) + PTR_CAST(BasicCollection,pVar) == pCollection ) { - pRet = p; - break; + return p; } } - return pRet; + return NULL; } ////////////////////////////////////////////////////////////////////////// // // DLL-Aufrufe -// -////////////////////////////////////////////////////////////////////////// void SbiRuntime::DllCall ( const String& aFuncName, // Funktionsname @@ -1283,15 +1270,6 @@ void SbiRuntime::DllCall } // MUSS NOCH IMPLEMENTIERT WERDEN - /* - String aMsg; - aMsg = "FUNC="; - aMsg += pFunc; - aMsg += " DLL="; - aMsg += pDLL; - MessBox( NULL, WB_OK, String( "DLL-CALL" ), aMsg ).Execute(); - Error( SbERR_NOT_IMPLEMENTED ); - */ SbxVariable* pRes = new SbxVariable( eResType ); SbiDllMgr* pDllMgr = pInst->GetDllMgr(); @@ -1310,3 +1288,5 @@ sal_uInt16 SbiRuntime::GetBase() { return pImg->GetBase(); } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx index 4004b40e882c..53b2ae11c76b 100644 --- a/basic/source/runtime/stdobj.cxx +++ b/basic/source/runtime/stdobj.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -31,15 +32,26 @@ #include "runtime.hxx" #include "stdobj.hxx" #include <basic/sbstdobj.hxx> +#include <sal/macros.h> #include "rtlproto.hxx" #include "sbintern.hxx" - +#include <boost/unordered_map.hpp> // Das nArgs-Feld eines Tabelleneintrags ist wie folgt verschluesselt: // Zur Zeit wird davon ausgegangen, dass Properties keine Parameter // benoetigen! -#define _ARGSMASK 0x007F // Bis zu 127 Argumente -#define _COMPTMASK 0x0080 // Only valid in compatibility mode +// previously _ARGSMASK was 0x007F ( e.g. up to 127 args ) however 63 should be +// enough, if not we need to increase the size of nArgs member in the Methods +// struct below. +// note: the limitation of 63 args is only for RTL functions defined here and +// does NOT impose a limit on User defined procedures ). This changes is to +// allow us space for a flag to blacklist some functions in vba mode + +#define _ARGSMASK 0x003F // 63 Arguments +#define _COMPTMASK 0x00C0 // COMPATABILITY mask +#define _COMPATONLY 0x0080 // procedure is visible in vba mode only +#define _NORMONLY 0x0040 // procedure is visible in normal mode only + #define _RWMASK 0x0F00 // Maske fuer R/W-Bits #define _TYPEMASK 0xF000 // Maske fuer den Typ des Eintrags @@ -69,6 +81,14 @@ struct Methods { sal_uInt16 nHash; // Hashcode }; +struct StringHashCode +{ + size_t operator()( const String& rStr ) const + { + return rtl_ustr_hashCode_WithLength( rStr.GetBuffer(), rStr.Len() ); + } +}; + static Methods aMethods[] = { { "AboutStarBasic", SbxNULL, 1 | _FUNCTION, RTLNAME(AboutStarBasic),0 }, @@ -78,7 +98,7 @@ static Methods aMethods[] = { { "Array", SbxOBJECT, _FUNCTION, RTLNAME(Array),0 }, { "Asc", SbxLONG, 1 | _FUNCTION, RTLNAME(Asc),0 }, { "string", SbxSTRING, 0,NULL,0 }, -{ "AscW", SbxLONG, 1 | _FUNCTION | _COMPTMASK, RTLNAME(Asc),0}, +{ "AscW", SbxLONG, 1 | _FUNCTION | _COMPATONLY, RTLNAME(Asc),0}, { "string", SbxSTRING, 0,NULL,0 }, { "Atn", SbxDOUBLE, 1 | _FUNCTION, RTLNAME(Atn),0 }, { "number", SbxDOUBLE, 0,NULL,0 }, @@ -91,7 +111,7 @@ static Methods aMethods[] = { { "ATTR_VOLUME", SbxINTEGER, _CPROP, RTLNAME(ATTR_VOLUME),0 }, { "Beep", SbxNULL, _FUNCTION, RTLNAME(Beep),0 }, -{ "Blue", SbxINTEGER, 1 | _FUNCTION, RTLNAME(Blue),0 }, +{ "Blue", SbxINTEGER, 1 | _FUNCTION | _NORMONLY, RTLNAME(Blue),0 }, { "RGB-Value", SbxLONG, 0,NULL,0 }, { "CallByName", SbxVARIANT, 3 | _FUNCTION, RTLNAME(CallByName),0 }, @@ -128,7 +148,7 @@ static Methods aMethods[] = { { "Chr", SbxSTRING, 1 | _FUNCTION, RTLNAME(Chr),0 }, { "string", SbxINTEGER, 0,NULL,0 }, -{ "ChrW", SbxSTRING, 1 | _FUNCTION | _COMPTMASK, RTLNAME(ChrW),0}, +{ "ChrW", SbxSTRING, 1 | _FUNCTION | _COMPATONLY, RTLNAME(ChrW),0}, { "string", SbxINTEGER, 0,NULL,0 }, { "CInt", SbxINTEGER, 1 | _FUNCTION, RTLNAME(CInt),0 }, @@ -177,7 +197,12 @@ static Methods aMethods[] = { { "expression", SbxVARIANT, 0,NULL,0 }, { "CVErr", SbxVARIANT, 1 | _FUNCTION, RTLNAME(CVErr),0 }, { "expression", SbxVARIANT, 0,NULL,0 }, - +{ "DDB", SbxDOUBLE, 5 | _FUNCTION | _COMPATONLY, RTLNAME(DDB),0 }, + { "Cost", SbxDOUBLE, 0, NULL,0 }, + { "Salvage", SbxDOUBLE, 0, NULL,0 }, + { "Life", SbxDOUBLE, 0, NULL,0 }, + { "Period", SbxDOUBLE, 0, NULL,0 }, + { "Factor", SbxVARIANT, _OPT, NULL,0 }, { "Date", SbxDATE, _LFUNCTION,RTLNAME(Date),0 }, { "DateAdd", SbxDATE, 3 | _FUNCTION, RTLNAME(DateAdd),0 }, { "Interval", SbxSTRING, 0,NULL,0 }, @@ -222,7 +247,7 @@ static Methods aMethods[] = { { "Dir", SbxSTRING, 2 | _FUNCTION, RTLNAME(Dir),0 }, { "FileSpec", SbxSTRING, _OPT, NULL,0 }, { "attrmask", SbxINTEGER, _OPT, NULL,0 }, -{ "DoEvents", SbxEMPTY, _FUNCTION, RTLNAME(DoEvents),0 }, +{ "DoEvents", SbxINTEGER, _FUNCTION, RTLNAME(DoEvents),0 }, { "DumpAllObjects", SbxEMPTY, 2 | _SUB, RTLNAME(DumpAllObjects),0 }, { "FileSpec", SbxSTRING, 0,NULL,0 }, { "DumpAll", SbxINTEGER, _OPT, NULL,0 }, @@ -267,7 +292,7 @@ static Methods aMethods[] = { { "Format", SbxSTRING, 2 | _FUNCTION, RTLNAME(Format),0 }, { "expression", SbxVARIANT, 0,NULL,0 }, { "format", SbxSTRING, _OPT, NULL,0 }, -{ "FormatDateTime", SbxSTRING, 2 | _FUNCTION | _COMPTMASK, RTLNAME(FormatDateTime),0 }, +{ "FormatDateTime", SbxSTRING, 2 | _FUNCTION | _COMPATONLY, RTLNAME(FormatDateTime),0 }, { "Date", SbxDATE, 0,NULL,0 }, { "NamedFormat", SbxINTEGER, _OPT, NULL,0 }, { "FRAMEANCHORCHAR", SbxINTEGER, _CPROP, RTLNAME(FRAMEANCHORCHAR),0 }, @@ -277,6 +302,12 @@ static Methods aMethods[] = { { "FreeLibrary", SbxNULL, 1 | _FUNCTION, RTLNAME(FreeLibrary),0 }, { "Modulename", SbxSTRING, 0,NULL,0 }, +{ "FV", SbxDOUBLE, 5 | _FUNCTION | _COMPATONLY, RTLNAME(FV),0 }, + { "Rate", SbxDOUBLE, 0, NULL,0 }, + { "NPer", SbxDOUBLE, 0, NULL,0 }, + { "Pmt", SbxDOUBLE, 0, NULL,0 }, + { "PV", SbxVARIANT, _OPT, NULL,0 }, + { "Due", SbxVARIANT, _OPT, NULL,0 }, { "Get", SbxNULL, 3 | _FUNCTION, RTLNAME(Get),0 }, { "filenumber", SbxINTEGER, 0,NULL,0 }, { "recordnumber", SbxLONG, 0,NULL,0 }, @@ -294,7 +325,7 @@ static Methods aMethods[] = { { "GetSystemTicks", SbxLONG, _FUNCTION,RTLNAME(GetSystemTicks),0 }, { "GetSystemType", SbxINTEGER, _FUNCTION,RTLNAME(GetSystemType),0 }, { "GlobalScope", SbxOBJECT, _FUNCTION,RTLNAME(GlobalScope),0 }, -{ "Green", SbxINTEGER, 1 | _FUNCTION, RTLNAME(Green),0 }, +{ "Green", SbxINTEGER, 1 | _FUNCTION | _NORMONLY, RTLNAME(Green),0 }, { "RGB-Value", SbxLONG, 0,NULL,0 }, { "HasUnoInterfaces", SbxBOOL, 1 | _FUNCTION, RTLNAME(HasUnoInterfaces),0}, @@ -316,7 +347,7 @@ static Methods aMethods[] = { { "Variant1", SbxVARIANT, 0,NULL,0 }, { "Variant2", SbxVARIANT, 0,NULL,0 }, -{ "Input", SbxSTRING, 2 | _FUNCTION | _COMPTMASK, RTLNAME(Input),0}, +{ "Input", SbxSTRING, 2 | _FUNCTION | _COMPATONLY, RTLNAME(Input),0}, { "Number", SbxLONG, 0,NULL,0 }, { "FileNumber", SbxLONG, 0,NULL,0 }, { "InputBox", SbxSTRING, 5 | _FUNCTION, RTLNAME(InputBox),0 }, @@ -330,13 +361,23 @@ static Methods aMethods[] = { { "String1", SbxSTRING, 0,NULL,0 }, { "String2", SbxSTRING, 0,NULL,0 }, { "Compare", SbxINTEGER, _OPT, NULL,0 }, -{ "InStrRev", SbxLONG, 4 | _FUNCTION | _COMPTMASK, RTLNAME(InStrRev),0}, +{ "InStrRev", SbxLONG, 4 | _FUNCTION | _COMPATONLY, RTLNAME(InStrRev),0}, { "String1", SbxSTRING, 0,NULL,0 }, { "String2", SbxSTRING, 0,NULL,0 }, { "Start", SbxSTRING, _OPT, NULL,0 }, { "Compare", SbxINTEGER, _OPT, NULL,0 }, { "Int", SbxDOUBLE, 1 | _FUNCTION, RTLNAME(Int),0 }, { "number", SbxDOUBLE, 0,NULL,0 }, +{ "IPmt", SbxDOUBLE, 6 | _FUNCTION | _COMPATONLY, RTLNAME(IPmt),0 }, + { "Rate", SbxDOUBLE, 0, NULL,0 }, + { "Per", SbxDOUBLE, 0, NULL,0 }, + { "NPer", SbxDOUBLE, 0, NULL,0 }, + { "PV", SbxDOUBLE, 0, NULL,0 }, + { "FV", SbxVARIANT, _OPT, NULL,0 }, + { "Due", SbxVARIANT, _OPT, NULL,0 }, +{ "IRR", SbxDOUBLE, 2 | _FUNCTION | _COMPATONLY, RTLNAME(IRR),0 }, + { "ValueArray", SbxARRAY, 0, NULL,0 }, + { "Guess", SbxVARIANT, _OPT, NULL,0 }, { "IsArray", SbxBOOL, 1 | _FUNCTION, RTLNAME(IsArray),0 }, { "Variant", SbxVARIANT, 0,NULL,0 }, { "IsDate", SbxBOOL, 1 | _FUNCTION, RTLNAME(IsDate),0 }, @@ -400,18 +441,22 @@ static Methods aMethods[] = { { "MB_YESNO", SbxINTEGER, _CPROP, RTLNAME(MB_YESNO),0 }, { "MB_YESNOCANCEL", SbxINTEGER, _CPROP, RTLNAME(MB_YESNOCANCEL),0 }, -{ "Me", SbxOBJECT, 0 | _FUNCTION | _COMPTMASK, RTLNAME(Me),0 }, +{ "Me", SbxOBJECT, 0 | _FUNCTION | _COMPATONLY, RTLNAME(Me),0 }, { "Mid", SbxSTRING, 3 | _LFUNCTION,RTLNAME(Mid),0 }, { "String", SbxSTRING, 0,NULL,0 }, { "StartPos", SbxLONG, 0,NULL,0 }, { "Length", SbxLONG, _OPT, NULL,0 }, { "Minute", SbxINTEGER, 1 | _FUNCTION, RTLNAME(Minute),0 }, { "Date", SbxDATE, 0,NULL,0 }, +{ "MIRR", SbxDOUBLE, 2 | _FUNCTION | _COMPATONLY, RTLNAME(MIRR),0 }, + { "ValueArray", SbxARRAY, 0, NULL,0 }, + { "FinanceRate", SbxDOUBLE, 0, NULL,0 }, + { "ReinvestRate", SbxDOUBLE, 0, NULL,0 }, { "MkDir", SbxNULL, 1 | _FUNCTION, RTLNAME(MkDir),0 }, { "pathname", SbxSTRING, 0,NULL,0 }, { "Month", SbxINTEGER, 1 | _FUNCTION, RTLNAME(Month),0 }, { "Date", SbxDATE, 0,NULL,0 }, -{ "MonthName", SbxSTRING, 2 | _FUNCTION | _COMPTMASK, RTLNAME(MonthName),0 }, +{ "MonthName", SbxSTRING, 2 | _FUNCTION | _COMPATONLY, RTLNAME(MonthName),0 }, { "Month", SbxINTEGER, 0,NULL,0 }, { "Abbreviate", SbxBOOL, _OPT, NULL,0 }, { "MsgBox", SbxINTEGER, 5 | _FUNCTION, RTLNAME(MsgBox),0 }, @@ -423,6 +468,15 @@ static Methods aMethods[] = { { "Nothing", SbxOBJECT, _CPROP, RTLNAME(Nothing),0 }, { "Now", SbxDATE, _FUNCTION, RTLNAME(Now),0 }, +{ "NPer", SbxDOUBLE, 5 | _FUNCTION | _COMPATONLY, RTLNAME(NPer),0 }, + { "Rate", SbxDOUBLE, 0, NULL,0 }, + { "Pmt", SbxDOUBLE, 0, NULL,0 }, + { "PV", SbxDOUBLE, 0, NULL,0 }, + { "FV", SbxVARIANT, _OPT, NULL,0 }, + { "Due", SbxVARIANT, _OPT, NULL,0 }, +{ "NPV", SbxDOUBLE, 2 | _FUNCTION | _COMPATONLY, RTLNAME(NPV),0 }, + { "Rate", SbxDOUBLE, 0, NULL,0 }, + { "ValueArray", SbxARRAY, 0, NULL,0 }, { "Null", SbxNULL, _CPROP, RTLNAME(Null),0 }, { "Oct", SbxSTRING, 1 | _FUNCTION, RTLNAME(Oct),0 }, @@ -434,17 +488,47 @@ static Methods aMethods[] = { { "stop", SbxLONG, 0,NULL,0 }, { "interval", SbxLONG, 0,NULL,0 }, { "Pi", SbxDOUBLE, _CPROP, RTLNAME(PI),0 }, + +{ "Pmt", SbxDOUBLE, 5 | _FUNCTION | _COMPATONLY, RTLNAME(Pmt),0 }, + { "Rate", SbxDOUBLE, 0, NULL,0 }, + { "NPer", SbxDOUBLE, 0, NULL,0 }, + { "PV", SbxDOUBLE, 0, NULL,0 }, + { "FV", SbxVARIANT, _OPT, NULL,0 }, + { "Due", SbxVARIANT, _OPT, NULL,0 }, + +{ "PPmt", SbxDOUBLE, 6 | _FUNCTION | _COMPATONLY, RTLNAME(PPmt),0 }, + { "Rate", SbxDOUBLE, 0, NULL,0 }, + { "Per", SbxDOUBLE, 0, NULL,0 }, + { "NPer", SbxDOUBLE, 0, NULL,0 }, + { "PV", SbxDOUBLE, 0, NULL,0 }, + { "FV", SbxVARIANT, _OPT, NULL,0 }, + { "Due", SbxVARIANT, _OPT, NULL,0 }, + { "Put", SbxNULL, 3 | _FUNCTION, RTLNAME(Put),0 }, { "filenumber", SbxINTEGER, 0,NULL,0 }, { "recordnumber", SbxLONG, 0,NULL,0 }, { "variablename", SbxVARIANT, 0,NULL,0 }, +{ "PV", SbxDOUBLE, 5 | _FUNCTION | _COMPATONLY, RTLNAME(PV),0 }, + { "Rate", SbxDOUBLE, 0, NULL,0 }, + { "NPer", SbxDOUBLE, 0, NULL,0 }, + { "Pmt", SbxDOUBLE, 0, NULL,0 }, + { "FV", SbxVARIANT, _OPT, NULL,0 }, + { "Due", SbxVARIANT, _OPT, NULL,0 }, + { "QBColor", SbxLONG, 1 | _FUNCTION, RTLNAME(QBColor),0 }, { "number", SbxINTEGER, 0,NULL,0 }, { "Randomize", SbxNULL, 1 | _FUNCTION, RTLNAME(Randomize),0 }, { "Number", SbxDOUBLE, _OPT, NULL,0 }, -{ "Red", SbxINTEGER, 1 | _FUNCTION, RTLNAME(Red),0 }, +{ "Rate", SbxDOUBLE, 6 | _FUNCTION | _COMPATONLY, RTLNAME(Rate),0 }, + { "NPer", SbxDOUBLE, 0, NULL,0 }, + { "Pmt", SbxDOUBLE, 0, NULL,0 }, + { "PV", SbxDOUBLE, 0, NULL,0 }, + { "FV", SbxVARIANT, _OPT, NULL,0 }, + { "Due", SbxVARIANT, _OPT, NULL,0 }, + { "Guess", SbxVARIANT, _OPT, NULL,0 }, +{ "Red", SbxINTEGER, 1 | _FUNCTION | _NORMONLY, RTLNAME(Red),0 }, { "RGB-Value", SbxLONG, 0,NULL,0 }, { "Reset", SbxNULL, 0 | _FUNCTION, RTLNAME(Reset),0 }, { "ResolvePath", SbxSTRING, 1 | _FUNCTION, RTLNAME(ResolvePath),0 }, @@ -465,12 +549,12 @@ static Methods aMethods[] = { { "Count", SbxLONG, 0,NULL,0 }, { "RmDir", SbxNULL, 1 | _FUNCTION, RTLNAME(RmDir),0 }, { "pathname", SbxSTRING, 0,NULL,0 }, -{ "Round", SbxDOUBLE, 2 | _FUNCTION | _COMPTMASK, RTLNAME(Round),0}, +{ "Round", SbxDOUBLE, 2 | _FUNCTION | _COMPATONLY, RTLNAME(Round),0}, { "Expression", SbxDOUBLE, 0,NULL,0 }, { "Numdecimalplaces", SbxINTEGER, _OPT, NULL,0 }, { "Rnd", SbxDOUBLE, 1 | _FUNCTION, RTLNAME(Rnd),0 }, { "Number", SbxDOUBLE, _OPT, NULL,0 }, -{ "RTL", SbxOBJECT, 0 | _FUNCTION | _COMPTMASK, RTLNAME(RTL),0}, +{ "RTL", SbxOBJECT, 0 | _FUNCTION | _COMPATONLY, RTLNAME(RTL),0}, { "RTrim", SbxSTRING, 1 | _FUNCTION, RTLNAME(RTrim),0 }, { "string", SbxSTRING, 0,NULL,0 }, @@ -497,6 +581,15 @@ static Methods aMethods[] = { { "WindowStyle", SbxINTEGER, _OPT, NULL,0 }, { "Sin", SbxDOUBLE, 1 | _FUNCTION, RTLNAME(Sin),0 }, { "number", SbxDOUBLE, 0,NULL,0 }, +{ "SLN", SbxDOUBLE, 2 | _FUNCTION | _COMPATONLY, RTLNAME(SLN),0 }, + { "Cost", SbxDOUBLE, 0,NULL,0 }, + { "Double", SbxDOUBLE, 0,NULL,0 }, + { "Life", SbxDOUBLE, 0,NULL,0 }, +{ "SYD", SbxDOUBLE, 2 | _FUNCTION | _COMPATONLY, RTLNAME(SYD),0 }, + { "Cost", SbxDOUBLE, 0,NULL,0 }, + { "Salvage", SbxDOUBLE, 0,NULL,0 }, + { "Life", SbxDOUBLE, 0,NULL,0 }, + { "Period", SbxDOUBLE, 0,NULL,0 }, { "Space", SbxSTRING, 1 | _FUNCTION, RTLNAME(Space),0 }, { "string", SbxLONG, 0,NULL,0 }, { "Spc", SbxSTRING, 1 | _FUNCTION, RTLNAME(Spc),0 }, @@ -520,7 +613,7 @@ static Methods aMethods[] = { { "String", SbxSTRING, 2 | _FUNCTION, RTLNAME(String),0 }, { "Count", SbxLONG, 0,NULL,0 }, { "Filler", SbxVARIANT, 0,NULL,0 }, -{ "StrReverse", SbxSTRING, 1 | _FUNCTION | _COMPTMASK, RTLNAME(StrReverse),0 }, +{ "StrReverse", SbxSTRING, 1 | _FUNCTION | _COMPATONLY, RTLNAME(StrReverse),0 }, { "String1", SbxSTRING, 0,NULL,0 }, { "Switch", SbxVARIANT, 2 | _FUNCTION, RTLNAME(Switch),0 }, { "Expression", SbxVARIANT, 0,NULL,0 }, @@ -615,13 +708,14 @@ static Methods aMethods[] = { { "Wait", SbxNULL, 1 | _FUNCTION, RTLNAME(Wait),0 }, { "Milliseconds", SbxLONG, 0,NULL,0 }, +{ "FuncCaller", SbxVARIANT, _FUNCTION, RTLNAME(FuncCaller),0 }, //#i64882# { "WaitUntil", SbxNULL, 1 | _FUNCTION, RTLNAME(WaitUntil),0 }, { "Date", SbxDOUBLE, 0,NULL,0 }, { "Weekday", SbxINTEGER, 2 | _FUNCTION, RTLNAME(Weekday),0 }, { "Date", SbxDATE, 0,NULL,0 }, { "Firstdayofweek", SbxINTEGER, _OPT, NULL,0 }, -{ "WeekdayName", SbxSTRING, 3 | _FUNCTION | _COMPTMASK, RTLNAME(WeekdayName),0 }, +{ "WeekdayName", SbxSTRING, 3 | _FUNCTION | _COMPATONLY, RTLNAME(WeekdayName),0 }, { "Weekday", SbxINTEGER, 0,NULL,0 }, { "Abbreviate", SbxBOOL, _OPT, NULL,0 }, { "Firstdayofweek", SbxINTEGER, _OPT, NULL,0 }, @@ -693,11 +787,11 @@ SbxVariable* SbiStdObject::Find( const String& rName, SbxClassType t ) && ( p->nHash == nHash_ ) && ( rName.EqualsIgnoreCaseAscii( p->pName ) ) ) { + SbiInstance* pInst = pINST; bFound = sal_True; if( p->nArgs & _COMPTMASK ) { - SbiInstance* pInst = pINST; - if( !pInst || !pInst->IsCompatibility() ) + if ( !pInst || ( pInst->IsCompatibility() && ( _NORMONLY & p->nArgs ) ) || ( !pInst->IsCompatibility() && ( _COMPATONLY & p->nArgs ) ) ) bFound = sal_False; } break; @@ -727,7 +821,7 @@ SbxVariable* SbiStdObject::Find( const String& rName, SbxClassType t ) return pVar; } -// SetModified muß bei der RTL abgklemmt werden +// SetModified mu� bei der RTL abgklemmt werden void SbiStdObject::SetModified( sal_Bool ) { } @@ -780,8 +874,6 @@ SbxInfo* SbiStdObject::GetInfo( short nIdx ) if( !nIdx ) return NULL; Methods* p = &aMethods[ --nIdx ]; - // Wenn mal eine Hilfedatei zur Verfuegung steht: - // SbxInfo* pInfo_ = new SbxInfo( Hilfedateiname, p->nHelpId ); SbxInfo* pInfo_ = new SbxInfo; short nPar = p->nArgs & _ARGSMASK; for( short i = 0; i < nPar; i++ ) @@ -796,3 +888,4 @@ SbxInfo* SbiStdObject::GetInfo( short nIdx ) return pInfo_; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/stdobj1.cxx b/basic/source/runtime/stdobj1.cxx index 29cbf16125c7..b8759d7826ae 100644 --- a/basic/source/runtime/stdobj1.cxx +++ b/basic/source/runtime/stdobj1.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -312,41 +313,6 @@ void SbStdFont::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, //----------------------------------------------------------------------------- -/* -class TransferableHelperImpl : public TransferableHelper -{ - SotFormatStringId mFormat; - String mString; - Graphic mGraphic; - - virtual void AddSupportedFormats(); - virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); - -public: - TransferableHelperImpl( void ) { mFormat = 0; } - TransferableHelperImpl( const String& rStr ) - mFormat( FORMAT_STRING ), mString( rStr ) {} - TransferableHelperImpl( const Graphic& rGraphic ); - mFormat( FORMAT_BITMAP ), mGraphic( rGraphic ) {} - -}; - -void TransferableHelperImpl::AddSupportedFormats() -{ -} - -sal_Bool TransferableHelperImpl::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) -{ - sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor ); - if( nFormat == FORMAT_STRING ) - { - } - else if( nFormat == FORMAT_BITMAP || - nFormat == FORMAT_GDIMETAFILE ) - { - } -} -*/ void SbStdClipboard::MethClear( SbxVariable*, SbxArray* pPar_, sal_Bool ) { @@ -356,7 +322,6 @@ void SbStdClipboard::MethClear( SbxVariable*, SbxArray* pPar_, sal_Bool ) return; } - //Clipboard::Clear(); } void SbStdClipboard::MethGetData( SbxVariable* pVar, SbxArray* pPar_, sal_Bool ) @@ -376,20 +341,6 @@ void SbStdClipboard::MethGetData( SbxVariable* pVar, SbxArray* pPar_, sal_Bool ) return; } - /* - if( nFormat == FORMAT_STRING ) - pVar->PutString( Clipboard::PasteString() ); - else - if( (nFormat == FORMAT_BITMAP) || - (nFormat == FORMAT_GDIMETAFILE ) ) - { - SbxObjectRef xPic = new SbStdPicture; - Graphic aGraph; - aGraph.Paste(); - ((SbStdPicture*)(SbxObject*)xPic)->SetGraphic( aGraph ); - pVar->PutObject( xPic ); - } - */ } void SbStdClipboard::MethGetFormat( SbxVariable* pVar, SbxArray* pPar_, sal_Bool ) @@ -408,7 +359,6 @@ void SbStdClipboard::MethGetFormat( SbxVariable* pVar, SbxArray* pPar_, sal_Bool } pVar->PutBool( sal_False ); - //pVar->PutBool( Clipboard::HasFormat( nFormat ) ); } void SbStdClipboard::MethGetText( SbxVariable* pVar, SbxArray* pPar_, sal_Bool ) @@ -420,7 +370,6 @@ void SbStdClipboard::MethGetText( SbxVariable* pVar, SbxArray* pPar_, sal_Bool ) } pVar->PutString( String() ); - //pVar->PutString( Clipboard::PasteString() ); } void SbStdClipboard::MethSetData( SbxVariable* pVar, SbxArray* pPar_, sal_Bool ) @@ -440,21 +389,6 @@ void SbStdClipboard::MethSetData( SbxVariable* pVar, SbxArray* pPar_, sal_Bool ) return; } - /* - if( nFormat == FORMAT_STRING ) - { - Clipboard::CopyString( pPar_->Get(1)->GetString() ); - } - else - if( (nFormat == FORMAT_BITMAP) || - (nFormat == FORMAT_GDIMETAFILE) ) - { - SbxObject* pObj = (SbxObject*)pPar_->Get(1)->GetObject(); - - if( pObj && pObj->IsA( TYPE( SbStdPicture ) ) ) - ((SbStdPicture*)(SbxObject*)pObj)->GetGraphic().Copy(); - } - */ } void SbStdClipboard::MethSetText( SbxVariable* pVar, SbxArray* pPar_, sal_Bool ) @@ -467,7 +401,6 @@ void SbStdClipboard::MethSetText( SbxVariable* pVar, SbxArray* pPar_, sal_Bool ) return; } - // Clipboard::CopyString( pPar_->Get(1)->GetString() ); } @@ -549,3 +482,4 @@ void SbStdClipboard::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index 462726a4c55f..bc3aeabf0255 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -47,7 +48,12 @@ Reference< XInterface > createComListener( const Any& aControlAny, const ::rtl:: const ::rtl::OUString& aPrefix, SbxObjectRef xScopeObj ); #include <algorithm> -#include <hash_map> +#include <boost/unordered_map.hpp> + +// for a patch forward declaring these methods below makes sense +// but, #FIXME lets really just move the methods to the top +void lcl_clearImpl( SbxVariableRef& refVar, SbxDataType& eType ); +void lcl_eraseImpl( SbxVariableRef& refVar, bool bVBAEnabled ); SbxVariable* getDefaultProp( SbxVariable* pRef ); @@ -60,34 +66,6 @@ void SbiRuntime::StepArith( SbxOperator eOp ) TOSMakeTemp(); SbxVariable* p2 = GetTOS(); - - // This could & should be moved to the MakeTempTOS() method in runtime.cxx - // In the code which this is cut'npaste from there is a check for a ref - // count != 1 based on which the copy of the SbxVariable is done. - // see orig code in MakeTempTOS ( and I'm not sure what the significance, - // of that is ) - // here we alway seem to have a refcount of 1. Also it seems that - // MakeTempTOS is called for other operation, so I hold off for now - // until I have a better idea - if ( bVBAEnabled - && ( p2->GetType() == SbxOBJECT || p2->GetType() == SbxVARIANT ) - ) - { - SbxVariable* pDflt = getDefaultProp( p2 ); - if ( pDflt ) - { - pDflt->Broadcast( SBX_HINT_DATAWANTED ); - // replacing new p2 on stack causes object pointed by - // pDft->pParent to be deleted, when p2->Compute() is - // called below pParent is accessed ( but its deleted ) - // so set it to NULL now - pDflt->SetParent( NULL ); - p2 = new SbxVariable( *pDflt ); - p2->SetFlag( SBX_READWRITE ); - refExprStk->Put( p2, nExprLvl - 1 ); - } - } - p2->ResetFlag( SBX_FIXED ); p2->Compute( eOp, *p1 ); @@ -110,19 +88,24 @@ void SbiRuntime::StepCompare( SbxOperator eOp ) // values ( and type ) set as appropriate SbxDataType p1Type = p1->GetType(); SbxDataType p2Type = p2->GetType(); + if ( p1Type == SbxEMPTY ) + { + p1->Broadcast( SBX_HINT_DATAWANTED ); + p1Type = p1->GetType(); + } + if ( p2Type == SbxEMPTY ) + { + p2->Broadcast( SBX_HINT_DATAWANTED ); + p2Type = p2->GetType(); + } if ( p1Type == p2Type ) { - if ( p1Type == SbxEMPTY ) - { - p1->Broadcast( SBX_HINT_DATAWANTED ); - p2->Broadcast( SBX_HINT_DATAWANTED ); - } // if both sides are an object and have default props // then we need to use the default props // we don't need to worry if only one side ( lhs, rhs ) is an // object ( object side will get coerced to correct type in // Compare ) - else if ( p1Type == SbxOBJECT ) + if ( p1Type == SbxOBJECT ) { SbxVariable* pDflt = getDefaultProp( p1 ); if ( pDflt ) @@ -141,8 +124,21 @@ void SbiRuntime::StepCompare( SbxOperator eOp ) } static SbxVariable* pTRUE = NULL; static SbxVariable* pFALSE = NULL; - - if( p2->Compare( eOp, *p1 ) ) + static SbxVariable* pNULL = NULL; + // why do this on non-windows ? + // why do this at all ? + // I dumbly follow the pattern :-/ + if ( bVBAEnabled && ( p1->IsNull() || p2->IsNull() ) ) + { + if( !pNULL ) + { + pNULL = new SbxVariable; + pNULL->PutNull(); + pNULL->AddRef(); + } + PushVar( pNULL ); + } + else if( p2->Compare( eOp, *p1 ) ) { if( !pTRUE ) { @@ -449,7 +445,8 @@ struct SbxVariablePtrHash { return (size_t)pVar; } }; -typedef std::hash_map< SbxVariable*, DimAsNewRecoverItem, SbxVariablePtrHash > DimAsNewRecoverHash; +typedef boost::unordered_map< SbxVariable*, DimAsNewRecoverItem, + SbxVariablePtrHash > DimAsNewRecoverHash; static DimAsNewRecoverHash GaDimAsNewRecoverHash; @@ -480,7 +477,6 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b // Check value, !object is no error for sure if, only if type is fixed SbxDataType eValType = refVal->GetType(); -// bool bGetValObject = false; if( !bHandleDefaultProp && eValType != SbxOBJECT && !(eValType & SbxARRAY) && refVal->IsFixed() ) { Error( SbERR_INVALID_USAGE_OBJECT ); @@ -693,7 +689,6 @@ void SbiRuntime::StepVBASET() } -// JSM 07.10.95 void SbiRuntime::StepLSET() { SbxVariableRef refVal = PopVar(); @@ -729,7 +724,6 @@ void SbiRuntime::StepLSET() } } -// JSM 07.10.95 void SbiRuntime::StepRSET() { SbxVariableRef refVal = PopVar(); @@ -785,6 +779,17 @@ void SbiRuntime::StepDIM() // #56204 DIM-Funktionalitaet in Hilfsmethode auslagern (step0.cxx) void SbiRuntime::DimImpl( SbxVariableRef refVar ) { + // If refDim then this DIM statement is terminating a ReDIM and + // previous StepERASE_CLEAR for an array, the following actions have + // been delayed from ( StepERASE_CLEAR ) 'till here + if ( refRedim ) + { + if ( !refRedimpArray ) // only erase the array not ReDim Preserve + lcl_eraseImpl( refVar, bVBAEnabled ); + SbxDataType eType = refVar->GetType(); + lcl_clearImpl( refVar, eType ); + refRedim = NULL; + } SbxArray* pDims = refVar->GetParameters(); // Muss eine gerade Anzahl Argumente haben // Man denke daran, dass Arg[0] nicht zaehlt! @@ -794,7 +799,7 @@ void SbiRuntime::DimImpl( SbxVariableRef refVar ) { SbxDataType eType = refVar->IsFixed() ? refVar->GetType() : SbxVARIANT; SbxDimArray* pArray = new SbxDimArray( eType ); - // AB 2.4.1996, auch Arrays ohne Dimensionsangaben zulassen (VB-komp.) + // auch Arrays ohne Dimensionsangaben zulassen (VB-komp.) if( pDims ) { refVar->ResetFlag( SBX_VAR_TO_DIM ); @@ -898,27 +903,11 @@ void SbiRuntime::StepREDIMP() sal_Int32 lBoundOld, uBoundOld; pNewArray->GetDim32( i, lBoundNew, uBoundNew ); pOldArray->GetDim32( i, lBoundOld, uBoundOld ); - - /* #69094 Allow all dimensions to be changed - although Visual Basic is not able to do so. - // All bounds but the last have to be the same - if( i < nDims && ( lBoundNew != lBoundOld || uBoundNew != uBoundOld ) ) - { - bRangeError = sal_True; - break; - } - else - */ - { - // #69094: if( i == nDims ) - { - lBoundNew = std::max( lBoundNew, lBoundOld ); - uBoundNew = std::min( uBoundNew, uBoundOld ); - } - short j = i - 1; - pActualIndices[j] = pLowerBounds[j] = lBoundNew; - pUpperBounds[j] = uBoundNew; - } + lBoundNew = std::max( lBoundNew, lBoundOld ); + uBoundNew = std::min( uBoundNew, uBoundOld ); + short j = i - 1; + pActualIndices[j] = pLowerBounds[j] = lBoundNew; + pUpperBounds[j] = uBoundNew; } } @@ -942,7 +931,6 @@ void SbiRuntime::StepREDIMP() } } - //StarBASIC::FatalError( SbERR_NOT_IMPLEMENTED ); } // REDIM_COPY @@ -952,6 +940,7 @@ void SbiRuntime::StepREDIMP() void SbiRuntime::StepREDIMP_ERASE() { SbxVariableRef refVar = PopVar(); + refRedim = refVar; SbxDataType eType = refVar->GetType(); if( eType & SbxARRAY ) { @@ -962,12 +951,6 @@ void SbiRuntime::StepREDIMP_ERASE() refRedimpArray = pDimArray; } - // As in ERASE - sal_uInt16 nSavFlags = refVar->GetFlags(); - refVar->ResetFlag( SBX_FIXED ); - refVar->SetType( SbxDataType(eType & 0x0FFF) ); - refVar->SetFlags( nSavFlags ); - refVar->Clear(); } else if( refVar->IsFixed() ) @@ -1014,7 +997,6 @@ void lcl_eraseImpl( SbxVariableRef& refVar, bool bVBAEnabled ) } } else - // AB 2.4.1996 // Arrays haben bei Erase nach VB ein recht komplexes Verhalten. Hier // werden zunaechst nur die Typ-Probleme bei REDIM (#26295) beseitigt: // Typ hart auf den Array-Typ setzen, da eine Variable mit Array @@ -1040,10 +1022,7 @@ void SbiRuntime::StepERASE() void SbiRuntime::StepERASE_CLEAR() { - SbxVariableRef refVar = PopVar(); - lcl_eraseImpl( refVar, bVBAEnabled ); - SbxDataType eType = refVar->GetType(); - lcl_clearImpl( refVar, eType ); + refRedim = PopVar(); } void SbiRuntime::StepARRAYACCESS() @@ -1090,7 +1069,6 @@ void SbiRuntime::StepARGV() SbxVariableRef pVal = PopVar(); // Before fix of #94916: - // if( pVal->ISA(SbxMethod) || pVal->ISA(SbxProperty) ) if( pVal->ISA(SbxMethod) || pVal->ISA(SbUnoProperty) || pVal->ISA(SbProcedureProperty) ) { // Methoden und Properties evaluieren! @@ -1186,11 +1164,6 @@ void SbiRuntime::StepINPUT() BasResId aId( IDS_SBERR_START + 4 ); String aMsg( aId ); - //****** DONT CHECK IN, TEST ONLY ******* - //****** DONT CHECK IN, TEST ONLY ******* - // ErrorBox( NULL, WB_OK, aMsg ).Execute(); - //****** DONT CHECK IN, TEST ONLY ******* - //****** DONT CHECK IN, TEST ONLY ******* pCode = pRestart; } @@ -1199,7 +1172,6 @@ void SbiRuntime::StepINPUT() } else { - // pIosys->ResetChannel(); PopVar(); } } @@ -1214,7 +1186,6 @@ void SbiRuntime::StepLINPUT() Error( pIosys->GetError() ); SbxVariableRef p = PopVar(); p->PutString( String( aInput, gsl_getSystemTextEncoding() ) ); - // pIosys->ResetChannel(); } // Programmende @@ -1372,26 +1343,13 @@ void SbiRuntime::StepRENAME() // Rename Tos+1 to Tos String aDest = pTos1->GetString(); String aSource = pTos->GetString(); - // <-- UCB if( hasUno() ) { implStepRenameUCB( aSource, aDest ); } else - // --> UCB { -#ifdef _OLD_FILE_IMPL - DirEntry aSourceDirEntry( aSource ); - if( aSourceDirEntry.Exists() ) - { - if( aSourceDirEntry.MoveTo( DirEntry(aDest) ) != FSYS_ERR_OK ) - StarBASIC::Error( SbERR_PATH_NOT_FOUND ); - } - else - StarBASIC::Error( SbERR_PATH_NOT_FOUND ); -#else implStepRenameOSL( aSource, aDest ); -#endif } } @@ -1422,7 +1380,6 @@ void SbiRuntime::StepEMPTY() SbxVariableRef xVar = new SbxVariable( SbxVARIANT ); xVar->PutErr( 448 ); PushVar( xVar ); - // ALT: PushVar( new SbxVariable( SbxEMPTY ) ); } // TOS = Fehlercode @@ -1438,3 +1395,4 @@ void SbiRuntime::StepERROR() Error( error ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx index 4fd91b692a4b..74d698974631 100644 --- a/basic/source/runtime/step1.cxx +++ b/basic/source/runtime/step1.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -92,6 +93,15 @@ void SbiRuntime::StepARGN( sal_uInt32 nOp1 ) { String aAlias( pImg->GetString( static_cast<short>( nOp1 ) ) ); SbxVariableRef pVal = PopVar(); + if( bVBAEnabled && ( pVal->ISA(SbxMethod) || pVal->ISA(SbUnoProperty) || pVal->ISA(SbProcedureProperty) ) ) + { + // named variables ( that are Any especially properties ) can be empty at this point and need a broadcast + if ( pVal->GetType() == SbxEMPTY ) + pVal->Broadcast( SBX_HINT_DATAWANTED ); + // Methoden und Properties evaluieren! + SbxVariable* pRes = new SbxVariable( *pVal ); + pVal = pRes; + } refArgv->Put( pVal, nArgc ); refArgv->PutAlias( aAlias, nArgc++ ); } @@ -109,8 +119,8 @@ void SbiRuntime::StepARGTYP( sal_uInt32 nOp1 ) SbxDataType t = (SbxDataType) (nOp1 & 0x7FFF); SbxVariable* pVar = refArgv->Get( refArgv->Count() - 1 ); // letztes Arg - // BYVAL prüfen - if( pVar->GetRefCount() > 2 ) // 2 ist normal für BYVAL + // BYVAL pr�fen + if( pVar->GetRefCount() > 2 ) // 2 ist normal f�r BYVAL { // Parameter ist eine Referenz if( bByVal ) @@ -121,7 +131,7 @@ void SbiRuntime::StepARGTYP( sal_uInt32 nOp1 ) refExprStk->Put( pVar, refArgv->Count() - 1 ); } else - pVar->SetFlag( SBX_REFERENCE ); // Ref-Flag für DllMgr + pVar->SetFlag( SBX_REFERENCE ); // Ref-Flag f�r DllMgr } else { @@ -181,7 +191,9 @@ void SbiRuntime::StepJUMPT( sal_uInt32 nOp1 ) void SbiRuntime::StepJUMPF( sal_uInt32 nOp1 ) { SbxVariableRef p = PopVar(); - if( !p->GetBool() ) + // In a test e.g. If Null then + // will evaluate Null will act as if False + if( ( bVBAEnabled && p->IsNull() ) || !p->GetBool() ) StepJUMP( nOp1 ); } @@ -200,12 +212,10 @@ void SbiRuntime::StepONJUMP( sal_uInt32 nOp1 ) if( nOp1 & 0x8000 ) { nOp1 &= 0x7FFF; - //PushGosub( pCode + 3 * nOp1 ); PushGosub( pCode + 5 * nOp1 ); } if( n < 1 || static_cast<sal_uInt32>(n) > nOp1 ) n = static_cast<sal_Int16>( nOp1 + 1 ); - //nOp1 = (sal_uInt32) ( (const char*) pCode - pImg->GetCode() ) + 3 * --n; nOp1 = (sal_uInt32) ( (const char*) pCode - pImg->GetCode() ) + 5 * --n; StepJUMP( nOp1 ); } @@ -366,7 +376,7 @@ void SbiRuntime::StepERRHDL( sal_uInt32 nOp1 ) void SbiRuntime::StepRESUME( sal_uInt32 nOp1 ) { - // AB #32714 Resume ohne Error? -> Fehler + // #32714 Resume ohne Error? -> Fehler if( !bInError ) { Error( SbERR_BAD_RESUME ); @@ -426,15 +436,15 @@ void SbiRuntime::StepPRCHAR( sal_uInt32 nOp1 ) // Check, ob TOS eine bestimmte Objektklasse ist (+StringID) -bool SbiRuntime::implIsClass( SbxObject* pObj, const String& aClass ) +bool SbiRuntime::implIsClass( SbxObject* pObj, const ::rtl::OUString& aClass ) { bool bRet = true; - if( aClass.Len() != 0 ) + if( !aClass.isEmpty() ) { bRet = pObj->IsClass( aClass ); if( !bRet ) - bRet = aClass.EqualsIgnoreCaseAscii( String( RTL_CONSTASCII_USTRINGPARAM("object") ) ); + bRet = aClass.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("object") ); if( !bRet ) { String aObjClass = pObj->GetClassName(); @@ -452,7 +462,7 @@ bool SbiRuntime::implIsClass( SbxObject* pObj, const String& aClass ) } bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal, - const String& aClass, bool bRaiseErrors, bool bDefault ) + const ::rtl::OUString& aClass, bool bRaiseErrors, bool bDefault ) { bool bOk = bDefault; @@ -571,3 +581,4 @@ void SbiRuntime::StepBASED( sal_uInt32 nOp1 ) +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index dc8ff0a5fd50..e9ed8b533b40 100755..100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -29,8 +30,6 @@ #include "precompiled_basic.hxx" #include "runtime.hxx" -#ifndef GCC -#endif #include "iosys.hxx" #include "image.hxx" #include "sbintern.hxx" @@ -90,7 +89,6 @@ SbxVariable* SbiRuntime::FindElement SbxVariable* p = new SbxVariable; p->PutString( sArg ); PushVar( p ); - // StepARGV(); nOp1 = nOp1 | 0x8000; // indicate params are present aName = String::CreateFromAscii("Evaluate"); @@ -141,7 +139,7 @@ SbxVariable* SbiRuntime::FindElement if ( pElem ) bSetName = false; // don't overwrite uno name else - pElem = getVBAConstant( aName ); + pElem = VBAConstantHelper::instance().getVBAConstant( aName ); } if( !pElem ) @@ -182,7 +180,6 @@ SbxVariable* SbiRuntime::FindElement // Hat das Ding Parameter, nicht einrichten! if( nOp1 & 0x8000 ) bFatalError = sal_True; - // ALT: StarBASIC::FatalError( nNotFound ); // Sonst, falls keine Parameter sind, anderen Error Code verwenden if( !bLocal || pImg->GetFlag( SBIMG_EXPLICIT ) ) @@ -253,7 +250,7 @@ SbxVariable* SbiRuntime::FindElement // Erst nach dem Setzen anfassen, da z.B. LEFT() // den Unterschied zwischen Left$() und Left() kennen muss - // AB 12.8.96: Da in PopVar() die Parameter von Methoden weggehauen + // Da in PopVar() die Parameter von Methoden weggehauen // werden, muessen wir hier explizit eine neue SbxMethod anlegen SbxVariable* pNew = new SbxMethod( *((SbxMethod*)pElem) ); // das ist der Call! //ALT: SbxVariable* pNew = new SbxVariable( *pElem ); // das ist der Call! @@ -287,7 +284,7 @@ SbxVariable* SbiRuntime::FindElement // Find-Funktion ueber Name fuer aktuellen Scope (z.B. Abfrage aus BASIC-IDE) SbxBase* SbiRuntime::FindElementExtern( const String& rName ) { - // Hinweis zu #35281#: Es darf nicht davon ausgegangen werden, dass + // Hinweis zu: Es darf nicht davon ausgegangen werden, dass // pMeth != null, da im RunInit noch keine gesetzt ist. SbxVariable* pElem = NULL; @@ -489,7 +486,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) { // Falls wir ein Array haben, wollen wir bitte das Array-Element! SbxArray* pPar; - if( pElem->GetType() & SbxARRAY ) + if( ( pElem->GetType() & SbxARRAY ) && (SbxVariable*)refRedim != pElem ) { SbxBase* pElemObj = pElem->GetObject(); SbxDimArray* pDimArray = PTR_CAST(SbxDimArray,pElemObj); @@ -521,7 +518,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) pPar->Put( NULL, 0 ); } // Index-Access bei UnoObjekten beruecksichtigen - else if( pElem->GetType() == SbxOBJECT && (!pElem->ISA(SbxMethod) || (bVBAEnabled && !pElem->IsBroadcaster()) ) ) + else if( pElem->GetType() == SbxOBJECT && !pElem->ISA(SbxMethod) && ( !bVBAEnabled || ( bVBAEnabled && !pElem->ISA(SbxProperty) ) ) ) { pPar = pElem->GetParameters(); if ( pPar ) @@ -736,7 +733,6 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) p = refParams->Get( i ); if( p->GetType() == SbxERROR && ( i ) ) - //if( p->GetType() == SbxEMPTY && ( i ) ) { // Wenn ein Parameter fehlt, kann er OPTIONAL sein sal_Bool bOpt = sal_False; @@ -771,6 +767,8 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) SaveRef( q ); *q = *p; p = q; + if ( i ) + refParams->Put( p, i ); } SetupArgs( p, nOp1 ); PushVar( CheckArray( p ) ); @@ -845,10 +843,6 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 nOp2 ) // Der Expr-Stack ist nun nicht mehr notwendig ClearExprStack(); - // #56368 Kuenstliche Referenz fuer StepElem wieder freigeben, - // damit sie nicht ueber ein Statement hinaus erhalten bleibt - //refSaveObj = NULL; - // #74254 Jetzt per Liste ClearRefs(); // Wir muessen hier hart abbrechen, da sonst Zeile und Spalte nicht mehr @@ -885,7 +879,7 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 nOp2 ) // #29955 for-Schleifen-Ebene korrigieren, #67452 NICHT im Error-Handler sonst Chaos if( !bInError ) { - // (Bei Sprüngen aus Schleifen tritt hier eine Differenz auf) + // (Bei Spr�ngen aus Schleifen tritt hier eine Differenz auf) sal_uInt16 nExspectedForLevel = static_cast<sal_uInt16>( nOp2 / 0x100 ); if( pGosubStk ) nExspectedForLevel = nExspectedForLevel + pGosubStk->nStartForLvl; @@ -897,9 +891,8 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 nOp2 ) } // 16.10.96: #31460 Neues Konzept fuer StepInto/Over/Out - // Erklärung siehe bei _ImplGetBreakCallLevel. + // Erkl�rung siehe bei _ImplGetBreakCallLevel. if( pInst->nCallLvl <= pInst->nBreakCallLvl ) - //if( nFlags & SbDEBUG_STEPINTO ) { StarBASIC* pStepBasic = GetCurrentBasic( &rBasic ); sal_uInt16 nNewFlags = pStepBasic->StepPoint( nLine, nCol1, nCol2 ); @@ -918,9 +911,6 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 nOp2 ) // Neuen BreakCallLevel ermitteln pInst->CalcBreakCallLevel( nNewFlags ); - //16.10.96, ALT: - //if( nNewFlags != SbDEBUG_CONTINUE ) - // nFlags = nNewFlags; } } @@ -1303,3 +1293,4 @@ void SbiRuntime::StepSTATIC( sal_uInt32 nOp1, sal_uInt32 nOp2 ) StepSTATIC_Impl( aName, t ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/runtime/wnt-mingw.s b/basic/source/runtime/wnt-mingw.s index 8c332c1a8ce8..8c332c1a8ce8 100644..100755 --- a/basic/source/runtime/wnt-mingw.s +++ b/basic/source/runtime/wnt-mingw.s diff --git a/basic/source/runtime/wnt.asm b/basic/source/runtime/wnt-x86.asm index 2a8710e34243..2a8710e34243 100644 --- a/basic/source/runtime/wnt.asm +++ b/basic/source/runtime/wnt-x86.asm diff --git a/basic/source/sample/collelem.cxx b/basic/source/sample/collelem.cxx index 0ada7b60ea6a..80ee91db309f 100644 --- a/basic/source/sample/collelem.cxx +++ b/basic/source/sample/collelem.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -77,3 +78,4 @@ void SampleElement::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType, } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sample/makefile.mk b/basic/source/sample/makefile.mk index 9aeb8e353414..5261f13cfe43 100644..100755 --- a/basic/source/sample/makefile.mk +++ b/basic/source/sample/makefile.mk @@ -40,6 +40,9 @@ CXXFILES = \ object.cxx \ collelem.cxx +EXCEPTIONSFILES= \ + $(OBJ)$/object.obj \ + $(OBJ)$/collelem.obj OBJFILES = \ $(OBJ)$/object.obj \ diff --git a/basic/source/sample/object.cxx b/basic/source/sample/object.cxx index 15ad6b0168f8..4322d5e1fe62 100644 --- a/basic/source/sample/object.cxx +++ b/basic/source/sample/object.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,12 +31,8 @@ #include <tools/errcode.hxx> #include <basic/sbxobj.hxx> #include <basic/sbx.hxx> -#ifndef __SBX_SBXVARIABLE_HXX //autogen #include <basic/sbxvar.hxx> -#endif -#ifndef _MSGBOX_HXX //autogen #include <vcl/msgbox.hxx> -#endif #include "object.hxx" #include "collelem.hxx" @@ -62,10 +59,6 @@ // Das Sample-Objekt wird in ..\app\mybasic.cxx wie folgt in StarBASIC // eingebaut: -// MyBasic::MyBasic() : StarBASIC() -// { -// AddFactory( new SampleObjectFac() ); -// } // Das nArgs-Feld eines Tabelleneintrags ist wie folgt verschluesselt: @@ -212,8 +205,6 @@ void SampleObject::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCT, SbxInfo* SampleObject::GetInfo( short nIdx ) { Methods* p = &aMethods[ nIdx ]; - // Wenn mal eine Hilfedatei zur Verfuegung steht: - // SbxInfo* pInfo_ = new SbxInfo( Hilfedateiname, p->nHelpId ); SbxInfo* pInfo_ = new SbxInfo; short nPar = p->nArgs & _ARGSMASK; for( short i = 0; i < nPar; i++ ) @@ -228,7 +219,6 @@ SbxInfo* SampleObject::GetInfo( short nIdx ) return pInfo_; } -//////////////////////////////////////////////////////////////////////////// // Properties und Methoden legen beim Get (bPut = sal_False) den Returnwert // im Element 0 des Argv ab; beim Put (bPut = sal_True) wird der Wert aus @@ -276,3 +266,4 @@ SbxObject* SampleObjectFac::CreateObject( const String& rClass ) return NULL; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/makefile.mk b/basic/source/sbx/makefile.mk index dfd8e72bf4da..332c6a0d426d 100644..100755 --- a/basic/source/sbx/makefile.mk +++ b/basic/source/sbx/makefile.mk @@ -41,34 +41,34 @@ SRS1NAME=$(TARGET) SRC1FILES= format.src SLOFILES= \ - $(SLO)$/sbxbase.obj \ + $(EXCEPTIONSFILES) \ + $(SLO)$/sbxbase.obj \ + $(SLO)$/sbxbool.obj \ + $(SLO)$/sbxbyte.obj \ + $(SLO)$/sbxchar.obj \ + $(SLO)$/sbxcoll.obj \ + $(SLO)$/sbxdec.obj \ + $(SLO)$/sbxform.obj \ + $(SLO)$/sbxint.obj \ + $(SLO)$/sbxlng.obj \ + $(SLO)$/sbxmstrm.obj \ + $(SLO)$/sbxobj.obj \ $(SLO)$/sbxres.obj \ - $(SLO)$/sbxvalue.obj \ - $(SLO)$/sbxvals.obj \ - $(SLO)$/sbxvar.obj \ + $(SLO)$/sbxsng.obj \ + $(SLO)$/sbxuint.obj \ + $(SLO)$/sbxulng.obj \ + $(SLO)$/sbxvar.obj + + +EXCEPTIONSFILES= \ $(SLO)$/sbxarray.obj \ - $(SLO)$/sbxobj.obj \ - $(SLO)$/sbxcoll.obj \ - $(SLO)$/sbxexec.obj \ - $(SLO)$/sbxint.obj \ - $(SLO)$/sbxlng.obj \ - $(SLO)$/sbxsng.obj \ - $(SLO)$/sbxmstrm.obj \ - $(SLO)$/sbxdbl.obj \ $(SLO)$/sbxcurr.obj \ - $(SLO)$/sbxdate.obj \ - $(SLO)$/sbxstr.obj \ - $(SLO)$/sbxbool.obj \ - $(SLO)$/sbxchar.obj \ - $(SLO)$/sbxbyte.obj \ - $(SLO)$/sbxuint.obj \ - $(SLO)$/sbxulng.obj \ - $(SLO)$/sbxform.obj \ + $(SLO)$/sbxdate.obj \ + $(SLO)$/sbxdbl.obj \ + $(SLO)$/sbxexec.obj \ $(SLO)$/sbxscan.obj \ - $(SLO)$/sbxdec.obj - - -EXCEPTIONSFILES=$(SLO)$/sbxarray.obj + $(SLO)$/sbxstr.obj \ + $(SLO)$/sbxvalue.obj \ # --- Targets ------------------------------------------------------------- diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx index 7a68f2ea5a31..0f9b81f8d479 100644 --- a/basic/source/sbx/sbxarray.cxx +++ b/basic/source/sbx/sbxarray.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -33,10 +34,10 @@ #include <vector> using namespace std; -struct SbxDim { // eine Array-Dimension: +struct SbxDim { // an array-dimension: SbxDim* pNext; // Link - sal_Int32 nLbound, nUbound; // Begrenzungen - sal_Int32 nSize; // Anzahl Elemente + sal_Int32 nLbound, nUbound; // Limitations + sal_Int32 nSize; // Number of elements }; class SbxVarEntry : public SbxVariableRef { @@ -58,11 +59,7 @@ public: TYPEINIT1(SbxArray,SbxBase) TYPEINIT1(SbxDimArray,SbxArray) -////////////////////////////////////////////////////////////////////////// -// // SbxArray -// -////////////////////////////////////////////////////////////////////////// SbxArray::SbxArray( SbxDataType t ) : SbxBase() { @@ -99,7 +96,7 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray ) if( pSrcRef->pAlias ) pDstRef->pAlias = new XubString( *pSrcRef->pAlias ); if( eType != SbxVARIANT ) - // Keine Objekte konvertieren + // Convert no objects if( eType != SbxOBJECT || pSrc_->GetClass() != SbxCLASS_OBJECT ) ((SbxVariable*) pSrc_)->Convert( eType ); pData->push_back( pDstRef ); @@ -149,7 +146,7 @@ sal_uInt16 SbxArray::Count() const SbxVariableRef& SbxArray::GetRef32( sal_uInt32 nIdx ) { - // Array ggf. vergroessern + // If necessary extend the array DBG_ASSERT( nIdx <= SBX_MAXINDEX32, "SBX: Array-Index > SBX_MAXINDEX32" ); // Very Hot Fix if( nIdx > SBX_MAXINDEX32 ) @@ -167,7 +164,7 @@ SbxVariableRef& SbxArray::GetRef32( sal_uInt32 nIdx ) SbxVariableRef& SbxArray::GetRef( sal_uInt16 nIdx ) { - // Array ggf. vergroessern + // If necessary extend the array DBG_ASSERT( nIdx <= SBX_MAXINDEX, "SBX: Array-Index > SBX_MAXINDEX" ); // Very Hot Fix if( nIdx > SBX_MAXINDEX ) @@ -229,7 +226,7 @@ void SbxArray::Put32( SbxVariable* pVar, sal_uInt32 nIdx ) { if( pVar ) if( eType != SbxVARIANT ) - // Keine Objekte konvertieren + // Convert no objects if( eType != SbxOBJECT || pVar->GetClass() != SbxCLASS_OBJECT ) pVar->Convert( eType ); SbxVariableRef& rRef = GetRef32( nIdx ); @@ -249,7 +246,7 @@ void SbxArray::Put( SbxVariable* pVar, sal_uInt16 nIdx ) { if( pVar ) if( eType != SbxVARIANT ) - // Keine Objekte konvertieren + // Convert no objects if( eType != SbxOBJECT || pVar->GetClass() != SbxCLASS_OBJECT ) pVar->Convert( eType ); SbxVariableRef& rRef = GetRef( nIdx ); @@ -354,7 +351,6 @@ void SbxArray::Remove( SbxVariable* pVar ) for( sal_uInt32 i = 0; i < pData->size(); i++ ) { SbxVariableRef* pRef = (*pData)[i]; - // SbxVariableRef* pRef = pData->GetObject( i ); if( *pRef == pVar ) { Remove32( i ); break; @@ -363,8 +359,8 @@ void SbxArray::Remove( SbxVariable* pVar ) } } -// Uebernahme der Daten aus dem uebergebenen Array, wobei -// gleichnamige Variable ueberschrieben werden. +// Taking over of the data from the passed array, at which +// the variable of the same name will be overwritten. void SbxArray::Merge( SbxArray* p ) { @@ -374,8 +370,8 @@ void SbxArray::Merge( SbxArray* p ) for( sal_uInt32 i = 0; i < nSize; i++ ) { SbxVarEntryPtr pRef1 = (*(p->pData))[i]; - // Ist das Element by name schon drin? - // Dann ueberschreiben! + // Is the element by name already inside? + // Then overwrite! SbxVariable* pVar = *pRef1; if( pVar ) { @@ -405,8 +401,8 @@ void SbxArray::Merge( SbxArray* p ) } } -// Suchen eines Elements ueber die Userdaten. Falls ein Element -// ein Objekt ist, wird dieses ebenfalls durchsucht. +// Search of an element via the user data. If the element is +// object, it will also be scanned. SbxVariable* SbxArray::FindUserData( sal_uInt32 nData ) { @@ -421,16 +417,16 @@ SbxVariable* SbxArray::FindUserData( sal_uInt32 nData ) { p = pVar; p->ResetFlag( SBX_EXTFOUND ); - break; // JSM 06.10.95 + break; // JSM 1995-10-06 } - // Haben wir ein Array/Objekt mit Extended Search? + // Did we have an array/object with extended search? else if( pVar->IsSet( SBX_EXTSEARCH ) ) { switch( pVar->GetClass() ) { case SbxCLASS_OBJECT: { - // Objekte duerfen ihren Parent nicht durchsuchen + // Objects are not allowed to scan their parent. sal_uInt16 nOld = pVar->GetFlags(); pVar->ResetFlag( SBX_GBLSEARCH ); p = ((SbxObject*) pVar)->FindUserData( nData ); @@ -453,8 +449,8 @@ SbxVariable* SbxArray::FindUserData( sal_uInt32 nData ) return p; } -// Suchen eines Elements ueber den Namen und den Typ. Falls ein Element -// ein Objekt ist, wird dieses ebenfalls durchsucht. +// Search of an element by his name and type. If an element is an object, +// it will also be scanned.. SbxVariable* SbxArray::Find( const XubString& rName, SbxClassType t ) { @@ -470,8 +466,7 @@ SbxVariable* SbxArray::Find( const XubString& rName, SbxClassType t ) SbxVariable* pVar = *pRef; if( pVar && pVar->IsVisible() ) { - // Die ganz sichere Suche klappt auch, wenn es - // keinen Hascode gibt! + // The very secure search works as well, if there is no hashcode! sal_uInt16 nVarHash = pVar->GetHashCode(); if( ( !nVarHash || nVarHash == nHash ) && ( t == SbxCLASS_DONTCARE || pVar->GetClass() == t ) @@ -481,14 +476,14 @@ SbxVariable* SbxArray::Find( const XubString& rName, SbxClassType t ) p->ResetFlag( SBX_EXTFOUND ); break; } - // Haben wir ein Array/Objekt mit Extended Search? + // Did we have an array/object with extended search? else if( bExtSearch && pVar->IsSet( SBX_EXTSEARCH ) ) { switch( pVar->GetClass() ) { case SbxCLASS_OBJECT: { - // Objekte duerfen ihren Parent nicht durchsuchen + // Objects are not allowed to scan their parent. sal_uInt16 nOld = pVar->GetFlags(); pVar->ResetFlag( SBX_GBLSEARCH ); p = ((SbxObject*) pVar)->Find( rName, t ); @@ -545,7 +540,7 @@ sal_Bool SbxArray::StoreData( SvStream& rStrm ) const { sal_uInt32 nElem = 0; sal_uInt32 n; - // Welche Elemente sind ueberhaupt definiert? + // Which elements are even defined? for( n = 0; n < pData->size(); n++ ) { SbxVariableRef* pRef = (*pData)[n]; @@ -576,11 +571,7 @@ void SbxArray::PutDirect( SbxVariable* pVar, sal_uInt32 nIdx ) } -////////////////////////////////////////////////////////////////////////// -// // SbxArray -// -////////////////////////////////////////////////////////////////////////// SbxDimArray::SbxDimArray( SbxDataType t ) : SbxArray( t ), mbHasFixedSize( false ) { @@ -630,7 +621,7 @@ void SbxDimArray::Clear() nDim = 0; } -// Dimension hinzufuegen +// Add a dimension void SbxDimArray::AddDimImpl32( sal_Int32 lb, sal_Int32 ub, sal_Bool bAllowSize0 ) { @@ -675,7 +666,7 @@ void SbxDimArray::unoAddDim32( sal_Int32 lb, sal_Int32 ub ) } -// Dimensionsdaten auslesen +// Readout dimension data sal_Bool SbxDimArray::GetDim32( sal_Int32 n, sal_Int32& rlb, sal_Int32& rub ) const { @@ -708,7 +699,7 @@ sal_Bool SbxDimArray::GetDim( short n, short& rlb, short& rub ) const return bRet; } -// Element-Ptr anhand einer Index-Liste +// Element-Ptr with the help of an index list sal_uInt32 SbxDimArray::Offset32( const sal_Int32* pIdx ) { @@ -779,7 +770,7 @@ void SbxDimArray::Put32( SbxVariable* p, const sal_Int32* pIdx ) } -// Element-Nr anhand eines Parameter-Arrays +// Element-Number with the help of Parameter-Array sal_uInt32 SbxDimArray::Offset32( SbxArray* pPar ) { @@ -788,7 +779,7 @@ sal_uInt32 SbxDimArray::Offset32( SbxArray* pPar ) SetError( SbxERR_BOUNDS ); return 0; } sal_uInt32 nPos = 0; - sal_uInt16 nOff = 1; // Nicht Element 0! + sal_uInt16 nOff = 1; // Non element 0! for( SbxDim* p = pFirst; p && !IsError(); p = p->pNext ) { sal_Int32 nIdx = pPar->Get( nOff++ )->GetLong(); @@ -855,3 +846,4 @@ sal_Bool SbxDimArray::StoreData( SvStream& rStrm ) const return SbxArray::StoreData( rStrm ); } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxbase.cxx b/basic/source/sbx/sbxbase.cxx index 54e45c79a8d2..77f34d90f370 100644 --- a/basic/source/sbx/sbxbase.cxx +++ b/basic/source/sbx/sbxbase.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -36,15 +37,15 @@ #include <basic/sbxfac.hxx> #include <basic/sbxbase.hxx> -// AppData-Struktur fuer SBX: +// AppData-Structure for SBX: SV_IMPL_PTRARR(SbxParams,SbxParamInfo*); SV_IMPL_PTRARR(SbxFacs,SbxFactory*); TYPEINIT0(SbxBase) -// SBX-Daten anfordern oder ggf. anlegen -// wir legen den Bereich einfach an und verzichten auf die Freigabe! +// Request SBX-Data or if necessary create them +// we just create the area and waive the release! SbxAppData* GetSbxData_Impl() { @@ -152,11 +153,11 @@ void SbxBase::AddFactory( SbxFactory* pFac ) SbxAppData* p = GetSbxData_Impl(); const SbxFactory* pTemp = pFac; - // AB, 6.3.96: HandleLast-Flag beruecksichtigen - sal_uInt16 nPos = p->aFacs.Count(); // Einfuege-Position - if( !pFac->IsHandleLast() ) // Nur, wenn nicht selbst HandleLast + // From 1996-03-06: take the HandleLast-Flag into account + sal_uInt16 nPos = p->aFacs.Count(); // Insert position + if( !pFac->IsHandleLast() ) // Only if not self HandleLast { - // Neue Factory vor Factories mit HandleLast einordnen + // Rank new factory in front of factories with HandleLast while( nPos > 0 && (static_cast<SbxFactory*>(p->aFacs.GetObject( nPos-1 )))->IsHandleLast() ) nPos--; @@ -200,7 +201,7 @@ SbxBase* SbxBase::Create( sal_uInt16 nSbxId, sal_uInt32 nCreator ) case SBXID_METHOD: return new SbxMethod( aEmptyStr, SbxEMPTY ); case SBXID_PROPERTY: return new SbxProperty( aEmptyStr, SbxEMPTY ); } - // Unbekanter Typ: ber die Factories gehen! + // Unknown type: go over the factories! SbxAppData* p = GetSbxData_Impl(); SbxBase* pNew = NULL; for( sal_uInt16 i = 0; i < p->aFacs.Count(); i++ ) @@ -245,7 +246,7 @@ SbxObject* SbxBase::CreateObject( const XubString& rClass ) static sal_Bool bStaticEnableBroadcasting = sal_True; -// Sbx-Loesung als Ersatz fuer SfxBroadcaster::Enable() +// Sbx-Solution in exchange for SfxBroadcaster::Enable() void SbxBase::StaticEnableBroadcasting( sal_Bool bEnable ) { bStaticEnableBroadcasting = bEnable; @@ -263,7 +264,7 @@ SbxBase* SbxBase::Load( SvStream& rStrm ) sal_uInt32 nCreator, nSize; rStrm >> nCreator >> nSbxId >> nFlags >> nVer; - // Eine Dummheit meinerseits korrigieren: + // Correcting a foolishness of mine: if( nFlags & SBX_RESERVED ) nFlags = ( nFlags & ~SBX_RESERVED ) | SBX_GBLSEARCH; @@ -282,7 +283,7 @@ SbxBase* SbxBase::Load( SvStream& rStrm ) rStrm.Seek( nOldPos ); if( !p->LoadCompleted() ) { - // Loeschen des Objekts + // Deleting of the object SbxBaseRef aRef( p ); p = NULL; } @@ -290,7 +291,7 @@ SbxBase* SbxBase::Load( SvStream& rStrm ) else { rStrm.SetError( SVSTREAM_FILEFORMAT_ERROR ); - // Loeschen des Objekts + // Deleting of the object SbxBaseRef aRef( p ); p = NULL; } @@ -300,7 +301,7 @@ SbxBase* SbxBase::Load( SvStream& rStrm ) return p; } -// Sbx-Objekt im Stream ueberspringen +// Skip the Sbx-Object inside the stream void SbxBase::Skip( SvStream& rStrm ) { sal_uInt16 nSbxId, nFlags, nVer; @@ -453,3 +454,4 @@ sal_Bool SbxInfo::StoreData( SvStream& rStrm ) const return sal_True; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxbool.cxx b/basic/source/sbx/sbxbool.cxx index 7b9ffe8a1136..7efb748355cc 100644 --- a/basic/source/sbx/sbxbool.cxx +++ b/basic/source/sbx/sbxbool.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,11 +33,6 @@ #include "sbxconv.hxx" #include "sbxres.hxx" -// AB 29.10.99 Unicode -#ifndef _USE_NO_NAMESPACE -using namespace rtl; -#endif - enum SbxBOOL ImpGetBool( const SbxValues* p ) { enum SbxBOOL nRes; @@ -75,14 +71,10 @@ enum SbxBOOL ImpGetBool( const SbxValues* p ) } break; case SbxSALINT64: + case SbxCURRENCY: nRes = p->nInt64 ? SbxTRUE : SbxFALSE; break; case SbxSALUINT64: nRes = p->uInt64 ? SbxTRUE : SbxFALSE; break; - case SbxULONG64: - nRes = !!p->nULong64 ? SbxTRUE : SbxFALSE; break; - case SbxLONG64: - case SbxCURRENCY: - nRes = !!p->nLong64 ? SbxTRUE : SbxFALSE; break; case SbxBYREF | SbxSTRING: case SbxSTRING: case SbxLPSTR: @@ -143,16 +135,11 @@ enum SbxBOOL ImpGetBool( const SbxValues* p ) case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: nRes = ( *p->pDouble != 0 ) ? SbxTRUE : SbxFALSE; break; + case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: nRes = ( *p->pnInt64 ) ? SbxTRUE : SbxFALSE; break; case SbxBYREF | SbxSALUINT64: nRes = ( *p->puInt64 ) ? SbxTRUE : SbxFALSE; break; - case SbxBYREF | SbxULONG64: - nRes = !!*p->pULong64 ? SbxTRUE : SbxFALSE; break; - case SbxBYREF | SbxLONG64: - case SbxBYREF | SbxCURRENCY: - nRes = !!*p->pLong64 ? SbxTRUE : SbxFALSE; break; - default: SbxBase::SetError( SbxERR_CONVERSION ); nRes = SbxFALSE; } @@ -184,15 +171,11 @@ void ImpPutBool( SbxValues* p, sal_Int16 n ) case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: case SbxSALINT64: - p->nInt64 = n; break; + p->nInt64 = (sal_Int64) n; break; case SbxSALUINT64: - p->uInt64 = n; break; - case SbxULONG64: - p->nULong64.Set( (sal_uInt32)n ); break; - case SbxLONG64: - case SbxCURRENCY: - p->nLong64.Set( (sal_Int32)n ); break; + p->uInt64 = (sal_uInt64) n; break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: ImpCreateDecimal( p )->setInt( (sal_Int16)n ); @@ -235,18 +218,14 @@ void ImpPutBool( SbxValues* p, sal_Int16 n ) case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = n; break; + case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: - *p->pnInt64 = n; break; + *p->pnInt64 = (sal_Int64) n; break; case SbxBYREF | SbxSALUINT64: - *p->puInt64 = n; break; - case SbxBYREF | SbxULONG64: - p->pULong64->Set( (sal_uInt32)n ); break; - case SbxBYREF | SbxLONG64: - case SbxBYREF | SbxCURRENCY: - p->pLong64->Set( (sal_Int32)n ); break; - + *p->puInt64 = (sal_uInt64) n; break; default: SbxBase::SetError( SbxERR_CONVERSION ); } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxbyte.cxx b/basic/source/sbx/sbxbyte.cxx index 1a9c80f1dd06..90d8ecc40a20 100644 --- a/basic/source/sbx/sbxbyte.cxx +++ b/basic/source/sbx/sbxbyte.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -94,8 +95,13 @@ start: else nRes = (sal_uInt8) p->nULong; break; + case SbxCURRENCY: case SbxSALINT64: - if( p->nInt64 > SbxMAXBYTE ) + { + sal_Int64 val = p->nInt64; + if ( p->eType == SbxCURRENCY ) + val = val / CURRENCY_FACTOR; + if( val > SbxMAXBYTE ) { SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXBYTE; } @@ -104,8 +110,9 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; } else - nRes = (sal_uInt8) p->nInt64; + nRes = (sal_uInt8) val; break; + } case SbxSALUINT64: if( p->uInt64 > SbxMAXBYTE ) { @@ -128,20 +135,11 @@ start: break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else if( p->eType == SbxDECIMAL ) + if( p->eType == SbxDECIMAL ) { dVal = 0.0; if( p->pDecimal ) @@ -200,7 +198,7 @@ start: case SbxBYREF | SbxBYTE: nRes = p->nByte; break; - // ab hier wird getestet + // from here on will be tested case SbxBYREF | SbxCHAR: aTmp.nChar = *p->pChar; goto ref; case SbxBYREF | SbxINTEGER: @@ -218,11 +216,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: @@ -258,16 +252,12 @@ void ImpPutByte( SbxValues* p, sal_uInt8 n ) case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxSALINT64: p->nInt64 = n; break; case SbxSALUINT64: p->uInt64 = n; break; - case SbxULONG64: - p->nULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxLONG64: - p->nLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxCURRENCY: - p->nLong64 = ImpDoubleToCurrency( (double)n ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: ImpCreateDecimal( p )->setByte( n ); @@ -311,19 +301,16 @@ void ImpPutByte( SbxValues* p, sal_uInt8 n ) case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = n; break; - case SbxBYREF | SbxULONG64: - *p->pULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxBYREF | SbxLONG64: - *p->pLong64 = ImpDoubleToINT64( (double)n ); break; + case SbxBYREF | SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; - case SbxBYREF | SbxCURRENCY: - *p->pLong64 = ImpDoubleToCurrency( (double)n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxchar.cxx b/basic/source/sbx/sbxchar.cxx index 578f0cfb8adf..ee4cb48b8efb 100644 --- a/basic/source/sbx/sbxchar.cxx +++ b/basic/source/sbx/sbxchar.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -31,11 +32,6 @@ #include <basic/sbx.hxx> #include "sbxconv.hxx" -// AB 29.10.99 Unicode -#ifndef _USE_NO_NAMESPACE -using namespace rtl; -#endif - xub_Unicode ImpGetChar( const SbxValues* p ) { SbxValues aTmp; @@ -85,8 +81,15 @@ start: else nRes = (xub_Unicode) p->nULong; break; + case SbxCURRENCY: case SbxSALINT64: - if( p->nInt64 > SbxMAXCHAR ) + { + sal_Int64 val = p->nInt64; + + if ( p->eType == SbxCURRENCY ) + val = val / CURRENCY_FACTOR; + + if( val > SbxMAXCHAR ) { SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXCHAR; } @@ -95,8 +98,9 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMINCHAR; } else - nRes = (xub_Unicode) p->nInt64; + nRes = (xub_Unicode) val; break; + } case SbxSALUINT64: if( p->uInt64 > SbxMAXCHAR ) { @@ -119,20 +123,11 @@ start: break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else if( p->eType == SbxDECIMAL ) + if( p->eType == SbxDECIMAL ) { dVal = 0.0; if( p->pDecimal ) @@ -188,7 +183,7 @@ start: case SbxBYREF | SbxCHAR: nRes = *p->pChar; break; - // ab hier wird getestet + // from here on will be tested case SbxBYREF | SbxBYTE: aTmp.nByte = *p->pByte; goto ref; case SbxBYREF | SbxINTEGER: @@ -206,11 +201,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: @@ -243,21 +234,17 @@ start: case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxSALINT64: p->nInt64 = n; break; case SbxSALUINT64: p->uInt64 = n; break; - case SbxULONG64: - p->nULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxLONG64: - p->nLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxCURRENCY: - p->nLong64 = ImpDoubleToCurrency( (double)n ); break; case SbxBYREF | SbxDECIMAL: ImpCreateDecimal( p )->setChar( n ); break; - // ab hier wird getestet + // from here on will be tested case SbxBYTE: aTmp.pByte = &p->nByte; goto direct; case SbxULONG: @@ -305,16 +292,12 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = (double) n; break; + case SbxBYREF | SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; - case SbxBYREF | SbxULONG64: - *p->pULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxBYREF | SbxLONG64: - *p->pLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxBYREF | SbxCURRENCY: - *p->pLong64 = ImpDoubleToCurrency( (double)n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); @@ -322,3 +305,4 @@ start: } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxcoll.cxx b/basic/source/sbx/sbxcoll.cxx index 1c95591e28dd..8cf068d657cb 100644 --- a/basic/source/sbx/sbxcoll.cxx +++ b/basic/source/sbx/sbxcoll.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -43,7 +44,6 @@ static const char* pItem; static const char* pRemove; static sal_uInt16 nCountHash = 0, nAddHash, nItemHash, nRemoveHash; -///////////////////////////////////////////////////////////////////////// SbxCollection::SbxCollection( const XubString& rClass ) : SbxObject( rClass ) @@ -60,7 +60,7 @@ SbxCollection::SbxCollection( const XubString& rClass ) nRemoveHash = MakeHashCode( String::CreateFromAscii( pRemove ) ); } Initialize(); - // Fuer Zugriffe auf sich selbst + // For Access on itself StartListening( GetBroadcaster(), sal_True ); } @@ -159,7 +159,7 @@ void SbxCollection::SFX_NOTIFY( SfxBroadcaster& rCst, const TypeId& rId1, SbxObject::SFX_NOTIFY( rCst, rId1, rHint, rId2 ); } -// Default: Argument ist Objekt +// Default: argument is object void SbxCollection::CollAdd( SbxArray* pPar_ ) { @@ -175,7 +175,7 @@ void SbxCollection::CollAdd( SbxArray* pPar_ ) } } -// Default: Index ab 1 oder der Objektname +// Default: index from 1 or object name void SbxCollection::CollItem( SbxArray* pPar_ ) { @@ -199,7 +199,7 @@ void SbxCollection::CollItem( SbxArray* pPar_ ) } } -// Default: Index ab 1 +// Default: index from 1 void SbxCollection::CollRemove( SbxArray* pPar_ ) { @@ -222,7 +222,6 @@ sal_Bool SbxCollection::LoadData( SvStream& rStrm, sal_uInt16 nVer ) return bRes; } -///////////////////////////////////////////////////////////////////////// SbxStdCollection::SbxStdCollection ( const XubString& rClass, const XubString& rElem, sal_Bool b ) @@ -250,7 +249,7 @@ SbxStdCollection& SbxStdCollection::operator=( const SbxStdCollection& r ) SbxStdCollection::~SbxStdCollection() {} -// Default: Fehler, wenn falsches Objekt +// Default: Error, if wrong object void SbxStdCollection::Insert( SbxVariable* p ) { @@ -299,3 +298,4 @@ sal_Bool SbxStdCollection::StoreData( SvStream& rStrm ) const return bRes; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxconv.hxx b/basic/source/sbx/sbxconv.hxx index 61edeef3a4fa..2a11f151d862 100644 --- a/basic/source/sbx/sbxconv.hxx +++ b/basic/source/sbx/sbxconv.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -38,7 +39,7 @@ extern SbxError ImpScan ( const ::rtl::OUString& rSrc, double& nVal, SbxDataType& rType, sal_uInt16* pLen, sal_Bool bAllowIntntl=sal_False, sal_Bool bOnlyIntntl=sal_False ); -// mit erweiterter Auswertung (International, "sal_True"/"sal_False") +// with advanced evaluation (International, "TRUE"/"FALSE") extern sal_Bool ImpConvStringExt( ::rtl::OUString& rSrc, SbxDataType eTargetType ); // SBXINT.CXX @@ -46,13 +47,15 @@ extern sal_Bool ImpConvStringExt( ::rtl::OUString& rSrc, SbxDataType eTargetType double ImpRound( double ); sal_Int16 ImpGetInteger( const SbxValues* ); void ImpPutInteger( SbxValues*, sal_Int16 ); + sal_Int64 ImpGetInt64( const SbxValues* ); void ImpPutInt64( SbxValues*, sal_Int64 ); sal_uInt64 ImpGetUInt64( const SbxValues* ); void ImpPutUInt64( SbxValues*, sal_uInt64 ); -sal_Int64 ImpDoubleToSalInt64( double d ); +sal_Int64 ImpDoubleToSalInt64 ( double d ); sal_uInt64 ImpDoubleToSalUInt64( double d ); +double ImpSalInt64ToDouble ( sal_Int64 n ); double ImpSalUInt64ToDouble( sal_uInt64 n ); // SBXLNG.CXX @@ -70,37 +73,18 @@ void ImpPutSingle( SbxValues*, float ); double ImpGetDouble( const SbxValues* ); void ImpPutDouble( SbxValues*, double, sal_Bool bCoreString=sal_False ); -#if FALSE -// SBX64.CXX - -SbxINT64 ImpGetINT64( const SbxValues* ); -void ImpPutINT64( SbxValues*, const SbxINT64& ); -SbxUINT64 ImpGetUINT64( const SbxValues* ); -void ImpPutUINT64( SbxValues*, const SbxUINT64& ); -#endif - // SBXCURR.CXX -SbxUINT64 ImpDoubleToUINT64( double ); -double ImpUINT64ToDouble( const SbxUINT64& ); -SbxINT64 ImpDoubleToINT64( double ); -double ImpINT64ToDouble( const SbxINT64& ); +sal_Int64 ImpGetCurrency( const SbxValues* ); +void ImpPutCurrency( SbxValues*, const sal_Int64 ); -#if TRUE -sal_Int32 ImpGetCurrLong( const SbxValues* ); -void ImpPutCurrLong( SbxValues*, sal_Int32 ); -sal_Int32 ImpDoubleToCurrLong( double ); -double ImpCurrLongToDouble( sal_Int32 ); -#endif +inline sal_Int64 ImpDoubleToCurrency( double d ) + { if (d > 0) return (sal_Int64)( d * CURRENCY_FACTOR + 0.5); + else return (sal_Int64)( d * CURRENCY_FACTOR - 0.5); + } -SbxINT64 ImpGetCurrency( const SbxValues* ); -void ImpPutCurrency( SbxValues*, const SbxINT64& ); -inline -SbxINT64 ImpDoubleToCurrency( double d ) - { return ImpDoubleToINT64( d * CURRENCY_FACTOR ); } -inline -double ImpCurrencyToDouble( const SbxINT64 &r ) - { return ImpINT64ToDouble( r ) / CURRENCY_FACTOR; } +inline double ImpCurrencyToDouble( const sal_Int64 r ) + { return (double)r / (double)CURRENCY_FACTOR; } // SBXDEC.CXX @@ -123,7 +107,7 @@ void ImpPutString( SbxValues*, const ::rtl::OUString* ); // SBXCHAR.CXX sal_Unicode ImpGetChar( const SbxValues* ); -void ImpPutChar( SbxValues*, sal_Unicode ); +void ImpPutChar( SbxValues*, sal_Unicode ); // SBXBYTE.CXX sal_uInt8 ImpGetByte( const SbxValues* ); @@ -144,8 +128,10 @@ void ImpPutULong( SbxValues*, sal_uInt32 ); enum SbxBOOL ImpGetBool( const SbxValues* ); void ImpPutBool( SbxValues*, sal_Int16 ); -// ByteArry <--> String +// ByteArray <--> String SbxArray* StringToByteArray(const ::rtl::OUString& rStr); ::rtl::OUString ByteArrayToString(SbxArray* pArr); #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxcurr.cxx b/basic/source/sbx/sbxcurr.cxx index 5b6e631d174f..0ea500bb0ba2 100644 --- a/basic/source/sbx/sbxcurr.cxx +++ b/basic/source/sbx/sbxcurr.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,101 +29,305 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#include <basic/sbx.hxx> #include <tools/errcode.hxx> +#include <vcl/svapp.hxx> // for SvtSysLocale -#define _TLBIGINT_INT64 -#include <tools/bigint.hxx> - +#include <basic/sbx.hxx> #include <basic/sbxvar.hxx> #include "sbxconv.hxx" -static ::rtl::OUString ImpCurrencyToString( const SbxINT64& ); -static SbxINT64 ImpStringToCurrency( const ::rtl::OUString& ); -SbxINT64 ImpGetCurrency( const SbxValues* p ) +static rtl::OUString ImpCurrencyToString( const sal_Int64 &rVal ) { - SbxValues aTmp; - SbxINT64 nRes; + bool isNeg = ( rVal < 0 ); + sal_Int64 absVal = isNeg ? -rVal : rVal; + + SvtSysLocale aSysLocale; + sal_Unicode cDecimalSep = '.'; +#if MAYBEFUTURE + sal_Unicode cThousandSep = ','; + const LocaleDataWrapper& rData = aSysLocale.GetLocaleData(); + cDecimalSep = rData.getNumDecimalSep().GetBuffer()[0]; + cThousandSep = rData.getNumThousandSep().GetBuffer()[0]; +#endif + + rtl::OUString aAbsStr = rtl::OUString::valueOf( absVal ); + rtl::OUStringBuffer aBuf; + + sal_Int32 initialLen = aAbsStr.getLength(); + + bool bLessThanOne = false; + if ( initialLen <= 4 ) // if less the 1 + bLessThanOne = true; + + sal_Int32 nCapacity = 6; // minimum e.g. 0.0000 + + if ( !bLessThanOne ) + { + nCapacity = initialLen + 1; +#if MAYBEFUTURE + if ( initialLen > 5 ) + { + sal_Int32 nThouSeperators = ( initialLen - 5 ) / 3; + nCapacity += nThouSeperators; + } +#endif + } + + if ( isNeg ) + ++nCapacity; + + aBuf.setLength( nCapacity ); + + + sal_Int32 nDigitCount = 0; + sal_Int32 nInsertIndex = nCapacity - 1; + sal_Int32 nEndIndex = isNeg ? 1 : 0; + + for ( sal_Int32 charCpyIndex = aAbsStr.getLength() - 1; nInsertIndex >= nEndIndex; ++nDigitCount ) + { + if ( nDigitCount == 4 ) + aBuf.setCharAt( nInsertIndex--, cDecimalSep ); +#if MAYBEFUTURE + if ( nDigitCount > 4 && ! ( ( nDigitCount - 4 ) % 3) ) + aBuf.setCharAt( nInsertIndex--, cThousandSep ); +#endif + if ( nDigitCount < initialLen ) + aBuf.setCharAt( nInsertIndex--, aAbsStr[ charCpyIndex-- ] ); + else + // Handle leading 0's to right of decimal point + // Note: in VBA the stringification is a little more complex + // but more natural as only the necessary digits + // to the right of the decimal places are displayed + // It would be great to conditionally be able to display like that too + // + // Val OOo (Cur) VBA (Cur) + // --- --------- --------- + // 0 0.0000 0 + // 0.1 0.1000 0.1 + + aBuf.setCharAt( nInsertIndex--, (sal_Unicode)'0' ); + } + if ( isNeg ) + aBuf.setCharAt( nInsertIndex, (sal_Unicode)'-' ); + + aAbsStr = aBuf.makeStringAndClear(); + return aAbsStr; +} + + +static sal_Int64 ImpStringToCurrency( const rtl::OUString &rStr ) +{ + + sal_Int32 nFractDigit = 4; + + SvtSysLocale aSysLocale; + sal_Unicode cDeciPnt = sal_Unicode('.'); + sal_Unicode c1000Sep = sal_Unicode(','); + +#if MAYBEFUTURE + const LocaleDataWrapper& rData = aSysLocale.GetLocaleData(); + sal_Unicode cLocaleDeciPnt = rData.getNumDecimalSep().GetBuffer()[0]; + sal_Unicode cLocale1000Sep = rData.getNumThousandSep().GetBuffer()[0]; + + // score each set of separators (Locale and Basic) on total number of matches + // if one set has more matches use that set + // if tied use the set with the only or rightmost decimal separator match + // currency is fixed pt system: usually expect the decimal pt, 1000sep may occur + sal_Int32 LocaleScore = 0; + sal_Int32 LocaleLastDeci = -1; + sal_Int32 LOBasicScore = 0; + sal_Int32 LOBasicLastDeci = -1; + + for( int idx=0; idx<rStr.getLength(); idx++ ) + { + if ( *(p+idx) == cLocaleDeciPnt ) + { + LocaleScore++; + LocaleLastDeci = idx; + } + if ( *(p+idx) == cLocale1000Sep ) + LocaleScore++; + + if ( *(p+idx) == cDeciPnt ) + { + LOBasicScore++; + LOBasicLastDeci = idx; + } + if ( *(p+idx) == c1000Sep ) + LOBasicScore++; + } + if ( ( LocaleScore > LOBasicScore ) + ||( LocaleScore = LOBasicScore && LocaleLastDeci > LOBasicLastDeci ) ) + { + cDeciPnt = cLocaleDeciPnt; + c1000Sep = cLocale1000Sep; + } +#endif + + // lets use the existing string number conversions + // there is a performance impact here ( multiple string copies ) + // but better I think than a home brewed string parser, if we need a parser + // we should share some existing ( possibly from calc is there a currency + // conversion there ? #TODO check ) + + rtl::OUString sTmp( rStr.trim() ); + const sal_Unicode* p = sTmp.getStr(); + + // normalise string number by removeing thousands & decimal point seperators + rtl::OUStringBuffer sNormalisedNumString( sTmp.getLength() + nFractDigit ); + + if ( *p == '-' || *p == '+' ) + sNormalisedNumString.append( *p ); + + while ( ( *p >= '0' && *p <= '9' ) ) + { + sNormalisedNumString.append( *p++ ); + // #TODO in vba mode set runtime error when a space ( or other ) + // illegal character is found + if( *p == c1000Sep ) + p++; + } + + bool bRoundUp = false; + + if( *p == cDeciPnt ) + { + p++; + while( nFractDigit && *p >= '0' && *p <= '9' ) + { + sNormalisedNumString.append( *p++ ); + nFractDigit--; + } + // Consume trailing content + if ( p != NULL ) + { + // Round up if necessary + if( *p >= '5' && *p <= '9' ) + bRoundUp = true; + while( *p >= '0' && *p <= '9' ) + p++; + } + + } + // can we raise error here ? ( previous behaviour was more forgiving ) + // so... not sure that could bread existing code, lets see if anyone + // complains. + + if ( p != sTmp.getStr() + sTmp.getLength() ) + SbxBase::SetError( SbxERR_CONVERSION ); + while( nFractDigit ) + { + sNormalisedNumString.append( sal_Unicode('0') ); + nFractDigit--; + } + + sal_Int64 result = sNormalisedNumString.makeStringAndClear().toInt64(); + + if ( bRoundUp ) + ++result; + return result; +} + + +sal_Int64 ImpGetCurrency( const SbxValues* p ) +{ + SbxValues aTmp; + sal_Int64 nRes; start: switch( +p->eType ) { + case SbxERROR: case SbxNULL: SbxBase::SetError( SbxERR_CONVERSION ); + nRes = 0; break; case SbxEMPTY: - nRes.SetNull(); break; - case SbxCHAR: - nRes = ImpDoubleToCurrency( (double)p->nChar ); break; + nRes = 0; break; + case SbxCURRENCY: + nRes = p->nInt64; break; case SbxBYTE: - nRes = ImpDoubleToCurrency( (double)p->nByte ); break; - case SbxINTEGER: + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nByte); + break; + case SbxCHAR: + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->pChar); + break; case SbxBOOL: - nRes = ImpDoubleToCurrency( (double)p->nInteger ); break; - case SbxERROR: + case SbxINTEGER: + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nInteger); + break; case SbxUSHORT: - nRes = ImpDoubleToCurrency( (double)p->nUShort ); break; - case SbxCURRENCY: - nRes = p->nLong64; break; + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nUShort); + break; case SbxLONG: - nRes = ImpDoubleToCurrency( (double)p->nLong ); + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nLong); break; case SbxULONG: - nRes = ImpDoubleToCurrency( (double)p->nULong ); + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(p->nULong); break; + case SbxSALINT64: - nRes = ImpDoubleToCurrency( (double)p->nInt64 ); - break; + { + nRes = p->nInt64 * CURRENCY_FACTOR; break; + if ( nRes > SbxMAXSALINT64 ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXSALINT64; + } + } case SbxSALUINT64: - nRes = ImpDoubleToCurrency( ImpSalUInt64ToDouble( p->uInt64 ) ); - break; - case SbxSINGLE: - if( p->nSingle > SbxMAXCURR ) + nRes = p->nInt64 * CURRENCY_FACTOR; break; + if ( nRes > SbxMAXSALINT64 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax(); + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXSALINT64; } - else if( p->nSingle < SbxMINCURR ) + else if ( nRes < SbxMINSALINT64 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin(); + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMINSALINT64; } - else - nRes = ImpDoubleToCurrency( (double)p->nSingle ); break; - case SbxDATE: - case SbxDOUBLE: - if( p->nDouble > SbxMAXCURR ) +//TODO: bring back SbxINT64 types here for limits -1 with flag value at SAL_MAX/MIN + case SbxSINGLE: + if( p->nSingle * CURRENCY_FACTOR + 0.5 > (float)SAL_MAX_INT64 + || p->nSingle * CURRENCY_FACTOR - 0.5 < (float)SAL_MIN_INT64 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax(); + nRes = SAL_MAX_INT64; + if( p->nSingle * CURRENCY_FACTOR - 0.5 < (float)SAL_MIN_INT64 ) + nRes = SAL_MIN_INT64; + SbxBase::SetError( SbxERR_OVERFLOW ); + break; } - else if( p->nDouble < SbxMINCURR ) + nRes = ImpDoubleToCurrency( (double)p->nSingle ); + break; + + case SbxDATE: + case SbxDOUBLE: + if( p->nDouble * CURRENCY_FACTOR + 0.5 > (double)SAL_MAX_INT64 + || p->nDouble * CURRENCY_FACTOR - 0.5 < (double)SAL_MIN_INT64 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin(); + nRes = SAL_MAX_INT64; + if( p->nDouble * CURRENCY_FACTOR - 0.5 < (double)SAL_MIN_INT64 ) + nRes = SAL_MIN_INT64; + SbxBase::SetError( SbxERR_OVERFLOW ); + break; } - else - nRes = ImpDoubleToCurrency( p->nDouble ); + nRes = ImpDoubleToCurrency( p->nDouble ); break; + case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { double d = 0.0; if( p->pDecimal ) p->pDecimal->getDouble( d ); - if( d > SbxMAXCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMax(); - } - else if( d < SbxMINCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); nRes.SetMin(); - } - else - nRes = ImpDoubleToCurrency( d ); + nRes = ImpDoubleToCurrency( d ); break; } + + case SbxBYREF | SbxSTRING: case SbxSTRING: case SbxLPSTR: if( !p->pOUString ) - nRes.SetNull(); + nRes=0; else nRes = ImpStringToCurrency( *p->pOUString ); break; @@ -133,25 +338,28 @@ start: nRes = pVal->GetCurrency(); else { - SbxBase::SetError( SbxERR_NO_OBJECT ); nRes.SetNull(); + SbxBase::SetError( SbxERR_NO_OBJECT ); + nRes=0; } break; } case SbxBYREF | SbxCHAR: - nRes = ImpDoubleToCurrency( (double)*p->pChar ); break; + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pChar); + break; case SbxBYREF | SbxBYTE: - nRes = ImpDoubleToCurrency( (double)*p->pByte ); break; - case SbxBYREF | SbxINTEGER: + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pByte); + break; case SbxBYREF | SbxBOOL: - nRes = ImpDoubleToCurrency( (double)*p->pInteger ); break; + case SbxBYREF | SbxINTEGER: + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pInteger); + break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: - nRes = ImpDoubleToCurrency( (double)*p->pUShort ); break; - case SbxBYREF | SbxCURRENCY: - nRes = *p->pLong64; break; + nRes = (sal_Int64)CURRENCY_FACTOR * (sal_Int64)(*p->pUShort); + break; - // ab hier muss getestet werden + // from here on had to be tested case SbxBYREF | SbxLONG: aTmp.nLong = *p->pLong; goto ref; case SbxBYREF | SbxULONG: @@ -161,28 +369,30 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; + case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: aTmp.uInt64 = *p->puInt64; goto ref; ref: - aTmp.eType = SbxDataType( p->eType & 0x0FFF ); + aTmp.eType = SbxDataType( p->eType & ~SbxBYREF ); p = &aTmp; goto start; default: - SbxBase::SetError( SbxERR_CONVERSION ); nRes.SetNull(); + SbxBase::SetError( SbxERR_CONVERSION ); + nRes=0; } return nRes; } -void ImpPutCurrency( SbxValues* p, const SbxINT64 &r ) + +void ImpPutCurrency( SbxValues* p, const sal_Int64 r ) { - double dVal = ImpCurrencyToDouble( r ); SbxValues aTmp; start: switch( +p->eType ) { - // Hier sind Tests notwendig + // Here are tests necessary case SbxCHAR: aTmp.pChar = &p->nChar; goto direct; case SbxBYTE: @@ -201,23 +411,25 @@ start: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; - // ab hier nicht mehr + // from here no longer case SbxSINGLE: - p->nSingle = (float)dVal; break; + p->nSingle = (float)( r / CURRENCY_FACTOR ); break; case SbxDATE: case SbxDOUBLE: - p->nDouble = dVal; break; - case SbxSALINT64: - p->nInt64 = ImpDoubleToSalInt64( dVal ); break; + p->nDouble = ImpCurrencyToDouble( r ); break; case SbxSALUINT64: - p->uInt64 = ImpDoubleToSalUInt64( dVal ); break; + p->uInt64 = r / CURRENCY_FACTOR; break; + case SbxSALINT64: + p->nInt64 = r / CURRENCY_FACTOR; break; + case SbxCURRENCY: - p->nLong64 = r; break; + p->nInt64 = r; break; + case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { SbxDecimal* pDec = ImpCreateDecimal( p ); - if( !pDec->setDouble( dVal ) ) + if( !pDec->setDouble( ImpCurrencyToDouble( r ) / CURRENCY_FACTOR ) ) SbxBase::SetError( SbxERR_OVERFLOW ); break; } @@ -225,7 +437,7 @@ start: case SbxSTRING: case SbxLPSTR: if( !p->pOUString ) - p->pOUString = new ::rtl::OUString; + p->pOUString = new rtl::OUString; *p->pOUString = ImpCurrencyToString( r ); break; @@ -239,157 +451,100 @@ start: break; } case SbxBYREF | SbxCHAR: - if( dVal > SbxMAXCHAR ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( val > SbxMAXCHAR ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXCHAR; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXCHAR; } - else if( dVal < SbxMINCHAR ) + else if( val < SbxMINCHAR ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMINCHAR; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMINCHAR; } - *p->pChar = (xub_Unicode) dVal; break; + *p->pChar = (sal_Unicode) val; break; + } case SbxBYREF | SbxBYTE: - if( dVal > SbxMAXBYTE ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( val > SbxMAXBYTE ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXBYTE; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXBYTE; } - else if( dVal < 0 ) + else if( val < 0 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0; + SbxBase::SetError( SbxERR_OVERFLOW ); val = 0; } - *p->pByte = (sal_uInt8) dVal; break; + *p->pByte = (sal_uInt8) val; break; + } case SbxBYREF | SbxINTEGER: case SbxBYREF | SbxBOOL: - if( dVal > SbxMAXINT ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( r > SbxMAXINT ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXINT; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXINT; } - else if( dVal < SbxMININT ) + else if( r < SbxMININT ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMININT; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMININT; } - *p->pInteger = (sal_Int16) dVal; break; + *p->pInteger = (sal_uInt16) val; break; + } case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: - if( dVal > SbxMAXUINT ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( val > SbxMAXUINT ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXUINT; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXUINT; } - else if( dVal < 0 ) + else if( val < 0 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0; + SbxBase::SetError( SbxERR_OVERFLOW ); val = 0; } - *p->pUShort = (sal_uInt16) dVal; break; + *p->pUShort = (sal_uInt16) val; break; + } case SbxBYREF | SbxLONG: - if( dVal > SbxMAXLNG ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( val > SbxMAXLNG ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXLNG; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXLNG; } - else if( dVal < SbxMINLNG ) + else if( val < SbxMINLNG ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMINLNG; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMINLNG; } - *p->pLong = (sal_Int32) dVal; break; + *p->pLong = (sal_Int32) val; break; + } case SbxBYREF | SbxULONG: - if( dVal > SbxMAXULNG ) + { + sal_Int64 val = r / CURRENCY_FACTOR; + if( val > SbxMAXULNG ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = SbxMAXULNG; + SbxBase::SetError( SbxERR_OVERFLOW ); val = SbxMAXULNG; } - else if( dVal < 0 ) + else if( val < 0 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); dVal = 0; + SbxBase::SetError( SbxERR_OVERFLOW ); val = 0; } - *p->pULong = (sal_uInt32) dVal; break; + *p->pULong = (sal_uInt32) val; break; + break; + } + case SbxBYREF | SbxCURRENCY: + *p->pnInt64 = r; break; case SbxBYREF | SbxSALINT64: - *p->pnInt64 = ImpDoubleToSalInt64( dVal ); break; + *p->pnInt64 = r / CURRENCY_FACTOR; break; case SbxBYREF | SbxSALUINT64: - *p->puInt64 = ImpDoubleToSalUInt64( dVal ); break; + *p->puInt64 = (sal_uInt64)r / CURRENCY_FACTOR; break; case SbxBYREF | SbxSINGLE: - *p->pSingle = (float) dVal; break; + p->nSingle = (float)( r / CURRENCY_FACTOR ); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: - *p->pDouble = (double) dVal; break; - case SbxBYREF | SbxCURRENCY: - *p->pLong64 = r; break; - + *p->pDouble = ImpCurrencyToDouble( r ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); } } -// Hilfs-Funktionen zur Wandlung - -static ::rtl::OUString ImpCurrencyToString( const SbxINT64 &r ) -{ - BigInt a10000 = 10000; - - //return GetpApp()->GetAppInternational().GetCurr( BigInt( r ), 4 ); - BigInt aInt( r ); - aInt.Abs(); - BigInt aFrac = aInt; - aInt /= a10000; - aFrac %= a10000; - aFrac += a10000; - - ::rtl::OUString aString; - if( r.nHigh < 0 ) - aString = ::rtl::OUString( (sal_Unicode)'-' ); - aString += aInt.GetString(); - aString += ::rtl::OUString( (sal_Unicode)'.' ); - aString += aFrac.GetString().GetBuffer()+1; - return aString; -} - -static SbxINT64 ImpStringToCurrency( const ::rtl::OUString &r ) -{ - int nDec = 4; - String aStr; - const sal_Unicode* p = r.getStr(); - - if( *p == '-' ) - aStr += *p++; - - while( *p >= '0' && *p <= '9' ) { - aStr += *p++; - if( *p == ',' ) - p++; - } - - if( *p == '.' ) { - p++; - while( nDec && *p >= '0' && *p <= '9' ) { - aStr += *p++; - nDec--; - } - } - while( nDec ) { - aStr += '0'; - nDec--; - } - - BigInt aBig( aStr ); - SbxINT64 nRes; - aBig.INT64( &nRes ); - return nRes; -} - -double ImpINT64ToDouble( const SbxINT64 &r ) -{ return (double)r.nHigh*(double)4294967296.0 + (double)r.nLow; } - -SbxINT64 ImpDoubleToINT64( double d ) -{ - SbxINT64 nRes; - nRes.Set( d ); - return nRes; -} - -double ImpUINT64ToDouble( const SbxUINT64 &r ) -{ return (double)r.nHigh*(double)4294967296.0 + (double)r.nLow; } - -SbxUINT64 ImpDoubleToUINT64( double d ) -{ - SbxUINT64 nRes; - nRes.Set( d ); - return nRes; -} - +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxdate.cxx b/basic/source/sbx/sbxdate.cxx index 1d0b81ed98f6..804506c18215 100644 --- a/basic/source/sbx/sbxdate.cxx +++ b/basic/source/sbx/sbxdate.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -66,12 +67,8 @@ double ImpGetDate( const SbxValues* p ) case SbxDATE: case SbxDOUBLE: nRes = p->nDouble; break; - case SbxULONG64: - nRes = ImpUINT64ToDouble( p->nULong64 ); break; - case SbxLONG64: - nRes = ImpINT64ToDouble( p->nLong64 ); break; case SbxCURRENCY: - nRes = ImpCurrencyToDouble( p->nLong64 ); break; + nRes = ImpCurrencyToDouble( p->nInt64 ); break; case SbxSALINT64: nRes = static_cast< double >(p->nInt64); break; case SbxSALUINT64: @@ -101,13 +98,13 @@ double ImpGetDate( const SbxValues* p ) xub_StrLen nCheckPos = 0; short nType = 127; - // Standard-Vorlagen des Formatters haben nur zweistellige - // Jahreszahl. Deshalb eigenes Format registrieren + // Default templates of the formatter have only two-digit + // date. Therefore register an own format. - // HACK, da der Numberformatter in PutandConvertEntry die Platzhalter - // fuer Monat, Tag, Jahr nicht entsprechend der Systemeinstellung - // austauscht. Problem: Print Year(Date) unter engl. BS - // siehe auch basic\source\runtime\runtime.cxx + // HACK, because the number formatter in PutandConvertEntry replace the wildcard + // for month, day, year not according to the configuration. + // Problem: Print Year(Date) under Engl. OS + // quod vide basic\source\runtime\runtime.cxx SvtSysLocale aSysLocale; DateFormat eDate = aSysLocale.GetLocaleData().getDateFormat(); @@ -173,12 +170,8 @@ double ImpGetDate( const SbxValues* p ) case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: nRes = *p->pDouble; break; - case SbxBYREF | SbxULONG64: - nRes = ImpUINT64ToDouble( *p->pULong64 ); break; - case SbxBYREF | SbxLONG64: - nRes = ImpINT64ToDouble( *p->pLong64 ); break; case SbxBYREF | SbxCURRENCY: - nRes = ImpCurrencyToDouble( *p->pLong64 ); break; + nRes = ImpCurrencyToDouble( *p->pnInt64 ); break; case SbxBYREF | SbxSALINT64: nRes = static_cast< double >(*p->pnInt64); break; case SbxBYREF | SbxSALUINT64: @@ -201,7 +194,7 @@ start: case SbxDOUBLE: p->nDouble = n; break; - // ab hier wird getestet + // from here will be tested case SbxCHAR: aTmp.pChar = &p->nChar; goto direct; case SbxBYTE: @@ -218,11 +211,7 @@ start: aTmp.pUShort = &p->nUShort; goto direct; case SbxSINGLE: aTmp.pSingle = &p->nSingle; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; case SbxSALINT64: aTmp.pnInt64 = &p->nInt64; goto direct; case SbxSALUINT64: @@ -260,7 +249,7 @@ start: SvtSysLocale aSysLocale; DateFormat eDate = aSysLocale.GetLocaleData().getDateFormat(); String aStr; - // ist der ganzzahlige Teil 0, wollen wir kein Jahr! + // if the whole-number part is 0, we want no year! if( n <= -1.0 || n >= 1.0 ) { // Time only if != 00:00:00 @@ -397,10 +386,11 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINCURR; } - *p->pLong64 = ImpDoubleToCurrency( n ); break; + *p->pnInt64 = ImpDoubleToCurrency( n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxdbl.cxx b/basic/source/sbx/sbxdbl.cxx index efbad5521f3b..c4bbbe46c4ec 100644 --- a/basic/source/sbx/sbxdbl.cxx +++ b/basic/source/sbx/sbxdbl.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -61,7 +62,7 @@ double ImpGetDouble( const SbxValues* p ) case SbxDOUBLE: nRes = p->nDouble; break; case SbxCURRENCY: - nRes = ImpCurrencyToDouble( p->nLong64 ); break; + nRes = ImpCurrencyToDouble( p->nInt64 ); break; case SbxSALINT64: nRes = static_cast< double >(p->nInt64); break; case SbxSALUINT64: @@ -128,7 +129,7 @@ double ImpGetDouble( const SbxValues* p ) case SbxBYREF | SbxDOUBLE: nRes = *p->pDouble; break; case SbxBYREF | SbxCURRENCY: - nRes = ImpCurrencyToDouble( *p->pLong64 ); break; + nRes = ImpCurrencyToDouble( *p->pnInt64 ); break; case SbxBYREF | SbxSALINT64: nRes = static_cast< double >(*p->pnInt64); break; case SbxBYREF | SbxSALUINT64: @@ -146,7 +147,7 @@ void ImpPutDouble( SbxValues* p, double n, sal_Bool bCoreString ) start: switch( +p->eType ) { - // Hier sind Tests notwendig + // Here are tests necessary case SbxCHAR: aTmp.pChar = &p->nChar; goto direct; case SbxBYTE: @@ -155,7 +156,6 @@ start: case SbxBOOL: aTmp.pInteger = &p->nInteger; goto direct; case SbxLONG: - case SbxCURRENCY: aTmp.pLong = &p->nLong; goto direct; case SbxULONG: aTmp.pULong = &p->nULong; goto direct; @@ -176,7 +176,19 @@ start: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; - // ab hier nicht mehr + case SbxCURRENCY: + if( n > SbxMAXCURR ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXCURR; + } + else if( n < SbxMINCURR ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINCURR; + } + p->nInt64 = ImpDoubleToCurrency( n ); + break; + + // from here on no longer case SbxSALINT64: p->nInt64 = ImpDoubleToSalInt64( n ); break; case SbxSALUINT64: @@ -297,10 +309,11 @@ start: { SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMINCURR; } - *p->pLong64 = ImpDoubleToCurrency( n ); break; + *p->pnInt64 = ImpDoubleToCurrency( n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxdec.cxx b/basic/source/sbx/sbxdec.cxx index 3a0e65c142e2..ddf9d68489a5 100644 --- a/basic/source/sbx/sbxdec.cxx +++ b/basic/source/sbx/sbxdec.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -35,14 +36,11 @@ #include <com/sun/star/bridge/oleautomation/Decimal.hpp> -// int GnDecCounter = 0; - // Implementation SbxDecimal SbxDecimal::SbxDecimal( void ) { setInt( 0 ); mnRefCount = 0; - // GnDecCounter++; } SbxDecimal::SbxDecimal( const SbxDecimal& rDec ) @@ -53,7 +51,6 @@ SbxDecimal::SbxDecimal( const SbxDecimal& rDec ) (void)rDec; #endif mnRefCount = 0; - // GnDecCounter++; } SbxDecimal::SbxDecimal @@ -69,7 +66,6 @@ SbxDecimal::SbxDecimal (void)rAutomationDec; #endif mnRefCount = 0; - // GnDecCounter++; } void SbxDecimal::fillAutomationDecimal @@ -88,7 +84,6 @@ void SbxDecimal::fillAutomationDecimal SbxDecimal::~SbxDecimal() { - // GnDecCounter--; } void releaseDecimalPtr( SbxDecimal*& rpDecimal ) @@ -493,38 +488,32 @@ start: if( !pnDecRes->setSingle( p->nSingle ) ) SbxBase::SetError( SbxERR_OVERFLOW ); break; + case SbxCURRENCY: + { + if( !pnDecRes->setDouble( ImpCurrencyToDouble( p->nInt64 ) ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); + break; + } case SbxSALINT64: { - double d = (double)p->nInt64; - pnDecRes->setDouble( d ); + if( !pnDecRes->setDouble( (double)p->nInt64 ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); break; } case SbxSALUINT64: { - double d = ImpSalUInt64ToDouble( p->uInt64 ); - pnDecRes->setDouble( d ); + if( !pnDecRes->setDouble( (double)p->uInt64 ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); break; } case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: - { - double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else - dVal = p->nDouble; - + { + double dVal = p->nDouble; if( !pnDecRes->setDouble( dVal ) ) SbxBase::SetError( SbxERR_OVERFLOW ); break; - } + } case SbxLPSTR: case SbxSTRING: case SbxBYREF | SbxSTRING: @@ -557,17 +546,13 @@ start: case SbxBYREF | SbxUSHORT: pnDecRes->setUShort( *p->pUShort ); break; - // ab hier muss getestet werden + // from here on had to be tested case SbxBYREF | SbxSINGLE: aTmp.nSingle = *p->pSingle; goto ref; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: @@ -597,7 +582,7 @@ void ImpPutDecimal( SbxValues* p, SbxDecimal* pDec ) start: switch( +p->eType ) { - // hier muss getestet werden + // here had to be tested case SbxCHAR: aTmp.pChar = &p->nChar; goto direct; case SbxBYTE: @@ -607,30 +592,28 @@ start: case SbxERROR: case SbxUSHORT: aTmp.pUShort = &p->nUShort; goto direct; - case SbxSALUINT64: - aTmp.puInt64 = &p->uInt64; goto direct; case SbxINTEGER: case SbxBOOL: aTmp.pInteger = &p->nInteger; goto direct; case SbxLONG: aTmp.pLong = &p->nLong; goto direct; + case SbxCURRENCY: case SbxSALINT64: aTmp.pnInt64 = &p->nInt64; goto direct; - case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; + case SbxSALUINT64: + aTmp.puInt64 = &p->uInt64; goto direct; + direct: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; - // ab hier nicht mehr + // from here on no longer case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { if( pDec != p->pDecimal ) { releaseDecimalPtr( p->pDecimal ); - // if( p->pDecimal ) - // p->pDecimal->ReleaseRef(); p->pDecimal = pDec; if( pDec ) pDec->addRef(); @@ -652,27 +635,12 @@ start: p->nDouble = d; break; } - case SbxULONG64: - { - double d; - pDec->getDouble( d ); - p->nULong64 = ImpDoubleToUINT64( d ); - break; - } - case SbxLONG64: - { - double d; - pDec->getDouble( d ); - p->nLong64 = ImpDoubleToINT64( d ); - break; - } case SbxLPSTR: case SbxSTRING: case SbxBYREF | SbxSTRING: if( !p->pOUString ) p->pOUString = new ::rtl::OUString; - // ImpCvtNum( (double) n, 0, *p->pString ); pDec->getString( *p->pOUString ); break; case SbxOBJECT: @@ -707,7 +675,6 @@ start: *p->pInteger = 0; } break; - // *p->pInteger = n; break; case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: if( !pDec->getUShort( *p->pUShort ) ) @@ -730,6 +697,12 @@ start: *p->pULong = 0; } break; + case SbxBYREF | SbxCURRENCY: + double d; + if( !pDec->getDouble( d ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); + *p->pnInt64 = ImpDoubleToCurrency( d ); + break; case SbxBYREF | SbxSALINT64: { double d; @@ -755,7 +728,6 @@ start: *p->pSingle = 0; } break; - // *p->pSingle = (float) n; break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: if( !pDec->getDouble( *p->pDouble ) ) @@ -764,28 +736,6 @@ start: *p->pDouble = 0; } break; - case SbxBYREF | SbxULONG64: - { - double d; - pDec->getDouble( d ); - *p->pULong64 = ImpDoubleToUINT64( d ); - break; - } - case SbxBYREF | SbxLONG64: - { - double d; - pDec->getDouble( d ); - *p->pLong64 = ImpDoubleToINT64( d ); - break; - } - case SbxBYREF | SbxCURRENCY: - { - double d; - pDec->getDouble( d ); - *p->pLong64 = ImpDoubleToCurrency( d ); - break; - } - default: SbxBase::SetError( SbxERR_CONVERSION ); } @@ -795,3 +745,4 @@ start: #endif } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxdec.hxx b/basic/source/sbx/sbxdec.hxx index 6b8cd7e31336..533ffb9aebb9 100644 --- a/basic/source/sbx/sbxdec.hxx +++ b/basic/source/sbx/sbxdec.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -33,17 +34,15 @@ #undef WB_LEFT #undef WB_RIGHT -#include <tools/prewin.h> -} // close extern "C" { + +#include <prewin.h> +#include <postwin.h> #ifndef __MINGW32__ #include <comutil.h> #endif #include <oleauto.h> -extern "C" { // reopen extern "C" { -#include <tools/postwin.h> - #endif #endif #include <basic/sbx.hxx> @@ -120,3 +119,4 @@ public: friend CmpResult compare( const SbxDecimal &rLeft, const SbxDecimal &rRight ); }; +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxexec.cxx b/basic/source/sbx/sbxexec.cxx index 9b43a94873f0..f12ffc0bf817 100644 --- a/basic/source/sbx/sbxexec.cxx +++ b/basic/source/sbx/sbxexec.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,9 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" #include <tools/errcode.hxx> -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif #include <basic/sbx.hxx> @@ -68,13 +67,13 @@ static const xub_Unicode* SkipWhitespace( const xub_Unicode* p ) return p; } -// Scannen eines Symbol. Das Symbol wird in rSym eingetragen, der Returnwert -// ist die neue Scanposition. Bei Fehlern ist das Symbol leer. +// Scanning of a symbol. The symbol were inserted in rSym, the return value +// is the new scan position. The symbol is at errors empty. static const xub_Unicode* Symbol( const xub_Unicode* p, XubString& rSym, const SbxSimpleCharClass& rCharClass ) { sal_uInt16 nLen = 0; - // Haben wir ein Sondersymbol? + // Did we have a nonstandard symbol? if( *p == '[' ) { rSym = ++p; @@ -84,16 +83,16 @@ static const xub_Unicode* Symbol( const xub_Unicode* p, XubString& rSym, const S } else { - // Ein Symbol muss mit einem Buchstaben oder einem Underline beginnen + // A symbol had to begin with a alphabetic character or an underline if( !rCharClass.isAlpha( *p ) && *p != '_' ) SbxBase::SetError( SbxERR_SYNTAX ); else { rSym = p; - // Dann darf es Buchstaben, Zahlen oder Underlines enthalten + // The it can contain alphabetic characters, numbers or underlines while( *p && (rCharClass.isAlphaNumeric( *p ) || *p == '_') ) p++, nLen++; - // BASIC-Standard-Suffixe werden ignoriert + // BASIC-Standard-Suffixes were ignored if( *p && (*p == '%' || *p == '&' || *p == '!' || *p == '#' || *p == '$' ) ) p++; } @@ -102,7 +101,7 @@ static const xub_Unicode* Symbol( const xub_Unicode* p, XubString& rSym, const S return p; } -// Qualifizierter Name. Element.Element.... +// Qualified name. Element.Element.... static SbxVariable* QualifiedName ( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode** ppBuf, SbxClassType t ) @@ -113,21 +112,21 @@ static SbxVariable* QualifiedName const xub_Unicode* p = SkipWhitespace( *ppBuf ); if( aCharClass.isAlpha( *p ) || *p == '_' || *p == '[' ) { - // Element einlesen + // Read in the element refVar = Element( pObj, pGbl, &p, t, aCharClass ); while( refVar.Is() && (*p == '.' || *p == '!') ) { - // Es folgt noch ein Objektelement. Das aktuelle Element - // muss also ein SBX-Objekt sein oder liefern! + // It follows still an objectelement. The current element + // had to be a SBX-Object or had to deliver such an object! pObj = PTR_CAST(SbxObject,(SbxVariable*) refVar); if( !pObj ) - // Dann muss es ein Objekt liefern + // Then it had to deliver an object pObj = PTR_CAST(SbxObject,refVar->GetObject()); refVar.Clear(); if( !pObj ) break; p++; - // Und das naechste Element bitte + // And the next element please refVar = Element( pObj, pGbl, &p, t, aCharClass ); } } @@ -139,8 +138,8 @@ static SbxVariable* QualifiedName return refVar; } -// Einlesen eines Operanden. Dies kann eine Zahl, ein String oder -// eine Funktion (mit optionalen Parametern) sein. +// Read in of an operand. This could be a number, a string or +// a function (with optional parameters). static SbxVariable* Operand ( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode** ppBuf, sal_Bool bVar ) @@ -154,7 +153,7 @@ static SbxVariable* Operand || *p == '-' || *p == '&' ) ) { - // Eine Zahl kann direkt eingescant werden! + // A number could be scanned in directly! sal_uInt16 nLen; if( !refVar->Scan( XubString( p ), &nLen ) ) refVar.Clear(); @@ -163,15 +162,15 @@ static SbxVariable* Operand } else if( !bVar && *p == '"' ) { - // Ein String + // A string XubString aString; p++; for( ;; ) { - // Das ist wohl ein Fehler + // This is perhaps an error if( !*p ) return NULL; - // Doppelte Quotes sind OK + // Double quotes are OK if( *p == '"' ) if( *++p != '"' ) break; @@ -187,8 +186,8 @@ static SbxVariable* Operand return refVar; } -// Einlesen einer einfachen Term. Die Operatoren +, -, * und / -// werden unterstuetzt. +// Read in of a simple term. The operands +, -, * and / +// are supported. static SbxVariable* MulDiv( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode** ppBuf ) { @@ -201,7 +200,7 @@ static SbxVariable* MulDiv( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode* SbxVariableRef refVar2( Operand( pObj, pGbl, &p, sal_False ) ); if( refVar2.Is() ) { - // temporaere Variable! + // temporary variable! SbxVariable* pVar = refVar; pVar = new SbxVariable( *pVar ); refVar = pVar; @@ -263,7 +262,7 @@ static SbxVariable* Assign( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode* { if( *p == '=' ) { - // Nur auf Props zuweisen! + // Assign only onto properties! if( refVar->GetClass() != SbxCLASS_PROPERTY ) { SbxBase::SetError( SbxERR_BAD_ACTION ); @@ -283,7 +282,7 @@ static SbxVariable* Assign( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode* } } else - // Einfacher Aufruf: einmal aktivieren + // Simple call: once activating refVar->Broadcast( SBX_HINT_DATAWANTED ); } *ppBuf = p; @@ -292,9 +291,9 @@ static SbxVariable* Assign( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode* return refVar; } -// Einlesen eines Elements. Dies ist ein Symbol, optional gefolgt -// von einer Parameterliste. Das Symbol wird im angegebenen Objekt -// gesucht und die Parameterliste wird ggf. angefuegt. +// Read in of an element. This is a symbol, optional followed +// by a parameter list. The symbol will be searched in the +// specified object and the parameter list will be attached if necessary. static SbxVariable* Element ( SbxObject* pObj, SbxObject* pGbl, const xub_Unicode** ppBuf, @@ -313,29 +312,29 @@ static SbxVariable* Element if( refVar.Is() ) { refVar->SetParameters( NULL ); - // folgen noch Parameter? + // Follow still parameter? p = SkipWhitespace( p ); if( *p == '(' ) { p++; SbxArrayRef refPar = new SbxArray; sal_uInt16 nArg = 0; - // Wird sind mal relaxed und akzeptieren auch - // das Zeilen- oder Komandoende als Begrenzer - // Parameter immer global suchen! + // We are once relaxed and accept as well + // the line- or commandend as delimiter + // Search parameter always global! while( *p && *p != ')' && *p != ']' ) { SbxVariableRef refArg = PlusMinus( pGbl, pGbl, &p ); if( !refArg ) { - // Fehler beim Parsing + // Error during the parsing refVar.Clear(); break; } else { - // Man kopiere den Parameter, damit - // man den aktuellen Zustand hat (loest auch - // den Aufruf per Zugriff aus) + // One copies the parameter, so that + // one have the current status (triggers also + // the call per access) SbxVariable* pArg = refArg; refPar->Put( new SbxVariable( *pArg ), ++nArg ); } @@ -358,7 +357,7 @@ static SbxVariable* Element return refVar; } -// Hauptroutine +// Mainroutine SbxVariable* SbxObject::Execute( const XubString& rTxt ) { @@ -399,3 +398,4 @@ SbxVariable* SbxObject::FindQualified( const XubString& rName, SbxClassType t ) return pVar; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxform.cxx b/basic/source/sbx/sbxform.cxx index 46b6e6caa445..61fbafdd37cf 100644 --- a/basic/source/sbx/sbxform.cxx +++ b/basic/source/sbx/sbxform.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -141,12 +142,6 @@ SbxBasicFormater::SbxBasicFormater( sal_Unicode _cDecPoint, sal_Unicode _cThousa } // Funktion zur Ausgabe eines Fehler-Textes (zum Debuggen) -/* -void SbxBasicFormater::ShowError( char * sErrMsg ) -{ -// cout << "ERROR in Format$(): " << sErrMsg << endl; -} -*/ // verschiebt alle Zeichen des Strings, angefangen von der nStartPos, // um eine Position zu gr"osseren Indizes, d.h. es wird Platz f"ur // ein neues (einzuf"ugendes) Zeichen geschafft. @@ -378,19 +373,16 @@ TODO: ggf einen 'intelligenten' Peek-Parser um Rundungsfehler bei // In bFoundFirstDigit wird ggf. ein Flag gesetzt wenn eine Ziffer // gefunden wurde, dies wird dazu verwendet um 'Fehler' beim Parsen 202 // zu vermeiden, die -// // ACHTUNG: anscheinend gibt es manchmal noch Probleme mit Rundungs-Fehlern! short SbxBasicFormater::GetDigitAtPos( double dNumber, short nPos, double& dNextNumber, sal_Bool& bFoundFirstDigit ) // ACHTUNG: nPos kann auch negativ werden, f"ur Stellen nach dem Dezimal-Punkt { - double dTemp = dNumber; - double dDigit,dPos; + double dDigit; short nMaxDigit; // erst mal aus der Zahl eine positive Zahl machen: dNumber = fabs( dNumber ); - dPos = (double)nPos; // "uberpr"ufe ob Zahl zu klein f"ur angegebene Stelle ist nMaxDigit = (short)get_number_of_digits( dNumber ); @@ -616,11 +608,6 @@ short SbxBasicFormater::AnalyseFormatString( const String& sFormatStrg, break; case '%': bPercent = sal_True; - /* old: - bPercent++; - if( bPercent>1 ) - return -2; // ERROR: zu viele Prozent-Zeichen - */ break; case '(': bCurrency = sal_True; @@ -641,11 +628,6 @@ short SbxBasicFormater::AnalyseFormatString( const String& sFormatStrg, nState = -1; // breche jetzt das Z"ahlen der Stellen ab bScientific = sal_True; } - /* old: - bScientific++; - if( bScientific>1 ) - return -3; // ERROR: zu viele Exponent-Zeichen - */ break; // EIGENES Kommando-Zeichen, das die Erzeugung der // Tausender-Trennzeichen einschaltet @@ -692,23 +674,11 @@ void SbxBasicFormater::ScanFormatString( double dNumber, - sonstige Fehler ? mehrfache Dezimalpunkte, E's, etc. --> Fehler werden zur Zeit einfach ignoriert */ - /*nErr =*/ AnalyseFormatString( sFormatStrg,nNoOfDigitsLeft,nNoOfDigitsRight, + AnalyseFormatString( sFormatStrg,nNoOfDigitsLeft,nNoOfDigitsRight, nNoOfOptionalDigitsLeft,nNoOfExponentDigits, nNoOfOptionalExponentDigits, bPercent,bCurrency,bScientific,bGenerateThousandSeparator, nMultipleThousandSeparators ); - /* es werden alle Fehler ignoriert, wie in Visual-Basic - if( nErr!=0 ) - { - char sBuffer[512]; - - //sprintf( sBuffer,"bad format-string >%s< err=%i",sFormatStrg,nErr ); - strcpy( sBuffer,"bad format-string" ); - ShowError( sBuffer ); - } - else - */ - { // Spezialbehandlung f"ur Spezialzeichen if( bPercent ) dNumber *= 100.0; @@ -736,8 +706,6 @@ void SbxBasicFormater::ScanFormatString( double dNumber, bDigitPosNegative = false; if( bScientific ) { - //if( nNoOfOptionalDigitsLeft>0 ) - // ShowError( "# in scientific-format in front of the decimal-point has no effect" ); // beim Exponent ggf. "uberz"ahlige Stellen vor dem Komma abziehen dExponent = dExponent - (double)(nNoOfDigitsLeft-1); nDigitPos = nMaxDigit; @@ -781,11 +749,10 @@ void SbxBasicFormater::ScanFormatString( double dNumber, // Behandlung der Mantisse if( bFirstDigit ) { - //org:bFirstDigit = sal_False; // ggf. Vorzeichen erzeugen // Bem.: bei bCurrency soll das negative // Vorzeichen durch () angezeigt werden - if( bIsNegative && !bCreateSign/*!bCurrency*/ && !bSignHappend ) + if( bIsNegative && !bCreateSign && !bSignHappend ) { // nur einmal ein Vorzeichen ausgeben bSignHappend = sal_True; @@ -959,19 +926,9 @@ void SbxBasicFormater::ScanFormatString( double dNumber, else StrAppendChar( sReturnStrg,'+' ); } - //else - // ShowError( "operator e/E did not find + or -" ); } - //else - // ShowError( "operator e/E ended with 0" ); break; case ',': - // ACHTUNG: nur falls Zahl bisher ausgegeben wurde - // das Zeichen ausgeben - ////--> Siehe Kommentar vom 11.7. in AnalyseFormatString() - ////if( !bFirstDigit ) - //// // gebe Tausender-Trennzeichen aus - //// StrAppendChar( sReturnStrg,cThousandSep ); break; case ';': break; @@ -1001,12 +958,9 @@ void SbxBasicFormater::ScanFormatString( double dNumber, ParseBack( sReturnStrg,sFormatStrg,i-1 ); // Sonderzeichen gefunden, gebe N"ACHSTES // Zeichen direkt aus (falls es existiert) - // i++; c = sFormatStrg.GetChar( ++i ); if( c!=0 ) StrAppendChar( sReturnStrg,c ); - //else - // ShowError( "operator \\ ended with 0" ); break; case CREATE_1000SEP_CHAR: // hier ignorieren, Aktion wurde schon in @@ -1018,9 +972,6 @@ void SbxBasicFormater::ScanFormatString( double dNumber, ( c>='A' && c<='Z' ) || ( c>='1' && c<='9' ) ) StrAppendChar( sReturnStrg,c ); - // else - // ignorieren ! - // ehemals: ShowError( "bad character in format-string" ); } } // Format-String wurde vollst"andig gescanned, @@ -1042,7 +993,6 @@ void SbxBasicFormater::ScanFormatString( double dNumber, // ABER nur Stellen nach dem Dezimal-Punkt k"onnen gel"oscht werden if( nNoOfDigitsRight>0 ) ParseBack( sReturnStrg,sFormatStrg,sFormatStrg.Len()-1 ); - } } String SbxBasicFormater::BasicFormatNull( String sFormatStrg ) @@ -1086,7 +1036,6 @@ String SbxBasicFormater::BasicFormat( double dNumber, String sFormatStrg ) String sPosFormatStrg = GetPosFormatString( sFormatStrg, bPosFormatFound ); String sNegFormatStrg = GetNegFormatString( sFormatStrg, bNegFormatFound ); String s0FormatStrg = Get0FormatString( sFormatStrg, b0FormatFound ); - //String sNullFormatStrg = GetNullFormatString( sFormatStrg, bNullFormatFound ); String sReturnStrg; String sTempStrg; @@ -1166,3 +1115,4 @@ sal_Bool SbxBasicFormater::isBasicFormat( String sFormatStrg ) return sal_False; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxint.cxx b/basic/source/sbx/sbxint.cxx index 4c4b3959e7a0..289622a016fd 100644 --- a/basic/source/sbx/sbxint.cxx +++ b/basic/source/sbx/sbxint.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -95,6 +96,22 @@ start: else nRes = (sal_Int16) ImpRound( p->nSingle ); break; + case SbxCURRENCY: + { + sal_Int64 tstVal = (sal_Int64) p->nInt64 / (sal_Int64) CURRENCY_FACTOR; + + if( tstVal > SbxMAXINT ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXINT; + } + else if( tstVal < SbxMININT ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMININT; + } + else + nRes = (sal_Int16) (tstVal); + break; + } case SbxSALINT64: if( p->nInt64 > SbxMAXINT ) { @@ -117,22 +134,12 @@ start: break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: + { + double dVal = 0.0; + if( p->eType == SbxDECIMAL ) { - double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else if( p->eType == SbxDECIMAL ) - { - dVal = 0.0; if( p->pDecimal ) p->pDecimal->getDouble( dVal ); } @@ -194,7 +201,7 @@ start: case SbxBYREF | SbxBOOL: nRes = *p->pInteger; break; - // ab hier muss getestet werden + // from here had to be tested case SbxBYREF | SbxLONG: aTmp.nLong = *p->pLong; goto ref; case SbxBYREF | SbxULONG: @@ -207,11 +214,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: @@ -232,7 +235,7 @@ void ImpPutInteger( SbxValues* p, sal_Int16 n ) start: switch( +p->eType ) { - // hier muss getestet werden + // here had to be tested case SbxCHAR: aTmp.pChar = &p->nChar; goto direct; case SbxBYTE: @@ -248,7 +251,7 @@ start: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; - // ab hier nicht mehr + // from here no tests needed case SbxINTEGER: case SbxBOOL: p->nInteger = n; break; @@ -259,14 +262,10 @@ start: case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxSALINT64: p->nInt64 = n; break; - case SbxULONG64: - p->nULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxLONG64: - p->nLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxCURRENCY: - p->nLong64 = ImpDoubleToCurrency( (double)n ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: ImpCreateDecimal( p )->setInt( n ); @@ -322,12 +321,15 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); n = 0; } *p->pULong = (sal_uInt32) n; break; + case SbxBYREF | SbxCURRENCY: + *p->pnInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: if( n < 0 ) { - SbxBase::SetError( SbxERR_OVERFLOW ); *p->puInt64 = 0; + SbxBase::SetError( SbxERR_OVERFLOW ); + *p->puInt64 = 0; } else *p->puInt64 = n; @@ -337,12 +339,6 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = (double) n; break; - case SbxBYREF | SbxULONG64: - *p->pULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxBYREF | SbxLONG64: - *p->pLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxBYREF | SbxCURRENCY: - *p->pLong64 = ImpDoubleToCurrency( (double)n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); @@ -384,6 +380,7 @@ sal_uInt64 ImpDoubleToSalUInt64( double d ) return nRes; } + double ImpSalUInt64ToDouble( sal_uInt64 n ) { double d = 0.0; @@ -415,33 +412,20 @@ start: nRes = p->nInteger; break; case SbxERROR: case SbxUSHORT: - nRes = p->nUShort; break; + nRes = (sal_Int64) p->nUShort; break; case SbxLONG: - nRes = p->nLong; break; + nRes = (sal_Int64) p->nLong; break; case SbxULONG: nRes = (sal_Int64) p->nULong; break; case SbxSINGLE: - nRes = ImpDoubleToSalInt64( (double)p->nSingle ); + nRes = (sal_Int64) p->nSingle; break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: - { - double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else - dVal = p->nDouble; - - nRes = ImpDoubleToSalInt64( dVal ); + nRes = (sal_Int64) p->nDouble; break; - } + case SbxCURRENCY: + nRes = p->nInt64 / CURRENCY_FACTOR; break; case SbxSALINT64: nRes = p->nInt64; break; case SbxSALUINT64: @@ -471,7 +455,7 @@ start: if( ImpScan( *p->pOUString, d, t, NULL ) != SbxERR_OK ) nRes = 0; else - nRes = ImpDoubleToSalInt64( d ); + nRes = (sal_Int64) d; } } break; @@ -498,10 +482,15 @@ start: nRes = *p->pLong; break; case SbxBYREF | SbxULONG: nRes = *p->pULong; break; + case SbxBYREF | SbxCURRENCY: + nRes = p->nInt64 / CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: nRes = *p->pnInt64; break; // from here the values has to be checked + case SbxBYREF | SbxSALUINT64: + aTmp.uInt64 = *p->puInt64; goto ref; + case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: aTmp.nUShort = *p->pUShort; goto ref; @@ -510,13 +499,6 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: - case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; - case SbxBYREF | SbxSALUINT64: - aTmp.uInt64 = *p->puInt64; goto ref; ref: aTmp.eType = SbxDataType( p->eType & 0x0FFF ); p = &aTmp; goto start; @@ -542,11 +524,6 @@ start: case SbxINTEGER: case SbxBOOL: aTmp.pInteger = &p->nInteger; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: - case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; case SbxULONG: aTmp.pULong = &p->nULong; goto direct; case SbxERROR: @@ -554,6 +531,9 @@ start: aTmp.pUShort = &p->nUShort; goto direct; case SbxLONG: aTmp.pnInt64 = &p->nInt64; goto direct; + case SbxCURRENCY: + case SbxSALINT64: + aTmp.pnInt64 = &p->nInt64; goto direct; case SbxSALUINT64: aTmp.puInt64 = &p->uInt64; goto direct; @@ -561,9 +541,6 @@ start: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; - // Check not neccessary - case SbxSALINT64: - p->nInt64 = n; break; case SbxSINGLE: p->nSingle = (float) n; break; case SbxDATE: @@ -659,16 +636,7 @@ start: case SbxBYREF | SbxDOUBLE: *p->pDouble = (double) n; break; case SbxBYREF | SbxCURRENCY: - if( n > SbxMAXCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); n = (sal_Int64) SbxMAXCURR; - } - else if( n < SbxMINCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); n = (sal_Int64) SbxMINCURR; - } - *p->pLong64 = ImpDoubleToCurrency( (double)n ); break; - + *p->pnInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: @@ -709,27 +677,16 @@ start: case SbxULONG: nRes = (sal_uInt64) p->nULong; break; case SbxSINGLE: - nRes = ImpDoubleToSalUInt64( (double)p->nSingle ); - break; + nRes = (sal_uInt64) p->nSingle; break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: { - double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else - dVal = p->nDouble; - - nRes = ImpDoubleToSalUInt64( dVal ); +//TODO overflow check + nRes = (sal_uInt64) p->nDouble; break; } + case SbxCURRENCY: + nRes = p->nInt64 * CURRENCY_FACTOR; break; case SbxSALINT64: if( p->nInt64 < 0 ) { @@ -737,6 +694,7 @@ start: } else nRes = (sal_uInt64) p->nInt64; + break; case SbxSALUINT64: nRes = p->uInt64; break; @@ -804,7 +762,7 @@ start: case SbxBYREF | SbxSALUINT64: nRes = *p->puInt64; break; - // from here the values has to be checked + // from here on the value has to be checked case SbxBYREF | SbxERROR: case SbxBYREF | SbxUSHORT: aTmp.nUShort = *p->pUShort; goto ref; @@ -813,11 +771,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; ref: @@ -845,11 +799,6 @@ start: case SbxINTEGER: case SbxBOOL: aTmp.pInteger = &p->nInteger; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: - case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; case SbxULONG: aTmp.pULong = &p->nULong; goto direct; case SbxERROR: @@ -857,6 +806,7 @@ start: aTmp.pUShort = &p->nUShort; goto direct; case SbxLONG: aTmp.pnInt64 = &p->nInt64; goto direct; + case SbxCURRENCY: case SbxSALINT64: aTmp.pnInt64 = &p->nInt64; goto direct; case SbxSINGLE: @@ -938,14 +888,12 @@ start: *p->pDouble = (float)ImpSalUInt64ToDouble( n ); break; case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: + *p->pDouble = ImpSalUInt64ToDouble( n ); break; case SbxBYREF | SbxCURRENCY: - if( n > SbxMAXSALINT64 || (sal_Int64)n > SbxMAXCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); n = (sal_Int64) SbxMAXCURR; - } - *p->pLong64 = ImpDoubleToCurrency( (double)(sal_Int64) n ); break; - + if ( n > ( SbxMAXSALINT64 / CURRENCY_FACTOR ) ) + SbxBase::SetError( SbxERR_OVERFLOW ); n = SbxMAXSALINT64; + *p->pnInt64 = ( sal_Int64) ( n * CURRENCY_FACTOR ); break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; case SbxBYREF | SbxSALINT64: @@ -961,3 +909,4 @@ start: } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxlng.cxx b/basic/source/sbx/sbxlng.cxx index ae873d8eba1b..dd772fe4a52a 100644 --- a/basic/source/sbx/sbxlng.cxx +++ b/basic/source/sbx/sbxlng.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -74,28 +75,28 @@ start: else nRes = (sal_Int32) ImpRound( p->nSingle ); break; - case SbxDATE: - case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: case SbxSALINT64: + nRes = p->nInt64; + break; case SbxSALUINT64: + nRes = p->uInt64; + break; case SbxCURRENCY: + { + sal_Int64 tstVal = p->nInt64 / CURRENCY_FACTOR; + nRes = (sal_Int32) (tstVal); + if( tstVal < SbxMINLNG || SbxMAXLNG < tstVal ) SbxBase::SetError( SbxERR_OVERFLOW ); + if( SbxMAXLNG < tstVal ) nRes = SbxMAXLNG; + if( tstVal < SbxMINLNG ) nRes = SbxMINLNG; + break; + } + case SbxDATE: + case SbxDOUBLE: case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else if( p->eType == SbxSALINT64 ) - dVal = static_cast< double >(p->nInt64); - else if( p->eType == SbxSALUINT64 ) - dVal = ImpSalUInt64ToDouble( p->uInt64 ); - else if( p->eType == SbxDECIMAL ) + if( p->eType == SbxDECIMAL ) { dVal = 0.0; if( p->pDecimal ) @@ -161,7 +162,7 @@ start: case SbxBYREF | SbxLONG: nRes = *p->pLong; break; - // ab hier muss getestet werden + // from here had to be tested case SbxBYREF | SbxULONG: aTmp.nULong = *p->pULong; goto ref; case SbxBYREF | SbxERROR: @@ -172,15 +173,12 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; + case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: aTmp.uInt64 = *p->puInt64; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: - case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; + ref: aTmp.eType = SbxDataType( p->eType & 0x0FFF ); p = &aTmp; goto start; @@ -198,7 +196,7 @@ void ImpPutLong( SbxValues* p, sal_Int32 n ) start: switch( +p->eType ) { - // Ab hier muss getestet werden + // From here had to be tested case SbxCHAR: aTmp.pChar = &p->nChar; goto direct; case SbxBYTE: @@ -206,11 +204,6 @@ start: case SbxINTEGER: case SbxBOOL: aTmp.pInteger = &p->nInteger; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: - case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; case SbxULONG: aTmp.pULong = &p->nULong; goto direct; case SbxSALUINT64: @@ -222,7 +215,7 @@ start: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; - // ab hier nicht mehr + // from here no longer case SbxLONG: p->nLong = n; break; case SbxSINGLE: @@ -230,6 +223,8 @@ start: case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxSALINT64: p->nInt64 = n; break; case SbxDECIMAL: @@ -319,23 +314,10 @@ start: case SbxBYREF | SbxDOUBLE: *p->pDouble = (double) n; break; case SbxBYREF | SbxCURRENCY: - double d; - if( n > SbxMAXCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); d = SbxMAXCURR; - } - else if( n < SbxMINCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); d = SbxMINCURR; - } - else - { - d = n; - } - *p->pLong64 = ImpDoubleToCurrency( d ); break; - + *p->pnInt64 = (sal_Int64)n * (sal_Int64)CURRENCY_FACTOR; break; default: SbxBase::SetError( SbxERR_CONVERSION ); } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxmstrm.cxx b/basic/source/sbx/sbxmstrm.cxx index 671c0bc5d1d9..e4ed782d75b2 100644 --- a/basic/source/sbx/sbxmstrm.cxx +++ b/basic/source/sbx/sbxmstrm.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -37,3 +38,5 @@ SbxDataType SbxMemoryStream::GetType() const SbxMemoryStream::~SbxMemoryStream() { } + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxobj.cxx b/basic/source/sbx/sbxobj.cxx index 266e39907b66..8c1bbbec6119 100644 --- a/basic/source/sbx/sbxobj.cxx +++ b/basic/source/sbx/sbxobj.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,7 +31,6 @@ #include <tools/stream.hxx> #include <vcl/sound.hxx> #include <basic/sbx.hxx> -#include <basic/sbxbase.hxx> #include "sbxres.hxx" #include <svl/brdcst.hxx> @@ -43,9 +43,7 @@ static const char* pParentProp; // Parent-Property static sal_uInt16 nNameHash = 0, nParentHash = 0; -///////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////// SbxObject::SbxObject( const XubString& rClass ) : SbxVariable( SbxOBJECT ), aClassName( rClass ) @@ -78,11 +76,11 @@ SbxObject& SbxObject::operator=( const SbxObject& r ) pMethods = new SbxArray; pProps = new SbxArray; pObjs = new SbxArray( SbxOBJECT ); - // Die Arrays werden kopiert, die Inhalte uebernommen + // The arrays were copied, the content taken over *pMethods = *r.pMethods; *pProps = *r.pProps; *pObjs = *r.pObjs; - // Da die Variablen uebernommen wurden, ist dies OK + // Because the variables were taken over, this is OK pDfltProp = r.pDfltProp; SetName( r.GetName() ); SetFlags( r.GetFlags() ); @@ -98,7 +96,7 @@ static void CheckParentsOnDelete( SbxObject* pObj, SbxArray* p ) SbxVariableRef& rRef = p->GetRef( i ); if( rRef->IsBroadcaster() ) pObj->EndListening( rRef->GetBroadcaster(), sal_True ); - // Hat das Element mehr als eine Referenz und noch einen Listener? + // Did the element have more then one reference and still a Listener? if( rRef->GetRefCount() > 1 ) { rRef->SetParent( NULL ); @@ -191,16 +189,16 @@ SbxVariable* SbxObject::FindUserData( sal_uInt32 nData ) pRes = pProps->FindUserData( nData ); if( !pRes ) pRes = pObjs->FindUserData( nData ); - // Search in den Parents? + // Search in the parents? if( !pRes && IsSet( SBX_GBLSEARCH ) ) { SbxObject* pCur = this; while( !pRes && pCur->pParent ) { - // Ich selbst bin schon durchsucht worden! + // I myself was already searched through! sal_uInt16 nOwn = pCur->GetFlags(); pCur->ResetFlag( SBX_EXTSEARCH ); - // Ich suche bereits global! + // I search already global! sal_uInt16 nPar = pCur->pParent->GetFlags(); pCur->pParent->ResetFlag( SBX_GBLSEARCH ); pRes = pCur->pParent->FindUserData( nData ); @@ -253,21 +251,21 @@ SbxVariable* SbxObject::Find( const XubString& rName, SbxClassType t ) if( pArray ) pRes = pArray->Find( rName, t ); } - // Extended Search im Objekt-Array? - // Fuer Objekte und DontCare ist das Objektarray bereits - // durchsucht worden + // ExtendedsSearch in the Object-Array? + // For objects and DontCare is the Objektarray already + // searched through if( !pRes && ( t == SbxCLASS_METHOD || t == SbxCLASS_PROPERTY ) ) pRes = pObjs->Find( rName, t ); - // Search in den Parents? + // Search in the parents? if( !pRes && IsSet( SBX_GBLSEARCH ) ) { SbxObject* pCur = this; while( !pRes && pCur->pParent ) { - // Ich selbst bin schon durchsucht worden! + // I myself was already searched through! sal_uInt16 nOwn = pCur->GetFlags(); pCur->ResetFlag( SBX_EXTSEARCH ); - // Ich suche bereits global! + // I search already global! sal_uInt16 nPar = pCur->pParent->GetFlags(); pCur->pParent->ResetFlag( SBX_GBLSEARCH ); pRes = pCur->pParent->Find( rName, t ); @@ -289,16 +287,16 @@ SbxVariable* SbxObject::Find( const XubString& rName, SbxClassType t ) return pRes; } -// Kurzform: Die Parent-Kette wird durchsucht -// Das ganze rekursiv, da Call() ueberladen sein kann -// Qualified Names sind zugelassen +// Abbreviated version: The parent-string will be searched through +// The whole thing recursive, because Call() might be overloaded +// Qualified names are allowed sal_Bool SbxObject::Call( const XubString& rName, SbxArray* pParam ) { SbxVariable* pMeth = FindQualified( rName, SbxCLASS_DONTCARE); if( pMeth && pMeth->ISA(SbxMethod) ) { - // FindQualified() koennte schon zugeschlagen haben! + // FindQualified() might have been stroked! if( pParam ) pMeth->SetParameters( pParam ); pMeth->Broadcast( SBX_HINT_DATAWANTED ); @@ -342,9 +340,9 @@ void SbxObject::SetDfltProperty( SbxProperty* p ) SetModified( sal_True ); } -// Suchen einer bereits vorhandenen Variablen. Falls sie gefunden wurde, -// wird der Index gesetzt, sonst wird der Count des Arrays geliefert. -// In jedem Fall wird das korrekte Array geliefert. +// Search of a already available variable. If she was located, +// the index will be set, elsewise will be delivered the Count of the Array. +// In any case it will be delivered the correct Array. SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) { @@ -361,7 +359,7 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) if( pArray ) { nArrayIdx = pArray->Count(); - // ist die Variable per Name vorhanden? + // Is the variable per name available? pArray->ResetFlag( SBX_EXTSEARCH ); SbxVariable* pOld = pArray->Find( pVar->GetName(), pVar->GetClass() ); if( pOld ) @@ -377,12 +375,12 @@ SbxArray* SbxObject::FindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) return pArray; } -// Falls ein neues Objekt eingerichtet wird, wird es, falls es bereits -// eines mit diesem Namen gibt, indiziert. +// If a new object will be established, this object will be indexed, +// if an object of this name exists already. SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataType dt ) { - // Ist das Objekt bereits vorhanden? + // Is the object already available? SbxArray* pArray = NULL; switch( ct ) { @@ -395,26 +393,12 @@ SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataTy } if( !pArray ) return NULL; - // Collections duerfen gleichnamige Objekte enthalten + // Collections may contain objects of the same name if( !( ct == SbxCLASS_OBJECT && ISA(SbxCollection) ) ) { SbxVariable* pRes = pArray->Find( rName, ct ); if( pRes ) { -/* Wegen haeufiger Probleme (z.B. #67000) erstmal ganz raus -#ifdef DBG_UTIL - if( pRes->GetHashCode() != nNameHash - && pRes->GetHashCode() != nParentHash ) - { - XubString aMsg( "SBX-Element \"" ); - aMsg += pRes->GetName(); - aMsg += "\"\n in Objekt \""; - aMsg += GetName(); - aMsg += "\" bereits vorhanden"; - DbgError( (const char*)aMsg.GetStr() ); - } -#endif -*/ return pRes; } } @@ -436,7 +420,7 @@ SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataTy pVar->SetParent( this ); pArray->Put( pVar, pArray->Count() ); SetModified( sal_True ); - // Das Objekt lauscht immer + // The object listen always StartListening( pVar->GetBroadcaster(), sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); return pVar; @@ -444,26 +428,12 @@ SbxVariable* SbxObject::Make( const XubString& rName, SbxClassType ct, SbxDataTy SbxObject* SbxObject::MakeObject( const XubString& rName, const XubString& rClass ) { - // Ist das Objekt bereits vorhanden? + // Is the object already available? if( !ISA(SbxCollection) ) { SbxVariable* pRes = pObjs->Find( rName, SbxCLASS_OBJECT ); if( pRes ) { -/* Wegen haeufiger Probleme (z.B. #67000) erstmal ganz raus -#ifdef DBG_UTIL - if( pRes->GetHashCode() != nNameHash - && pRes->GetHashCode() != nParentHash ) - { - XubString aMsg( "SBX-Objekt \"" ); - aMsg += pRes->GetName(); - aMsg += "\"\n in Objekt \""; - aMsg += GetName(); - aMsg += "\" bereits vorhanden"; - DbgError( (const char*)aMsg.GetStr() ); - } -#endif -*/ return PTR_CAST(SbxObject,pRes); } } @@ -474,7 +444,7 @@ SbxObject* SbxObject::MakeObject( const XubString& rName, const XubString& rClas pVar->SetParent( this ); pObjs->Put( pVar, pObjs->Count() ); SetModified( sal_True ); - // Das Objekt lauscht immer + // The object listen always StartListening( pVar->GetBroadcaster(), sal_True ); Broadcast( SBX_HINT_OBJECTCHANGED ); } @@ -487,34 +457,20 @@ void SbxObject::Insert( SbxVariable* pVar ) SbxArray* pArray = FindVar( pVar, nIdx ); if( pArray ) { - // Hinein damit. Man sollte allerdings auf die Pointer aufpassen! + // Into with it. But you should pay attention at the Pointer! if( nIdx < pArray->Count() ) { - // dann gibt es dieses Element bereits - // Bei Collections duerfen gleichnamige Objekte hinein + // Then this element exists already + // There are objects of the same name allowed at collections if( pArray == pObjs && ISA(SbxCollection) ) nIdx = pArray->Count(); else { SbxVariable* pOld = pArray->Get( nIdx ); - // schon drin: ueberschreiben + // already inside: overwrite if( pOld == pVar ) return; -/* Wegen haeufiger Probleme (z.B. #67000) erstmal ganz raus -#ifdef DBG_UTIL - if( pOld->GetHashCode() != nNameHash - && pOld->GetHashCode() != nParentHash ) - { - XubString aMsg( "SBX-Element \"" ); - aMsg += pVar->GetName(); - aMsg += "\"\n in Objekt \""; - aMsg += GetName(); - aMsg += "\" bereits vorhanden"; - DbgError( (const char*)aMsg.GetStr() ); - } -#endif -*/ EndListening( pOld->GetBroadcaster(), sal_True ); if( pVar->GetClass() == SbxCLASS_PROPERTY ) { @@ -545,8 +501,8 @@ void SbxObject::Insert( SbxVariable* pVar ) } } -// AB 23.4.1997, Optimierung, Einfuegen ohne Ueberpruefung auf doppelte -// Eintraege und ohne Broadcasts, wird nur in SO2/auto.cxx genutzt +// Optimisation, Insertion without checking about +// double entry and without broadcasts, will only be used in SO2/auto.cxx void SbxObject::QuickInsert( SbxVariable* pVar ) { SbxArray* pArray = NULL; @@ -585,7 +541,7 @@ void SbxObject::QuickInsert( SbxVariable* pVar ) } } -// AB 23.3.1997, Spezial-Methode, gleichnamige Controls zulassen +// special method, allow controls of the same name void SbxObject::VCPtrInsert( SbxVariable* pVar ) { SbxArray* pArray = NULL; @@ -643,11 +599,11 @@ void SbxObject::Remove( SbxVariable* pVar ) } } -// AB 23.3.1997, Loeschen per Pointer fuer Controls (doppelte Namen!) +// cleanup per Pointer for Controls (double names!) void SbxObject::VCPtrRemove( SbxVariable* pVar ) { sal_uInt16 nIdx; - // Neu FindVar-Methode, sonst identisch mit normaler Methode + // New FindVar-Method, otherwise identical with the normal method SbxArray* pArray = VCPtrFindVar( pVar, nIdx ); if( pArray && nIdx < pArray->Count() ) { @@ -664,7 +620,7 @@ void SbxObject::VCPtrRemove( SbxVariable* pVar ) } } -// AB 23.3.1997, Zugehoerige Spezial-Methode, nur ueber Pointer suchen +// associated special method, search only by Pointer SbxArray* SbxObject::VCPtrFindVar( SbxVariable* pVar, sal_uInt16& nArrayIdx ) { SbxArray* pArray = NULL; @@ -709,8 +665,6 @@ void SbxObject::SetPos( SbxVariable* pVar, sal_uInt16 nPos ) pArray->Insert( refVar, nPos ); } } -// SetModified( sal_True ); -// Broadcast( SBX_HINT_OBJECTCHANGED ); } static sal_Bool LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray ) @@ -732,19 +686,19 @@ static sal_Bool LoadArray( SvStream& rStrm, SbxObject* pThis, SbxArray* pArray ) return sal_True; } -// Der Load eines Objekts ist additiv! +// The load of an object is additive! sal_Bool SbxObject::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { - // Hilfe fuer das Einlesen alter Objekte: einfach sal_True zurueck, - // LoadPrivateData() muss Default-Zustand herstellen + // Help for the read in of old objects: just TRUE back, + // LoadPrivateData() had to set the default status up if( !nVer ) return sal_True; pDfltProp = NULL; if( !SbxVariable::LoadData( rStrm, nVer ) ) return sal_False; - // Wenn kein fremdes Objekt enthalten ist, uns selbst eintragen + // If it contains no alien object, insert ourselves if( aData.eType == SbxOBJECT && !aData.pObj ) aData.pObj = this; sal_uInt32 nSize; @@ -764,7 +718,7 @@ sal_Bool SbxObject::LoadData( SvStream& rStrm, sal_uInt16 nVer ) || !LoadArray( rStrm, this, pProps ) || !LoadArray( rStrm, this, pObjs ) ) return sal_False; - // Properties setzen + // Set properties if( aDfltProp.Len() ) pDfltProp = (SbxProperty*) pProps->Find( aDfltProp, SbxCLASS_PROPERTY ); SetModified( sal_False ); @@ -801,7 +755,7 @@ sal_Bool SbxObject::StoreData( SvStream& rStrm ) const XubString SbxObject::GenerateSource( const XubString &rLinePrefix, const SbxObject* ) { - // Properties in einem String einsammeln + // Collect the properties in a String XubString aSource; SbxArrayRef xProps( GetProperties() ); bool bLineFeed = false; @@ -813,7 +767,7 @@ XubString SbxObject::GenerateSource( const XubString &rLinePrefix, && !( xProp->GetHashCode() == nNameHash && aPropName.EqualsIgnoreCaseAscii( pNameProp ) ) ) { - // ausser vor dem ersten Property immer einen Umbruch einfuegen + // Insert a break except in front of the first property if ( bLineFeed ) aSource.AppendAscii( "\n" ); else @@ -824,17 +778,17 @@ XubString SbxObject::GenerateSource( const XubString &rLinePrefix, aSource += aPropName; aSource.AppendAscii( " = " ); - // den Property-Wert textuell darstellen + // Display the property value textual switch ( xProp->GetType() ) { case SbxEMPTY: case SbxNULL: - // kein Wert + // no value break; case SbxSTRING: { - // Strings in Anf"uhrungszeichen + // Strings in quotation mark aSource.AppendAscii( "\"" ); aSource += xProp->GetString(); aSource.AppendAscii( "\"" ); @@ -843,7 +797,7 @@ XubString SbxObject::GenerateSource( const XubString &rLinePrefix, default: { - // sonstiges wie z.B. Zahlen direkt + // miscellaneous, such as e.g.numerary directly aSource += xProp->GetString(); break; } @@ -892,7 +846,7 @@ static sal_Bool CollectAttrs( const SbxBase* p, XubString& rRes ) void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill ) { - // Einr"uckung + // Shifting static sal_uInt16 nLevel = 0; if ( nLevel > 10 ) { @@ -904,11 +858,11 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill ) for ( sal_uInt16 n = 1; n < nLevel; ++n ) aIndent.AppendAscii( " " ); - // ggf. Objekt vervollst"andigen + // if necessary complete the object if ( bFill ) GetAll( SbxCLASS_DONTCARE ); - // Daten des Objekts selbst ausgeben + // Output the data of the object itself ByteString aNameStr( (const UniString&)GetName(), RTL_TEXTENCODING_ASCII_US ); ByteString aClassNameStr( (const UniString&)aClassName, RTL_TEXTENCODING_ASCII_US ); rStrm << "Object( " @@ -957,7 +911,7 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill ) aLine.AppendAscii( " !! Not a Method !!" ); rStrm.WriteByteString( aLine, RTL_TEXTENCODING_ASCII_US ); - // bei Object-Methods auch das Object ausgeben + // Output also the object at object-methods if ( pVar->GetValues_Impl().eType == SbxOBJECT && pVar->GetValues_Impl().pObj && pVar->GetValues_Impl().pObj != this && @@ -990,7 +944,7 @@ void SbxObject::Dump( SvStream& rStrm, sal_Bool bFill ) aLine.AppendAscii( " !! Not a Property !!" ); rStrm.WriteByteString( aLine, RTL_TEXTENCODING_ASCII_US ); - // bei Object-Properties auch das Object ausgeben + // output also the object at object properties if ( pVar->GetValues_Impl().eType == SbxOBJECT && pVar->GetValues_Impl().pObj && pVar->GetValues_Impl().pObj != this && @@ -1051,98 +1005,18 @@ SbxClassType SbxProperty::GetClass() const return SbxCLASS_PROPERTY; } -void SbxObject::GarbageCollection( sal_uIntPtr nObjects ) +void SbxObject::GarbageCollection( sal_uIntPtr /* nObjects */ ) -/* [Beschreibung] +/* [Description] - Diese statische Methode durchsucht die n"achsten 'nObjects' der zur Zeit - existierenden <SbxObject>-Instanzen nach zyklischen Referenzen, die sich - nur noch selbst am Leben erhalten. Ist 'nObjects==0', dann werden - alle existierenden durchsucht. + This statistic method browse the next 'nObjects' of the currently existing + <SbxObject>-Instances for cyclic references, which keep only themselfes alive + If there is 'nObjects==0', then all existing will be browsed. - zur Zeit nur implementiert: Object -> Parent-Property -> Parent -> Object + currently only implemented: Object -> Parent-Property -> Parent -> Object */ { - (void)nObjects; - - static sal_Bool bInGarbageCollection = sal_False; - if ( bInGarbageCollection ) - return; - bInGarbageCollection = sal_True; - -#if 0 - // erstes Object dieser Runde anspringen - sal_Bool bAll = !nObjects; - if ( bAll ) - rObjects.First(); - SbxObject *pObj = rObjects.GetCurObject(); - if ( !pObj ) - pObj = rObjects.First(); - - while ( pObj && 0 != nObjects-- ) - { - // hat der Parent nur noch 1 Ref-Count? - SbxObject *pParent = PTR_CAST( SbxObject, pObj->GetParent() ); - if ( pParent && 1 == pParent->GetRefCount() ) - { - // dann alle Properies des Objects durchsuchen - SbxArray *pProps = pObj->GetProperties(); - for ( sal_uInt16 n = 0; n < pProps->Count(); ++n ) - { - // verweist die Property auf den Parent des Object? - SbxVariable *pProp = pProps->Get(n); - const SbxValues &rValues = pProp->GetValues_Impl(); - if ( SbxOBJECT == rValues.eType && - pParent == rValues.pObj ) - { -#ifdef DBG_UTIL - DbgOutf( "SBX: %s.%s with Object %s was garbage", - pObj->GetName().GetStr(), - pProp->GetName().GetStr(), - pParent->GetName().GetStr() ); -#endif - // dann freigeben - pProp->SbxValue::Clear(); - Sound::Beep(); - break; - } - } - } - - // zum n"achsten - pObj = rObjects.Next(); - if ( !bAll && !pObj ) - pObj = rObjects.First(); - } -#endif - -// AB 28.10. Zur 507a vorerst raus, da SfxBroadcaster::Enable() wegfaellt -#if 0 -#ifdef DBG_UTIL - SbxVarList_Impl &rVars = GetSbxData_Impl()->aVars; - DbgOutf( "SBX: garbage collector done, %lu objects remainding", - rVars.Count() ); - if ( rVars.Count() > 200 && rVars.Count() < 210 ) - { - SvFileStream aStream( "d:\\tmp\\dump.sbx", STREAM_STD_WRITE ); - SfxBroadcaster::Enable(sal_False); - for ( sal_uIntPtr n = 0; n < rVars.Count(); ++n ) - { - SbxVariable *pVar = rVars.GetObject(n); - SbxObject *pObj = PTR_CAST(SbxObject, pVar); - sal_uInt16 nFlags = pVar->GetFlags(); - pVar->SetFlag(SBX_NO_BROADCAST); - if ( pObj ) - pObj->Dump(aStream); - else if ( !pVar->GetParent() || !pVar->GetParent()->ISA(SbxObject) ) - pVar->Dump(aStream); - pVar->SetFlags(nFlags); - } - SfxBroadcaster::Enable(sal_True); - } -#endif -#endif - bInGarbageCollection = sal_False; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxres.cxx b/basic/source/sbx/sbxres.cxx index ec1e1f4c900e..5b6466e21e2c 100644 --- a/basic/source/sbx/sbxres.cxx +++ b/basic/source/sbx/sbxres.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -75,7 +76,7 @@ static const char* pSbxRes[] = { "Item", "Remove", - "Error ", // mit Blank! + "Error ", // with blank! "False", "True" }; @@ -89,3 +90,4 @@ SbxRes::SbxRes( sal_uInt16 nId ) : ::rtl::OUString( ::rtl::OUString::createFromAscii( GetSbxRes( nId ) ) ) {} +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxres.hxx b/basic/source/sbx/sbxres.hxx index 75fddc0d90fe..c50b197a4e88 100644 --- a/basic/source/sbx/sbxres.hxx +++ b/basic/source/sbx/sbxres.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -30,9 +31,9 @@ #include <tools/string.hxx> -// Zur Zeit sind Ressources im SVTOOLS-Projekt nicht vorgesehen. -// Da es sich um unkritische Ressourcen handelt (BASIC-Keywords), -// koennen wir mit Dummies arbeiten. +// Currently there are no resources provided in the SVTOOLS-Project. +// Because it is non-critical resources (BASIC-Keywords), +// we can work with dummies. #define STRING_TYPES 0 #define STRING_EMPTY 0 @@ -85,3 +86,5 @@ const char* GetSbxRes( sal_uInt16 ); #endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx index d1bf716234a8..95d4b8dbc836 100644 --- a/basic/source/sbx/sbxscan.cxx +++ b/basic/source/sbx/sbxscan.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -37,9 +38,7 @@ #include <stdlib.h> #endif -#ifndef _APP_HXX //autogen #include <vcl/svapp.hxx> -#endif #include <math.h> #include <string.h> #include <ctype.h> @@ -263,7 +262,6 @@ SbxError SbxValue::ScanNumIntnl( const String& rSrc, double& nVal, sal_Bool bSin return nRetError; } -//////////////////////////////////////////////////////////////////////////// static double roundArray[] = { 5.0e+0, 0.5e+0, 0.5e-1, 0.5e-2, 0.5e-3, 0.5e-4, 0.5e-5, 0.5e-6, 0.5e-7, @@ -290,7 +288,7 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth, short nExp = 0; // Exponent short nDig = nPrec + 1; // Anzahl Digits in Zahl short nDec; // Anzahl Vorkommastellen - register int i, digit; + register int i; // Komma besorgen sal_Unicode cDecimalSep, cThousandSep; @@ -340,6 +338,7 @@ static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth, // Zahl ausgeben: if( nDig > 0 ) { + register int digit; for( i = 0 ; ; ++i ) { if( i < 16 ) @@ -406,7 +405,7 @@ void ImpCvtNum( double nNum, short nPrec, ::rtl::OUString& rRes, sal_Bool bCoreS *p++ = '-'; } double dMaxNumWithoutExp = (nPrec == 6) ? 1E6 : 1E14; - myftoa( nNum, p, nPrec,( nNum &&( nNum < 1E-1 || nNum > dMaxNumWithoutExp ) ) ? 4:0, + myftoa( nNum, p, nPrec,( nNum &&( nNum < 1E-1 || nNum >= dMaxNumWithoutExp ) ) ? 4:0, sal_False, sal_True, cDecimalSep ); // Trailing Zeroes weg: for( p = cBuf; *p &&( *p != 'E' ); p++ ) {} @@ -428,7 +427,7 @@ sal_Bool ImpConvStringExt( ::rtl::OUString& rSrc, SbxDataType eTargetType ) sal_Bool bChanged = sal_False; ::rtl::OUString aNewString; - // Nur Spezial-Fälle behandeln, als Default tun wir nichts + // Nur Spezial-F�lle behandeln, als Default tun wir nichts switch( eTargetType ) { // Bei Fliesskomma International beruecksichtigen @@ -606,7 +605,6 @@ static sal_uInt16 printfmtstr( const XubString& rStr, XubString& rRes, const Xub return (sal_uInt16) ( pFmt - pFmtStart ); } -///////////////////////////////////////////////////////////////////////// sal_Bool SbxValue::Scan( const XubString& rSrc, sal_uInt16* pLen ) { @@ -748,8 +746,6 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const SvNumberFormatter aFormatter( xFactory, eLangType ); sal_uInt32 nIndex; - xub_StrLen nCheckPos = 0; - short nType; double nNumber; Color* pCol; @@ -758,6 +754,8 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const // number format, use SvNumberFormatter to handle it. if( bSuccess ) { + xub_StrLen nCheckPos = 0; + short nType; String aFmtStr = *pFmt; VbaFormatInfo* pInfo = getFormatInfo( aFmtStr ); if( pInfo && pInfo->meType != VBA_FORMAT_TYPE_NULL ) @@ -932,8 +930,6 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const rRes = pData->pBasicFormater->BasicFormatNull( *pFmt ); } - // Die alte Implementierung: - //old: printfmtnum( GetDouble(), rRes, *pFmt ); } else { @@ -966,3 +962,4 @@ void SbxValue::Format( XubString& rRes, const XubString* pFmt ) const } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxsng.cxx b/basic/source/sbx/sbxsng.cxx index 50313cfe1780..62c98131a2c2 100644 --- a/basic/source/sbx/sbxsng.cxx +++ b/basic/source/sbx/sbxsng.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -58,10 +59,6 @@ start: nRes = (float) p->nULong; break; case SbxSINGLE: nRes = p->nSingle; break; - case SbxSALINT64: - nRes = (float) p->nInt64; break; - case SbxSALUINT64: - nRes = (float) ImpSalUInt64ToDouble( p->uInt64 ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: if( p->pDecimal ) @@ -71,17 +68,17 @@ start: break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: case SbxCURRENCY: + case SbxSALINT64: + case SbxSALUINT64: { double dVal; if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); + dVal = ImpCurrencyToDouble( p->nInt64 ); + else if( p->eType == SbxSALINT64 ) + dVal = (float) p->nInt64; + else if( p->eType == SbxSALUINT64 ) + dVal = (float) p->uInt64; else dVal = p->nDouble; @@ -95,6 +92,7 @@ start: SbxBase::SetError( SbxERR_OVERFLOW ); nRes = static_cast< float >(SbxMINSNG); } + // tests for underflow - storing value too small for precision of single else if( dVal > 0 && dVal < SbxMAXSNG2 ) { SbxBase::SetError( SbxERR_OVERFLOW ); @@ -162,19 +160,15 @@ start: nRes = *p->pUShort; break; case SbxBYREF | SbxSINGLE: nRes = *p->pSingle; break; - // ab hier muss getestet werden + // from here had to be tested case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxSALINT64: - nRes = (float) *p->pnInt64; break; - case SbxBYREF | SbxSALUINT64: - nRes = (float) ImpSalUInt64ToDouble( *p->puInt64 ); break; case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; + aTmp.nInt64 = *p->pnInt64; goto ref; + case SbxBYREF | SbxSALUINT64: + aTmp.uInt64 = *p->puInt64; goto ref; ref: aTmp.eType = SbxDataType( p->eType & 0x0FFF ); p = &aTmp; goto start; @@ -205,11 +199,7 @@ start: case SbxERROR: case SbxUSHORT: aTmp.pUShort = &p->nUShort; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; case SbxSALINT64: aTmp.pnInt64 = &p->nInt64; goto direct; case SbxSALUINT64: @@ -226,7 +216,7 @@ start: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; - // keine Tests ab hier + // from here no tests case SbxSINGLE: p->nSingle = n; break; case SbxDATE: @@ -333,9 +323,9 @@ start: case SbxBYREF | SbxDOUBLE: *p->pDouble = (double) n; break; case SbxBYREF | SbxSALINT64: - *p->pnInt64 = ImpDoubleToSalInt64( (double) n ); break; + *p->pnInt64 = (sal_Int64)n; break; case SbxBYREF | SbxSALUINT64: - *p->puInt64 = ImpDoubleToSalUInt64( (double) n ); break; + *p->puInt64 = (sal_uInt64)n; break; case SbxBYREF | SbxCURRENCY: double d; if( n > SbxMAXCURR ) @@ -350,10 +340,11 @@ start: { d = n; } - *p->pLong64 = ImpDoubleToCurrency( n ); break; + *p->pnInt64 = ImpDoubleToCurrency( d ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxstr.cxx b/basic/source/sbx/sbxstr.cxx index 3a73c2757579..27d1ca192868 100644 --- a/basic/source/sbx/sbxstr.cxx +++ b/basic/source/sbx/sbxstr.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -32,17 +33,10 @@ #include "sbxconv.hxx" #include "sbxres.hxx" #include "runtime.hxx" -#ifndef _RTL_USTRBUF_HXX_ #include <rtl/ustrbuf.hxx> -#endif -// AB 29.10.99 Unicode -#ifndef _USE_NO_NAMESPACE -using namespace rtl; -#endif - -// Die Konversion eines Items auf String wird ueber die Put-Methoden -// der einzelnen Datentypen abgewickelt, um doppelten Code zu vermeiden. +// The conversion of an item onto String was handled via the Put-Methods +// of the several data types to avoid double code. ::rtl::OUString ImpGetString( const SbxValues* p ) { @@ -75,7 +69,7 @@ using namespace rtl; case SbxDOUBLE: ImpPutDouble( &aTmp, p->nDouble ); break; case SbxCURRENCY: - ImpPutCurrency( &aTmp, p->nLong64 ); break; + ImpPutCurrency( &aTmp, p->nInt64 ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: ImpPutDecimal( &aTmp, p->pDecimal ); break; @@ -107,7 +101,7 @@ using namespace rtl; break; } case SbxERROR: - // Hier wird der String "Error n" erzeugt + // Here will be created the String "Error n" aRes = SbxRes( STRING_ERRORMSG ); aRes += ::rtl::OUString( p->nUShort ); break; case SbxDATE: @@ -133,7 +127,7 @@ using namespace rtl; case SbxBYREF | SbxDOUBLE: ImpPutDouble( &aTmp, *p->pDouble ); break; case SbxBYREF | SbxCURRENCY: - ImpPutCurrency( &aTmp, *p->pLong64 ); break; + ImpPutCurrency( &aTmp, *p->pnInt64 ); break; case SbxBYREF | SbxSALINT64: ImpPutInt64( &aTmp, *p->pnInt64 ); break; case SbxBYREF | SbxSALUINT64: @@ -144,19 +138,19 @@ using namespace rtl; return aRes; } -// AB 10.4.97, neue Funktion fuer SbxValue::GetCoreString() +// From 1997-04-10, new function for SbxValue::GetCoreString() ::rtl::OUString ImpGetCoreString( const SbxValues* p ) { - // Vorerst nur fuer double + // For now only for double if( ( p->eType & (~SbxBYREF) ) == SbxDOUBLE ) { SbxValues aTmp; XubString aRes; aTmp.eType = SbxSTRING; if( p->eType == SbxDOUBLE ) - ImpPutDouble( &aTmp, p->nDouble, /*bCoreString=*/sal_True ); + ImpPutDouble( &aTmp, p->nDouble, sal_True ); // true = bCoreString else - ImpPutDouble( &aTmp, *p->pDouble, /*bCoreString=*/sal_True ); + ImpPutDouble( &aTmp, *p->pDouble, sal_True ); // true = bCoreString return aRes; } else @@ -168,7 +162,7 @@ void ImpPutString( SbxValues* p, const ::rtl::OUString* n ) SbxValues aTmp; aTmp.eType = SbxSTRING; ::rtl::OUString* pTmp = NULL; - // Sicherheitshalber, falls ein NULL-Ptr kommt + // as a precaution, if a NULL-Ptr appears if( !n ) n = pTmp = new ::rtl::OUString; aTmp.pOUString = (::rtl::OUString*)n; @@ -194,8 +188,8 @@ void ImpPutString( SbxValues* p, const ::rtl::OUString* n ) p->nDouble = ImpGetDate( &aTmp ); break; case SbxDOUBLE: p->nDouble = ImpGetDouble( &aTmp ); break; - case SbxULONG64: - p->nLong64 = ImpGetCurrency( &aTmp ); break; + case SbxCURRENCY: + p->nInt64 = ImpGetCurrency( &aTmp ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: releaseDecimalPtr( p->pDecimal ); @@ -250,13 +244,18 @@ void ImpPutString( SbxValues* p, const ::rtl::OUString* n ) case SbxBYREF | SbxDOUBLE: *p->pDouble = ImpGetDouble( p ); break; case SbxBYREF | SbxCURRENCY: - *p->pLong64 = ImpGetCurrency( p ); break; + *p->pnInt64 = ImpGetCurrency( p ); break; + case SbxBYREF | SbxSALINT64: + *p->pnInt64 = ImpGetInt64( p ); break; + case SbxBYREF | SbxSALUINT64: + *p->puInt64 = ImpGetUInt64( p ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); } delete pTmp; } + // Convert string to an array of bytes, preserving unicode (2bytes per character) SbxArray* StringToByteArray(const ::rtl::OUString& rStr) { @@ -293,7 +292,7 @@ SbxArray* StringToByteArray(const ::rtl::OUString& rStr) ::rtl::OUString ByteArrayToString(SbxArray* pArr) { sal_uInt16 nCount = pArr->Count(); - OUStringBuffer aStrBuf; + ::rtl::OUStringBuffer aStrBuf; sal_Unicode aChar = 0; for( sal_uInt16 i = 0 ; i < nCount ; i++ ) { @@ -317,3 +316,6 @@ SbxArray* StringToByteArray(const ::rtl::OUString& rStr) return aStrBuf.makeStringAndClear(); } + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxuint.cxx b/basic/source/sbx/sbxuint.cxx index 6bfc0c39d260..5922b3571987 100644 --- a/basic/source/sbx/sbxuint.cxx +++ b/basic/source/sbx/sbxuint.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -80,6 +81,18 @@ start: else nRes = (sal_uInt16) p->nULong; break; + case SbxCURRENCY: + if( p->nInt64 / CURRENCY_FACTOR > SbxMAXUINT ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = SbxMAXUINT; + } + else if( p->nInt64 < 0 ) + { + SbxBase::SetError( SbxERR_OVERFLOW ); nRes = 0; + } + else + nRes = (sal_uInt16) (p->nInt64 / CURRENCY_FACTOR); + break; case SbxSALINT64: if( p->nInt64 > SbxMAXUINT ) { @@ -114,20 +127,11 @@ start: break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: - case SbxCURRENCY: case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: { double dVal; - if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); - else if( p->eType == SbxDECIMAL ) + if( p->eType == SbxDECIMAL ) { dVal = 0.0; if( p->pDecimal ) @@ -189,7 +193,7 @@ start: case SbxBYREF | SbxUSHORT: nRes = *p->pUShort; break; - // ab hier wird getestet + // from here on will be tested case SbxBYREF | SbxCHAR: aTmp.nChar = *p->pChar; goto ref; case SbxBYREF | SbxINTEGER: @@ -204,11 +208,7 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: @@ -242,22 +242,18 @@ start: case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: + p->nInt64 = n * CURRENCY_FACTOR; break; case SbxSALINT64: p->nInt64 = n; break; case SbxSALUINT64: p->uInt64 = n; break; - case SbxULONG64: - p->nULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxLONG64: - p->nLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxCURRENCY: - p->nLong64 = ImpDoubleToCurrency( (double)n ); break; case SbxDECIMAL: case SbxBYREF | SbxDECIMAL: ImpCreateDecimal( p )->setUInt( n ); break; - // Tests ab hier + // from here on tests case SbxCHAR: aTmp.pChar = &p->nChar; goto direct; case SbxBYTE: @@ -313,19 +309,16 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = n; break; + case SbxBYREF | SbxCURRENCY: + *p->pnInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; - case SbxBYREF | SbxULONG64: - *p->pULong64 = ImpDoubleToUINT64( (double)n ); break; - case SbxBYREF | SbxLONG64: - *p->pLong64 = ImpDoubleToINT64( (double)n ); break; - case SbxBYREF | SbxCURRENCY: - *p->pLong64 = ImpDoubleToCurrency( (double)n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxulng.cxx b/basic/source/sbx/sbxulng.cxx index 7322863f3475..b8f74b4bf5e6 100644 --- a/basic/source/sbx/sbxulng.cxx +++ b/basic/source/sbx/sbxulng.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -84,8 +85,6 @@ start: break; case SbxDATE: case SbxDOUBLE: - case SbxLONG64: - case SbxULONG64: case SbxSALINT64: case SbxSALUINT64: case SbxCURRENCY: @@ -94,11 +93,7 @@ start: { double dVal; if( p->eType == SbxCURRENCY ) - dVal = ImpCurrencyToDouble( p->nLong64 ); - else if( p->eType == SbxLONG64 ) - dVal = ImpINT64ToDouble( p->nLong64 ); - else if( p->eType == SbxULONG64 ) - dVal = ImpUINT64ToDouble( p->nULong64 ); + dVal = ImpCurrencyToDouble( p->nInt64 ); else if( p->eType == SbxSALINT64 ) dVal = static_cast< double >(p->nInt64); else if( p->eType == SbxSALUINT64 ) @@ -167,7 +162,7 @@ start: case SbxBYREF | SbxULONG: nRes = *p->pULong; break; - // Tests ab hier + // from here on tests case SbxBYREF | SbxCHAR: aTmp.nChar = *p->pChar; goto ref; case SbxBYREF | SbxINTEGER: @@ -180,15 +175,11 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: aTmp.nDouble = *p->pDouble; goto ref; + case SbxBYREF | SbxCURRENCY: case SbxBYREF | SbxSALINT64: aTmp.nInt64 = *p->pnInt64; goto ref; case SbxBYREF | SbxSALUINT64: aTmp.uInt64 = *p->puInt64; goto ref; - case SbxBYREF | SbxULONG64: - aTmp.nULong64 = *p->pULong64; goto ref; - case SbxBYREF | SbxLONG64: - case SbxBYREF | SbxCURRENCY: - aTmp.nLong64 = *p->pLong64; goto ref; ref: aTmp.eType = SbxDataType( p->eType & 0x0FFF ); p = &aTmp; goto start; @@ -212,8 +203,9 @@ start: case SbxDATE: case SbxDOUBLE: p->nDouble = n; break; + case SbxCURRENCY: case SbxSALINT64: - p->nInt64 = n; break; + aTmp.pnInt64 = &p->nInt64; goto direct; case SbxSALUINT64: p->uInt64 = n; break; case SbxDECIMAL: @@ -221,7 +213,7 @@ start: ImpCreateDecimal( p )->setULong( n ); break; - // Tests ab hier + // from here on tests case SbxCHAR: aTmp.pChar = &p->nChar; goto direct; case SbxUINT: @@ -234,11 +226,6 @@ start: case SbxERROR: case SbxUSHORT: aTmp.pUShort = &p->nUShort; goto direct; - case SbxULONG64: - aTmp.pULong64 = &p->nULong64; goto direct; - case SbxLONG64: - case SbxCURRENCY: - aTmp.pLong64 = &p->nLong64; goto direct; direct: aTmp.eType = SbxDataType( p->eType | SbxBYREF ); p = &aTmp; goto start; @@ -298,24 +285,16 @@ start: case SbxBYREF | SbxDATE: case SbxBYREF | SbxDOUBLE: *p->pDouble = n; break; + case SbxBYREF | SbxCURRENCY: + *p->pnInt64 = n * CURRENCY_FACTOR; break; case SbxBYREF | SbxSALINT64: *p->pnInt64 = n; break; case SbxBYREF | SbxSALUINT64: *p->puInt64 = n; break; - case SbxBYREF | SbxCURRENCY: - double d; - if( n > SbxMAXCURR ) - { - SbxBase::SetError( SbxERR_OVERFLOW ); d = SbxMAXCURR; - } - else - { - d = n; - } - *p->pLong64 = ImpDoubleToCurrency( n ); break; default: SbxBase::SetError( SbxERR_CONVERSION ); } } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index d7a3e27603ab..8b55561d2acf 100755..100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -28,163 +29,22 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_basic.hxx" -#define _TLBIGINT_INT64 -#include <tools/bigint.hxx> +#include <math.h> #include <tools/stream.hxx> #include <basic/sbx.hxx> #include "sbxconv.hxx" -#include <math.h> #include "runtime.hxx" -// AB 29.10.99 Unicode -#ifndef _USE_NO_NAMESPACE -using namespace rtl; -#endif - TYPEINIT1(SbxValue,SbxBase) -/////////////////////////// SbxINT64 ///////////////////////////////////// -SbxINT64 &SbxINT64::operator -= ( const SbxINT64 &r ) -{ - BigInt b( *this ); - b -= BigInt( r ); - b.INT64( this ); - return *this; -} -SbxINT64 &SbxINT64::operator += ( const SbxINT64 &r ) -{ - BigInt b( *this ); - b += BigInt( r ); - b.INT64( this ); - return *this; -} -SbxINT64 &SbxINT64::operator *= ( const SbxINT64 &r ) -{ - BigInt b( *this ); - b *= BigInt( r ); - b.INT64( this ); - return *this; -} -SbxINT64 &SbxINT64::operator %= ( const SbxINT64 &r ) -{ - BigInt b( *this ); - b %= BigInt( r ); - b.INT64( this ); - return *this; -} -SbxINT64 &SbxINT64::operator /= ( const SbxINT64 &r ) -{ - BigInt b( *this ); - b /= BigInt( r ); - b.INT64( this ); - return *this; -} -SbxINT64 &SbxINT64::operator &= ( const SbxINT64 &r ) -{ - nHigh &= r.nHigh; - nLow &= r.nLow; - return *this; -} -SbxINT64 &SbxINT64::operator |= ( const SbxINT64 &r ) -{ - nHigh |= r.nHigh; - nLow |= r.nLow; - return *this; -} -SbxINT64 &SbxINT64::operator ^= ( const SbxINT64 &r ) -{ - nHigh ^= r.nHigh; - nLow ^= r.nLow; - return *this; -} - -SbxINT64 operator - ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a(l); - a -= r; - return a; -} -SbxINT64 operator + ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a(l); - a += r; - return a; -} -SbxINT64 operator / ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a(l); - a /= r; - return a; -} -SbxINT64 operator % ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a(l); - a %= r; - return a; -} -SbxINT64 operator * ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a(l); - a *= r; - return a; -} -SbxINT64 operator & ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a; - a.nHigh = r.nHigh & l.nHigh; - a.nLow = r.nLow & l.nLow; - return a; -} -SbxINT64 operator | ( const SbxINT64 &l, const SbxINT64 &r ) -{ - SbxINT64 a; - a.nHigh = r.nHigh | l.nHigh; - a.nLow = r.nLow | l.nLow; - return a; -} -SbxINT64 operator ^ ( const SbxINT64 &r, const SbxINT64 &l ) -{ - SbxINT64 a; - a.nHigh = r.nHigh ^ l.nHigh; - a.nLow = r.nLow ^ l.nLow; - return a; -} - -SbxINT64 operator - ( const SbxINT64 &r ) -{ - SbxINT64 a( r ); - a.CHS(); - return a; -} -SbxINT64 operator ~ ( const SbxINT64 &r ) -{ - SbxINT64 a; - a.nHigh = ~r.nHigh; - a.nLow = ~r.nLow; - return a; -} - -SbxUINT64 &SbxUINT64::operator %= ( const SbxUINT64 &r ) -{ - BigInt b( *this ); - b %= BigInt( r ); - b.UINT64( this ); - return *this; -} -SbxUINT64 &SbxUINT64::operator /= ( const SbxUINT64 &r ) -{ - BigInt b( *this ); - b /= BigInt( r ); - b.UINT64( this ); - return *this; -} -/////////////////////////// Fehlerbehandlung ///////////////////////////// +///////////////////////////// error handling ////////////////////////////// +// bring back ?? was ever in ?? currently ifdef out ? #ifdef _USED -// NOCH NACHZUBAUEN! +// STILL Reverse ENGINEERING! -// Das Default-Handling setzt nur den Fehlercode. +// The default handling sets the error code only. #ifndef WNT #if defined ( UNX ) @@ -208,8 +68,7 @@ int matherr( struct _exception* p ) #endif // _USED - -///////////////////////////// Konstruktoren ////////////////////////////// +///////////////////////////// constructors ////////////////////////////// SbxValue::SbxValue() : SbxBase() { @@ -229,9 +88,9 @@ SbxValue::SbxValue( SbxDataType t, void* p ) : SbxBase() switch( t & 0x0FFF ) { case SbxINTEGER: n |= SbxBYREF; aData.pInteger = (sal_Int16*) p; break; - case SbxULONG64: n |= SbxBYREF; aData.pULong64 = (SbxUINT64*) p; break; - case SbxLONG64: - case SbxCURRENCY: n |= SbxBYREF; aData.pLong64 = (SbxINT64*) p; break; + case SbxSALUINT64: n |= SbxBYREF; aData.puInt64 = (sal_uInt64*) p; break; + case SbxSALINT64: + case SbxCURRENCY: n |= SbxBYREF; aData.pnInt64 = (sal_Int64*) p; break; case SbxLONG: n |= SbxBYREF; aData.pLong = (sal_Int32*) p; break; case SbxSINGLE: n |= SbxBYREF; aData.pSingle = (float*) p; break; case SbxDATE: @@ -241,7 +100,7 @@ SbxValue::SbxValue( SbxDataType t, void* p ) : SbxBase() case SbxUSHORT: case SbxBOOL: n |= SbxBYREF; aData.pUShort = (sal_uInt16*) p; break; case SbxULONG: n |= SbxBYREF; aData.pULong = (sal_uInt32*) p; break; - case SbxCHAR: n |= SbxBYREF; aData.pChar = (xub_Unicode*) p; break; + case SbxCHAR: n |= SbxBYREF; aData.pChar = (sal_Unicode*) p; break; case SbxBYTE: n |= SbxBYREF; aData.pByte = (sal_uInt8*) p; break; case SbxINT: n |= SbxBYREF; aData.pInt = (int*) p; break; case SbxOBJECT: @@ -276,7 +135,7 @@ SbxValue::SbxValue( const SbxValue& r ) { ((SbxValue*) &r)->Broadcast( SBX_HINT_DATAWANTED ); aData = r.aData; - // Pointer kopieren, Referenzen inkrementieren + // Copy pointer, increment references switch( aData.eType ) { case SbxSTRING: @@ -328,16 +187,16 @@ SbxValue& SbxValue::operator=( const SbxValue& r ) return *this; } } - // Den Inhalt der Variablen auslesen + // Readout the content of the variables SbxValues aNew; if( IsFixed() ) - // fest: dann muss der Typ stimmen + // firm: then the type had to match aNew.eType = aData.eType; else if( r.IsFixed() ) - // Quelle fest: Typ uebernehmen + // Source firm: take over the type aNew.eType = SbxDataType( r.aData.eType & 0x0FFF ); else - // beides Variant: dann isses egal + // both variant: then it is equal aNew.eType = SbxVARIANT; if( r.Get( aNew ) ) Put( aNew ); @@ -353,10 +212,10 @@ SbxValue::~SbxValue() SetFlag( SBX_WRITE ); SbxValue::Clear(); #else - // Provisorischer Fix fuer Solaris 5.0 Compiler Bug - // bei Nutzung virtueller Vererbung. Virtuelle Calls - // im Destruktor vermeiden. Statt Clear() zu rufen - // moegliche Objekt-Referenzen direkt freigeben. + // Provisional fix for the Solaris 5.0 compiler bbug + // at using virtual inheritance. Avoid virtual calls + // in the destructor. Instead of calling clear() + // de-allocate posible object references direct. if( aData.eType == SbxOBJECT ) { if( aData.pObj && aData.pObj != this ) @@ -423,19 +282,19 @@ void SbxValue::Clear() void SbxValue::Broadcast( sal_uIntPtr ) {} -//////////////////////////// Daten auslesen ////////////////////////////// +//////////////////////////// Readout data ////////////////////////////// -// Ermitteln der "richtigen" Variablen. Falls es ein Objekt ist, wird -// entweder das Objekt selbst oder dessen Default-Property angesprochen. -// Falls die Variable eine Variable oder ein Objekt enthaelt, wird -// dieses angesprochen. +// Detect the "right" variables. If it is an object, will be addressed either +// the object itself or its default property. +// If the variable contain a variable or an object, this will be +// addressed. SbxValue* SbxValue::TheRealValue() const { return TheRealValue( sal_True ); } -// #55226 Zusaetzliche Info transportieren +// #55226 ship additional information bool handleToStringForCOMObjects( SbxObject* pObj, SbxValue* pVal ); // sbunoobj.cxx SbxValue* SbxValue::TheRealValue( sal_Bool bObjInObjError ) const @@ -446,19 +305,19 @@ SbxValue* SbxValue::TheRealValue( sal_Bool bObjInObjError ) const SbxDataType t = SbxDataType( p->aData.eType & 0x0FFF ); if( t == SbxOBJECT ) { - // Der Block enthaelt ein Objekt oder eine Variable + // The block contains an object or a variable SbxObject* pObj = PTR_CAST(SbxObject,p->aData.pObj); if( pObj ) { - // Hat das Objekt eine Default-Property? + // Has the object a default property? SbxVariable* pDflt = pObj->GetDfltProperty(); - // Falls dies ein Objekt ist und sich selbst enthaelt, - // koennen wir nicht darauf zugreifen - // #55226# Die alte Bedingung, um einen Fehler zu setzen, - // ist nicht richtig, da z.B. eine ganz normale Variant- - // Variable mit Objekt davon betroffen sein kann, wenn ein - // anderer Wert zugewiesen werden soll. Daher mit Flag. + // If this is an object and contains itself, + // we cannot access on it + // The old condition to set an error + // is not correct, because e.g. a regular variant variable with an object + // could be affected thereof, if another value should be assigned. + // Therefore with flag. if( bObjInObjError && !pDflt && ((SbxValue*) pObj)->aData.eType == SbxOBJECT && ((SbxValue*) pObj)->aData.pObj == pObj ) @@ -472,24 +331,20 @@ SbxValue* SbxValue::TheRealValue( sal_Bool bObjInObjError ) const } else if( pDflt ) p = pDflt; - /* ALT: - else - p = pDflt ? pDflt : (SbxVariable*) pObj; - */ break; } - // Haben wir ein Array? + // Did we have an array? SbxArray* pArray = PTR_CAST(SbxArray,p->aData.pObj); if( pArray ) { - // Ggf. Parameter holen + // When indicated get the parameter SbxArray* pPar = NULL; SbxVariable* pVar = PTR_CAST(SbxVariable,p); if( pVar ) pPar = pVar->GetParameters(); if( pPar ) { - // Haben wir ein dimensioniertes Array? + // Did we have a dimensioned array? SbxDimArray* pDimArray = PTR_CAST(SbxDimArray,p->aData.pObj); if( pDimArray ) p = pDimArray->Get( pPar ); @@ -498,7 +353,7 @@ SbxValue* SbxValue::TheRealValue( sal_Bool bObjInObjError ) const break; } } - // Sonst einen SbxValue annehmen + // Elsewise guess a SbxValue SbxValue* pVal = PTR_CAST(SbxValue,p->aData.pObj); if( pVal ) p = pVal; @@ -524,8 +379,8 @@ sal_Bool SbxValue::Get( SbxValues& rRes ) const } else { - // Falls nach einem Objekt oder einem VARIANT gefragt wird, nicht - // die wahren Werte suchen + // If there was asked for an object or a VARIANT, don't search + // the real values SbxValue* p = (SbxValue*) this; if( rRes.eType != SbxOBJECT && rRes.eType != SbxVARIANT ) p = TheRealValue(); @@ -544,7 +399,7 @@ sal_Bool SbxValue::Get( SbxValues& rRes ) const case SbxSALUINT64: rRes.uInt64 = ImpGetUInt64( &p->aData ); break; case SbxSINGLE: rRes.nSingle = ImpGetSingle( &p->aData ); break; case SbxDOUBLE: rRes.nDouble = ImpGetDouble( &p->aData ); break; - case SbxCURRENCY:rRes.nLong64 = ImpGetCurrency( &p->aData ); break; + case SbxCURRENCY:rRes.nInt64 = ImpGetCurrency( &p->aData ); break; case SbxDECIMAL: rRes.pDecimal = ImpGetDecimal( &p->aData ); break; case SbxDATE: rRes.nDouble = ImpGetDate( &p->aData ); break; case SbxBOOL: @@ -595,7 +450,7 @@ sal_Bool SbxValue::Get( SbxValues& rRes ) const } else { - // Objekt enthielt sich selbst + // Object contained itself SbxDataType eTemp = rRes.eType; memset( &rRes, 0, sizeof( SbxValues ) ); rRes.eType = eTemp; @@ -675,28 +530,26 @@ sal_Bool SbxValue::GetBool() const #define GET( g, e, t, m ) \ t SbxValue::g() const { SbxValues aRes(e); Get( aRes ); return aRes.m; } -GET( GetByte, SbxBYTE, sal_uInt8, nByte ) -GET( GetChar, SbxCHAR, xub_Unicode, nChar ) -GET( GetCurrency, SbxCURRENCY, SbxINT64, nLong64 ) -GET( GetDate, SbxDATE, double, nDouble ) -GET( GetData, SbxDATAOBJECT, void*, pData ) -GET( GetDouble, SbxDOUBLE, double, nDouble ) -GET( GetErr, SbxERROR, sal_uInt16, nUShort ) -GET( GetInt, SbxINT, int, nInt ) -GET( GetInteger, SbxINTEGER, sal_Int16, nInteger ) -GET( GetLong, SbxLONG, sal_Int32, nLong ) -GET( GetLong64, SbxLONG64, SbxINT64, nLong64 ) -GET( GetObject, SbxOBJECT, SbxBase*, pObj ) -GET( GetSingle, SbxSINGLE, float, nSingle ) -GET( GetULong, SbxULONG, sal_uInt32, nULong ) -GET( GetULong64, SbxULONG64, SbxUINT64, nULong64 ) -GET( GetUShort, SbxUSHORT, sal_uInt16, nUShort ) -GET( GetInt64, SbxSALINT64, sal_Int64, nInt64 ) -GET( GetUInt64, SbxSALUINT64, sal_uInt64, uInt64 ) -GET( GetDecimal, SbxDECIMAL, SbxDecimal*, pDecimal ) - - -//////////////////////////// Daten schreiben ///////////////////////////// +GET( GetByte, SbxBYTE, sal_uInt8, nByte ) +GET( GetChar, SbxCHAR, xub_Unicode, nChar ) +GET( GetCurrency, SbxCURRENCY, sal_Int64, nInt64 ) +GET( GetDate, SbxDATE, double, nDouble ) +GET( GetData, SbxDATAOBJECT, void*, pData ) +GET( GetDouble, SbxDOUBLE, double, nDouble ) +GET( GetErr, SbxERROR, sal_uInt16, nUShort ) +GET( GetInt, SbxINT, int, nInt ) +GET( GetInteger, SbxINTEGER, sal_Int16, nInteger ) +GET( GetLong, SbxLONG, sal_Int32, nLong ) +GET( GetObject, SbxOBJECT, SbxBase*, pObj ) +GET( GetSingle, SbxSINGLE, float, nSingle ) +GET( GetULong, SbxULONG, sal_uInt32, nULong ) +GET( GetUShort, SbxUSHORT, sal_uInt16, nUShort ) +GET( GetInt64, SbxSALINT64, sal_Int64, nInt64 ) +GET( GetUInt64, SbxSALUINT64, sal_uInt64, uInt64 ) +GET( GetDecimal, SbxDECIMAL, SbxDecimal*, pDecimal ) + + +//////////////////////////// Write data ///////////////////////////// sal_Bool SbxValue::Put( const SbxValues& rVal ) { @@ -710,11 +563,11 @@ sal_Bool SbxValue::Put( const SbxValues& rVal ) SetError( SbxERR_NOTIMP ); else { - // Falls nach einem Objekt gefragt wird, nicht - // die wahren Werte suchen + // If there was asked for an object, don't search + // the real values SbxValue* p = this; if( rVal.eType != SbxOBJECT ) - p = TheRealValue( sal_False ); // #55226 Hier keinen Fehler erlauben + p = TheRealValue( sal_False ); // Don't allow an error here if( p ) { if( !p->CanWrite() ) @@ -731,7 +584,7 @@ sal_Bool SbxValue::Put( const SbxValues& rVal ) case SbxSALUINT64: ImpPutUInt64( &p->aData, rVal.uInt64 ); break; case SbxSINGLE: ImpPutSingle( &p->aData, rVal.nSingle ); break; case SbxDOUBLE: ImpPutDouble( &p->aData, rVal.nDouble ); break; - case SbxCURRENCY: ImpPutCurrency( &p->aData, rVal.nLong64 ); break; + case SbxCURRENCY: ImpPutCurrency( &p->aData, rVal.nInt64 ); break; case SbxDECIMAL: ImpPutDecimal( &p->aData, rVal.pDecimal ); break; case SbxDATE: ImpPutDate( &p->aData, rVal.nDouble ); break; case SbxBOOL: ImpPutBool( &p->aData, rVal.nInteger ); break; @@ -758,22 +611,22 @@ sal_Bool SbxValue::Put( const SbxValues& rVal ) case SbxOBJECT: if( !p->IsFixed() || p->aData.eType == SbxOBJECT ) { - // ist schon drin + // is already inside if( p->aData.eType == SbxOBJECT && p->aData.pObj == rVal.pObj ) break; - // Nur den Werteteil loeschen! + // Delete only the value part! p->SbxValue::Clear(); - // eingentliche Zuweisung + // real allocation p->aData.pObj = rVal.pObj; - // ggf. Ref-Count mitzaehlen + // if necessary cont in Ref-Count if( p->aData.pObj && p->aData.pObj != p ) { if ( p != this ) { - DBG_ERROR( "TheRealValue" ); + OSL_FAIL( "TheRealValue" ); } HACK(nicht bei Parent-Prop - sonst CyclicRef) SbxVariable *pThisVar = PTR_CAST(SbxVariable, this); @@ -809,36 +662,36 @@ sal_Bool SbxValue::Put( const SbxValues& rVal ) return bRes; } -// AB, 28.3.96: -// Methode, um bei speziellen Typen eine Vorbehandlung des Strings -// durchzufuehren. Insbesondere erforderlich fuer BASIC-IDE, damit -// die Ausgaben im Watch-Fenster mit PutStringExt zurueckgeschrieben -// werden koennen, wenn Floats mit ',' als Dezimaltrenner oder BOOLs -// explizit mit "TRUE" oder "FALSE" angegeben werden. -// Implementierung in ImpConvStringExt (SBXSCAN.CXX) +// From 1996-03-28: +// Method to execute a pretreatment of the strings at special types. +// In particular necessary for BASIC-IDE, so that +// the output in the Watch-Window can be writen back with PutStringExt, +// if Float were declared with ',' as the decimal seperator or BOOl +// explicit with "TRUE" or "FALSE". +// Implementation in ImpConvStringExt (SBXSCAN.CXX) sal_Bool SbxValue::PutStringExt( const ::rtl::OUString& r ) { - // Kopieren, bei Unicode gleich konvertieren + // Copy; if it is Unicode convert it immediately ::rtl::OUString aStr( r ); - // Eigenen Typ bestimmen (nicht wie in Put() mit TheRealValue(), - // Objekte werden sowieso nicht behandelt) + // Identify the own type (not as in Put() with TheRealValue(), + // Objects are not handled anyway) SbxDataType eTargetType = SbxDataType( aData.eType & 0x0FFF ); - // Source-Value basteln + // tinker a Source-Value SbxValues aRes; aRes.eType = SbxSTRING; - // Nur, wenn wirklich was konvertiert wurde, Kopie nehmen, - // sonst Original (Unicode bleibt erhalten) + // Only if really something was converted, take the copy, + // elsewise take the original (Unicode remain) sal_Bool bRet; if( ImpConvStringExt( aStr, eTargetType ) ) aRes.pOUString = (::rtl::OUString*)&aStr; else aRes.pOUString = (::rtl::OUString*)&r; - // #34939: Bei Strings. die eine Zahl enthalten und wenn this einen - // Num-Typ hat, Fixed-Flag setzen, damit der Typ nicht veraendert wird + // #34939: Set a Fixed-Flag at Strings. which contain a number, and + // if this has a Num-Type, so that the type will not be changed sal_uInt16 nFlags_ = GetFlags(); if( ( eTargetType >= SbxINTEGER && eTargetType <= SbxCURRENCY ) || ( eTargetType >= SbxCHAR && eTargetType <= SbxUINT ) || @@ -853,8 +706,8 @@ sal_Bool SbxValue::PutStringExt( const ::rtl::OUString& r ) Put( aRes ); bRet = sal_Bool( !IsError() ); - // Falls das mit dem FIXED einen Error gegeben hat, zuruecksetzen - // (UI-Aktion sollte keinen Error ergeben, sondern nur scheitern) + // If it throwed an error with FIXED, set it back + // (UI-Action should not cast an error, but only fail) if( !bRet ) ResetError(); @@ -945,8 +798,8 @@ sal_Bool SbxValue::p( t n ) \ { SbxValues aRes(e); aRes.m = n; Put( aRes ); return sal_Bool( !IsError() ); } PUT( PutByte, SbxBYTE, sal_uInt8, nByte ) -PUT( PutChar, SbxCHAR, xub_Unicode, nChar ) -PUT( PutCurrency, SbxCURRENCY, const SbxINT64&, nLong64 ) +PUT( PutChar, SbxCHAR, sal_Unicode, nChar ) +PUT( PutCurrency, SbxCURRENCY, const sal_Int64&, nInt64 ) PUT( PutDate, SbxDATE, double, nDouble ) PUT( PutData, SbxDATAOBJECT, void*, pData ) PUT( PutDouble, SbxDOUBLE, double, nDouble ) @@ -954,28 +807,26 @@ PUT( PutErr, SbxERROR, sal_uInt16, nUShort ) PUT( PutInt, SbxINT, int, nInt ) PUT( PutInteger, SbxINTEGER, sal_Int16, nInteger ) PUT( PutLong, SbxLONG, sal_Int32, nLong ) -PUT( PutLong64, SbxLONG64, const SbxINT64&, nLong64 ) PUT( PutObject, SbxOBJECT, SbxBase*, pObj ) PUT( PutSingle, SbxSINGLE, float, nSingle ) PUT( PutULong, SbxULONG, sal_uInt32, nULong ) -PUT( PutULong64, SbxULONG64, const SbxUINT64&, nULong64 ) PUT( PutUShort, SbxUSHORT, sal_uInt16, nUShort ) PUT( PutInt64, SbxSALINT64, sal_Int64, nInt64 ) PUT( PutUInt64, SbxSALUINT64, sal_uInt64, uInt64 ) PUT( PutDecimal, SbxDECIMAL, SbxDecimal*, pDecimal ) -////////////////////////// Setzen des Datentyps /////////////////////////// +////////////////////////// Setting of the data type /////////////////////////// sal_Bool SbxValue::IsFixed() const { return ( (GetFlags() & SBX_FIXED) | (aData.eType & SbxBYREF) ) != 0; } -// Eine Variable ist numerisch, wenn sie EMPTY oder wirklich numerisch ist -// oder einen vollstaendig konvertierbaren String enthaelt +// A variable is numeric, if it is EMPTY or realy numeric +// or if it contains a complete convertible String -// #41692, fuer RTL und Basic-Core getrennt implementieren +// #41692, implement it for RTL and Basic-Core seperably sal_Bool SbxValue::IsNumeric() const { return ImpIsNumeric( /*bOnlyIntntl*/sal_False ); @@ -993,7 +844,7 @@ sal_Bool SbxValue::ImpIsNumeric( sal_Bool bOnlyIntntl ) const { SetError( SbxERR_PROP_WRITEONLY ); return sal_False; } - // Downcast pruefen!!! + // Test downcast!!! if( this->ISA(SbxVariable) ) ((SbxVariable*)this)->Broadcast( SBX_HINT_DATAWANTED ); SbxDataType t = GetType(); @@ -1039,7 +890,7 @@ sal_Bool SbxValue::SetType( SbxDataType t ) return sal_True; if( ( t & 0x0FFF ) == SbxVARIANT ) { - // Versuch, den Datentyp auf Variant zu setzen + // Trial to set the data type to Variant ResetFlag( SBX_FIXED ); if( IsFixed() ) { @@ -1055,7 +906,7 @@ sal_Bool SbxValue::SetType( SbxDataType t ) } else { - // Eventuelle Objekte freigeben + // De-allocate potential objects switch( aData.eType ) { case SbxSTRING: @@ -1078,7 +929,7 @@ sal_Bool SbxValue::SetType( SbxDataType t ) break; default: break; } - // Das klappt immer, da auch die Float-Repraesentationen 0 sind. + // This works always, because the Float representations are 0 as well. memset( &aData, 0, sizeof( SbxValues ) ); aData.eType = t; } @@ -1095,7 +946,7 @@ sal_Bool SbxValue::Convert( SbxDataType eTo ) return sal_False; if( eTo == SbxVARIANT ) { - // Versuch, den Datentyp auf Variant zu setzen + // Trial to set the data type to Variant ResetFlag( SBX_FIXED ); if( IsFixed() ) { @@ -1104,19 +955,19 @@ sal_Bool SbxValue::Convert( SbxDataType eTo ) else return sal_True; } - // Convert from Null geht niemals. Einmal Null, immer Null! + // Converting from zero doesn't work. Once zero, always zero! if( aData.eType == SbxNULL ) { SetError( SbxERR_CONVERSION ); return sal_False; } - // Konversion der Daten: + // Conversion of the data: SbxValues aNew; aNew.eType = eTo; if( Get( aNew ) ) { - // Der Datentyp konnte konvertiert werden. Bei Fixed-Elementen - // ist hier Ende, da die Daten nicht uebernommen zu werden brauchen + // The data type could be converted. It ends here with fixed elements, + // because the data had not to be taken over if( !IsFixed() ) { SetType( eTo ); @@ -1129,7 +980,7 @@ sal_Bool SbxValue::Convert( SbxDataType eTo ) else return sal_False; } -////////////////////////////////// Rechnen ///////////////////////////////// +////////////////////////////////// Calculating ///////////////////////////////// sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) { @@ -1144,21 +995,21 @@ sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) SetError( SbxERR_PROP_READONLY ); else if( !rOp.CanRead() ) SetError( SbxERR_PROP_WRITEONLY ); - // Sonderregel 1: Ist ein Operand Null, ist das Ergebnis Null + // Special rule 1: If one operand is zero, the result is zero else if( eThisType == SbxNULL || eOpType == SbxNULL ) SetType( SbxNULL ); - // Sonderregel 2: Ist ein Operand Empty, ist das Ergebnis der 2. Operand + // Special rule 2: If the operand is Empty, the result is the 2. operand else if( eThisType == SbxEMPTY && !bVBAInterop ) *this = rOp; - // 13.2.96: Nicht schon vor Get auf SbxEMPTY pruefen + // 1996-2-13: Don't test already before Get upon SbxEMPTY else { SbxValues aL, aR; bool bDecimal = false; - if( bVBAInterop && ( ( eThisType == SbxSTRING && eOpType != SbxSTRING ) || - ( eThisType != SbxSTRING && eOpType == SbxSTRING ) ) && + if( bVBAInterop && ( ( eThisType == SbxSTRING && eOpType != SbxSTRING && eOpType != SbxEMPTY ) || + ( eThisType != SbxSTRING && eThisType != SbxEMPTY && eOpType == SbxSTRING ) ) && ( eOp == SbxMUL || eOp == SbxDIV || eOp == SbxPLUS || eOp == SbxMINUS ) ) { goto Lbl_OpIsDouble; @@ -1167,20 +1018,20 @@ sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) { if( eOp == SbxCAT || eOp == SbxPLUS ) { - // AB 5.11.1999, OUString beruecksichtigen + // From 1999-11-5, keep OUString in mind aL.eType = aR.eType = SbxSTRING; rOp.Get( aR ); - // AB 8.12.1999, #70399: Hier wieder GetType() rufen, Get() kann Typ aendern! + // From 1999-12-8, #70399: Here call GetType() again, Get() can change the type! if( rOp.GetType() == SbxEMPTY ) goto Lbl_OpIsEmpty; Get( aL ); - // #30576: Erstmal testen, ob Wandlung geklappt hat + // #30576: To begin with test, if the conversion worked if( aL.pOUString != NULL && aR.pOUString != NULL ) { *aL.pOUString += *aR.pOUString; } - // Nicht einmal Left OK? + // Not even Left OK? else if( aL.pOUString == NULL ) { aL.pOUString = new ::rtl::OUString(); @@ -1191,34 +1042,26 @@ sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) SetError( SbxERR_CONVERSION ); } else if( eOpType == SbxSTRING && rOp.IsFixed() ) - { // Numerisch: rechts darf kein String stehen + { // Numeric: there is no String allowed on the right side SetError( SbxERR_CONVERSION ); + // falls all the way out } else if( ( eOp >= SbxIDIV && eOp <= SbxNOT ) || eOp == SbxMOD ) { if( GetType() == eOpType ) { - if( GetType() == SbxULONG64 - || GetType() == SbxLONG64 - || GetType() == SbxCURRENCY - || GetType() == SbxULONG ) + if( GetType() == SbxSALUINT64 || GetType() == SbxSALINT64 + || GetType() == SbxCURRENCY || GetType() == SbxULONG ) aL.eType = aR.eType = GetType(); -// else if( GetType() == SbxDouble || GetType() == SbxSingle ) -// aL.eType = aR.eType = SbxLONG64; + else if ( bVBAInterop && eOpType == SbxBOOL ) + aL.eType = aR.eType = SbxBOOL; else aL.eType = aR.eType = SbxLONG; } - else if( GetType() == SbxCURRENCY || eOpType == SbxCURRENCY - || GetType() == SbxULONG64 || eOpType == SbxULONG64 - || GetType() == SbxLONG64 || eOpType == SbxLONG64 ) - aL.eType = aR.eType = SbxLONG64; -// else if( GetType() == SbxDouble || rOP.GetType() == SbxDouble -// || GetType() == SbxSingle || rOP.GetType() == SbxSingle ) -// aL.eType = aR.eType = SbxLONG64; else aL.eType = aR.eType = SbxLONG; - if( rOp.Get( aR ) ) + if( rOp.Get( aR ) ) // re-do Get after type assigns above { if( rOp.GetType() == SbxEMPTY ) { @@ -1229,13 +1072,17 @@ sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) { case SbxIDIV: if( aL.eType == SbxCURRENCY ) - aL.eType = SbxLONG64; - if( aL.eType == SbxLONG64 ) - if( !aR.nLong64 ) SetError( SbxERR_ZERODIV ); - else aL.nLong64 /= aR.nLong64; - else if( aL.eType == SbxULONG64 ) - if( !aR.nULong64 ) SetError( SbxERR_ZERODIV ); - else aL.nULong64 /= aR.nULong64; + if( !aR.nInt64 ) SetError( SbxERR_ZERODIV ); + else { + aL.nInt64 /= aR.nInt64; + aL.nInt64 *= CURRENCY_FACTOR; + } + else if( aL.eType == SbxSALUINT64 ) + if( !aR.uInt64 ) SetError( SbxERR_ZERODIV ); + else aL.uInt64 /= aR.uInt64; + else if( aL.eType == SbxSALINT64 ) + if( !aR.nInt64 ) SetError( SbxERR_ZERODIV ); + else aL.nInt64 /= aR.nInt64; else if( aL.eType == SbxLONG ) if( !aR.nLong ) SetError( SbxERR_ZERODIV ); else aL.nLong /= aR.nLong; @@ -1244,14 +1091,12 @@ sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) else aL.nULong /= aR.nULong; break; case SbxMOD: - if( aL.eType == SbxCURRENCY ) - aL.eType = SbxLONG64; - if( aL.eType == SbxLONG64 ) - if( !aR.nLong64 ) SetError( SbxERR_ZERODIV ); - else aL.nLong64 %= aR.nLong64; - else if( aL.eType == SbxULONG64 ) - if( !aR.nULong64 ) SetError( SbxERR_ZERODIV ); - else aL.nULong64 %= aR.nULong64; + if( aL.eType == SbxCURRENCY || aL.eType == SbxSALINT64 ) + if( !aR.nInt64 ) SetError( SbxERR_ZERODIV ); + else aL.nInt64 %= aR.nInt64; + else if( aL.eType == SbxSALUINT64 ) + if( !aR.uInt64 ) SetError( SbxERR_ZERODIV ); + else aL.uInt64 %= aR.uInt64; else if( aL.eType == SbxLONG ) if( !aR.nLong ) SetError( SbxERR_ZERODIV ); else aL.nLong %= aR.nLong; @@ -1261,37 +1106,42 @@ sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) break; case SbxAND: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 &= aR.nLong64; + aL.nInt64 &= aR.nInt64; else aL.nLong &= aR.nLong; break; case SbxOR: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 |= aR.nLong64; + aL.nInt64 |= aR.nInt64; else aL.nLong |= aR.nLong; break; case SbxXOR: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 ^= aR.nLong64; + aL.nInt64 ^= aR.nInt64; else aL.nLong ^= aR.nLong; break; case SbxEQV: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 = (aL.nLong64 & aR.nLong64) | (~aL.nLong64 & ~aR.nLong64); + aL.nInt64 = (aL.nInt64 & aR.nInt64) | (~aL.nInt64 & ~aR.nInt64); else aL.nLong = (aL.nLong & aR.nLong) | (~aL.nLong & ~aR.nLong); break; case SbxIMP: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 = ~aL.nLong64 | aR.nLong64; + aL.nInt64 = ~aL.nInt64 | aR.nInt64; else aL.nLong = ~aL.nLong | aR.nLong; break; case SbxNOT: if( aL.eType != SbxLONG && aL.eType != SbxULONG ) - aL.nLong64 = ~aL.nLong64; + { + if ( aL.eType != SbxBOOL ) + aL.nInt64 = ~aL.nInt64; + else + aL.nLong = ~aL.nLong; + } else aL.nLong = ~aL.nLong; break; @@ -1299,8 +1149,8 @@ sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) } } } - else if( ( GetType() == SbxDECIMAL || rOp.GetType() == SbxDECIMAL ) && - ( eOp == SbxMUL || eOp == SbxDIV || eOp == SbxPLUS || eOp == SbxMINUS || eOp == SbxNEG ) ) + else if( ( GetType() == SbxDECIMAL || rOp.GetType() == SbxDECIMAL ) + && ( eOp == SbxMUL || eOp == SbxDIV || eOp == SbxPLUS || eOp == SbxMINUS || eOp == SbxNEG ) ) { aL.eType = aR.eType = SbxDECIMAL; bDecimal = true; @@ -1356,52 +1206,81 @@ sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) if( rOp.Get( aR ) ) { - static BigInt n10K( 10000 ); - if( rOp.GetType() == SbxEMPTY ) goto Lbl_OpIsEmpty; if( Get( aL ) ) switch( eOp ) { + double dTest; case SbxMUL: - { - // #i20704 Implement directly - BigInt b1( aL.nLong64 ); - BigInt b2( aR.nLong64 ); - b1 *= b2; - b1 /= n10K; - double d = double( b1 ) / 10000.0; - if( d > SbxMAXCURR || d < SbxMINCURR ) + // first overflow check: see if product will fit - test real value of product (hence 2 curr factors) + dTest = (double)aL.nInt64 * (double)aR.nInt64 / (double)CURRENCY_FACTOR_SQUARE; + if( dTest < SbxMINCURR || SbxMAXCURR < dTest) + { + aL.nInt64 = SAL_MAX_INT64; + if( dTest < SbxMINCURR ) aL.nInt64 = SAL_MIN_INT64; SetError( SbxERR_OVERFLOW ); - else - b1.INT64( &aL.nLong64 ); + break; + } + // second overflow check: see if unscaled product overflows - if so use doubles + dTest = (double)aL.nInt64 * (double)aR.nInt64; + if( dTest < SAL_MIN_INT64 || SAL_MAX_INT64 < dTest) + { + aL.nInt64 = (sal_Int64)( dTest / (double)CURRENCY_FACTOR ); + break; + } + // precise calc: multiply then scale back (move decimal pt) + aL.nInt64 *= aR.nInt64; + aL.nInt64 /= CURRENCY_FACTOR; break; - } + case SbxDIV: - if( !aR.nLong64 ) + if( !aR.nInt64 ) { SetError( SbxERR_ZERODIV ); + break; } - else + // first overflow check: see if quotient will fit - calc real value of quotient (curr factors cancel) + dTest = (double)aL.nInt64 / (double)aR.nInt64; + if( dTest < SbxMINCURR || SbxMAXCURR < dTest) { - // #i20704 Implement directly - BigInt b1( aL.nLong64 ); - BigInt b2( aR.nLong64 ); - b1 *= n10K; - b1 /= b2; - double d = double( b1 ) / 10000.0; - if( d > SbxMAXCURR || d < SbxMINCURR ) - SetError( SbxERR_OVERFLOW ); - else - b1.INT64( &aL.nLong64 ); + SetError( SbxERR_OVERFLOW ); + break; } + // second overflow check: see if scaled dividend overflows - if so use doubles + dTest = (double)aL.nInt64 * (double)CURRENCY_FACTOR; + if( dTest < SAL_MIN_INT64 || SAL_MAX_INT64 < dTest) + { + aL.nInt64 = (sal_Int64)(dTest / (double)aR.nInt64); + break; + } + // precise calc: scale (move decimal pt) then divide + aL.nInt64 *= CURRENCY_FACTOR; + aL.nInt64 /= aR.nInt64; break; + case SbxPLUS: - aL.nLong64 += aR.nLong64; break; + dTest = ( (double)aL.nInt64 + (double)aR.nInt64 ) / (double)CURRENCY_FACTOR; + if( dTest < SbxMINCURR || SbxMAXCURR < dTest) + { + SetError( SbxERR_OVERFLOW ); + break; + } + aL.nInt64 += aR.nInt64; + break; + case SbxMINUS: - aL.nLong64 -= aR.nLong64; break; + dTest = ( (double)aL.nInt64 - (double)aR.nInt64 ) / (double)CURRENCY_FACTOR; + if( dTest < SbxMINCURR || SbxMAXCURR < dTest) + { + SetError( SbxERR_OVERFLOW ); + break; + } + aL.nInt64 -= aR.nInt64; + break; case SbxNEG: - aL.nLong64 = -aL.nLong64; break; + aL.nInt64 = -aL.nInt64; + break; default: SetError( SbxERR_NOTIMP ); } @@ -1409,7 +1288,7 @@ sal_Bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) } else Lbl_OpIsDouble: - { // Andere Operatoren + { // other types and operators including Date, Double and Single aL.eType = aR.eType = SbxDOUBLE; if( rOp.Get( aR ) ) { @@ -1432,6 +1311,9 @@ Lbl_OpIsDouble: else aL.nDouble /= aR.nDouble; break; case SbxPLUS: aL.nDouble += aR.nDouble; break; + // #45465 Date needs with "+" a special handling: forces date type + if( GetType() == SbxDATE || rOp.GetType() == SbxDATE ) + aL.eType = SbxDATE; case SbxMINUS: aL.nDouble -= aR.nDouble; break; case SbxNEG: @@ -1440,9 +1322,6 @@ Lbl_OpIsDouble: SetError( SbxERR_NOTIMP ); } - // #45465 Date braucht bei + eine Spezial-Behandlung - if( eOp == SbxPLUS && (GetType() == SbxDATE || rOp.GetType() == SbxDATE ) ) - aL.eType = SbxDATE; } } @@ -1463,7 +1342,7 @@ Lbl_OpIsEmpty: return bRes; } -// Die Vergleichs-Routine liefert sal_True oder sal_False. +// The comparison routine deliver TRUE or FALSE. sal_Bool SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const { @@ -1481,11 +1360,11 @@ sal_Bool SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const } else if( GetType() == SbxEMPTY && rOp.GetType() == SbxEMPTY ) bRes = !bVBAInterop ? sal_True : ( eOp == SbxEQ ? sal_True : sal_False ); - // Sonderregel 1: Ist ein Operand Null, ist das Ergebnis FALSE + // Special rule 1: If an operand is zero, the result is FALSE else if( GetType() == SbxNULL || rOp.GetType() == SbxNULL ) bRes = sal_False; - // Sonderregel 2: Wenn beide Variant sind und einer ist numerisch, - // und der andere ein String, ist num < str + // Special rule 2: If both are variant and one is numeric + // and the other is a String, num is < str else if( !IsFixed() && !rOp.IsFixed() && ( rOp.GetType() == SbxSTRING && GetType() != SbxSTRING && IsNumeric() ) && !bVBAInterop ) @@ -1498,8 +1377,8 @@ sal_Bool SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const else { SbxValues aL, aR; - // Wenn einer der Operanden ein String ist, - // findet ein Stringvergleich statt + // If one of the operands is a String, + // a String comparing take place if( GetType() == SbxSTRING || rOp.GetType() == SbxSTRING ) { aL.eType = aR.eType = SbxSTRING; @@ -1521,8 +1400,8 @@ sal_Bool SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const SetError( SbxERR_NOTIMP ); } } - // AB 19.12.95: Wenn SbxSINGLE beteiligt, auf SINGLE konvertieren, - // sonst gibt es numerische Fehler + // From 1995-12-19: If SbxSINGLE participate, then convert to SINGLE, + // elsewise it shows a numeric error else if( GetType() == SbxSINGLE || rOp.GetType() == SbxSINGLE ) { aL.eType = aR.eType = SbxSINGLE; @@ -1578,11 +1457,10 @@ sal_Bool SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const releaseDecimalPtr( aL.pDecimal ); releaseDecimalPtr( aR.pDecimal ); } - // Alles andere auf SbxDOUBLE-Basis vergleichen + // Everything else comparing on a SbxDOUBLE-Basis else { aL.eType = aR.eType = SbxDOUBLE; - //if( Get( aL ) && rOp.Get( aR ) ) bool bGetL = Get( aL ); bool bGetR = rOp.Get( aR ); if( bGetL && bGetR ) @@ -1621,10 +1499,12 @@ sal_Bool SbxValue::Compare( SbxOperator eOp, const SbxValue& rOp ) const return bRes; } -///////////////////////////// Lesen/Schreiben //////////////////////////// +///////////////////////////// Reading/Writing //////////////////////////// sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) { + // #TODO see if these types are really dumped to any stream + // more than likely this is functionality used in the binfilter alone SbxValue::Clear(); sal_uInt16 nType; r >> nType; @@ -1638,7 +1518,7 @@ sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) r >> aData.nLong; break; case SbxSINGLE: { - // Floats als ASCII + // Floats as ASCII XubString aVal; r.ReadByteString( aVal, RTL_TEXTENCODING_ASCII_US ); double d; @@ -1654,7 +1534,7 @@ sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) case SbxDATE: case SbxDOUBLE: { - // Floats als ASCII + // Floats as ASCII XubString aVal; r.ReadByteString( aVal, RTL_TEXTENCODING_ASCII_US ); SbxDataType t; @@ -1665,15 +1545,21 @@ sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) } break; } - case SbxULONG64: - { - r >> aData.nULong64.nHigh >> aData.nULong64.nLow; + case SbxSALUINT64: + case SbxSALINT64: + // Rather ugly use of the union here because we only + // have a SvStream& SvStream::operator>>(sal_uInt64&) available to us + // There is no SvStream::operator>>(sal_Int64&) due to conflict with + // SvStream::operator>>(long&) ( at least on 64 bit linux ) + r >> aData.uInt64; break; - } - case SbxLONG64: case SbxCURRENCY: { - r >> aData.nLong64.nHigh >> aData.nLong64.nLow; + sal_uInt32 tmpHi = 0; + sal_uInt32 tmpLo = 0; + r >> tmpHi >> tmpLo; + aData.nInt64 = ((sal_Int64)tmpHi << 32); + aData.nInt64 |= (sal_Int64)tmpLo; break; } case SbxSTRING: @@ -1683,7 +1569,7 @@ sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) if( aVal.Len() ) aData.pOUString = new ::rtl::OUString( aVal ); else - aData.pOUString = NULL; // JSM 22.09.1995 + aData.pOUString = NULL; // JSM 1995-09-22 break; } case SbxERROR: @@ -1722,7 +1608,7 @@ sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) { sal_uInt8 n; r >> n; - // Passt der Int auf diesem System? + // Match the Int on this system? if( n > SAL_TYPES_SIZEOFINT ) r >> aData.nLong, aData.eType = SbxLONG; else @@ -1733,7 +1619,7 @@ sal_Bool SbxValue::LoadData( SvStream& r, sal_uInt16 ) { sal_uInt8 n; r >> n; - // Passt der UInt auf diesem System? + // Match the UInt on this system? if( n > SAL_TYPES_SIZEOFINT ) r >> aData.nULong, aData.eType = SbxULONG; else @@ -1773,7 +1659,7 @@ sal_Bool SbxValue::StoreData( SvStream& r ) const case SbxLONG: r << aData.nLong; break; case SbxDATE: - // #49935: Als double speichern, sonst Fehler beim Einlesen + // #49935: Save as double, elsewise an error during the read in ((SbxValue*)this)->aData.eType = (SbxDataType)( ( nType & 0xF000 ) | SbxDOUBLE ); r.WriteByteString( GetCoreString(), RTL_TEXTENCODING_ASCII_US ); ((SbxValue*)this)->aData.eType = (SbxDataType)nType; @@ -1782,15 +1668,16 @@ sal_Bool SbxValue::StoreData( SvStream& r ) const case SbxDOUBLE: r.WriteByteString( GetCoreString(), RTL_TEXTENCODING_ASCII_US ); break; - case SbxULONG64: - { - r << aData.nULong64.nHigh << aData.nULong64.nLow; + case SbxSALUINT64: + case SbxSALINT64: + // see comment in SbxValue::StoreData + r << aData.uInt64; break; - } - case SbxLONG64: case SbxCURRENCY: { - r << aData.nLong64.nHigh << aData.nLong64.nLow; + sal_Int32 tmpHi = ( (aData.nInt64 >> 32) & 0xFFFFFFFF ); + sal_Int32 tmpLo = ( sal_Int32 )aData.nInt64; + r << tmpHi << tmpLo; break; } case SbxSTRING: @@ -1808,7 +1695,7 @@ sal_Bool SbxValue::StoreData( SvStream& r ) const case SbxUSHORT: r << aData.nUShort; break; case SbxOBJECT: - // sich selbst als Objektptr speichern geht nicht! + // to save itself as Objektptr doesn't work! if( aData.pObj ) { if( PTR_CAST(SbxValue,aData.pObj) != this ) @@ -1862,3 +1749,4 @@ sal_Bool SbxValue::StoreData( SvStream& r ) const return sal_True; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index 1f33cc8acfd2..9a99f06b151c 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -33,7 +34,6 @@ #include "svl/brdcst.hxx" #include <basic/sbx.hxx> -#include <basic/sbxbase.hxx> #include "sbxres.hxx" #include "sbxconv.hxx" #include <math.h> @@ -73,7 +73,7 @@ class SbxVariableImpl }; -///////////////////////////// Konstruktoren ////////////////////////////// +///////////////////////////// Constructors ////////////////////////////// SbxVariable::SbxVariable() : SbxValue() { @@ -84,7 +84,6 @@ SbxVariable::SbxVariable() : SbxValue() nHash = 0; #ifdef DBG_UTIL DbgOutf( "SbxVariable::Ctor %lx=%ld", (void*)this, ++nVar ); - GetSbxData_Impl()->aVars.Insert( this, LIST_APPEND ); #endif } @@ -119,7 +118,6 @@ SbxVariable::SbxVariable( const SbxVariable& r ) if ( maName.EqualsAscii( aCellsStr ) ) maName.AssignAscii( aCellsStr, sizeof( aCellsStr )-1 ); DbgOutf( "SbxVariable::Ctor %lx=%ld", (void*)this, ++nVar ); - GetSbxData_Impl()->aVars.Insert( this, LIST_APPEND ); #endif } @@ -132,7 +130,6 @@ SbxVariable::SbxVariable( SbxDataType t, void* p ) : SbxValue( t, p ) nHash = 0; #ifdef DBG_UTIL DbgOutf( "SbxVariable::Ctor %lx=%ld", (void*)this, ++nVar ); - GetSbxData_Impl()->aVars.Insert( this, LIST_APPEND ); #endif } @@ -146,7 +143,6 @@ SbxVariable::~SbxVariable() static sal_Char const aCellsStr[] = "Cells"; if ( maName.EqualsAscii( aCellsStr ) ) maName.AssignAscii( aCellsStr, sizeof( aCellsStr )-1 ); - GetSbxData_Impl()->aVars.Remove( this ); #endif if( IsSet( SBX_DIM_AS_NEW )) removeDimAsNewRecoverItem( this ); @@ -163,31 +159,31 @@ SfxBroadcaster& SbxVariable::GetBroadcaster() return *pCst; } -// Eines Tages kann man vielleicht den Parameter 0 schleifen, -// dann entfaellt die Kopiererei... +// Perhaps some day one could cut the parameter 0. +// then the copying will be dropped ... void SbxVariable::Broadcast( sal_uIntPtr nHintId ) { if( pCst && !IsSet( SBX_NO_BROADCAST ) && StaticIsEnabledBroadcasting() ) { - // Da die Methode von aussen aufrufbar ist, hier noch einmal - // die Berechtigung testen + // Because the method could be called from outside, check the Da die Methode von aussen aufrufbar ist, hier noch einmal + // rights here again if( nHintId & SBX_HINT_DATAWANTED ) if( !CanRead() ) return; if( nHintId & SBX_HINT_DATACHANGED ) if( !CanWrite() ) return; - // Weitere Broadcasts verhindern + // Avoid further broadcasting SfxBroadcaster* pSave = pCst; pCst = NULL; sal_uInt16 nSaveFlags = GetFlags(); SetFlag( SBX_READWRITE ); if( mpPar.Is() ) - // this, als Element 0 eintragen, aber den Parent nicht umsetzen! + // Register this as element 0, but don't change over the parent! mpPar->GetRef( 0 ) = this; pSave->Broadcast( SbxHint( nHintId, this ) ); - delete pCst; // wer weiss schon, auf welche Gedanken mancher kommt? + delete pCst; // who knows already, onto which thoughts someone comes? pCst = pSave; SetFlags( nSaveFlags ); } @@ -215,7 +211,7 @@ void SbxVariable::SetParameters( SbxArray* p ) } -/////////////////////////// Name der Variablen /////////////////////////// +/////////////////////////// Name of the variables /////////////////////////// void SbxVariable::SetName( const XubString& rName ) { @@ -228,15 +224,15 @@ const XubString& SbxVariable::GetName( SbxNameType t ) const static char cSuffixes[] = " %&!#@ $"; if( t == SbxNAME_NONE ) return maName; - // Parameter-Infos anfordern (nicht fuer Objekte) + // Request parameter-information (not for objects) ((SbxVariable*)this)->GetInfo(); - // Nix anfuegen, wenn einfache Property (keine leeren Klammern) + // Append nothing, if it is a simple property (no empty brackets) if( !pInfo || ( !pInfo->aParams.Count() && GetClass() == SbxCLASS_PROPERTY ) ) return maName; xub_Unicode cType = ' '; XubString aTmp( maName ); - // Kurzer Typ? Dann holen, evtl. ist dieser 0. + // short type? Then fetch it, posible this is 0. SbxDataType et = GetType(); if( t == SbxNAME_SHORT_TYPES ) { @@ -258,7 +254,7 @@ const XubString& SbxVariable::GetName( SbxNameType t ) const aTmp += String( SbxRes( STRING_BYREF ) ); aTmp += q->aName; cType = ' '; - // Kurzer Typ? Dann holen, evtl. ist dieser 0. + // short type? Then fetch it, posible this is 0. if( t == SbxNAME_SHORT_TYPES ) { if( nt <= SbxSTRING ) @@ -274,7 +270,7 @@ const XubString& SbxVariable::GetName( SbxNameType t ) const { if( q->eType & SbxARRAY ) aTmp.AppendAscii( "()" ); - // langer Typ? + // long type? if( t != SbxNAME_SHORT ) { aTmp += String( SbxRes( STRING_AS ) ); @@ -287,7 +283,7 @@ const XubString& SbxVariable::GetName( SbxNameType t ) const } } aTmp += ')'; - // Langer Typ? Dann holen + // Long type? Then fetch it if( t == SbxNAME_LONG_TYPES && et != SbxEMPTY ) { aTmp += String( SbxRes( STRING_AS ) ); @@ -301,7 +297,7 @@ const XubString& SbxVariable::GetName( SbxNameType t ) const return aToolString; } -// Einen simplen Hashcode erzeugen: Es werden die ersten 6 Zeichen gewertet. +// Create a simple hashcode: the first six characters were evaluated. sal_uInt16 SbxVariable::MakeHashCode( const XubString& rName ) { @@ -314,7 +310,7 @@ sal_uInt16 SbxVariable::MakeHashCode( const XubString& rName ) { sal_uInt8 c = (sal_uInt8)*p; p++; - // Falls wir ein Schweinezeichen haben, abbrechen!! + // If we have a commen sigen break!! if( c >= 0x80 ) return 0; n = sal::static_int_cast< sal_uInt16 >( ( n << 3 ) + toupper( c ) ); @@ -322,7 +318,7 @@ sal_uInt16 SbxVariable::MakeHashCode( const XubString& rName ) return n; } -////////////////////////////// Operatoren //////////////////////////////// +////////////////////////////// Operators //////////////////////////////// SbxVariable& SbxVariable::operator=( const SbxVariable& r ) { @@ -339,7 +335,7 @@ SbxVariable& SbxVariable::operator=( const SbxVariable& r ) return *this; } -//////////////////////////////// Konversion //////////////////////////////// +//////////////////////////////// Conversion //////////////////////////////// SbxDataType SbxVariable::GetType() const { @@ -361,17 +357,17 @@ void SbxVariable::SetModified( sal_Bool b ) if( IsSet( SBX_NO_MODIFY ) ) return; SbxBase::SetModified( b ); - if( pParent && pParent != this ) //??? HotFix: Rekursion raus MM + if( pParent && pParent != this ) //??? HotFix: Recursion out here MM pParent->SetModified( b ); } void SbxVariable::SetParent( SbxObject* p ) { #ifdef DBG_UTIL - // wird der Parent eines SbxObjects gesetzt? + // Will the parent of a SbxObject be set? if ( p && ISA(SbxObject) ) { - // dann mu\s dieses auch Child vom neuen Parent sein + // then this had to be a child of the new parent sal_Bool bFound = sal_False; SbxArray *pChilds = p->GetObjects(); if ( pChilds ) @@ -430,7 +426,7 @@ void SbxVariable::ClearComListener( void ) } -////////////////////////////// Laden/Speichern ///////////////////////////// +////////////////////////////// Loading/Saving ///////////////////////////// sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) { @@ -454,7 +450,7 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) sal_uInt32 nTemp; rStrm >> nTemp; nUserData = nTemp; - // Korrektur: Alte Methoden haben statt SbxNULL jetzt SbxEMPTY + // correction: old methods have instead of SbxNULL now SbxEMPTY if( nType == SbxNULL && GetClass() == SbxCLASS_METHOD ) nType = SbxEMPTY; SbxValues aTmp; @@ -472,7 +468,7 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) rStrm >> aTmp.nLong; break; case SbxSINGLE: { - // Floats als ASCII + // Floats as ASCII rStrm.ReadByteString( aTmpString, RTL_TEXTENCODING_ASCII_US ); double d; SbxDataType t; @@ -487,7 +483,7 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) case SbxDATE: case SbxDOUBLE: { - // Floats als ASCII + // Floats as ASCII rStrm.ReadByteString( aTmpString, RTL_TEXTENCODING_ASCII_US ); SbxDataType t; if( ImpScan( aTmpString, aTmp.nDouble, t, NULL ) != SbxERR_OK ) @@ -509,14 +505,14 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) DBG_ASSERT( !this, "Nicht unterstuetzer Datentyp geladen" ); return sal_False; } - // Wert putten + // putt value if( nType != SbxNULL && nType != SbxEMPTY && !Put( aTmp ) ) return sal_False; } rStrm >> cMark; - // cMark ist auch eine Versionsnummer! + // cMark is also a version number! // 1: initial version - // 2: mit nUserData + // 2: with nUserData if( cMark ) { if( cMark > 2 ) @@ -524,7 +520,7 @@ sal_Bool SbxVariable::LoadData( SvStream& rStrm, sal_uInt16 nVer ) pInfo = new SbxInfo; pInfo->LoadData( rStrm, (sal_uInt16) cMark ); } - // Privatdaten nur laden, wenn es eine SbxVariable ist + // Load private data only, if it is a SbxVariable if( GetClass() == SbxCLASS_VARIABLE && !LoadPrivateData( rStrm, nVer ) ) return sal_False; ((SbxVariable*) this)->Broadcast( SBX_HINT_DATACHANGED ); @@ -539,16 +535,16 @@ sal_Bool SbxVariable::StoreData( SvStream& rStrm ) const sal_Bool bValStore; if( this->IsA( TYPE(SbxMethod) ) ) { - // #50200 Verhindern, dass Objekte, die zur Laufzeit als Return-Wert - // in der Methode als Value gespeichert sind, mit gespeichert werden + // #50200 Avoid that objects , which during the runtime + // as return-value are saved in the method as a value were saved SbxVariable* pThis = (SbxVariable*)this; sal_uInt16 nSaveFlags = GetFlags(); pThis->SetFlag( SBX_WRITE ); pThis->SbxValue::Clear(); pThis->SetFlags( nSaveFlags ); - // Damit die Methode in keinem Fall ausgefuehrt wird! - // CAST, um const zu umgehen! + // So that the method will not be executed in any case! + // CAST, to avoid const! pThis->SetFlag( SBX_NO_BROADCAST ); bValStore = SbxValue::StoreData( rStrm ); pThis->ResetFlag( SBX_NO_BROADCAST ); @@ -557,18 +553,16 @@ sal_Bool SbxVariable::StoreData( SvStream& rStrm ) const bValStore = SbxValue::StoreData( rStrm ); if( !bValStore ) return sal_False; - // if( !SbxValue::StoreData( rStrm ) ) - // return sal_False; rStrm.WriteByteString( maName, RTL_TEXTENCODING_ASCII_US ); rStrm << (sal_uInt32)nUserData; if( pInfo.Is() ) { - rStrm << (sal_uInt8) 2; // Version 2: mit UserData! + rStrm << (sal_uInt8) 2; // Version 2: with UserData! pInfo->StoreData( rStrm ); } else rStrm << (sal_uInt8) 0; - // Privatdaten nur speichern, wenn es eine SbxVariable ist + // Save private data only, if it is a SbxVariable if( GetClass() == SbxCLASS_VARIABLE ) return StorePrivateData( rStrm ); else @@ -637,7 +631,7 @@ void SbxAlias::SFX_NOTIFY( SfxBroadcaster&, const TypeId&, if( p && p->GetId() == SBX_HINT_DYING ) { xAlias.Clear(); - // Alias loeschen? + // delete the alias? if( pParent ) pParent->Remove( this ); } @@ -656,7 +650,7 @@ void SbxVariable::Dump( SvStream& rStrm, sal_Bool bFill ) rStrm << " no parent"; rStrm << " ) "; - // bei Object-Vars auch das Object ausgeben + // output also the object at object-vars if ( GetValues_Impl().eType == SbxOBJECT && GetValues_Impl().pObj && GetValues_Impl().pObj != this && @@ -669,3 +663,4 @@ void SbxVariable::Dump( SvStream& rStrm, sal_Bool bFill ) rStrm << endl; } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/uno/dlgcont.cxx b/basic/source/uno/dlgcont.cxx index f173ae5f18ff..2a39b06276d3 100644 --- a/basic/source/uno/dlgcont.cxx +++ b/basic/source/uno/dlgcont.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -40,6 +41,7 @@ #include <com/sun/star/xml/sax/XExtendedDocumentHandler.hpp> #include "com/sun/star/resource/XStringResourceWithStorage.hpp" #include "com/sun/star/resource/XStringResourceWithLocation.hpp" +#include "com/sun/star/document/XGraphicObjectResolver.hpp" #include "dlgcont.hxx" #include "sbmodule.hxx" #include <comphelper/processfactory.hxx> @@ -68,11 +70,14 @@ 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 ::rtl::OUString; + using com::sun::star::uno::Reference; +#define GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:" + //============================================================================ // Implementation class SfxDialogLibraryContainer @@ -132,7 +137,7 @@ bool writeOasis2OOoLibraryElement( Reference< beans::XPropertySet > xProps( xMSF, UNO_QUERY ); OSL_ASSERT( xProps.is() ); OSL_VERIFY( xProps->getPropertyValue( - OUString::createFromAscii(("DefaultContext")) ) >>= xContext ); + OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); Reference< lang::XMultiComponentFactory > xSMgr( xContext->getServiceManager() ); @@ -178,7 +183,7 @@ bool writeOasis2OOoLibraryElement( xml::sax::InputSource source; source.aInputStream = xInput; - source.sSystemId = OUString::createFromAscii( "virtual file" ); + source.sSystemId = OUString(RTL_CONSTASCII_USTRINGPARAM("virtual file")); xParser->parseStream( source ); @@ -224,6 +229,35 @@ void SAL_CALL SfxDialogLibraryContainer::writeLibraryElement xInput->closeInput(); } +void lcl_deepInspectForEmbeddedImages( const Reference< XInterface >& xIf, std::vector< rtl::OUString >& rvEmbedImgUrls ) +{ + static rtl::OUString sImageURL= OUString(RTL_CONSTASCII_USTRINGPARAM( "ImageURL" ) ); + Reference< beans::XPropertySet > xProps( xIf, UNO_QUERY ); + if ( xProps.is() ) + { + + if ( xProps->getPropertySetInfo()->hasPropertyByName( sImageURL ) ) + { + rtl::OUString sURL; + xProps->getPropertyValue( sImageURL ) >>= sURL; + if ( sURL.getLength() && sURL.compareToAscii( GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( GRAPHOBJ_URLPREFIX ) ) == 0 ) + rvEmbedImgUrls.push_back( sURL ); + } + } + Reference< XNameContainer > xContainer( xIf, UNO_QUERY ); + if ( xContainer.is() ) + { + Sequence< rtl::OUString > sNames = xContainer->getElementNames(); + sal_Int32 nContainees = sNames.getLength(); + for ( sal_Int32 index = 0; index < nContainees; ++index ) + { + Reference< XInterface > xCtrl; + xContainer->getByName( sNames[ index ] ) >>= xCtrl; + lcl_deepInspectForEmbeddedImages( xCtrl, rvEmbedImgUrls ); + } + } +} + void SfxDialogLibraryContainer::storeLibrariesToStorage( const uno::Reference< embed::XStorage >& xStorage ) throw ( RuntimeException ) { LibraryContainerMethodGuard aGuard( *this ); @@ -252,6 +286,54 @@ void SfxDialogLibraryContainer::storeLibrariesToStorage( const uno::Reference< e SfxLibraryContainer::storeLibrariesToStorage( xStorage ); + // we need to export out any embedded image object(s) + // associated with any Dialogs. First, we need to actually gather any such urls + // for each dialog in this container + Sequence< OUString > sLibraries = getElementNames(); + for ( sal_Int32 i=0; i < sLibraries.getLength(); ++i ) + { + // libraries will already be loaded from above + Reference< XNameContainer > xLib; + getByName( sLibraries[ i ] ) >>= xLib; + if ( xLib.is() ) + { + Sequence< OUString > sDialogs = xLib->getElementNames(); + sal_Int32 nDialogs( sDialogs.getLength() ); + for ( sal_Int32 j=0; j < nDialogs; ++j ) + { + // Each Dialog has an associated xISP + Reference< io::XInputStreamProvider > xISP; + xLib->getByName( sDialogs[ j ] ) >>= xISP; + if ( xISP.is() ) + { + Reference< io::XInputStream > xInput( xISP->createInputStream() ); + Reference< XNameContainer > xDialogModel( mxMSF->createInstance + ( OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY ); + Reference< XComponentContext > xContext; + Reference< beans::XPropertySet > xProps( mxMSF, UNO_QUERY ); + OSL_ASSERT( xProps.is() ); + OSL_VERIFY( xProps->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext")) ) >>= xContext ); + ::xmlscript::importDialogModel( xInput, xDialogModel, xContext, mxOwnerDocument ); + std::vector< rtl::OUString > vEmbeddedImageURLs; + lcl_deepInspectForEmbeddedImages( Reference< XInterface >( xDialogModel, UNO_QUERY ), vEmbeddedImageURLs ); + if ( !vEmbeddedImageURLs.empty() ) + { + // Export the images to the storage + Sequence< Any > aArgs( 1 ); + aArgs[ 0 ] <<= xStorage; + Reference< document::XGraphicObjectResolver > xGraphicResolver( mxMSF->createInstanceWithArguments( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Svx.GraphicExportHelper" ) ), aArgs ), UNO_QUERY ); + std::vector< rtl::OUString >::iterator it = vEmbeddedImageURLs.begin(); + std::vector< rtl::OUString >::iterator it_end = vEmbeddedImageURLs.end(); + if ( xGraphicResolver.is() ) + { + for ( sal_Int32 count = 0; it != it_end; ++it, ++count ) + xGraphicResolver->resolveGraphicObjectURL( *it ); + } + } + } + } + } + } mbOasis2OOoFormat = sal_False; } @@ -267,7 +349,7 @@ Any SAL_CALL SfxDialogLibraryContainer::importLibraryElement //Reference< XMultiServiceFactory > xMSF( comphelper::getProcessServiceFactory() ); //if( !xMSF.is() ) //{ - // OSL_ENSURE( 0, "### couln't get ProcessServiceFactory\n" ); + // OSL_FAIL( "### couln't get ProcessServiceFactory\n" ); // return aRetAny; //} @@ -275,7 +357,7 @@ Any SAL_CALL SfxDialogLibraryContainer::importLibraryElement OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ) ), UNO_QUERY ); if( !xParser.is() ) { - OSL_ENSURE( 0, "### couln't create sax parser component\n" ); + OSL_FAIL( "### couln't create sax parser component\n" ); return aRetAny; } @@ -283,7 +365,7 @@ Any SAL_CALL SfxDialogLibraryContainer::importLibraryElement ( OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.awt.UnoControlDialogModel" ) ) ), UNO_QUERY ); if( !xDialogModel.is() ) { - OSL_ENSURE( 0, "### couln't create com.sun.star.awt.UnoControlDialogModel component\n" ); + OSL_FAIL( "### couln't create com.sun.star.awt.UnoControlDialogModel component\n" ); return aRetAny; } @@ -322,12 +404,12 @@ Any SAL_CALL SfxDialogLibraryContainer::importLibraryElement try { // start parsing - xParser->setDocumentHandler( ::xmlscript::importDialogModel( xDialogModel, xContext ) ); + xParser->setDocumentHandler( ::xmlscript::importDialogModel( xDialogModel, xContext, mxOwnerDocument ) ); xParser->parseStream( source ); } catch( Exception& ) { - OSL_ENSURE( 0, "Parsing error\n" ); + OSL_FAIL( "Parsing error\n" ); SfxErrorContext aEc( ERRCTX_SFX_LOADBASIC, aFile ); sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL; ErrorHandler::HandleError( nErrorCode ); @@ -336,7 +418,7 @@ Any SAL_CALL SfxDialogLibraryContainer::importLibraryElement // Create InputStream, TODO: Implement own InputStreamProvider // to avoid creating the DialogModel here! - Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext ); + Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, mxOwnerDocument ); aRetAny <<= xISP; return aRetAny; } @@ -352,8 +434,8 @@ SfxLibraryContainer* SfxDialogLibraryContainer::createInstanceImpl( void ) } -static OUString aResourceFileNameBase = OUString::createFromAscii( "DialogStrings" ); -static OUString aResourceFileCommentBase = OUString::createFromAscii( "# Strings for Dialog Library " ); +static OUString aResourceFileNameBase(RTL_CONSTASCII_USTRINGPARAM("DialogStrings")); +static OUString aResourceFileCommentBase(RTL_CONSTASCII_USTRINGPARAM("# Strings for Dialog Library ")); // Resource handling Reference< ::com::sun::star::resource::XStringResourcePersistence > @@ -380,7 +462,7 @@ Reference< ::com::sun::star::resource::XStringResourcePersistence > // TODO: Ctor xRet = Reference< resource::XStringResourcePersistence >( mxMSF->createInstance - ( OUString::createFromAscii( "com.sun.star.resource.StringResourceWithStorage" ) ), UNO_QUERY ); + ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.resource.StringResourceWithStorage")) ), UNO_QUERY ); uno::Reference< embed::XStorage > xLibrariesStor; uno::Reference< embed::XStorage > xLibraryStor; @@ -428,7 +510,7 @@ Reference< ::com::sun::star::resource::XStringResourcePersistence > // TODO: Ctor xRet = Reference< resource::XStringResourcePersistence >( mxMSF->createInstance - ( OUString::createFromAscii( "com.sun.star.resource.StringResourceWithLocation" ) ), UNO_QUERY ); + ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.resource.StringResourceWithLocation")) ), UNO_QUERY ); // TODO: Ctor if( xRet.is() ) @@ -484,7 +566,11 @@ void SfxDialogLibraryContainer::onNewRootStorage() } } - +sal_Bool SAL_CALL +SfxDialogLibraryContainer:: HasExecutableCode( const ::rtl::OUString& /*Library*/ ) throw (uno::RuntimeException) +{ + return sal_False; // dialog library has no executable code +} //============================================================================ // Service @@ -506,9 +592,9 @@ Sequence< ::rtl::OUString > SAL_CALL SfxDialogLibraryContainer::getSupportedServ Sequence< OUString > SfxDialogLibraryContainer::getSupportedServiceNames_static() { Sequence< OUString > aServiceNames( 2 ); - aServiceNames[0] = OUString::createFromAscii( "com.sun.star.script.DocumentDialogLibraryContainer" ); + aServiceNames[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.DocumentDialogLibraryContainer")); // plus, for compatibility: - aServiceNames[1] = OUString::createFromAscii( "com.sun.star.script.DialogLibraryContainer" ); + aServiceNames[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.script.DialogLibraryContainer")); return aServiceNames; } @@ -520,7 +606,7 @@ OUString SfxDialogLibraryContainer::getImplementationName_static() MutexGuard aGuard( Mutex::getGlobalMutex() ); if( bNeedsInit ) { - aImplName = OUString::createFromAscii( "com.sun.star.comp.sfx2.DialogLibraryContainer" ); + aImplName = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sfx2.DialogLibraryContainer")); bNeedsInit = sal_False; } return aImplName; @@ -656,3 +742,4 @@ bool SAL_CALL SfxDialogLibrary::isLibraryElementValid( ::com::sun::star::uno::An } //============================================================================ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/uno/makefile.mk b/basic/source/uno/makefile.mk index 52e7f7004c4d..52e7f7004c4d 100644..100755 --- a/basic/source/uno/makefile.mk +++ b/basic/source/uno/makefile.mk diff --git a/basic/source/uno/modsizeexceeded.cxx b/basic/source/uno/modsizeexceeded.cxx index 3efc7f2d230b..d46108e92dad 100644 --- a/basic/source/uno/modsizeexceeded.cxx +++ b/basic/source/uno/modsizeexceeded.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -34,9 +35,10 @@ using namespace com::sun::star; using namespace cppu; -using namespace rtl; using namespace osl; +using ::rtl::OUString; + ModuleSizeExceeded::ModuleSizeExceeded( const uno::Sequence< ::rtl::OUString >& sModules ) { script::ModuleSizeExceededRequest aReq; @@ -66,3 +68,4 @@ ModuleSizeExceeded::isApprove() const } +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index ae110f4bcf6e..72208e516350 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -33,10 +34,10 @@ #include <com/sun/star/embed/XTransactedObject.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <vcl/svapp.hxx> -#include <vos/mutex.hxx> +#include <osl/mutex.hxx> #include <tools/errinf.hxx> #include <osl/mutex.hxx> -#include <vos/diagnose.hxx> +#include <osl/diagnose.h> #include <rtl/uri.hxx> #include <rtl/strbuf.hxx> #include <comphelper/processfactory.hxx> @@ -64,8 +65,10 @@ #include <com/sun/star/script/vba/VBAScriptEventId.hpp> #include <com/sun/star/deployment/ExtensionManager.hpp> #include <comphelper/storagehelper.hxx> +#include <comphelper/anytostring.hxx> #include <cppuhelper/exc_hlp.hxx> #include <basic/sbmod.hxx> +#include <boost/scoped_ptr.hpp> namespace basic { @@ -86,11 +89,15 @@ using namespace com::sun::star::frame; using namespace com::sun::star::deployment; using namespace com::sun::star; using namespace cppu; -using namespace rtl; using namespace osl; using com::sun::star::uno::Reference; +using ::rtl::OUString; +using ::rtl::OStringBuffer; +using ::rtl::OUStringToOString; +using ::rtl::Uri; + // #i34411: Flag for error handling during migration static bool GbMigrationSuppressErrors = false; @@ -377,21 +384,21 @@ SfxLibraryContainer::SfxLibraryContainer( void ) mxMSF = comphelper::getProcessServiceFactory(); if( !mxMSF.is() ) { - OSL_ENSURE( 0, "### couln't get ProcessServiceFactory\n" ); + OSL_FAIL( "### couln't get ProcessServiceFactory\n" ); } mxSFI = Reference< XSimpleFileAccess >( mxMSF->createInstance - ( OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY ); + ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")) ), UNO_QUERY ); if( !mxSFI.is() ) { - OSL_ENSURE( 0, "### couln't create SimpleFileAccess component\n" ); + OSL_FAIL( "### couln't create SimpleFileAccess component\n" ); } mxStringSubstitution = Reference< XStringSubstitution >( mxMSF->createInstance - ( OUString::createFromAscii( "com.sun.star.util.PathSubstitution" ) ), UNO_QUERY ); + ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.util.PathSubstitution")) ), UNO_QUERY ); if( !mxStringSubstitution.is() ) { - OSL_ENSURE( 0, "### couln't create PathSubstitution component\n" ); + OSL_FAIL( "### couln't create PathSubstitution component\n" ); } } @@ -573,14 +580,14 @@ static void createVariableURL( OUString& rStr, const OUString& rLibName, const OUString& rInfoFileName, bool bUser ) { if( bUser ) - rStr = OUString::createFromAscii( "$(USER)/basic/" ); + rStr = OUString(RTL_CONSTASCII_USTRINGPARAM("$(USER)/basic/")); else - rStr = OUString::createFromAscii( "$(INST)/share/basic/" ); + rStr = OUString(RTL_CONSTASCII_USTRINGPARAM("$(INST)/share/basic/")); rStr += rLibName; - rStr += OUString::createFromAscii( "/" ); + rStr += OUString(sal_Unicode('/')); rStr += rInfoFileName; - rStr += OUString::createFromAscii( ".xlb/" ); + rStr += OUString(RTL_CONSTASCII_USTRINGPARAM(".xlb/")); } sal_Bool SfxLibraryContainer::init( const OUString& rInitialDocumentURL, const uno::Reference< embed::XStorage >& rxInitialStorage ) @@ -666,7 +673,7 @@ sal_Bool SfxLibraryContainer::init_Impl( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ) ), UNO_QUERY ); if( !xParser.is() ) { - OSL_ENSURE( 0, "### couln't create sax parser component\n" ); + OSL_FAIL( "### couln't create sax parser component\n" ); return sal_False; } @@ -679,7 +686,6 @@ sal_Bool SfxLibraryContainer::init_Impl( // #110009: Scope to force the StorageRefs to be destructed and // so the streams to be closed before the preload operation { - // #110009 uno::Reference< embed::XStorage > xLibrariesStor; String aFileName; @@ -697,9 +703,6 @@ sal_Bool SfxLibraryContainer::init_Impl( { uno::Reference< io::XStream > xStream; xLibrariesStor = xStorage->openStorageElement( maLibrariesDir, embed::ElementModes::READ ); - //if ( !xLibrariesStor.is() ) - // TODO: the method must either return a storage or throw an exception - //throw uno::RuntimeException(); if ( xLibrariesStor.is() ) { @@ -821,13 +824,13 @@ sal_Bool SfxLibraryContainer::init_Impl( catch ( xml::sax::SAXException& e ) { (void) e; // avoid warning - OSL_ENSURE( 0, OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + OSL_FAIL( OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); return sal_False; } catch ( io::IOException& e ) { (void) e; // avoid warning - OSL_ENSURE( 0, OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + OSL_FAIL( OUStringToOString( e.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); return sal_False; } @@ -920,7 +923,7 @@ sal_Bool SfxLibraryContainer::init_Impl( aMessage.append( ::rtl::OUStringToOString( rLib.aName, osl_getThreadTextEncoding() ) ); aMessage.append( "'.\n\nException:" ); aMessage.append( ::rtl::OUStringToOString( ::comphelper::anyToString( aError ), osl_getThreadTextEncoding() ) ); - OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); + OSL_FAIL( aMessage.makeStringAndClear().getStr() ); #endif } } @@ -932,7 +935,7 @@ sal_Bool SfxLibraryContainer::init_Impl( sal_Bool bLoaded = implLoadLibraryIndexFile( pImplLib, rLib, xLibraryStor, aIndexFileName ); if( bLoaded && aLibName != rLib.aName ) { - OSL_ENSURE( 0, "Different library names in library" + OSL_FAIL( "Different library names in library" " container and library info files!\n" ); } if( GbMigrationSuppressErrors && !bLoaded ) @@ -972,7 +975,6 @@ sal_Bool SfxLibraryContainer::init_Impl( // #110009: END Scope to force the StorageRefs to be destructed } - // #110009 if( !bStorage && meInitMode == DEFAULT ) { @@ -983,11 +985,11 @@ sal_Bool SfxLibraryContainer::init_Impl( catch( uno::Exception& ) { // TODO: error handling? - OSL_ASSERT( "Cannot access extensions!" ); + OSL_FAIL( "Cannot access extensions!" ); } } - // #110009 Preload? + // Preload? { Sequence< OUString > aNames = maNameContainer.getElementNames(); const OUString* pNames = aNames.getConstArray(); @@ -1001,7 +1003,6 @@ sal_Bool SfxLibraryContainer::init_Impl( } } - // #118803# upgrade installation 7.0 -> 8.0 if( meInitMode == DEFAULT ) { INetURLObject aUserBasicInetObj( String(maLibraryPath).GetToken(1) ); @@ -1021,10 +1022,9 @@ sal_Bool SfxLibraryContainer::init_Impl( { INetURLObject aPrevUserBasicInetObj = aPrevUserBasicInetObj_1; String aPrevFolder = aPrevUserBasicInetObj.GetMainURL( INetURLObject::NO_DECODE ); - bool bSecondTime = false; if( mxSFI->isFolder( aPrevFolder ) ) { - // #110101 Check if Standard folder exists and is complete + // Check if Standard folder exists and is complete INetURLObject aUserBasicStandardInetObj( aUserBasicInetObj ); aUserBasicStandardInetObj.insertName( aStandardStr, sal_True, INetURLObject::LAST_SEGMENT, sal_True, INetURLObject::ENCODE_ALL ); @@ -1067,7 +1067,6 @@ sal_Bool SfxLibraryContainer::init_Impl( } else { - bSecondTime = true; aPrevUserBasicInetObj = aPrevUserBasicInetObj_2; aPrevFolder = aPrevUserBasicInetObj.GetMainURL( INetURLObject::NO_DECODE ); } @@ -1116,10 +1115,10 @@ sal_Bool SfxLibraryContainer::init_Impl( mxSFI->move( aFolderUserBasic, aPrevFolder ); mxSFI->move( aFolderTmp, aFolderUserBasic ); - OUString aUserSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE" ); - OUString aSharedSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE" ); - OUString aBundledSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$BUNDLED_EXTENSIONS" ); - OUString aInstSearchStr = OUString::createFromAscii( "$(INST)" ); + OUString aUserSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")); + OUString aSharedSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")); + OUString aBundledSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$BUNDLED_EXTENSIONS")); + OUString aInstSearchStr(RTL_CONSTASCII_USTRINGPARAM("$(INST)")); Sequence< OUString > aNames = pPrevCont->getElementNames(); const OUString* pNames = aNames.getConstArray(); @@ -1201,7 +1200,7 @@ sal_Bool SfxLibraryContainer::init_Impl( // #i93163 if( bCleanUp ) { - DBG_ERROR( "Upgrade of Basic installation failed somehow" ); + OSL_FAIL( "Upgrade of Basic installation failed somehow" ); static char strErrorSavFolderName[] = "__basic_80_err"; INetURLObject aPrevUserBasicInetObj_Err( aUserBasicInetObj ); @@ -1245,7 +1244,7 @@ void SfxLibraryContainer::implScanExtensions( void ) bool bPureDialogLib = false; while( (aLibURL = aScriptIt.nextBasicOrDialogLibrary( bPureDialogLib )).getLength() > 0 ) { - if( bPureDialogLib && maInfoFileName.equalsAscii( "script" ) ) + if( bPureDialogLib && maInfoFileName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "script" ) ) ) continue; // Extract lib name @@ -1267,9 +1266,9 @@ void SfxLibraryContainer::implScanExtensions( void ) // Add index file to URL OUString aIndexFileURL = aLibURL; if( nReduceCopy == 0 ) - aIndexFileURL += OUString::createFromAscii( "/" ); + aIndexFileURL += OUString(sal_Unicode('/')); aIndexFileURL += maInfoFileName; - aIndexFileURL += OUString::createFromAscii( ".xlb" ); + aIndexFileURL += OUString(RTL_CONSTASCII_USTRINGPARAM(".xlb")); // Create link const bool bReadOnly = false; @@ -1409,7 +1408,6 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib, OUString aStreamName = aElementName; aStreamName += String( RTL_CONSTASCII_USTRINGPARAM(".xml") ); - /*Any aElement = pLib->getByName( aElementName );*/ if( !isLibraryElementValid( pLib->getByName( aElementName ) ) ) { #if OSL_DEBUG_LEVEL > 0 @@ -1417,7 +1415,7 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib, aMessage.append( "invalid library element '" ); aMessage.append( ::rtl::OUStringToOString( aElementName, osl_getThreadTextEncoding() ) ); aMessage.append( "'." ); - OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); + OSL_FAIL( aMessage.makeStringAndClear().getStr() ); #endif continue; } @@ -1425,7 +1423,6 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib, uno::Reference< io::XStream > xElementStream = xStorage->openStreamElement( aStreamName, embed::ElementModes::READWRITE ); - //if ( !xElementStream.is() ) // throw uno::RuntimeException(); // TODO: method must either return the stream or throw an exception String aPropName( String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("MediaType") ) ); @@ -1434,27 +1431,23 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib, uno::Reference< beans::XPropertySet > xProps( xElementStream, uno::UNO_QUERY ); OSL_ENSURE( xProps.is(), "The StorageStream must implement XPropertySet interface!\n" ); //if ( !xProps.is() ) //TODO - // throw uno::RuntimeException(); if ( xProps.is() ) { xProps->setPropertyValue( aPropName, uno::makeAny( aMime ) ); // #87671 Allow encryption -//REMOVE aPropName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("Encrypted") ); aPropName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "UseCommonStoragePasswordEncryption" ) ); xProps->setPropertyValue( aPropName, uno::makeAny( sal_True ) ); Reference< XOutputStream > xOutput = xElementStream->getOutputStream(); Reference< XNameContainer > xLib( pLib ); writeLibraryElement( xLib, aElementName, xOutput ); - // writeLibraryElement closes the stream - // xOutput->closeOutput(); } } catch( uno::Exception& ) { - OSL_ENSURE( sal_False, "Problem during storing of library!\n" ); + OSL_FAIL( "Problem during storing of library!\n" ); // TODO: error handling? } } @@ -1499,7 +1492,6 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib, aElementInetObj.setExtension( maLibElementFileExtension ); String aElementPath( aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ) ); - /*Any aElement = pLib->getByName( aElementName );*/ if( !isLibraryElementValid( pLib->getByName( aElementName ) ) ) { #if OSL_DEBUG_LEVEL > 0 @@ -1507,7 +1499,7 @@ void SfxLibraryContainer::implStoreLibrary( SfxLibrary* pLib, aMessage.append( "invalid library element '" ); aMessage.append( ::rtl::OUStringToOString( aElementName, osl_getThreadTextEncoding() ) ); aMessage.append( "'." ); - OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); + OSL_FAIL( aMessage.makeStringAndClear().getStr() ); #endif continue; } @@ -1560,7 +1552,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib, OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ) ), UNO_QUERY ); if( !xHandler.is() ) { - OSL_ENSURE( 0, "### couln't create sax-writer component\n" ); + OSL_FAIL( "### couln't create sax-writer component\n" ); return; } @@ -1579,7 +1571,6 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib, xInfoStream = xStorage->openStreamElement( aStreamName, embed::ElementModes::READWRITE ); OSL_ENSURE( xInfoStream.is(), "No stream!\n" ); uno::Reference< beans::XPropertySet > xProps( xInfoStream, uno::UNO_QUERY ); - //if ( !xProps.is() ) // throw uno::RuntimeException(); // TODO if ( xProps.is() ) @@ -1589,7 +1580,6 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib, xProps->setPropertyValue( aPropName, uno::makeAny( aMime ) ); // #87671 Allow encryption -//REMOVE aPropName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM("Encrypted") ); aPropName = String::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "UseCommonStoragePasswordEncryption" ) ); xProps->setPropertyValue( aPropName, uno::makeAny( sal_True ) ); @@ -1598,7 +1588,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib, } catch( uno::Exception& ) { - OSL_ENSURE( sal_False, "Problem during storing of library index file!\n" ); + OSL_FAIL( "Problem during storing of library index file!\n" ); // TODO: error handling? } } @@ -1647,7 +1637,7 @@ void SfxLibraryContainer::implStoreLibraryIndexFile( SfxLibrary* pLib, } if( !xOut.is() ) { - OSL_ENSURE( 0, "### couln't open output stream\n" ); + OSL_FAIL( "### couln't open output stream\n" ); return; } @@ -1665,7 +1655,7 @@ sal_Bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib, OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ) ), UNO_QUERY ); if( !xParser.is() ) { - OSL_ENSURE( 0, "### couln't create sax parser component\n" ); + OSL_FAIL( "### couln't create sax parser component\n" ); return sal_False; } @@ -1723,7 +1713,6 @@ sal_Bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib, } if( !xInput.is() ) { - // OSL_ENSURE( 0, "### couln't open input stream\n" ); return sal_False; } @@ -1738,10 +1727,7 @@ sal_Bool SfxLibraryContainer::implLoadLibraryIndexFile( SfxLibrary* pLib, } catch( Exception& ) { - // throw WrappedTargetException( OUString::createFromAscii( "parsing error!\n" ), - // Reference< XInterface >(), - // makeAny( e ) ); - OSL_ENSURE( 0, "Parsing error\n" ); + OSL_FAIL( "Parsing error\n" ); SfxErrorContext aEc( ERRCTX_SFX_LOADBASIC, aLibInfoPath ); sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL; ErrorHandler::HandleError( nErrorCode ); @@ -1804,7 +1790,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto if( !nLibsToSave ) return; - ::xmlscript::LibDescriptorArray* pLibArray = new ::xmlscript::LibDescriptorArray( nLibsToSave ); + boost::scoped_ptr< ::xmlscript::LibDescriptorArray > pLibArray(new ::xmlscript::LibDescriptorArray(nLibsToSave)); // Write to storage? sal_Bool bStorage = i_rStorage.is(); @@ -1815,7 +1801,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto if ( bStorage ) { // Don't write if only empty standard lib exists - if ( ( nNameCount == 1 ) && ( aNames[0].equalsAscii( "Standard" ) ) ) + if ( ( nNameCount == 1 ) && ( aNames[0].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Standard" ) ) ) ) { Any aLibAny = maNameContainer.getByName( aNames[0] ); Reference< XNameAccess > xNameAccess; @@ -1936,7 +1922,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto aMessage.append( ::rtl::OUStringToOString( rLib.aName, osl_getThreadTextEncoding() ) ); aMessage.append( "'.\n\nException:" ); aMessage.append( ::rtl::OUStringToOString( ::comphelper::anyToString( aError ), osl_getThreadTextEncoding() ) ); - OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); + OSL_FAIL( aMessage.makeStringAndClear().getStr() ); #endif return; } @@ -2041,7 +2027,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ) ), UNO_QUERY ); if( !xHandler.is() ) { - OSL_ENSURE( 0, "### couln't create sax-writer component\n" ); + OSL_FAIL( "### couln't create sax-writer component\n" ); return; } @@ -2101,7 +2087,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto } if( !xOut.is() ) { - OSL_ENSURE( 0, "### couln't open output stream\n" ); + OSL_FAIL( "### couln't open output stream\n" ); return; } @@ -2110,7 +2096,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto try { - xmlscript::exportLibraryContainer( xHandler, pLibArray ); + xmlscript::exportLibraryContainer( xHandler, pLibArray.get() ); if ( bStorage ) { uno::Reference< embed::XTransactedObject > xTransact( xTargetLibrariesStor, uno::UNO_QUERY ); @@ -2123,12 +2109,10 @@ void SfxLibraryContainer::storeLibraries_Impl( const uno::Reference< embed::XSto } catch( uno::Exception& ) { - OSL_ENSURE( sal_False, "Problem during storing of libraries!\n" ); + OSL_FAIL( "Problem during storing of libraries!\n" ); sal_uIntPtr nErrorCode = ERRCODE_IO_GENERAL; ErrorHandler::HandleError( nErrorCode ); } - - delete pLibArray; } @@ -2223,9 +2207,9 @@ Reference< XNameAccess > SAL_CALL SfxLibraryContainer::createLibraryLink maNameContainer.insertByName( Name, aElement ); maModifiable.setModified( sal_True ); - OUString aUserSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE" ); - OUString aSharedSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE" ); - OUString aBundledSearchStr = OUString::createFromAscii( "vnd.sun.star.expand:$BUNDLED_EXTENSIONS" ); + OUString aUserSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE")); + OUString aSharedSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE")); + OUString aBundledSearchStr(RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$BUNDLED_EXTENSIONS")); if( StorageURL.indexOf( aUserSearchStr ) != -1 ) { pNewLib->mbExtension = sal_True; @@ -2359,7 +2343,7 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name ) aMessage.append( ::rtl::OUStringToOString( Name, osl_getThreadTextEncoding() ) ); aMessage.append( "'.\n\nException:" ); aMessage.append( ::rtl::OUStringToOString( ::comphelper::anyToString( aError ), osl_getThreadTextEncoding() ) ); - OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); + OSL_FAIL( aMessage.makeStringAndClear().getStr() ); #endif return; } @@ -2409,7 +2393,7 @@ void SAL_CALL SfxLibraryContainer::loadLibrary( const OUString& Name ) aMessage.append( "couln't open library element stream - attempted to open library '" ); aMessage.append( ::rtl::OUStringToOString( Name, osl_getThreadTextEncoding() ) ); aMessage.append( "'." ); - OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); + OSL_FAIL( aMessage.makeStringAndClear().getStr() ); #endif return; } @@ -2753,7 +2737,7 @@ void SAL_CALL SfxLibraryContainer::exportLibrary( const OUString& Name, const OU if( Handler.is() ) { xToUseSFI = Reference< XSimpleFileAccess >( mxMSF->createInstance - ( OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ) ), UNO_QUERY ); + ( OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.SimpleFileAccess")) ), UNO_QUERY ); if( xToUseSFI.is() ) xToUseSFI->setInteractionHandler( Handler ); } @@ -2889,6 +2873,18 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa } } +void SAL_CALL SfxLibraryContainer::setProjectName( const ::rtl::OUString& _projectname ) throw (RuntimeException) +{ + msProjectName = _projectname; + BasicManager* pBasMgr = getBasicManager(); + // Temporary HACK + // Some parts of the VBA handling ( e.g. in core basic ) + // code expect the name of the VBA project to be set as the name of + // the basic manager. Provide fail back here. + if( pBasMgr ) + pBasMgr->SetName( msProjectName ); +} + sal_Int32 SAL_CALL SfxLibraryContainer::getRunningVBAScripts() throw (RuntimeException) { LibraryContainerMethodGuard aGuard( *this ); @@ -3006,23 +3002,14 @@ Any SAL_CALL SfxLibrary::queryInterface( const Type& rType ) { Any aRet; - /* - if( mbReadOnly ) - { - aRet = Any( ::cppu::queryInterface( rType, - static_cast< XContainer * >( this ), - static_cast< XNameAccess * >( this ) ) ); - } - else - { - */ - aRet = Any( ::cppu::queryInterface( rType, + aRet = Any( + ::cppu::queryInterface( + rType, static_cast< XContainer * >( this ), static_cast< XNameContainer * >( this ), static_cast< XNameAccess * >( this ), static_cast< XElementAccess * >( this ), static_cast< XChangesNotifier * >( this ) ) ); - //} if( !aRet.hasValue() ) aRet = OComponentHelper::queryInterface( rType ); return aRet; @@ -3222,8 +3209,8 @@ void SAL_CALL SfxLibrary::removeChangesListener( const Reference< XChangesListen //============================================================================ // Implementation class ScriptExtensionIterator -static rtl::OUString aBasicLibMediaType( rtl::OUString::createFromAscii( "application/vnd.sun.star.basic-library" ) ); -static rtl::OUString aDialogLibMediaType( rtl::OUString::createFromAscii( "application/vnd.sun.star.dialog-library" ) ); +#define sBasicLibMediaType "application/vnd.sun.star.basic-library" +#define sDialogLibMediaType "application/vnd.sun.star.dialog-library" ScriptExtensionIterator::ScriptExtensionIterator( void ) : m_eState( USER_EXTENSIONS ) @@ -3247,7 +3234,7 @@ ScriptExtensionIterator::ScriptExtensionIterator( void ) if( !m_xContext.is() ) { throw RuntimeException( - ::rtl::OUString::createFromAscii( "ScriptExtensionIterator::init(), no XComponentContext" ), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ScriptExtensionIterator::init(), no XComponentContext")), Reference< XInterface >() ); } } @@ -3292,7 +3279,7 @@ rtl::OUString ScriptExtensionIterator::nextBasicOrDialogLibrary( bool& rbPureDia break; } case END_REACHED: - VOS_ENSURE( false, "ScriptExtensionIterator::nextBasicOrDialogLibrary(): Invalid case END_REACHED" ); + OSL_FAIL( "ScriptExtensionIterator::nextBasicOrDialogLibrary(): Invalid case END_REACHED" ); break; } } @@ -3374,11 +3361,11 @@ Reference< deployment::XPackage > ScriptSubPackageIterator::implDetectScriptPack { const Reference< deployment::XPackageTypeInfo > xPackageTypeInfo = xPackage->getPackageType(); rtl::OUString aMediaType = xPackageTypeInfo->getMediaType(); - if( aMediaType.equals( aBasicLibMediaType ) ) + if( aMediaType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sBasicLibMediaType)) ) { xScriptPackage = xPackage; } - else if( aMediaType.equals( aDialogLibMediaType ) ) + else if( aMediaType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sDialogLibMediaType)) ) { rbPureDialogLib = true; xScriptPackage = xPackage; @@ -3420,12 +3407,12 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetScriptPackageF const Reference< deployment::XPackage > xSubPkg = pSeq[ iPkg ]; const Reference< deployment::XPackageTypeInfo > xPackageTypeInfo = xSubPkg->getPackageType(); rtl::OUString aMediaType = xPackageTypeInfo->getMediaType(); - if( aMediaType.equals( aBasicLibMediaType ) ) + if( aMediaType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sBasicLibMediaType)) ) { xScriptPackage = xSubPkg; break; } - else if( aMediaType.equals( aDialogLibMediaType ) ) + else if( aMediaType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sDialogLibMediaType)) ) { rbPureDialogLib = true; xScriptPackage = xSubPkg; @@ -3437,11 +3424,11 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetScriptPackageF { const Reference< deployment::XPackageTypeInfo > xPackageTypeInfo = xPackage->getPackageType(); rtl::OUString aMediaType = xPackageTypeInfo->getMediaType(); - if( aMediaType.equals( aBasicLibMediaType ) ) + if( aMediaType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sBasicLibMediaType)) ) { xScriptPackage = xPackage; } - else if( aMediaType.equals( aDialogLibMediaType ) ) + else if( aMediaType.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM(sDialogLibMediaType)) ) { rbPureDialogLib = true; xScriptPackage = xPackage; @@ -3464,7 +3451,7 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextUserScript Reference< XExtensionManager > xManager = ExtensionManager::get( m_xContext ); m_aUserPackagesSeq = xManager->getDeployedExtensions - (rtl::OUString::createFromAscii("user"), + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); } catch( com::sun::star::uno::DeploymentException& ) @@ -3487,7 +3474,7 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextUserScript { const Reference< deployment::XPackage >* pUserPackages = m_aUserPackagesSeq.getConstArray(); Reference< deployment::XPackage > xPackage = pUserPackages[ m_iUserPackage ]; - VOS_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextUserScriptPackage(): Invalid package" ); + OSL_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextUserScriptPackage(): Invalid package" ); m_pScriptSubPackageIterator = new ScriptSubPackageIterator( xPackage ); } @@ -3518,7 +3505,7 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScri Reference< XExtensionManager > xSharedManager = ExtensionManager::get( m_xContext ); m_aSharedPackagesSeq = xSharedManager->getDeployedExtensions - (rtl::OUString::createFromAscii("shared"), + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("shared")), Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); } catch( com::sun::star::uno::DeploymentException& ) @@ -3540,7 +3527,7 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScri { const Reference< deployment::XPackage >* pSharedPackages = m_aSharedPackagesSeq.getConstArray(); Reference< deployment::XPackage > xPackage = pSharedPackages[ m_iSharedPackage ]; - VOS_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextSharedScriptPackage(): Invalid package" ); + OSL_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextSharedScriptPackage(): Invalid package" ); m_pScriptSubPackageIterator = new ScriptSubPackageIterator( xPackage ); } @@ -3571,7 +3558,7 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextBundledScr Reference< XExtensionManager > xManager = ExtensionManager::get( m_xContext ); m_aBundledPackagesSeq = xManager->getDeployedExtensions - (rtl::OUString::createFromAscii("bundled"), + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bundled")), Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() ); } catch( com::sun::star::uno::DeploymentException& ) @@ -3593,7 +3580,7 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextBundledScr { const Reference< deployment::XPackage >* pBundledPackages = m_aBundledPackagesSeq.getConstArray(); Reference< deployment::XPackage > xPackage = pBundledPackages[ m_iBundledPackage ]; - VOS_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextBundledScriptPackage(): Invalid package" ); + OSL_ENSURE( xPackage.is(), "ScriptExtensionIterator::implGetNextBundledScriptPackage(): Invalid package" ); m_pScriptSubPackageIterator = new ScriptSubPackageIterator( xPackage ); } @@ -3613,3 +3600,5 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextBundledScr } } // namespace basic + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/uno/sbmodule.cxx b/basic/source/uno/sbmodule.cxx index db9383a019b5..3c8d115b1912 100644 --- a/basic/source/uno/sbmodule.cxx +++ b/basic/source/uno/sbmodule.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -42,3 +43,4 @@ namespace basic //........................................................................ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/uno/sbmodule.hxx b/basic/source/uno/sbmodule.hxx index 459dac691896..2dd0b3dd7910 100644 --- a/basic/source/uno/sbmodule.hxx +++ b/basic/source/uno/sbmodule.hxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -43,3 +44,4 @@ namespace basic #endif // SBMODULE_HXX +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/uno/sbservices.cxx b/basic/source/uno/sbservices.cxx index 7a1a4fd2d1cb..5c4e1fc98309 100644 --- a/basic/source/uno/sbservices.cxx +++ b/basic/source/uno/sbservices.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -61,3 +62,4 @@ namespace basic IMPLEMENT_COMPONENT_LIBRARY_API( ::basic::BasicModule, ::basic::initializeModule ) +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx index f51ce54cd7ee..d6a22045766c 100644 --- a/basic/source/uno/scriptcont.cxx +++ b/basic/source/uno/scriptcont.cxx @@ -1,3 +1,4 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -43,9 +44,7 @@ #include <com/sun/star/task/ErrorCodeIOException.hpp> #include <com/sun/star/script/ModuleType.hpp> #include <comphelper/processfactory.hxx> -#ifndef _COMPHELPER_STORAGEHELPER_HXX_ #include <comphelper/storagehelper.hxx> -#endif #include <unotools/streamwrap.hxx> #include <unotools/ucbstreamhelper.hxx> #include <osl/mutex.hxx> @@ -66,7 +65,8 @@ #include <xmlscript/xmlmod_imexp.hxx> #include <cppuhelper/factory.hxx> #include <com/sun/star/util/VetoException.hpp> - +#include <com/sun/star/script/XLibraryQueryExecutable.hpp> +#include <cppuhelper/implbase1.hxx> namespace basic { @@ -84,6 +84,8 @@ using namespace osl; using ::rtl::OUString; +using ::rtl::OUString; + //============================================================================ // Implementation class SfxScriptLibraryContainer @@ -136,7 +138,6 @@ sal_Bool SfxScriptLibraryContainer::hasLibraryPassword( const String& rLibraryNa return pImplLib->mbPasswordProtected; } - // Ctor for service SfxScriptLibraryContainer::SfxScriptLibraryContainer( void ) :maScriptLanguage( RTL_CONSTASCII_USTRINGPARAM( "StarBasic" ) ) @@ -197,7 +198,7 @@ void SAL_CALL SfxScriptLibraryContainer::writeLibraryElement OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Writer") ) ), UNO_QUERY ); if( !xHandler.is() ) { - OSL_ENSURE( 0, "### couln't create sax-writer component\n" ); + OSL_FAIL( "### couln't create sax-writer component\n" ); return; } @@ -254,7 +255,7 @@ Any SAL_CALL SfxScriptLibraryContainer::importLibraryElement OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.sax.Parser") ) ), UNO_QUERY ); if( !xParser.is() ) { - OSL_ENSURE( 0, "### couln't create sax parser component\n" ); + OSL_FAIL( "### couln't create sax parser component\n" ); return aRetAny; } @@ -395,8 +396,6 @@ void SAL_CALL SfxScriptLibraryContainer::importFromOldStorage( const ::rtl::OUSt SotStorageRef xStorage = new SotStorage( sal_False, aFile ); if( xStorage.Is() && xStorage->GetError() == ERRCODE_NONE ) { - // We need a BasicManager to avoid problems - // StarBASIC* pBas = new StarBASIC(); BasicManager* pBasicManager = new BasicManager( *(SotStorage*)xStorage, aFile ); // Set info @@ -640,7 +639,6 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, SbModule* pMod = pBasicLib->FindModule( aElementName ); if( pMod ) { - //OUString aCodeStreamName( RTL_CONSTASCII_USTRINGPARAM("code.bin") ); OUString aCodeStreamName = aElementName; aCodeStreamName += String( RTL_CONSTASCII_USTRINGPARAM(".bin") ); @@ -675,7 +673,6 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, if( pLib->mbPasswordVerified || pLib->mbDoc50Password ) { - /*Any aElement = pLib->getByName( aElementName );*/ if( !isLibraryElementValid( pLib->getByName( aElementName ) ) ) { #if OSL_DEBUG_LEVEL > 0 @@ -683,7 +680,7 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, aMessage.append( "invalid library element '" ); aMessage.append( ::rtl::OUStringToOString( aElementName, osl_getThreadTextEncoding() ) ); aMessage.append( "'." ); - OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); + OSL_FAIL( aMessage.makeStringAndClear().getStr() ); #endif continue; } @@ -709,12 +706,10 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, Reference< XOutputStream > xOutput = xSourceStream->getOutputStream(); Reference< XNameContainer > xLib( pLib ); writeLibraryElement( xLib, aElementName, xOutput ); - // writeLibraryElement should have the stream already closed - // xOutput->closeOutput(); } catch( uno::Exception& ) { - OSL_ENSURE( sal_False, "Problem on storing of password library!\n" ); + OSL_FAIL( "Problem on storing of password library!\n" ); // TODO: error handling } } @@ -761,7 +756,6 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, aElementInetObj.setExtension( OUString( RTL_CONSTASCII_USTRINGPARAM("pba") ) ); String aElementPath = aElementInetObj.GetMainURL( INetURLObject::NO_DECODE ); - /*Any aElement = pLib->getByName( aElementName );*/ if( !isLibraryElementValid( pLib->getByName( aElementName ) ) ) { #if OSL_DEBUG_LEVEL > 0 @@ -769,7 +763,7 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, aMessage.append( "invalid library element '" ); aMessage.append( ::rtl::OUStringToOString( aElementName, osl_getThreadTextEncoding() ) ); aMessage.append( "'." ); - OSL_ENSURE( false, aMessage.makeStringAndClear().getStr() ); + OSL_FAIL( aMessage.makeStringAndClear().getStr() ); #endif continue; } @@ -860,13 +854,10 @@ sal_Bool SfxScriptLibraryContainer::implStorePasswordLibrary( SfxLibrary* pLib, // TODO: handle error } - // Storage Dtor commits too, that makes problems - // xElementRootStorage->Commit(); } } catch( Exception& ) { - //throw e; } } return sal_True; @@ -935,7 +926,7 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary } catch( uno::Exception& ) { - OSL_ENSURE( 0, "### couln't open sub storage for library\n" ); + OSL_FAIL( "### couln't open sub storage for library\n" ); return sal_False; } } @@ -954,7 +945,6 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary pBasicLib->SetModified( sal_False ); } - //OUString aCodeStreamName( RTL_CONSTASCII_USTRINGPARAM("code.bin") ); OUString aCodeStreamName= aElementName; aCodeStreamName += String( RTL_CONSTASCII_USTRINGPARAM(".bin") ); @@ -1144,11 +1134,6 @@ sal_Bool SfxScriptLibraryContainer::implLoadPasswordLibrary } } -//REMOVE // If the password is verified the library must remain modified, because -//REMOVE // otherwise for saving the storage would be copied and that doesn't work -//REMOVE // with mtg's storages when the password is verified -//REMOVE if( !pLib->mbPasswordVerified ) -//REMOVE pLib->mbModified = sal_False; return bRet; } @@ -1157,6 +1142,17 @@ void SfxScriptLibraryContainer::onNewRootStorage() { } +sal_Bool SAL_CALL +SfxScriptLibraryContainer:: HasExecutableCode( const ::rtl::OUString& Library ) throw (uno::RuntimeException) +{ + BasicManager* pBasicMgr = getBasicManager(); + OSL_ENSURE( pBasicMgr, "we need a basicmanager, really we do" ); + if ( pBasicMgr ) + return pBasicMgr->HasExeCode( Library ); // need to change this to take name + // default to it has code if we can't decide + return sal_True; +} + //============================================================================ // Service void createRegistryInfo_SfxScriptLibraryContainer() @@ -1177,9 +1173,9 @@ Sequence< ::rtl::OUString > SAL_CALL SfxScriptLibraryContainer::getSupportedServ Sequence< OUString > SfxScriptLibraryContainer::getSupportedServiceNames_static() { Sequence< OUString > aServiceNames( 2 ); - aServiceNames[0] = OUString::createFromAscii( "com.sun.star.script.DocumentScriptLibraryContainer" ); + aServiceNames[0] = OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.DocumentScriptLibraryContainer" )); // plus, for compatibility: - aServiceNames[1] = OUString::createFromAscii( "com.sun.star.script.ScriptLibraryContainer" ); + aServiceNames[1] = OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.script.ScriptLibraryContainer" )); return aServiceNames; } @@ -1191,7 +1187,7 @@ OUString SfxScriptLibraryContainer::getImplementationName_static() MutexGuard aGuard( Mutex::getGlobalMutex() ); if( bNeedsInit ) { - aImplName = OUString::createFromAscii( "com.sun.star.comp.sfx2.ScriptLibraryContainer" ); + aImplName = OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.sfx2.ScriptLibraryContainer" )); bNeedsInit = sal_False; } return aImplName; @@ -1318,3 +1314,5 @@ void SAL_CALL SfxScriptLibrary::removeModuleInfo( const ::rtl::OUString& ModuleN //============================================================================ } // namespace basic + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/basic/util/makefile.mk b/basic/util/makefile.mk index ae4456cbc923..29564fddd125 100644..100755 --- a/basic/util/makefile.mk +++ b/basic/util/makefile.mk @@ -57,22 +57,16 @@ SHL1STDLIBS= \ $(SVTOOLLIB) \ $(SVLLIB) \ $(VCLLIB) \ - $(VOSLIB) \ $(SALLIB) \ $(SALHELPERLIB) \ $(COMPHELPERLIB) \ $(UNOTOOLSLIB) \ $(SOTLIB) \ - $(VOSLIB) \ $(XMLSCRIPTLIB) # Uncomment the following line if DBG_TRACE_PROFILING is active in source/inc/sbtrace.hxx # SHL1STDLIBS+=$(CANVASTOOLSLIB) -.IF "$(SOLAR_JAVA)" != "TRUE" -SHL1STDLIBS+=$(SJLIB) -.ENDIF - .IF "$(GUI)"=="WNT" SHL1STDLIBS+= \ $(UWINAPILIB) \ diff --git a/basic/util/sb.component b/basic/util/sb.component index 4687bd1e7d0b..4687bd1e7d0b 100644..100755 --- a/basic/util/sb.component +++ b/basic/util/sb.component diff --git a/basic/workben/makefile.mk b/basic/workben/makefile.mk deleted file mode 100644 index 6ec2a9971b9e..000000000000 --- a/basic/workben/makefile.mk +++ /dev/null @@ -1,89 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=.. - -PRJNAME=basic -TARGET=miniapp -TARGETTYPE=GUI - -# --- Settings --------------------------------------------------- - -.INCLUDE : settings.mk - -# --- SBASIC IDE -------------------------------------------------------- - -APP1TARGET=$(PRJNAME)app -APP1STDLIBS= \ - $(SALLIB) \ - $(TOOLSLIB) \ - $(UNOTOOLSLIB) \ - $(SVTOOLLIB) \ - $(SVLLIB) \ - $(VCLLIB) \ - $(COMPHELPERLIB) \ - $(UCBHELPERLIB) \ - $(CPPUHELPERLIB) \ - $(CPPULIB) \ - $(SJLIB) \ - $(SOTLIB) \ - $(VOSLIB) - -#.IF "$(GUI)"=="WNT" || "$(COM)"=="GCC" -#APP1STDLIBS+=$(CPPULIB) -#.ENDIF -#.IF "$(GUI)"=="UNX" -#APP1STDLIBS+= \ -# $(VOSLIB) \ -# $(SALLIB) -#.ENDIF - -.IF "$(GUI)"!="OS2" -APP1LIBS= \ - $(LB)$/basic.lib -.ENDIF -APP1LIBS+= \ - $(LB)$/app.lib \ - $(LB)$/sample.lib -.IF "$(GUI)"=="UNX" || "$(GUI)"=="OS2" -APP1STDLIBS+= \ - $(BASICLIB) -.ENDIF - - -APP1DEPN= $(L)$/itools.lib $(SVLIBDEPEND) $(LB)$/basic.lib $(LB)$/app.lib $(LB)$/sample.lib - -APP1OBJS = $(OBJ)$/ttbasic.obj - -.IF "$(GUI)" != "UNX" -APP1OBJS+= \ - $(OBJ)$/app.obj \ - $(SLO)$/sbintern.obj -.ENDIF - -.INCLUDE : target.mk - diff --git a/basic/workben/mgrtest.cxx b/basic/workben/mgrtest.cxx index 7e3efc597ac1..a269bcde5b7b 100644 --- a/basic/workben/mgrtest.cxx +++ b/basic/workben/mgrtest.cxx @@ -526,7 +526,6 @@ void __EXPORT TestWindow::Resize() void __EXPORT TestWindow::KeyInput( const KeyEvent& rKEvt ) { - char nCharCode = rKEvt.GetCharCode(); sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode(); // Nur bei Alt-Return |