Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_FRAMEWORK_INC_UIFACTORY_CONFIGURATIONACCESSFACTORYMANAGER_HXX
21 : #define INCLUDED_FRAMEWORK_INC_UIFACTORY_CONFIGURATIONACCESSFACTORYMANAGER_HXX
22 :
23 : #include <sal/config.h>
24 :
25 : #include <com/sun/star/beans/PropertyValue.hpp>
26 : #include <com/sun/star/container/XContainerListener.hpp>
27 : #include <com/sun/star/container/XNameAccess.hpp>
28 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 : #include <com/sun/star/uno/XComponentContext.hpp>
30 :
31 : #include <cppuhelper/implbase1.hxx>
32 : #include <rtl/ustring.hxx>
33 :
34 : #include <unordered_map>
35 :
36 : namespace framework {
37 :
38 : class ConfigurationAccess_FactoryManager : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
39 : {
40 : public:
41 : ConfigurationAccess_FactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext, const OUString& _sRoot );
42 : virtual ~ConfigurationAccess_FactoryManager();
43 :
44 : void readConfigurationData();
45 :
46 : OUString getFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule ) const;
47 : void addFactorySpecifierToTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule, const OUString& aServiceSpecifier );
48 : void removeFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule );
49 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > getFactoriesDescription() const;
50 :
51 : // container.XContainerListener
52 : virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
53 : virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
54 : virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
55 :
56 : // lang.XEventListener
57 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
58 :
59 : private:
60 222 : class FactoryManagerMap : public std::unordered_map<OUString,
61 : OUString,
62 : OUStringHash,
63 : std::equal_to< OUString > >
64 : {
65 : inline void free()
66 : {
67 : FactoryManagerMap().swap( *this );// get rid of reserved capacity
68 : }
69 : };
70 :
71 : bool impl_getElementProps( const ::com::sun::star::uno::Any& rElement, OUString& rType, OUString& rName, OUString& rModule, OUString& rServiceSpecifier ) const;
72 :
73 : mutable osl::Mutex m_aMutex;
74 : OUString m_aPropType;
75 : OUString m_aPropName;
76 : OUString m_aPropModule;
77 : OUString m_aPropFactory;
78 : OUString m_sRoot;
79 : FactoryManagerMap m_aFactoryManagerMap;
80 : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider;
81 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xConfigAccess;
82 : ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xConfigListener;
83 : bool m_bConfigAccessInitialized;
84 : };
85 :
86 : } // namespace framework
87 :
88 : #endif // INCLUDED_FRAMEWORK_INC_UIFACTORY_CONFIGURATIONACCESSFACTORYMANAGER_HXX
89 :
90 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|