update credits
[LibreOffice.git] / framework / inc / uifactory / uielementfactorymanager.hxx
blobd9fddc4cbc959635fac8a2c146b2613cc6aaadfd
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 __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
21 #define __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
23 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
24 with solaris headers ...
26 #include <vector>
27 #include <list>
29 #include <threadhelp/threadhelpbase.hxx>
30 #include <macros/generic.hxx>
31 #include <macros/xinterface.hxx>
32 #include <macros/xtypeprovider.hxx>
33 #include <macros/xserviceinfo.hxx>
34 #include <stdtypes.h>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/ui/XUIElementFactoryManager.hpp>
38 #include <com/sun/star/container/XContainerListener.hpp>
39 #include <com/sun/star/container/XNameAccess.hpp>
40 #include "com/sun/star/frame/XModuleManager2.hpp"
42 #include <cppuhelper/implbase1.hxx>
43 #include <cppuhelper/implbase2.hxx>
44 #include <rtl/ustring.hxx>
46 namespace framework
49 class ConfigurationAccess_FactoryManager : // interfaces
50 // baseclasses
51 // Order is necessary for right initialization!
52 private ThreadHelpBase ,
53 public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
55 public:
56 ConfigurationAccess_FactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& rxContext, const OUString& _sRoot );
57 virtual ~ConfigurationAccess_FactoryManager();
59 void readConfigurationData();
61 OUString getFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule ) const;
62 void addFactorySpecifierToTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule, const OUString& aServiceSpecifier );
63 void removeFactorySpecifierFromTypeNameModule( const OUString& rType, const OUString& rName, const OUString& rModule );
64 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > getFactoriesDescription() const;
66 // container.XContainerListener
67 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
68 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
69 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
71 // lang.XEventListener
72 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
74 private:
75 class FactoryManagerMap : public boost::unordered_map< OUString,
76 OUString,
77 OUStringHash,
78 ::std::equal_to< OUString > >
80 inline void free()
82 FactoryManagerMap().swap( *this );
86 sal_Bool impl_getElementProps( const ::com::sun::star::uno::Any& rElement, OUString& rType, OUString& rName, OUString& rModule, OUString& rServiceSpecifier ) const;
88 OUString m_aPropType;
89 OUString m_aPropName;
90 OUString m_aPropModule;
91 OUString m_aPropFactory;
92 OUString m_sRoot;
93 FactoryManagerMap m_aFactoryManagerMap;
94 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider;
95 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xConfigAccess;
96 ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xConfigListener;
97 sal_Bool m_bConfigAccessInitialized;
101 class UIElementFactoryManager : private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses.
102 public ::cppu::WeakImplHelper2< ::com::sun::star::lang::XServiceInfo,
103 ::com::sun::star::ui::XUIElementFactoryManager>
105 public:
106 UIElementFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext );
107 virtual ~UIElementFactoryManager();
109 // XInterface, XTypeProvider, XServiceInfo
110 DECLARE_XSERVICEINFO
112 // XUIElementFactory
113 virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const OUString& ResourceURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Args ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
115 // XUIElementFactoryRegistration
116 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getRegisteredFactories( ) throw (::com::sun::star::uno::RuntimeException);
117 virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElementFactory > SAL_CALL getFactory( const OUString& ResourceURL, const OUString& ModuleIdentifier ) throw (::com::sun::star::uno::RuntimeException);
118 virtual void SAL_CALL registerFactory( const OUString& aType, const OUString& aName, const OUString& aModuleIdentifier, const OUString& aFactoryImplementationName ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
119 virtual void SAL_CALL deregisterFactory( const OUString& aType, const OUString& aName, const OUString& aModuleIdentifier ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
121 private:
123 sal_Bool m_bConfigRead;
124 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
125 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 > m_xModuleManager;
126 ConfigurationAccess_FactoryManager* m_pConfigAccess;
129 } // namespace framework
131 #endif // __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */