diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-08-09 12:32:07 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-08-09 12:47:03 +0100 |
commit | 16f75f1f773035df36437763588d5a3acbb70935 (patch) | |
tree | 3d35c0f147b6d7889d9f847179785e3cdf2075e5 /basic | |
parent | 490b51371dede5910fed770fe70fd1870db0fffa (diff) |
reduce static_initialization_and_destruction chain
Change-Id: I9fdefd428b858fd5581412d6f8e896a0eb680fef
Diffstat (limited to 'basic')
-rw-r--r-- | basic/inc/basic/sbstar.hxx | 2 | ||||
-rw-r--r-- | basic/source/classes/sb.cxx | 16 | ||||
-rw-r--r-- | basic/source/classes/sbunoobj.cxx | 20 | ||||
-rw-r--r-- | basic/source/runtime/step0.cxx | 20 |
4 files changed, 30 insertions, 28 deletions
diff --git a/basic/inc/basic/sbstar.hxx b/basic/inc/basic/sbstar.hxx index 1b0cd71972c4..6a75304ee9f2 100644 --- a/basic/inc/basic/sbstar.hxx +++ b/basic/inc/basic/sbstar.hxx @@ -172,7 +172,7 @@ public: SbxObjectRef getRTL( void ) { return pRtl; } sal_Bool IsDocBasic() { return bDocBasic; } - SbxVariable* VBAFind( const String& rName, SbxClassType t ); + SbxVariable* VBAFind( const rtl::OUString& rName, SbxClassType t ); bool GetUNOConstant( const sal_Char* _pAsciiName, ::com::sun::star::uno::Any& aOut ); void QuitAndExitApplication(); sal_Bool IsQuitApplication() { return bQuit; }; diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 85358089e665..1a625bdb9a75 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -230,10 +230,9 @@ SbxObject* StarBASIC::getVBAGlobals( ) } // i#i68894# -SbxVariable* StarBASIC::VBAFind( const String& rName, SbxClassType t ) +SbxVariable* StarBASIC::VBAFind( const rtl::OUString& rName, SbxClassType t ) { - const static String aThisComponent( RTL_CONSTASCII_USTRINGPARAM("ThisComponent") ); - if( rName == aThisComponent ) + if( rName == "ThisComponent" ) return NULL; // rename to init globals if ( getVBAGlobals( ) ) @@ -778,15 +777,13 @@ SbxVariable* SbClassModuleObject::Find( const rtl::OUString& rName, SbxClassType void SbClassModuleObject::triggerInitializeEvent( void ) { - static String aInitMethodName( RTL_CONSTASCII_USTRINGPARAM("Class_Initialize") ); - if( mbInitializeEventDone ) return; mbInitializeEventDone = true; // Search method - SbxVariable* pMeth = SbxObject::Find( aInitMethodName, SbxCLASS_METHOD ); + SbxVariable* pMeth = SbxObject::Find(rtl::OUString("Class_Initialize"), SbxCLASS_METHOD); if( pMeth ) { SbxValues aVals; @@ -796,13 +793,11 @@ void SbClassModuleObject::triggerInitializeEvent( void ) void SbClassModuleObject::triggerTerminateEvent( void ) { - static String aTermMethodName( RTL_CONSTASCII_USTRINGPARAM("Class_Terminate") ); - if( !mbInitializeEventDone || GetSbData()->bRunInit ) return; // Search method - SbxVariable* pMeth = SbxObject::Find( aTermMethodName, SbxCLASS_METHOD ); + SbxVariable* pMeth = SbxObject::Find( rtl::OUString("Class_Terminate"), SbxCLASS_METHOD ); if( pMeth ) { SbxValues aVals; @@ -1264,8 +1259,6 @@ void StarBASIC::DeInitAllModules( void ) // If this fails again a conventional search over objects is performend. SbxVariable* StarBASIC::Find( const rtl::OUString& rName, SbxClassType t ) { - static String aMainStr( RTL_CONSTASCII_USTRINGPARAM("Main") ); - SbxVariable* pRes = NULL; SbModule* pNamed = NULL; // "Extended" search in Runtime Lib @@ -1314,6 +1307,7 @@ SbxVariable* StarBASIC::Find( const rtl::OUString& rName, SbxClassType t ) break; } } + rtl::OUString aMainStr("Main"); if( !pRes && pNamed && ( t == SbxCLASS_METHOD || t == SbxCLASS_DONTCARE ) && !pNamed->GetName().EqualsIgnoreCaseAscii( aMainStr ) ) pRes = pNamed->Find( aMainStr, SbxCLASS_METHOD ); diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index 4a8a8f73a9f1..b9ec529876b2 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -30,8 +30,9 @@ #include <comphelper/extract.hxx> #include <comphelper/processfactory.hxx> -#include <rtl/ustrbuf.hxx> +#include <rtl/instance.hxx> #include <rtl/strbuf.hxx> +#include <rtl/ustrbuf.hxx> #include <com/sun/star/script/ArrayWrapper.hpp> #include <com/sun/star/script/NativeObjectWrapper.hpp> @@ -530,32 +531,35 @@ struct ObjectItem : m_xNativeObj( pNativeObj ) {} }; -static std::vector< ObjectItem > GaNativeObjectWrapperVector; + +typedef std::vector< ObjectItem > NativeObjectWrapperVector; +class GaNativeObjectWrapperVector : public rtl::Static<NativeObjectWrapperVector, GaNativeObjectWrapperVector> {}; void clearNativeObjectWrapperVector( void ) { - GaNativeObjectWrapperVector.clear(); + GaNativeObjectWrapperVector::get().clear(); } sal_uInt32 lcl_registerNativeObjectWrapper( SbxObject* pNativeObj ) { - sal_uInt32 nIndex = GaNativeObjectWrapperVector.size(); - GaNativeObjectWrapperVector.push_back( ObjectItem( pNativeObj ) ); + NativeObjectWrapperVector &rNativeObjectWrapperVector = GaNativeObjectWrapperVector::get(); + sal_uInt32 nIndex = rNativeObjectWrapperVector.size(); + rNativeObjectWrapperVector.push_back( ObjectItem( pNativeObj ) ); return nIndex; } SbxObject* lcl_getNativeObject( sal_uInt32 nIndex ) { SbxObjectRef xRetObj; - if( nIndex < GaNativeObjectWrapperVector.size() ) + NativeObjectWrapperVector &rNativeObjectWrapperVector = GaNativeObjectWrapperVector::get(); + if( nIndex < rNativeObjectWrapperVector.size() ) { - ObjectItem& rItem = GaNativeObjectWrapperVector[ nIndex ]; + ObjectItem& rItem = rNativeObjectWrapperVector[ nIndex ]; xRetObj = rItem.m_xNativeObj; } return xRetObj; } - // convert from Uno to Sbx SbxDataType unoToSbxType( TypeClass eType ) { diff --git a/basic/source/runtime/step0.cxx b/basic/source/runtime/step0.cxx index d2bc2d5b4669..9a48a9beafbb 100644 --- a/basic/source/runtime/step0.cxx +++ b/basic/source/runtime/step0.cxx @@ -30,6 +30,7 @@ #include "image.hxx" #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/util/SearchOptions.hpp> +#include <rtl/instance.hxx> #include <vcl/svapp.hxx> #include <unotools/textsearch.hxx> @@ -459,13 +460,14 @@ struct SbxVariablePtrHash typedef boost::unordered_map< SbxVariable*, DimAsNewRecoverItem, SbxVariablePtrHash > DimAsNewRecoverHash; -static DimAsNewRecoverHash GaDimAsNewRecoverHash; +class GaDimAsNewRecoverHash : public rtl::Static<DimAsNewRecoverHash, GaDimAsNewRecoverHash> {}; void removeDimAsNewRecoverItem( SbxVariable* pVar ) { - DimAsNewRecoverHash::iterator it = GaDimAsNewRecoverHash.find( pVar ); - if( it != GaDimAsNewRecoverHash.end() ) - GaDimAsNewRecoverHash.erase( it ); + DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get(); + DimAsNewRecoverHash::iterator it = rDimAsNewRecoverHash.find( pVar ); + if( it != rDimAsNewRecoverHash.end() ) + rDimAsNewRecoverHash.erase( it ); } @@ -620,8 +622,9 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b if( xPrevVarObj.Is() ) { // Object is overwritten with NULL, instantiate init object - DimAsNewRecoverHash::iterator it = GaDimAsNewRecoverHash.find( refVar ); - if( it != GaDimAsNewRecoverHash.end() ) + DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get(); + DimAsNewRecoverHash::iterator it = rDimAsNewRecoverHash.find( refVar ); + if( it != rDimAsNewRecoverHash.end() ) { const DimAsNewRecoverItem& rItem = it->second; if( rItem.m_pClassModule != NULL ) @@ -654,15 +657,16 @@ void SbiRuntime::StepSET_Impl( SbxVariableRef& refVal, SbxVariableRef& refVar, b String aObjClass = pValObj->GetClassName(); SbClassModuleObject* pClassModuleObj = PTR_CAST(SbClassModuleObject,pValObjBase); + DimAsNewRecoverHash &rDimAsNewRecoverHash = GaDimAsNewRecoverHash::get(); if( pClassModuleObj != NULL ) { SbModule* pClassModule = pClassModuleObj->getClassModule(); - GaDimAsNewRecoverHash[refVar] = + rDimAsNewRecoverHash[refVar] = DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), pClassModule ); } else if( aObjClass.EqualsIgnoreCaseAscii( "Collection" ) ) { - GaDimAsNewRecoverHash[refVar] = + rDimAsNewRecoverHash[refVar] = DimAsNewRecoverItem( aObjClass, pValObj->GetName(), pValObj->GetParent(), NULL ); } } |