Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #ifndef EXTENSIONS_RESOURCE_OOORESOURCELOADER_HXX
31 : : #define EXTENSIONS_RESOURCE_OOORESOURCELOADER_HXX
32 : :
33 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 : : #include <com/sun/star/resource/XResourceBundleLoader.hpp>
35 : : #include <com/sun/star/uno/XComponentContext.hpp>
36 : : #include <cppuhelper/implbase1.hxx>
37 : :
38 : : #include <functional>
39 : : #include <map>
40 : : #include <utility>
41 : :
42 : : namespace extensions { namespace resource
43 : : {
44 : : typedef ::std::pair< ::rtl::OUString, ::com::sun::star::lang::Locale> ResourceBundleDescriptor;
45 : :
46 : : struct ResourceBundleDescriptorLess : public ::std::binary_function<ResourceBundleDescriptor, ResourceBundleDescriptor, bool>
47 : : {
48 : 4 : bool operator()( const ResourceBundleDescriptor& _lhs, const ResourceBundleDescriptor& _rhs ) const
49 : : {
50 [ - + ]: 4 : if ( _lhs.first < _rhs.first )
51 : 0 : return true;
52 [ - + ]: 4 : if ( _lhs.second.Language < _rhs.second.Language )
53 : 0 : return true;
54 [ - + ]: 4 : if ( _lhs.second.Country < _rhs.second.Country )
55 : 0 : return true;
56 [ - + ]: 4 : if ( _lhs.second.Variant < _rhs.second.Variant )
57 : 0 : return true;
58 : 4 : return false;
59 : : }
60 : : };
61 : :
62 [ + - ][ - + ]: 4 : class OpenOfficeResourceLoader : public ::cppu::WeakImplHelper1< ::com::sun::star::resource::XResourceBundleLoader>
63 : : {
64 : : public:
65 : : typedef ::std::map<
66 : : ResourceBundleDescriptor,
67 : : ::com::sun::star::uno::WeakReference< ::com::sun::star::resource::XResourceBundle>,
68 : : ResourceBundleDescriptorLess> ResourceBundleCache;
69 : :
70 : : OpenOfficeResourceLoader(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const&);
71 : : // XResourceBundleLoader
72 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::resource::XResourceBundle> SAL_CALL loadBundle_Default( const ::rtl::OUString& aBaseName ) throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException);
73 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::resource::XResourceBundle> SAL_CALL loadBundle( const ::rtl::OUString& abaseName, const ::com::sun::star::lang::Locale& aLocale ) throw (::com::sun::star::resource::MissingResourceException, ::com::sun::star::uno::RuntimeException);
74 : :
75 : : private:
76 : : OpenOfficeResourceLoader(); // never implemented
77 : : OpenOfficeResourceLoader( const OpenOfficeResourceLoader& ); // never implemented
78 : : OpenOfficeResourceLoader& operator=( const OpenOfficeResourceLoader& ); // never implemented
79 : : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext;
80 : : ::osl::Mutex m_aMutex;
81 : : ResourceBundleCache m_aBundleCache;
82 : : };
83 : : }}
84 : :
85 : : #endif // EXTENSIONS_RESOURCE_OOORESOURCELOADER_HXX
86 : :
87 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|