1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svtdata.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
35 #include <tools/resmgr.hxx>
36 #include <tools/shl.hxx>
37 #include <vos/process.hxx>
38 #include <svtools/svtdata.hxx>
40 namespace unnamed_svtools_svtdata
{}
41 using namespace unnamed_svtools_svtdata
;
42 // unnamed namespaces don't work well yet
44 //============================================================================
45 namespace unnamed_svtools_svtdata
{
47 typedef std::map
< rtl::OUString
, SimpleResMgr
* > SimpleResMgrMap
;
51 //============================================================================
55 //============================================================================
57 ImpSvtData::~ImpSvtData()
60 for (SimpleResMgrMap::iterator t
61 = static_cast< SimpleResMgrMap
* >(m_pThreadsafeRMs
)->begin();
62 t
!= static_cast< SimpleResMgrMap
* >(m_pThreadsafeRMs
)->end(); ++t
)
64 delete static_cast< SimpleResMgrMap
* >(m_pThreadsafeRMs
);
67 //============================================================================
68 ResMgr
* ImpSvtData::GetResMgr(const ::com::sun::star::lang::Locale aLocale
)
72 pResMgr
= ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(svt
), aLocale
);
77 //============================================================================
78 SimpleResMgr
* ImpSvtData::GetSimpleRM(const ::com::sun::star::lang::Locale
& rLocale
)
80 if (!m_pThreadsafeRMs
)
81 m_pThreadsafeRMs
= new SimpleResMgrMap
;
82 rtl::OUString aISOcode
= rLocale
.Language
;
83 aISOcode
+= rtl::OStringToOUString("-", RTL_TEXTENCODING_UTF8
);
84 aISOcode
+= rLocale
.Country
;
86 SimpleResMgr
*& rResMgr
87 = (*static_cast< SimpleResMgrMap
* >(m_pThreadsafeRMs
))[aISOcode
];
90 rResMgr
= new SimpleResMgr(CREATEVERSIONRESMGR_NAME(svs
), rLocale
);
95 ResMgr
* ImpSvtData::GetPatchResMgr(const ::com::sun::star::lang::Locale
& aLocale
)
99 pPatchResMgr
= ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(svp
), aLocale
);
104 //============================================================================
106 ImpSvtData
& ImpSvtData::GetSvtData()
108 void ** pAppData
= GetAppData(SHL_SVT
);
110 *pAppData
= new ImpSvtData
;
111 return *static_cast<ImpSvtData
*>(*pAppData
);