basic/source/runtime/basrdll.cxx | 19 +++++---- idl/inc/globals.hxx | 9 +--- idl/source/cmptools/lex.cxx | 4 - idl/source/prj/command.cxx | 13 +----- idl/source/prj/database.cxx | 2 idl/source/prj/globals.cxx | 21 +++++----- idl/source/prj/svidl.cxx | 1 include/basic/basrdll.hxx | 2 include/svx/svdetc.hxx | 10 ---- include/tools/shl.hxx | 8 +-- svx/source/svdraw/svdetc.cxx | 9 ++++ sw/qa/extras/uiwriter/uiwriter.cxx | 4 - tools/source/ref/errinf.cxx | 77 +++++++++++++------------------------ 13 files changed, 79 insertions(+), 100 deletions(-)
New commits: commit f9663211b6a452b45242786eeed227c0779fba9b Author: Stephan Bergmann <[email protected]> Date: Tue Jul 7 07:47:52 2015 +0200 loplugin:stringconstant Change-Id: I2908fc052d44a8bddf8ebb628f67ce346ac519c7 diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx index 8bbf6eb..d3c6272 100644 --- a/sw/qa/extras/uiwriter/uiwriter.cxx +++ b/sw/qa/extras/uiwriter/uiwriter.cxx @@ -1010,8 +1010,8 @@ void SwUiWriterTest::testTdf81995() { uno::Reference<text::XDefaultNumberingProvider> xDefNum(m_xSFactory->createInstance("com.sun.star.text.DefaultNumberingProvider"), uno::UNO_QUERY); com::sun::star::lang::Locale alocale; - alocale.Language = OUString("en"); - alocale.Country = OUString("US"); + alocale.Language = "en"; + alocale.Country = "US"; uno::Sequence<uno::Reference<container::XIndexAccess>> aIndexAccess(xDefNum->getDefaultOutlineNumberings(alocale)); CPPUNIT_ASSERT_EQUAL(sal_Int32(8), aIndexAccess.getLength()); for(int i=0;i<aIndexAccess.getLength();i++) commit e69fd541ca4fd542f7e39ca8a1dd9cc113b95be2 Author: Stephan Bergmann <[email protected]> Date: Mon Jul 6 23:15:00 2015 +0200 Replace GetAppData(SHL_IDL) with a static pointer var Change-Id: Ia1e22ff95457a958ef26974091aa2092b32505bd diff --git a/basic/source/runtime/basrdll.cxx b/basic/source/runtime/basrdll.cxx index e02c0f67..e10b7b3 100644 --- a/basic/source/runtime/basrdll.cxx +++ b/basic/source/runtime/basrdll.cxx @@ -17,7 +17,6 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <tools/shl.hxx> #include <vcl/svapp.hxx> #include <svl/solar.hrc> #include <tools/debug.hxx> @@ -46,15 +45,21 @@ struct BasicDLL::Impl { } }; +namespace { + +BasicDLL * BASIC_DLL; + +} + BasResId::BasResId( sal_uInt32 nId ) : - ResId( nId, *(BASIC_DLL()->GetBasResMgr()) ) + ResId( nId, *(BASIC_DLL->GetBasResMgr()) ) { } BasicDLL::BasicDLL() : m_xImpl(new Impl) { - BASIC_DLL() = this; + BASIC_DLL = this; } BasicDLL::~BasicDLL() @@ -65,7 +70,7 @@ ResMgr* BasicDLL::GetBasResMgr() const { return m_xImpl->xBasResMgr.get(); } void BasicDLL::EnableBreak( bool bEnable ) { - BasicDLL* pThis = BASIC_DLL(); + BasicDLL* pThis = BASIC_DLL; DBG_ASSERT( pThis, "BasicDLL::EnableBreak: No instance yet!" ); if ( pThis ) { @@ -75,7 +80,7 @@ void BasicDLL::EnableBreak( bool bEnable ) void BasicDLL::SetDebugMode( bool bDebugMode ) { - BasicDLL* pThis = BASIC_DLL(); + BasicDLL* pThis = BASIC_DLL; DBG_ASSERT( pThis, "BasicDLL::EnableBreak: No instance yet!" ); if ( pThis ) { @@ -86,7 +91,7 @@ void BasicDLL::SetDebugMode( bool bDebugMode ) void BasicDLL::BasicBreak() { - BasicDLL* pThis = BASIC_DLL(); + BasicDLL* pThis = BASIC_DLL; DBG_ASSERT( pThis, "BasicDLL::EnableBreak: No instance yet!" ); if ( pThis ) { @@ -106,7 +111,7 @@ void BasicDLL::BasicBreak() SbxAppData& GetSbxData_Impl() { - return *BASIC_DLL()->m_xImpl->xSbxAppData; + return *BASIC_DLL->m_xImpl->xSbxAppData; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/basic/basrdll.hxx b/include/basic/basrdll.hxx index 159e856..623ec6a 100644 --- a/include/basic/basrdll.hxx +++ b/include/basic/basrdll.hxx @@ -43,8 +43,6 @@ public: static void SetDebugMode( bool bDebugMode ); }; -#define BASIC_DLL() (*reinterpret_cast<BasicDLL**>(GetAppData( SHL_BASIC )) ) - #endif // INCLUDED_BASIC_BASRDLL_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/tools/shl.hxx b/include/tools/shl.hxx index c310c55..db6693c 100644 --- a/include/tools/shl.hxx +++ b/include/tools/shl.hxx @@ -47,7 +47,7 @@ //20 (SHL_IDE) removed //21 (SHL_EDIT) removed //22 (SHL_VCED) removed -#define SHL_BASIC 23 +//23 (SHL_BASIC) removed //24 (SHL_HELP) removed //25 (SHL_LNKCCH) removed //26 (SHL_CHANNEL) removed commit e294fa9283071cb2816b6d8c759ed76ee552410e Author: Stephan Bergmann <[email protected]> Date: Mon Jul 6 23:10:38 2015 +0200 Replace GetAppData(SHL_IDL) with an rtl::Static Change-Id: Ia7a75c4686734aa811006858343666d2edfde8a1 diff --git a/idl/inc/globals.hxx b/idl/inc/globals.hxx index 3569d97..014aac7 100644 --- a/idl/inc/globals.hxx +++ b/idl/inc/globals.hxx @@ -125,13 +125,12 @@ public: ~IdlDll(); }; -IdlDll * GetIdlApp(); -#define IDLAPP GetIdlApp() +IdlDll & GetIdlApp(); #define SV_GLOBAL_HASH_ACCESS( Name ) \ - if( !IDLAPP->pGlobalNames ) \ - IDLAPP->pGlobalNames = new SvGlobalHashNames(); \ - return IDLAPP->pGlobalNames->MM_##Name; + if( !GetIdlApp().pGlobalNames ) \ + GetIdlApp().pGlobalNames = new SvGlobalHashNames(); \ + return GetIdlApp().pGlobalNames->MM_##Name; #define HASH_INLINE( Name ) \ inline SvStringHashEntry * SvHash_##Name() { SV_GLOBAL_HASH_ACCESS( Name ) } diff --git a/idl/source/cmptools/lex.cxx b/idl/source/cmptools/lex.cxx index ef60694..571f4c1 100644 --- a/idl/source/cmptools/lex.cxx +++ b/idl/source/cmptools/lex.cxx @@ -342,8 +342,8 @@ bool SvTokenStream::MakeToken( SvToken & rToken ) else { sal_uInt32 nHashId; - if( IDLAPP->pHashTable->Test( aStr, &nHashId ) ) - rToken.SetHash( IDLAPP->pHashTable->Get( nHashId ) ); + if( GetIdlApp().pHashTable->Test( aStr, &nHashId ) ) + rToken.SetHash( GetIdlApp().pHashTable->Get( nHashId ) ); else { rToken.nType = SVTOKEN_IDENTIFIER; diff --git a/idl/source/prj/command.cxx b/idl/source/prj/command.cxx index 39c1bc4..44dd491 100644 --- a/idl/source/prj/command.cxx +++ b/idl/source/prj/command.cxx @@ -116,15 +116,10 @@ char CommandLineSyntax[] = void Init() { - if( !IDLAPP->pHashTable ) - IDLAPP->pHashTable = new SvStringHashTable( 2801 ); - if( !IDLAPP->pGlobalNames ) - IDLAPP->pGlobalNames = new SvGlobalHashNames(); -} - -void DeInit() -{ - delete IDLAPP; + if( !GetIdlApp().pHashTable ) + GetIdlApp().pHashTable = new SvStringHashTable( 2801 ); + if( !GetIdlApp().pGlobalNames ) + GetIdlApp().pGlobalNames = new SvGlobalHashNames(); } bool ReadIdl( SvIdlWorkingBase * pDataBase, const SvCommand & rCommand ) diff --git a/idl/source/prj/database.cxx b/idl/source/prj/database.cxx index 865332f..0aba117 100644 --- a/idl/source/prj/database.cxx +++ b/idl/source/prj/database.cxx @@ -531,7 +531,7 @@ void SvIdlDataBase::WriteError( SvTokenStream & rInStm ) } if( pTok && pTok->IsIdentifier() ) { - OString aN = IDLAPP->pHashTable->GetNearString( pTok->GetString() ); + OString aN = GetIdlApp().pHashTable->GetNearString( pTok->GetString() ); if( !aN.isEmpty() ) fprintf( stderr, "%s versus %s\n", pTok->GetString().getStr(), aN.getStr() ); } diff --git a/idl/source/prj/globals.cxx b/idl/source/prj/globals.cxx index 38b2d16..b36b845 100644 --- a/idl/source/prj/globals.cxx +++ b/idl/source/prj/globals.cxx @@ -17,19 +17,20 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ - -#include <tools/shl.hxx> +#include <sal/config.h> #include <globals.hxx> #include <database.hxx> -IdlDll * GetIdlApp() +namespace { + +struct TheIdlDll: public rtl::Static<IdlDll, TheIdlDll> {}; + +} + +IdlDll & GetIdlApp() { - if( !(*reinterpret_cast<IdlDll**>(GetAppData(SHL_IDL))) ) - { - (*reinterpret_cast<IdlDll**>(GetAppData(SHL_IDL))) = new IdlDll(); - } - return (*reinterpret_cast<IdlDll**>(GetAppData(SHL_IDL))); + return TheIdlDll::get(); } IdlDll::IdlDll() @@ -47,8 +48,8 @@ IdlDll::~IdlDll() inline SvStringHashEntry * INS( const OString& rName ) { sal_uInt32 nIdx; - IDLAPP->pHashTable->Insert( rName, &nIdx ); - return IDLAPP->pHashTable->Get( nIdx ); + GetIdlApp().pHashTable->Insert( rName, &nIdx ); + return GetIdlApp().pHashTable->Get( nIdx ); } #define A_ENTRY( Name ) , MM_##Name( INS( #Name ) ) diff --git a/idl/source/prj/svidl.cxx b/idl/source/prj/svidl.cxx index ee1bb85..676dd6f 100644 --- a/idl/source/prj/svidl.cxx +++ b/idl/source/prj/svidl.cxx @@ -211,7 +211,6 @@ int main ( int argc, char ** argv) } delete pDataBase; - DeInit(); if( nExit != 0 ) fprintf( stderr, "svidl terminated with errors\n" ); return nExit; diff --git a/include/tools/shl.hxx b/include/tools/shl.hxx index e4bce55..c310c55 100644 --- a/include/tools/shl.hxx +++ b/include/tools/shl.hxx @@ -43,7 +43,7 @@ //16 (SHL_SFC) removed //17 (SHL_SFX) removed //18 (SHL_SO2) removed -#define SHL_IDL 19 +//19 (SHL_IDL) removed //20 (SHL_IDE) removed //21 (SHL_EDIT) removed //22 (SHL_VCED) removed commit af1be90e528ceeca70ee8f266fc6f6d8682b2c0d Author: Stephan Bergmann <[email protected]> Date: Mon Jul 6 22:58:05 2015 +0200 Replace GetAppData(SHL_SVD) with an rtl::Static Change-Id: Ie1ccffe5461475a0425891861f825aeea149e876 diff --git a/include/svx/svdetc.hxx b/include/svx/svdetc.hxx index 47d1dc6..1b8a97a 100644 --- a/include/svx/svdetc.hxx +++ b/include/svx/svdetc.hxx @@ -24,7 +24,6 @@ #include <editeng/outliner.hxx> #include <svx/svxdllapi.h> #include <tools/link.hxx> -#include <tools/shl.hxx> #include <tools/fract.hxx> #include <vcl/outdev.hxx> @@ -239,14 +238,7 @@ public: OLEObjCache& GetOLEObjCache() { return aOLEObjCache; } }; -inline SdrGlobalData& GetSdrGlobalData() -{ - void** ppAppData=GetAppData(SHL_SVD); - if (*ppAppData==NULL) { - *ppAppData=new SdrGlobalData; - } - return *static_cast<SdrGlobalData*>(*ppAppData); -} +SVX_DLLPUBLIC SdrGlobalData & GetSdrGlobalData(); namespace sdr { diff --git a/include/tools/shl.hxx b/include/tools/shl.hxx index 1e79019..e4bce55 100644 --- a/include/tools/shl.hxx +++ b/include/tools/shl.hxx @@ -38,7 +38,7 @@ //11 (SHL_IPC) removed //12 (SHL_SVX) removed //13 (SHL_ITEM) removed -#define SHL_SVD 14 +//14 (SHL_SVD) removed //15 (SHL_SI) removed //16 (SHL_SFC) removed //17 (SHL_SFX) removed diff --git a/svx/source/svdraw/svdetc.cxx b/svx/source/svdraw/svdetc.cxx index abdb896..76e75f8 100644 --- a/svx/source/svdraw/svdetc.cxx +++ b/svx/source/svdraw/svdetc.cxx @@ -92,6 +92,15 @@ const LocaleDataWrapper* SdrGlobalData::GetLocaleData() return pLocaleData; } +namespace { + +struct TheSdrGlobalData: public rtl::Static<SdrGlobalData, TheSdrGlobalData> {}; + +} + +SdrGlobalData & GetSdrGlobalData() { + return TheSdrGlobalData::get(); +} OLEObjCache::OLEObjCache() { commit 1fd5509aaa7956ecdff5099c52818809ce8d45ed Author: Stephan Bergmann <[email protected]> Date: Mon Jul 6 22:49:48 2015 +0200 Replace GetAppData(SHL_ERR) with an rtl::Static Change-Id: I3932afa803ceb6429d4e5cf63af59131307d5c6e diff --git a/include/tools/shl.hxx b/include/tools/shl.hxx index 4da6400..1e79019 100644 --- a/include/tools/shl.hxx +++ b/include/tools/shl.hxx @@ -34,7 +34,7 @@ // 7 (SHL_SV) removed // 8 (SHL_SVT) removed #define SHL_SVDDE 9 -#define SHL_ERR 10 +// 10 (SHL_ERR) removed //11 (SHL_IPC) removed //12 (SHL_SVX) removed //13 (SHL_ITEM) removed diff --git a/tools/source/ref/errinf.cxx b/tools/source/ref/errinf.cxx index 5952601de..34ebe20 100644 --- a/tools/source/ref/errinf.cxx +++ b/tools/source/ref/errinf.cxx @@ -18,7 +18,6 @@ */ #include <limits.h> -#include <tools/shl.hxx> #include <tools/debug.hxx> #include <tools/errinf.hxx> #include <rtl/strbuf.hxx> @@ -42,10 +41,10 @@ public: DynamicErrorInfo *ppDcr[ERRCODE_DYNAMIC_COUNT]; sal_uInt16 nNextDcr; EDcrData(); - -static EDcrData *GetData(); }; +struct TheEDcrData: public rtl::Static<EDcrData, TheEDcrData> {}; + class EDcr_Impl { sal_uIntPtr lErrId; @@ -70,40 +69,27 @@ EDcrData::EDcrData() ppDcr[n]=0; } -EDcrData *EDcrData::GetData() -{ - EDcrData **ppDat=reinterpret_cast<EDcrData **>(GetAppData(SHL_ERR)); - if(!*ppDat) - { - return (*ppDat=new EDcrData); - } - else - return *ppDat; -} - void EDcr_Impl::RegisterEDcr(DynamicErrorInfo *pDcr) { // Register dynamic identifier - EDcrData* pData=EDcrData::GetData(); - lErrId= (((sal_uIntPtr)pData->nNextDcr + 1) << ERRCODE_DYNAMIC_SHIFT) + + EDcrData& pData=TheEDcrData::get(); + lErrId= (((sal_uIntPtr)pData.nNextDcr + 1) << ERRCODE_DYNAMIC_SHIFT) + pDcr->GetErrorCode(); - DynamicErrorInfo **ppDcr=pData->ppDcr; - sal_uInt16 nNext=pData->nNextDcr; + DynamicErrorInfo **ppDcr=pData.ppDcr; + sal_uInt16 nNext=pData.nNextDcr; if(ppDcr[nNext]) { delete ppDcr[nNext]; } ppDcr[nNext]=pDcr; - if(++pData->nNextDcr>=ERRCODE_DYNAMIC_COUNT) - pData->nNextDcr=0; + if(++pData.nNextDcr>=ERRCODE_DYNAMIC_COUNT) + pData.nNextDcr=0; } void EDcr_Impl::UnRegisterEDcr(DynamicErrorInfo *pDcr) { - - EDcrData* pData=EDcrData::GetData(); - DynamicErrorInfo **ppDcr=pData->ppDcr; + DynamicErrorInfo **ppDcr=TheEDcrData::get().ppDcr; sal_uIntPtr lIdx=( ((sal_uIntPtr)(*pDcr) & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1; DBG_ASSERT(ppDcr[lIdx]==pDcr,"ErrHdl: Error nicht gefunden"); @@ -147,7 +133,7 @@ DynamicErrorInfo::~DynamicErrorInfo() ErrorInfo* EDcr_Impl::GetDynamicErrorInfo(sal_uIntPtr lId) { sal_uIntPtr lIdx=((lId & ERRCODE_DYNAMIC_MASK)>>ERRCODE_DYNAMIC_SHIFT)-1; - DynamicErrorInfo* pDcr=EDcrData::GetData()->ppDcr[lIdx]; + DynamicErrorInfo* pDcr=TheEDcrData::get().ppDcr[lIdx]; if(pDcr && (sal_uIntPtr)(*pDcr)==lId) return pDcr; else @@ -192,8 +178,7 @@ struct ErrorContextImpl ErrorContext::ErrorContext(vcl::Window *pWinP) { pImpl = new ErrorContextImpl(); - EDcrData *pData=EDcrData::GetData(); - ErrorContext *&pHdl = pData->pFirstCtx; + ErrorContext *&pHdl = TheEDcrData::get().pFirstCtx; pImpl->pWin = pWinP; pImpl->pNext = pHdl; pHdl = this; @@ -201,7 +186,7 @@ ErrorContext::ErrorContext(vcl::Window *pWinP) ErrorContext::~ErrorContext() { - ErrorContext **ppCtx=&(EDcrData::GetData()->pFirstCtx); + ErrorContext **ppCtx=&(TheEDcrData::get().pFirstCtx); while(*ppCtx && *ppCtx!=this) ppCtx=&((*ppCtx)->pImpl->pNext); if(*ppCtx) @@ -211,23 +196,23 @@ ErrorContext::~ErrorContext() ErrorContext *ErrorContext::GetContext() { - return EDcrData::GetData()->pFirstCtx; + return TheEDcrData::get().pFirstCtx; } ErrorHandler::ErrorHandler() { pImpl=new ErrHdl_Impl; - EDcrData *pData=EDcrData::GetData(); - ErrorHandler *&pHdl=pData->pFirstHdl; + EDcrData &pData=TheEDcrData::get(); + ErrorHandler *&pHdl=pData.pFirstHdl; pImpl->pNext=pHdl; pHdl=this; - if(!pData->pDsp) + if(!pData.pDsp) RegisterDisplay(&aDspFunc); } ErrorHandler::~ErrorHandler() { - ErrorHandler **ppHdl=&(EDcrData::GetData()->pFirstHdl); + ErrorHandler **ppHdl=&(TheEDcrData::get().pFirstHdl); while(*ppHdl && *ppHdl!=this) ppHdl=&((*ppHdl)->pImpl->pNext); if(*ppHdl) @@ -242,16 +227,16 @@ vcl::Window* ErrorContext::GetParent() void ErrorHandler::RegisterDisplay(WindowDisplayErrorFunc *aDsp) { - EDcrData *pData=EDcrData::GetData(); - pData->bIsWindowDsp=true; - pData->pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); + EDcrData &pData=TheEDcrData::get(); + pData.bIsWindowDsp=true; + pData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); } void ErrorHandler::RegisterDisplay(BasicDisplayErrorFunc *aDsp) { - EDcrData *pData=EDcrData::GetData(); - pData->bIsWindowDsp=false; - pData->pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); + EDcrData &pData=TheEDcrData::get(); + pData.bIsWindowDsp=false; + pData.pDsp = reinterpret_cast< DisplayFnPtr >(aDsp); } /** Handles an error. @@ -279,7 +264,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl( OUString aAction; if(!lId || lId == ERRCODE_ABORT) return 0; - EDcrData *pData=EDcrData::GetData(); + EDcrData &pData=TheEDcrData::get(); ErrorInfo *pInfo=ErrorInfo::GetErrorInfo(lId); ErrorContext *pCtx=ErrorContext::GetContext(); if(pCtx) @@ -308,7 +293,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl( nErrFlags = nDynFlags; } - if(ErrHdl_Impl::CreateString(pData->pFirstHdl,pInfo,aErr,nErrFlags)) + if(ErrHdl_Impl::CreateString(pData.pFirstHdl,pInfo,aErr,nErrFlags)) { if (bJustCreateString) { @@ -317,7 +302,7 @@ sal_uInt16 ErrorHandler::HandleError_Impl( } else { - if(!pData->pDsp) + if(!pData.pDsp) { OStringBuffer aStr("Action: "); aStr.append(OUStringToOString(aAction, RTL_TEXTENCODING_ASCII_US)); @@ -328,16 +313,16 @@ sal_uInt16 ErrorHandler::HandleError_Impl( else { delete pInfo; - if(!pData->bIsWindowDsp) + if(!pData.bIsWindowDsp) { - (*reinterpret_cast<BasicDisplayErrorFunc*>(pData->pDsp))(aErr,aAction); + (*reinterpret_cast<BasicDisplayErrorFunc*>(pData.pDsp))(aErr,aAction); return 0; } else { if (nFlags != USHRT_MAX) nErrFlags = nFlags; - return (*reinterpret_cast<WindowDisplayErrorFunc*>(pData->pDsp))( + return (*reinterpret_cast<WindowDisplayErrorFunc*>(pData.pDsp))( pParent, nErrFlags, aErr, aAction); } } commit 99769c53a11a5cf76158197bfb2d65229245756a Author: Stephan Bergmann <[email protected]> Date: Mon Jul 6 22:41:39 2015 +0200 Unused #ifdef BOOTSTRAP Change-Id: I71b7fba7bb77c9df2befde6dc9629d3cb1586f62 diff --git a/tools/source/ref/errinf.cxx b/tools/source/ref/errinf.cxx index d97c91d..5952601de 100644 --- a/tools/source/ref/errinf.cxx +++ b/tools/source/ref/errinf.cxx @@ -72,9 +72,6 @@ EDcrData::EDcrData() EDcrData *EDcrData::GetData() { -#ifdef BOOTSTRAP - return 0x0; -#else EDcrData **ppDat=reinterpret_cast<EDcrData **>(GetAppData(SHL_ERR)); if(!*ppDat) { @@ -82,7 +79,6 @@ EDcrData *EDcrData::GetData() } else return *ppDat; -#endif } void EDcr_Impl::RegisterEDcr(DynamicErrorInfo *pDcr) _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
