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 #include "core_resource.hxx"
25 #include <tools/simplerm.hxx>
26 
27 // ---- needed as long as we have no contexts for components ---
28 #include <vcl/svapp.hxx>
29 //---------------------------------------------------
30 #include <comphelper/configurationhelper.hxx>
31 #include <osl/thread.h>
32 #include <com/sun/star/util/XMacroExpander.hpp>
33 #include <com/sun/star/beans/XPropertySet.hpp>
34 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <rtl/uri.hxx>
36 
37 #ifndef _SOLAR_HRC
38 #include <svl/solar.hrc>
39 #endif
40 #include "ModuleHelper.hxx"
41 //.........................................................................
42 namespace reportdesign
43 {
44     using namespace ::com::sun::star;
45 	//==================================================================
46 	//= ResourceManager
47 	//==================================================================
48 	SimpleResMgr* ResourceManager::m_pImpl = NULL;
49 
50 	//------------------------------------------------------------------
~EnsureDelete()51 	ResourceManager::EnsureDelete::~EnsureDelete()
52 	{
53 		delete ResourceManager::m_pImpl;
54 	}
55 
56 	//------------------------------------------------------------------
ensureImplExists(const uno::Reference<lang::XMultiComponentFactory> &)57 	void ResourceManager::ensureImplExists(const uno::Reference< lang::XMultiComponentFactory >& /* _rM */)
58 	{
59 		if (!m_pImpl)
60         {
61 			// now that we have an impl class make sure it's deleted on unloading the library
62 			static ResourceManager::EnsureDelete	s_aDeleteTheImplClass;
63 
64             ::com::sun::star::lang::Locale aLocale = Application::GetSettings().GetUILocale();
65 
66             rtl::OString sResLibName = rtl::OString( "rpt" );
67             m_pImpl = SimpleResMgr::Create( sResLibName.getStr(), aLocale);
68         }
69 	}
70 
71 	//------------------------------------------------------------------
loadString(sal_uInt16 _nResId,const uno::Reference<lang::XMultiComponentFactory> & _rM)72 	::rtl::OUString ResourceManager::loadString(sal_uInt16 _nResId,const uno::Reference< lang::XMultiComponentFactory >& _rM)
73 	{
74 		::rtl::OUString sReturn;
75 
76 		ensureImplExists(_rM);
77 		if (m_pImpl)
78 			sReturn = m_pImpl->ReadString(_nResId);
79 
80 		return sReturn;
81 	}
82 
83 //.........................................................................
84 }
85 //.........................................................................
86 
87