1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_svl.hxx" 26 27 #include <map> 28 #include <tools/resmgr.hxx> 29 #include <tools/shl.hxx> 30 #include <vos/process.hxx> 31 #include <svl/svldata.hxx> 32 33 namespace unnamed_svl_svldata {} 34 using namespace unnamed_svl_svldata; 35 // unnamed namespaces don't work well yet 36 37 //============================================================================ 38 namespace unnamed_svl_svldata { 39 40 typedef std::map< rtl::OUString, SimpleResMgr * > SimpleResMgrMap; 41 42 } 43 44 //============================================================================ 45 // 46 // ImpSvlData 47 // 48 //============================================================================ 49 50 static ImpSvlData* pSvlData = 0; 51 ~ImpSvlData()52ImpSvlData::~ImpSvlData() 53 { 54 for (SimpleResMgrMap::iterator t 55 = static_cast< SimpleResMgrMap * >(m_pThreadsafeRMs)->begin(); 56 t != static_cast< SimpleResMgrMap * >(m_pThreadsafeRMs)->end(); ++t) 57 delete t->second; 58 delete static_cast< SimpleResMgrMap * >(m_pThreadsafeRMs); 59 } 60 61 //============================================================================ GetSimpleRM(const::com::sun::star::lang::Locale & rLocale)62SimpleResMgr* ImpSvlData::GetSimpleRM(const ::com::sun::star::lang::Locale& rLocale) 63 { 64 if (!m_pThreadsafeRMs) 65 m_pThreadsafeRMs = new SimpleResMgrMap; 66 rtl::OUString aISOcode = rLocale.Language; 67 aISOcode += rtl::OStringToOUString("-", RTL_TEXTENCODING_UTF8); 68 aISOcode += rLocale.Country; 69 70 SimpleResMgr *& rResMgr 71 = (*static_cast< SimpleResMgrMap * >(m_pThreadsafeRMs))[aISOcode]; 72 if (!rResMgr) 73 { 74 rResMgr = new SimpleResMgr(CREATEVERSIONRESMGR_NAME(svl), rLocale ); 75 } 76 return rResMgr; 77 } 78 79 //============================================================================ 80 // static GetSvlData()81ImpSvlData & ImpSvlData::GetSvlData() 82 { 83 if (!pSvlData) 84 pSvlData= new ImpSvlData; 85 return *pSvlData; 86 } 87 88