1f8e07b45SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f8e07b45SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f8e07b45SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f8e07b45SAndrew Rist  * distributed with this work for additional information
6f8e07b45SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f8e07b45SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f8e07b45SAndrew Rist  * "License"); you may not use this file except in compliance
9f8e07b45SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f8e07b45SAndrew Rist  *
11f8e07b45SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f8e07b45SAndrew Rist  *
13f8e07b45SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f8e07b45SAndrew Rist  * software distributed under the License is distributed on an
15f8e07b45SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f8e07b45SAndrew Rist  * KIND, either express or implied.  See the License for the
17f8e07b45SAndrew Rist  * specific language governing permissions and limitations
18f8e07b45SAndrew Rist  * under the License.
19f8e07b45SAndrew Rist  *
20f8e07b45SAndrew Rist  *************************************************************/
21f8e07b45SAndrew Rist 
22f8e07b45SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
25cdf0e10cSrcweir #define __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
26cdf0e10cSrcweir 
27*15289133Smseidel /** Attention: stl headers must(!) be included at first. Otherwise it can make trouble
28cdf0e10cSrcweir                with solaris headers ...
29cdf0e10cSrcweir */
30cdf0e10cSrcweir #include <vector>
31cdf0e10cSrcweir #include <list>
32cdf0e10cSrcweir 
33cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34cdf0e10cSrcweir //	my own includes
35cdf0e10cSrcweir //_________________________________________________________________________________________________________________
36cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx>
37cdf0e10cSrcweir #include <macros/generic.hxx>
38cdf0e10cSrcweir #include <macros/xinterface.hxx>
39cdf0e10cSrcweir #include <macros/xtypeprovider.hxx>
40cdf0e10cSrcweir #include <macros/xserviceinfo.hxx>
41cdf0e10cSrcweir #include <stdtypes.h>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //_________________________________________________________________________________________________________________
44cdf0e10cSrcweir //	interface includes
45cdf0e10cSrcweir //_________________________________________________________________________________________________________________
46cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
47cdf0e10cSrcweir #include <com/sun/star/ui/XUIElementFactory.hpp>
48cdf0e10cSrcweir #include <com/sun/star/ui/XUIElementFactoryRegistration.hpp>
49cdf0e10cSrcweir #include <com/sun/star/container/XContainerListener.hpp>
50cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
51cdf0e10cSrcweir #include "com/sun/star/frame/XModuleManager.hpp"
52cdf0e10cSrcweir 
53cdf0e10cSrcweir //_________________________________________________________________________________________________________________
54cdf0e10cSrcweir //	other includes
55cdf0e10cSrcweir //_________________________________________________________________________________________________________________
56cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx>
57cdf0e10cSrcweir #include <cppuhelper/implbase3.hxx>
58cdf0e10cSrcweir #include <rtl/ustring.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir namespace framework
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     class ConfigurationAccess_FactoryManager : // interfaces
64cdf0e10cSrcweir                                                     // baseclasses
6507a3d7f1SPedro Giffuni 							                        // Order is necessary for right initialization!
66cdf0e10cSrcweir                                                     private ThreadHelpBase                           ,
67cdf0e10cSrcweir                                                     public  ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
68cdf0e10cSrcweir {
69cdf0e10cSrcweir     public:
70cdf0e10cSrcweir                       ConfigurationAccess_FactoryManager( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager,const ::rtl::OUString& _sRoot );
71cdf0e10cSrcweir         virtual       ~ConfigurationAccess_FactoryManager();
72cdf0e10cSrcweir 
73cdf0e10cSrcweir         void          readConfigurationData();
74cdf0e10cSrcweir 
75cdf0e10cSrcweir         rtl::OUString                           getFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule ) const;
76cdf0e10cSrcweir         void                                    addFactorySpecifierToTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule, const rtl::OUString& aServiceSpecifier );
77cdf0e10cSrcweir         void                                    removeFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule );
78cdf0e10cSrcweir         ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >   getFactoriesDescription() const;
79cdf0e10cSrcweir 
80cdf0e10cSrcweir         // container.XContainerListener
81cdf0e10cSrcweir     virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
82cdf0e10cSrcweir     virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
83cdf0e10cSrcweir     virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
84cdf0e10cSrcweir 
85cdf0e10cSrcweir     // lang.XEventListener
86cdf0e10cSrcweir     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
87cdf0e10cSrcweir 
88cdf0e10cSrcweir     private:
89cdf0e10cSrcweir         class FactoryManagerMap : public std::hash_map< rtl::OUString,
90cdf0e10cSrcweir                                                      rtl::OUString,
915758ad8cSAriel Constenla-Haile                                                      rtl::OUStringHash,
92cdf0e10cSrcweir                                                      ::std::equal_to< ::rtl::OUString > >
93cdf0e10cSrcweir         {
free()94cdf0e10cSrcweir             inline void free()
95cdf0e10cSrcweir             {
96cdf0e10cSrcweir                 FactoryManagerMap().swap( *this );
97cdf0e10cSrcweir             }
98cdf0e10cSrcweir         };
99cdf0e10cSrcweir 
100cdf0e10cSrcweir         sal_Bool impl_getElementProps( const ::com::sun::star::uno::Any& rElement, rtl::OUString& rType, rtl::OUString& rName, rtl::OUString& rModule, rtl::OUString& rServiceSpecifier ) const;
101cdf0e10cSrcweir 
102cdf0e10cSrcweir         rtl::OUString                     m_aPropType;
103cdf0e10cSrcweir         rtl::OUString                     m_aPropName;
104cdf0e10cSrcweir         rtl::OUString                     m_aPropModule;
105cdf0e10cSrcweir         rtl::OUString                     m_aPropFactory;
106cdf0e10cSrcweir         ::rtl::OUString                   m_sRoot;
107cdf0e10cSrcweir         FactoryManagerMap                 m_aFactoryManagerMap;
108cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
109cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider;
110cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >     m_xConfigAccess;
111cdf0e10cSrcweir         sal_Bool                          m_bConfigAccessInitialized;
112cdf0e10cSrcweir         bool							  m_bConfigDirty;
113cdf0e10cSrcweir };
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 
11630acf5e8Spfg class UIElementFactoryManager :  private ThreadHelpBase							                    ,	// Struct for right initialization of mutex member! Must be first of baseclasses.
117cdf0e10cSrcweir                                  public ::cppu::WeakImplHelper3< ::com::sun::star::lang::XServiceInfo,
118cdf0e10cSrcweir                                                                  ::com::sun::star::ui::XUIElementFactory,
119cdf0e10cSrcweir                                                                  ::com::sun::star::ui::XUIElementFactoryRegistration>
120cdf0e10cSrcweir {
121cdf0e10cSrcweir 	public:
122cdf0e10cSrcweir 		UIElementFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
123cdf0e10cSrcweir 		virtual ~UIElementFactoryManager();
124cdf0e10cSrcweir 
125cdf0e10cSrcweir         //  XInterface, XTypeProvider, XServiceInfo
126cdf0e10cSrcweir 		DECLARE_XSERVICEINFO
127cdf0e10cSrcweir 
128cdf0e10cSrcweir         // XUIElementFactory
129cdf0e10cSrcweir         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);
130cdf0e10cSrcweir 
131cdf0e10cSrcweir         // XUIElementFactoryRegistration
132cdf0e10cSrcweir         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);
133cdf0e10cSrcweir         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);
134cdf0e10cSrcweir         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);
135cdf0e10cSrcweir         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);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     private:
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         sal_Bool                                                                            m_bConfigRead;
140cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >    m_xServiceManager;
141cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager;
142cdf0e10cSrcweir         ConfigurationAccess_FactoryManager*                                        m_pConfigAccess;
143cdf0e10cSrcweir };
144cdf0e10cSrcweir 
145cdf0e10cSrcweir } // namespace framework
146cdf0e10cSrcweir 
147cdf0e10cSrcweir #endif // __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
148