sw/inc/swtypes.hxx | 8 ++++---- sw/source/core/doc/DocumentStylePoolManager.cxx | 8 ++++---- sw/source/core/doc/SwStyleNameMapper.cxx | 4 ++-- sw/source/core/doc/doclay.cxx | 8 ++++---- sw/source/core/docnode/ndsect.cxx | 2 +- sw/source/core/docnode/ndtbl.cxx | 2 +- sw/source/ui/dialog/swdialmgr.cxx | 16 +++------------- sw/source/ui/dialog/swuiexp.cxx | 2 -- sw/source/uibase/app/swmodule.cxx | 15 ++++++++++++--- sw/source/uibase/utlui/initui.cxx | 4 ++-- 10 files changed, 33 insertions(+), 36 deletions(-)
New commits: commit 3954c5114468b46a6ffd3804feb9fe0a26f95e75 Author: Michael Meeks <michael.me...@collabora.com> Date: Mon Apr 30 13:52:56 2018 +0100 Adapt writer translations dynamically for multiple users. Change-Id: Id152cc2a3e12acf4850b035f3b5dba7b54fa455d Reviewed-on: https://gerrit.libreoffice.org/53661 Reviewed-by: Aron Budea <aron.bu...@collabora.com> Tested-by: Aron Budea <aron.bu...@collabora.com> diff --git a/sw/inc/swtypes.hxx b/sw/inc/swtypes.hxx index d5114cd033c6..977cea446c0f 100644 --- a/sw/inc/swtypes.hxx +++ b/sw/inc/swtypes.hxx @@ -154,10 +154,10 @@ enum RndStdIds RND_DRAW_OBJECT // A draw-Object! For the SwDoc-interface only! }; -extern ResMgr* pSwResMgr; - // defined in sw/source/uibase/app/swmodule.cxx for the sw library and in - // sw/source/ui/dialog/swdialmgr.cxx for the swui library -#define SW_RES(i) ResId(i,*pSwResMgr) +// defined in sw/source/uibase/app/swmodule.cxx for the sw library and in +SW_DLLPUBLIC ResMgr &GetSwResMgr(); + +#define SW_RES(i) ResId(i,GetSwResMgr()) #define SW_RESSTR(i) SW_RES(i).toString() css::uno::Reference< css::linguistic2::XSpellChecker1 > GetSpellChecker(); diff --git a/sw/source/core/doc/DocumentStylePoolManager.cxx b/sw/source/core/doc/DocumentStylePoolManager.cxx index 5e1f71b6c446..65667c887892 100644 --- a/sw/source/core/doc/DocumentStylePoolManager.cxx +++ b/sw/source/core/doc/DocumentStylePoolManager.cxx @@ -322,7 +322,7 @@ SwTextFormatColl* DocumentStylePoolManager::GetTextCollFromPool( sal_uInt16 nId, if( !nResId ) return GetTextCollFromPool( RES_POOLCOLL_STANDARD ); - ResId aResId( nResId + nId, *pSwResMgr ); + ResId aResId( nResId + nId, GetSwResMgr() ); OUString aNm( aResId ); // A Set for all to-be-set Attributes @@ -1145,7 +1145,7 @@ SwFormat* DocumentStylePoolManager::GetFormatFromPool( sal_uInt16 nId ) return pNewFormat; } - ResId aResId( nRCId + nId, *pSwResMgr ); + ResId aResId( nRCId + nId, GetSwResMgr() ); OUString aNm( aResId ); SwAttrSet aSet( m_rDoc.GetAttrPool(), pWhichRange ); @@ -1392,7 +1392,7 @@ SwPageDesc* DocumentStylePoolManager::GetPageDescFromPool( sal_uInt16 nId, bool SwPageDesc* pNewPgDsc = nullptr; { - const ResId aResId( sal_uInt32(RC_POOLPAGEDESC_BEGIN + nId - RES_POOLPAGE_BEGIN), *pSwResMgr ); + const ResId aResId( sal_uInt32(RC_POOLPAGEDESC_BEGIN + nId - RES_POOLPAGE_BEGIN), GetSwResMgr() ); const OUString aNm( aResId ); const bool bIsModified = m_rDoc.getIDocumentState().IsModified(); @@ -1565,7 +1565,7 @@ SwNumRule* DocumentStylePoolManager::GetNumRuleFromPool( sal_uInt16 nId ) nId = RES_POOLNUMRULE_BEGIN; } - ResId aResId( sal_uInt32(RC_POOLNUMRULE_BEGIN + nId - RES_POOLNUMRULE_BEGIN), *pSwResMgr ); + ResId aResId( sal_uInt32(RC_POOLNUMRULE_BEGIN + nId - RES_POOLNUMRULE_BEGIN), GetSwResMgr() ); OUString aNm( aResId ); SwCharFormat *pNumCFormat = nullptr, *pBullCFormat = nullptr; diff --git a/sw/source/core/doc/SwStyleNameMapper.cxx b/sw/source/core/doc/SwStyleNameMapper.cxx index e14379c82429..d0b8417b0c4b 100644 --- a/sw/source/core/doc/SwStyleNameMapper.cxx +++ b/sw/source/core/doc/SwStyleNameMapper.cxx @@ -20,6 +20,7 @@ #include <numeric> #include <tuple> +#include <swtypes.hxx> #include <SwStyleNameMapper.hxx> #include <tools/resmgr.hxx> #include <poolfmt.hxx> @@ -29,7 +30,6 @@ #include <stdlib.h> #endif -extern ResMgr* pSwResMgr; // Initialise UI names to 0 std::vector<OUString> *SwStyleNameMapper::s_pTextUINameArray = nullptr, *SwStyleNameMapper::s_pListsUINameArray = nullptr, @@ -349,7 +349,7 @@ lcl_NewUINameArray(sal_uInt16 nStt, sal_uInt16 const nEnd) pNameArray->reserve(nEnd - nStt); while( nStt < nEnd ) { - const ResId aRId( nStt, *pSwResMgr ); + const ResId aRId( nStt, GetSwResMgr() ); pNameArray->push_back(OUString(aRId)); ++nStt; } diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx index 0f1c560538ab..f94207acda36 100644 --- a/sw/source/core/doc/doclay.cxx +++ b/sw/source/core/doc/doclay.cxx @@ -1282,7 +1282,7 @@ static OUString lcl_GetUniqueFlyName(const SwDoc* pDoc, sal_uInt16 nDefStrId, RE return newName; } - ResId aId( nDefStrId, *pSwResMgr ); + ResId aId( nDefStrId, GetSwResMgr() ); OUString aName( aId ); sal_Int32 nNmLen = aName.getLength(); @@ -1413,9 +1413,9 @@ void SwDoc::SetAllUniqueFlyNames() { sal_Int32 n, nFlyNum = 0, nGrfNum = 0, nOLENum = 0; - ResId nFrameId( STR_FRAME_DEFNAME, *pSwResMgr ), - nGrfId( STR_GRAPHIC_DEFNAME, *pSwResMgr ), - nOLEId( STR_OBJECT_DEFNAME, *pSwResMgr ); + ResId nFrameId( STR_FRAME_DEFNAME, GetSwResMgr() ), + nGrfId( STR_GRAPHIC_DEFNAME, GetSwResMgr() ), + nOLEId( STR_OBJECT_DEFNAME, GetSwResMgr() ); const OUString sFlyNm( nFrameId ); const OUString sGrfNm( nGrfId ); const OUString sOLENm( nOLEId ); diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx index 62d87c8a0144..c81855861ed3 100644 --- a/sw/source/core/docnode/ndsect.cxx +++ b/sw/source/core/docnode/ndsect.cxx @@ -1359,7 +1359,7 @@ OUString SwDoc::GetUniqueSectionName( const OUString* pChkStr ) const return newName; } - const OUString aName( ResId( STR_REGION_DEFNAME, *pSwResMgr ) ); + const OUString aName( ResId( STR_REGION_DEFNAME, GetSwResMgr() ) ); SwSectionFormats::size_type nNum = 0; const SwSectionFormats::size_type nFlagSize = ( mpSectionFormatTable->size() / 8 ) + 2; diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx index 02d1474293c1..ce7f731a3a9d 100644 --- a/sw/source/core/docnode/ndtbl.cxx +++ b/sw/source/core/docnode/ndtbl.cxx @@ -3913,7 +3913,7 @@ OUString SwDoc::GetUniqueTableName() const return newName; } - ResId aId( STR_TABLE_DEFNAME, *pSwResMgr ); + ResId aId( STR_TABLE_DEFNAME, GetSwResMgr() ); const OUString aName( aId ); const size_t nFlagSize = ( mpTableFrameFormatTable->size() / 8 ) + 2; diff --git a/sw/source/ui/dialog/swdialmgr.cxx b/sw/source/ui/dialog/swdialmgr.cxx index 16f11e0ca3c6..81954f7c0434 100644 --- a/sw/source/ui/dialog/swdialmgr.cxx +++ b/sw/source/ui/dialog/swdialmgr.cxx @@ -18,22 +18,12 @@ */ #include "dialmgr.hxx" +#include <swtypes.hxx> #include <tools/resmgr.hxx> -#ifndef DISABLE_DYNLOADING -ResMgr* pSwResMgr=nullptr; -#else -static ResMgr *pSwResMgr; -#endif - -ResMgr* SwDialogsResMgr::GetResMgr() +ResMgr *SwDialogsResMgr::GetResMgr() { - if ( !pSwResMgr ) - { - pSwResMgr = ResMgr::CreateResMgr( "sw" ); - } - - return pSwResMgr; + return &GetSwResMgr(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/dialog/swuiexp.cxx b/sw/source/ui/dialog/swuiexp.cxx index b53ee82b5921..afb699bb1870 100644 --- a/sw/source/ui/dialog/swuiexp.cxx +++ b/sw/source/ui/dialog/swuiexp.cxx @@ -53,8 +53,6 @@ namespace swui { if ( !pFactory ) pFactory = new SwAbstractDialogFactory_Impl; - if ( !pSwResMgr) - SwDialogsResMgr::GetResMgr(); return pFactory; } } diff --git a/sw/source/uibase/app/swmodule.cxx b/sw/source/uibase/app/swmodule.cxx index 48f94c8aad83..2edfc5bd25ed 100644 --- a/sw/source/uibase/app/swmodule.cxx +++ b/sw/source/uibase/app/swmodule.cxx @@ -125,7 +125,6 @@ #include <app.hrc> #include <svx/xmlsecctrl.hxx> -ResMgr *pSwResMgr = nullptr; bool g_bNoInterrupt = false; #include <sfx2/app.hxx> @@ -138,6 +137,17 @@ bool g_bNoInterrupt = false; using namespace com::sun::star; +ResMgr & GetSwResMgr() +{ + // not threadsafe + static std::unique_ptr<ResMgr> pResourceManager; + const LanguageTag& rLocale = Application::GetSettings().GetUILanguageTag(); + if( ! pResourceManager || pResourceManager->GetLocale() != rLocale ) + pResourceManager.reset( ResMgr::CreateResMgr("sw", rLocale) ); + OSL_ASSERT( pResourceManager ); + return *pResourceManager.get(); +} + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -169,12 +179,11 @@ SwModule::SwModule( SfxObjectFactory* pWebFact, m_pXSelection( nullptr ) { SetName( "StarWriter" ); - pSwResMgr = GetResMgr(); SvxErrorHandler::ensure(); m_pErrorHandler = new SfxErrorHandler( RID_SW_ERRHDL, ERRCODE_AREA_SW, ERRCODE_AREA_SW_END, - pSwResMgr ); + &GetSwResMgr() ); m_pModuleConfig = new SwModuleOptions; diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx index 5829a7a9bedc..ee364a1762d2 100644 --- a/sw/source/uibase/utlui/initui.cxx +++ b/sw/source/uibase/utlui/initui.cxx @@ -284,11 +284,11 @@ void ShellResource::GetAutoFormatNameLst_() const } ImpAutoFormatNameListLoader::ImpAutoFormatNameListLoader( std::vector<OUString>& rLst ) - : Resource( ResId(RID_SHELLRES_AUTOFMTSTRS, *pSwResMgr) ) + : Resource( ResId(RID_SHELLRES_AUTOFMTSTRS, GetSwResMgr()) ) { for( sal_uInt16 n = 0; n < STR_AUTOFMTREDL_END; ++n ) { - OUString p(ResId(n + 1, *pSwResMgr)); + OUString p(ResId(n + 1, GetSwResMgr())); if(STR_AUTOFMTREDL_TYPO == n) { #ifdef _WIN32 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits