merge the formfield patch from ooo-build
[ooovba.git] / framework / inc / uifactory / uielementfactorymanager.hxx
blob046062c3888a0cdd23c2a703e310b5318205497c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: uielementfactorymanager.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
32 #define __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_
34 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
35 with solaris headers ...
37 #include <vector>
38 #include <list>
40 //_________________________________________________________________________________________________________________
41 // my own includes
42 //_________________________________________________________________________________________________________________
43 #include <threadhelp/threadhelpbase.hxx>
44 #include <macros/generic.hxx>
45 #include <macros/xinterface.hxx>
46 #include <macros/xtypeprovider.hxx>
47 #include <macros/xserviceinfo.hxx>
48 #include <stdtypes.h>
50 //_________________________________________________________________________________________________________________
51 // interface includes
52 //_________________________________________________________________________________________________________________
53 #include <com/sun/star/lang/XServiceInfo.hpp>
54 #include <com/sun/star/ui/XUIElementFactory.hpp>
55 #include <com/sun/star/ui/XUIElementFactoryRegistration.hpp>
56 #include <com/sun/star/container/XContainerListener.hpp>
57 #include <com/sun/star/container/XNameAccess.hpp>
58 #include "com/sun/star/frame/XModuleManager.hpp"
60 //_________________________________________________________________________________________________________________
61 // other includes
62 //_________________________________________________________________________________________________________________
63 #include <cppuhelper/implbase1.hxx>
64 #include <cppuhelper/implbase3.hxx>
65 #include <rtl/ustring.hxx>
67 namespace framework
70 class ConfigurationAccess_FactoryManager : // interfaces
71 // baseclasses
72 // Order is neccessary for right initialization!
73 private ThreadHelpBase ,
74 public ::cppu::WeakImplHelper1< ::com::sun::star::container::XContainerListener>
76 public:
77 ConfigurationAccess_FactoryManager( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rServiceManager,const ::rtl::OUString& _sRoot );
78 virtual ~ConfigurationAccess_FactoryManager();
80 void readConfigurationData();
82 rtl::OUString getFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule ) const;
83 void addFactorySpecifierToTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule, const rtl::OUString& aServiceSpecifier );
84 void removeFactorySpecifierFromTypeNameModule( const rtl::OUString& rType, const rtl::OUString& rName, const rtl::OUString& rModule );
85 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > getFactoriesDescription() const;
87 // container.XContainerListener
88 virtual void SAL_CALL elementInserted( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
89 virtual void SAL_CALL elementRemoved( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
90 virtual void SAL_CALL elementReplaced( const ::com::sun::star::container::ContainerEvent& Event ) throw (::com::sun::star::uno::RuntimeException);
92 // lang.XEventListener
93 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
95 private:
96 class FactoryManagerMap : public std::hash_map< rtl::OUString,
97 rtl::OUString,
98 OUStringHashCode,
99 ::std::equal_to< ::rtl::OUString > >
101 inline void free()
103 FactoryManagerMap().swap( *this );
107 sal_Bool impl_getElementProps( const ::com::sun::star::uno::Any& rElement, rtl::OUString& rType, rtl::OUString& rName, rtl::OUString& rModule, rtl::OUString& rServiceSpecifier ) const;
109 rtl::OUString m_aPropType;
110 rtl::OUString m_aPropName;
111 rtl::OUString m_aPropModule;
112 rtl::OUString m_aPropFactory;
113 ::rtl::OUString m_sRoot;
114 FactoryManagerMap m_aFactoryManagerMap;
115 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
116 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xConfigProvider;
117 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > m_xConfigAccess;
118 sal_Bool m_bConfigAccessInitialized;
119 bool m_bConfigDirty;
123 class UIElementFactoryManager : private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses.
124 public ::cppu::WeakImplHelper3< ::com::sun::star::lang::XServiceInfo,
125 ::com::sun::star::ui::XUIElementFactory,
126 ::com::sun::star::ui::XUIElementFactoryRegistration>
128 public:
129 UIElementFactoryManager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager );
130 virtual ~UIElementFactoryManager();
132 // XInterface, XTypeProvider, XServiceInfo
133 DECLARE_XSERVICEINFO
135 // XUIElementFactory
136 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);
138 // XUIElementFactoryRegistration
139 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);
140 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);
141 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);
142 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);
144 private:
146 sal_Bool m_bConfigRead;
147 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
148 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > m_xModuleManager;
149 ConfigurationAccess_FactoryManager* m_pConfigAccess;
152 } // namespace framework
154 #endif // __FRAMEWORK_UIFACTORY_UIELEMENTFACTORYMANAGER_HXX_