merge the formfield patch from ooo-build
[ooovba.git] / framework / inc / services / modulemanager.hxx
blobcd06868614ad1903e514b2722249a2ef182e2211
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: modulemanager.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_SERVICES_MODULEMANAGER_HXX_
32 #define __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_
34 //_______________________________________________
35 // own includes
37 #include <threadhelp/threadhelpbase.hxx>
38 #include <macros/xinterface.hxx>
39 #include <macros/xtypeprovider.hxx>
40 #include <macros/xserviceinfo.hxx>
41 #include <general.h>
42 #include <general.h>
43 #include <stdtypes.h>
45 //_______________________________________________
46 // interface includes
47 #include <com/sun/star/uno/XInterface.hpp>
48 #include <com/sun/star/lang/XTypeProvider.hpp>
49 #include <com/sun/star/lang/XServiceInfo.hpp>
50 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
51 #include <com/sun/star/frame/XModuleManager.hpp>
52 #include <com/sun/star/container/XNameReplace.hpp>
53 #include <com/sun/star/container/XContainerQuery.hpp>
55 //_______________________________________________
56 // other includes
57 #include <cppuhelper/weak.hxx>
59 //_______________________________________________
60 // definition
62 namespace framework
65 //_______________________________________________
66 /**
67 implements the service com.sun.star.frame.ModuleManager
69 class ModuleManager : public css::lang::XTypeProvider
70 , public css::lang::XServiceInfo
71 , public css::frame::XModuleManager
72 , public css::container::XNameReplace // => XNameAccess, XElementAccess
73 , public css::container::XContainerQuery
74 // attention! Must be the first base class to guarentee right initialize lock ...
75 , private ThreadHelpBase
76 , public ::cppu::OWeakObject
78 //___________________________________________
79 // member
81 private:
83 //---------------------------------------
84 /** the global uno service manager.
85 Must be used to create own needed services.
87 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
89 //---------------------------------------
90 /** points to the underlying configuration.
91 This ModuleManager does not cache - it calls directly the
92 configuration API!
94 css::uno::Reference< css::container::XNameAccess > m_xCFG;
96 //___________________________________________
97 // interface
99 public:
101 ModuleManager(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR);
102 virtual ~ModuleManager( );
104 // XInterface, XTypeProvider, XServiceInfo
105 FWK_DECLARE_XINTERFACE
106 FWK_DECLARE_XTYPEPROVIDER
107 DECLARE_XSERVICEINFO
109 // XModuleManager
110 virtual ::rtl::OUString SAL_CALL identify(const css::uno::Reference< css::uno::XInterface >& xModule)
111 throw(css::lang::IllegalArgumentException,
112 css::frame::UnknownModuleException,
113 css::uno::RuntimeException );
115 // XNameReplace
116 virtual void SAL_CALL replaceByName(const ::rtl::OUString& sName ,
117 const css::uno::Any& aValue)
118 throw (css::lang::IllegalArgumentException ,
119 css::container::NoSuchElementException,
120 css::lang::WrappedTargetException ,
121 css::uno::RuntimeException );
123 // XNameAccess
124 virtual css::uno::Any SAL_CALL getByName(const ::rtl::OUString& sName)
125 throw(css::container::NoSuchElementException,
126 css::lang::WrappedTargetException ,
127 css::uno::RuntimeException );
129 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
130 throw(css::uno::RuntimeException);
132 virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& sName)
133 throw(css::uno::RuntimeException);
135 // XElementAccess
136 virtual css::uno::Type SAL_CALL getElementType()
137 throw(css::uno::RuntimeException);
139 virtual sal_Bool SAL_CALL hasElements()
140 throw(css::uno::RuntimeException);
142 // XContainerQuery
143 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByQuery(const ::rtl::OUString& sQuery)
144 throw(css::uno::RuntimeException);
146 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByProperties(const css::uno::Sequence< css::beans::NamedValue >& lProperties)
147 throw(css::uno::RuntimeException);
148 //___________________________________________
149 // helper
151 private:
153 //---------------------------------------
154 /** @short open the underlying configuration.
156 @descr This method must be called everytimes
157 a (reaonly!) configuration is needed. Because
158 method works together with the member
159 m_xCFG, open it on demand and cache it
160 afterwards.
162 Note: A writable configuration access
163 must be created explicitly. Otherwise
164 we cant make sure that broken write requests
165 wont affect our read access !
167 @return [com.sun.star.container.XNameAccess]
168 the configuration object
170 @throw [com.sun.star.uno.RuntimeException]
171 if config could not be opened successfully!
173 @threadsafe
175 css::uno::Reference< css::container::XNameAccess > implts_getConfig()
176 throw(css::uno::RuntimeException);
178 //---------------------------------------
179 /** @short makes the real identification of the module.
181 @descr It checks for the optional but preferred interface
182 XModule first. If this module does not exists at the
183 given component it tries to use XServiceInfo instead.
185 Note: This method try to locate a suitable module name.
186 Nothing else. Selecting the right component and throwing suitable
187 exceptions must be done outside.
189 @see identify()
191 @param xComponent
192 the module for identification.
194 @return The identifier of the given module.
195 Can be empty if given component is not a real module !
197 @threadsafe
199 ::rtl::OUString implts_identify(const css::uno::Reference< css::uno::XInterface >& xComponent);
202 } // namespace framework
204 #endif // __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_