Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / extensions / source / resource / oooresourceloader.hxx
blobdccc2c2a7fd3531c118b996c07515034bd8c7947
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_EXTENSIONS_SOURCE_RESOURCE_OOORESOURCELOADER_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_RESOURCE_OOORESOURCELOADER_HXX
23 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 #include <com/sun/star/resource/XResourceBundleLoader.hpp>
25 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <cppuhelper/implbase.hxx>
28 #include <functional>
29 #include <map>
30 #include <utility>
32 namespace extensions { namespace resource
34 typedef std::pair< OUString, css::lang::Locale> ResourceBundleDescriptor;
36 struct ResourceBundleDescriptorLess : public std::binary_function<ResourceBundleDescriptor, ResourceBundleDescriptor, bool>
38 bool operator()( const ResourceBundleDescriptor& _lhs, const ResourceBundleDescriptor& _rhs ) const
40 if ( _lhs.first < _rhs.first )
41 return true;
42 if ( _lhs.second.Language < _rhs.second.Language )
43 return true;
44 if ( _lhs.second.Country < _rhs.second.Country )
45 return true;
46 if ( _lhs.second.Variant < _rhs.second.Variant )
47 return true;
48 return false;
52 class OpenOfficeResourceLoader : public ::cppu::WeakImplHelper< css::resource::XResourceBundleLoader>
54 public:
55 typedef std::map<
56 ResourceBundleDescriptor,
57 css::uno::WeakReference< css::resource::XResourceBundle>,
58 ResourceBundleDescriptorLess> ResourceBundleCache;
60 OpenOfficeResourceLoader(css::uno::Reference< css::uno::XComponentContext> const&);
61 // XResourceBundleLoader
62 virtual css::uno::Reference< css::resource::XResourceBundle> SAL_CALL loadBundle_Default( const OUString& aBaseName ) override;
63 virtual css::uno::Reference< css::resource::XResourceBundle> SAL_CALL loadBundle( const OUString& abaseName, const css::lang::Locale& aLocale ) override;
65 private:
66 OpenOfficeResourceLoader( const OpenOfficeResourceLoader& ) = delete;
67 OpenOfficeResourceLoader& operator=( const OpenOfficeResourceLoader& ) = delete;
68 css::uno::Reference< css::uno::XComponentContext> m_xContext;
69 ::osl::Mutex m_aMutex;
70 ResourceBundleCache m_aBundleCache;
74 #endif // INCLUDED_EXTENSIONS_SOURCE_RESOURCE_OOORESOURCELOADER_HXX
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */