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 : : #ifndef __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
30 : : #define __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
31 : :
32 : : /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
33 : : with solaris headers ...
34 : : */
35 : : #include <vector>
36 : : #include <list>
37 : :
38 : : #include <threadhelp/threadhelpbase.hxx>
39 : : #include <macros/generic.hxx>
40 : : #include <macros/xinterface.hxx>
41 : : #include <macros/xtypeprovider.hxx>
42 : : #include <macros/xserviceinfo.hxx>
43 : : #include <stdtypes.h>
44 : :
45 : : #include <com/sun/star/lang/XServiceInfo.hpp>
46 : : #include <com/sun/star/ui/XUIElementFactory.hpp>
47 : : #include <com/sun/star/ui/XUIElementFactoryRegistration.hpp>
48 : : #include <com/sun/star/container/XContainerListener.hpp>
49 : : #include <com/sun/star/container/XNameAccess.hpp>
50 : : #include "com/sun/star/frame/XModuleManager.hpp"
51 : :
52 : : #include <cppuhelper/implbase1.hxx>
53 : : #include <cppuhelper/implbase3.hxx>
54 : : #include <rtl/ustring.hxx>
55 : :
56 : : namespace framework
57 : : {
58 : :
59 : : class ConfigurationAccess_FactoryManager : // interfaces
60 : : // baseclasses
61 : : // Order is neccessary for right initialization!
62 : : private ThreadHelpBase ,
63 : : public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
64 : : {
65 : : public:
66 : : ConfigurationAccess_FactoryManager( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager,const ::rtl::OUString& _sRoot );
67 : : virtual ~ConfigurationAccess_FactoryManager();
68 : :
69 : : void readConfigurationData();
70 : :
71 : : rtl::OUString getFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule ) const;
72 : : void addFactorySpecifierToTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule, const rtl::OUString& aServiceSpecifier );
73 : : void removeFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule );
74 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > getFactoriesDescription() const;
75 : :
76 : : // container.XContainerListener
77 : : virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
78 : : virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
79 : : virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
80 : :
81 : : // lang.XEventListener
82 : : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
83 : :
84 : : private:
85 [ + - ]: 216 : class FactoryManagerMap : public boost::unordered_map< rtl::OUString,
86 : : rtl::OUString,
87 : : OUStringHashCode,
88 : : ::std::equal_to< ::rtl::OUString > >
89 : : {
90 : : inline void free()
91 : : {
92 : : FactoryManagerMap().swap( *this );
93 : : }
94 : : };
95 : :
96 : : sal_Bool impl_getElementProps( const ::com::sun::star::uno::Any& rElement, rtl::OUString& rType, rtl::OUString& rName, rtl::OUString& rModule, rtl::OUString& rServiceSpecifier ) const;
97 : :
98 : : rtl::OUString m_aPropType;
99 : : rtl::OUString m_aPropName;
100 : : rtl::OUString m_aPropModule;
101 : : rtl::OUString m_aPropFactory;
102 : : ::rtl::OUString m_sRoot;
103 : : FactoryManagerMap m_aFactoryManagerMap;
104 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
105 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider;
106 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xConfigAccess;
107 : : ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener > m_xConfigListener;
108 : : sal_Bool m_bConfigAccessInitialized;
109 : : };
110 : :
111 : :
112 : : class UIElementFactoryManager : private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses.
113 : : public ::cppu::WeakImplHelper3< ::com::sun::star::lang::XServiceInfo,
114 : : ::com::sun::star::ui::XUIElementFactory,
115 : : ::com::sun::star::ui::XUIElementFactoryRegistration>
116 : : {
117 : : public:
118 : : UIElementFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
119 : : virtual ~UIElementFactoryManager();
120 : :
121 : : // XInterface, XTypeProvider, XServiceInfo
122 : : DECLARE_XSERVICEINFO
123 : :
124 : : // XUIElementFactory
125 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElement > SAL_CALL createUIElement( const ::rtl::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);
126 : :
127 : : // XUIElementFactoryRegistration
128 : : 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);
129 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIElementFactory > SAL_CALL getFactory( const ::rtl::OUString& ResourceURL, const ::rtl::OUString& ModuleIdentifier ) throw (::com::sun::star::uno::RuntimeException);
130 : : virtual void SAL_CALL registerFactory( const ::rtl::OUString& aType, const ::rtl::OUString& aName, const ::rtl::OUString& aModuleIdentifier, const ::rtl::OUString& aFactoryImplementationName ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
131 : : virtual void SAL_CALL deregisterFactory( const ::rtl::OUString& aType, const ::rtl::OUString& aName, const ::rtl::OUString& aModuleIdentifier ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
132 : :
133 : : private:
134 : :
135 : : sal_Bool m_bConfigRead;
136 : : ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
137 : : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager;
138 : : ConfigurationAccess_FactoryManager* m_pConfigAccess;
139 : : };
140 : :
141 : : } // namespace framework
142 : :
143 : : #endif // __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
144 : :
145 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|