1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 29 #define __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 30 31 //_______________________________________________ 32 // own includes 33 34 #include <threadhelp/threadhelpbase.hxx> 35 #include <macros/xinterface.hxx> 36 #include <macros/xtypeprovider.hxx> 37 #include <macros/xserviceinfo.hxx> 38 #include <general.h> 39 #include <general.h> 40 #include <stdtypes.h> 41 42 //_______________________________________________ 43 // interface includes 44 #include <com/sun/star/uno/XInterface.hpp> 45 #include <com/sun/star/lang/XTypeProvider.hpp> 46 #include <com/sun/star/lang/XServiceInfo.hpp> 47 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 48 #include <com/sun/star/frame/XModuleManager.hpp> 49 #include <com/sun/star/container/XNameReplace.hpp> 50 #include <com/sun/star/container/XContainerQuery.hpp> 51 52 //_______________________________________________ 53 // other includes 54 #include <cppuhelper/weak.hxx> 55 56 //_______________________________________________ 57 // definition 58 59 namespace framework 60 { 61 62 //_______________________________________________ 63 /** 64 implements the service com.sun.star.frame.ModuleManager 65 */ 66 class ModuleManager : public css::lang::XTypeProvider 67 , public css::lang::XServiceInfo 68 , public css::frame::XModuleManager 69 , public css::container::XNameReplace // => XNameAccess, XElementAccess 70 , public css::container::XContainerQuery 71 // attention! Must be the first base class to guarentee right initialize lock ... 72 , private ThreadHelpBase 73 , public ::cppu::OWeakObject 74 { 75 //___________________________________________ 76 // member 77 78 private: 79 80 //--------------------------------------- 81 /** the global uno service manager. 82 Must be used to create own needed services. 83 */ 84 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 85 86 //--------------------------------------- 87 /** points to the underlying configuration. 88 This ModuleManager does not cache - it calls directly the 89 configuration API! 90 */ 91 css::uno::Reference< css::container::XNameAccess > m_xCFG; 92 93 //___________________________________________ 94 // interface 95 96 public: 97 98 ModuleManager(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR); 99 virtual ~ModuleManager( ); 100 101 // XInterface, XTypeProvider, XServiceInfo 102 FWK_DECLARE_XINTERFACE 103 FWK_DECLARE_XTYPEPROVIDER 104 DECLARE_XSERVICEINFO 105 106 // XModuleManager 107 virtual ::rtl::OUString SAL_CALL identify(const css::uno::Reference< css::uno::XInterface >& xModule) 108 throw(css::lang::IllegalArgumentException, 109 css::frame::UnknownModuleException, 110 css::uno::RuntimeException ); 111 112 // XNameReplace 113 virtual void SAL_CALL replaceByName(const ::rtl::OUString& sName , 114 const css::uno::Any& aValue) 115 throw (css::lang::IllegalArgumentException , 116 css::container::NoSuchElementException, 117 css::lang::WrappedTargetException , 118 css::uno::RuntimeException ); 119 120 // XNameAccess 121 virtual css::uno::Any SAL_CALL getByName(const ::rtl::OUString& sName) 122 throw(css::container::NoSuchElementException, 123 css::lang::WrappedTargetException , 124 css::uno::RuntimeException ); 125 126 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames() 127 throw(css::uno::RuntimeException); 128 129 virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& sName) 130 throw(css::uno::RuntimeException); 131 132 // XElementAccess 133 virtual css::uno::Type SAL_CALL getElementType() 134 throw(css::uno::RuntimeException); 135 136 virtual sal_Bool SAL_CALL hasElements() 137 throw(css::uno::RuntimeException); 138 139 // XContainerQuery 140 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByQuery(const ::rtl::OUString& sQuery) 141 throw(css::uno::RuntimeException); 142 143 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByProperties(const css::uno::Sequence< css::beans::NamedValue >& lProperties) 144 throw(css::uno::RuntimeException); 145 //___________________________________________ 146 // helper 147 148 private: 149 150 //--------------------------------------- 151 /** @short open the underlying configuration. 152 153 @descr This method must be called everytimes 154 a (reaonly!) configuration is needed. Because 155 method works together with the member 156 m_xCFG, open it on demand and cache it 157 afterwards. 158 159 Note: A writable configuration access 160 must be created explicitly. Otherwise 161 we cant make sure that broken write requests 162 wont affect our read access ! 163 164 @return [com.sun.star.container.XNameAccess] 165 the configuration object 166 167 @throw [com.sun.star.uno.RuntimeException] 168 if config could not be opened successfully! 169 170 @threadsafe 171 */ 172 css::uno::Reference< css::container::XNameAccess > implts_getConfig() 173 throw(css::uno::RuntimeException); 174 175 //--------------------------------------- 176 /** @short makes the real identification of the module. 177 178 @descr It checks for the optional but preferred interface 179 XModule first. If this module does not exists at the 180 given component it tries to use XServiceInfo instead. 181 182 Note: This method try to locate a suitable module name. 183 Nothing else. Selecting the right component and throwing suitable 184 exceptions must be done outside. 185 186 @see identify() 187 188 @param xComponent 189 the module for identification. 190 191 @return The identifier of the given module. 192 Can be empty if given component is not a real module ! 193 194 @threadsafe 195 */ 196 ::rtl::OUString implts_identify(const css::uno::Reference< css::uno::XInterface >& xComponent); 197 }; 198 199 } // namespace framework 200 201 #endif // __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 202