1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 25 #define __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 26 27 //_______________________________________________ 28 // own includes 29 30 #include <threadhelp/threadhelpbase.hxx> 31 #include <macros/xinterface.hxx> 32 #include <macros/xtypeprovider.hxx> 33 #include <macros/xserviceinfo.hxx> 34 #include <general.h> 35 #include <general.h> 36 #include <stdtypes.h> 37 38 //_______________________________________________ 39 // interface includes 40 #include <com/sun/star/uno/XInterface.hpp> 41 #include <com/sun/star/lang/XTypeProvider.hpp> 42 #include <com/sun/star/lang/XServiceInfo.hpp> 43 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 44 #include <com/sun/star/frame/XModuleManager.hpp> 45 #include <com/sun/star/container/XNameReplace.hpp> 46 #include <com/sun/star/container/XContainerQuery.hpp> 47 48 //_______________________________________________ 49 // other includes 50 #include <cppuhelper/weak.hxx> 51 52 //_______________________________________________ 53 // definition 54 55 namespace framework 56 { 57 58 //_______________________________________________ 59 /** 60 implements the service com.sun.star.frame.ModuleManager 61 */ 62 class ModuleManager : public css::lang::XTypeProvider 63 , public css::lang::XServiceInfo 64 , public css::frame::XModuleManager 65 , public css::container::XNameReplace // => XNameAccess, XElementAccess 66 , public css::container::XContainerQuery 67 // attention! Must be the first base class to guarantee right initialize lock ... 68 , private ThreadHelpBase 69 , public ::cppu::OWeakObject 70 { 71 //___________________________________________ 72 // member 73 74 private: 75 76 //--------------------------------------- 77 /** the global uno service manager. 78 Must be used to create own needed services. 79 */ 80 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 81 82 //--------------------------------------- 83 /** points to the underlying configuration. 84 This ModuleManager does not cache - it calls directly the 85 configuration API! 86 */ 87 css::uno::Reference< css::container::XNameAccess > m_xCFG; 88 89 //___________________________________________ 90 // interface 91 92 public: 93 94 ModuleManager(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR); 95 virtual ~ModuleManager( ); 96 97 // XInterface, XTypeProvider, XServiceInfo 98 FWK_DECLARE_XINTERFACE 99 FWK_DECLARE_XTYPEPROVIDER 100 DECLARE_XSERVICEINFO 101 102 // XModuleManager 103 virtual ::rtl::OUString SAL_CALL identify(const css::uno::Reference< css::uno::XInterface >& xModule); 104 105 // XNameReplace 106 virtual void SAL_CALL replaceByName(const ::rtl::OUString& sName , 107 const css::uno::Any& aValue); 108 109 // XNameAccess 110 virtual css::uno::Any SAL_CALL getByName(const ::rtl::OUString& sName); 111 112 virtual css::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(); 113 114 virtual sal_Bool SAL_CALL hasByName(const ::rtl::OUString& sName); 115 116 // XElementAccess 117 virtual css::uno::Type SAL_CALL getElementType(); 118 119 virtual sal_Bool SAL_CALL hasElements(); 120 121 // XContainerQuery 122 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByQuery(const ::rtl::OUString& sQuery); 123 124 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createSubSetEnumerationByProperties(const css::uno::Sequence< css::beans::NamedValue >& lProperties); 125 //___________________________________________ 126 // helper 127 128 private: 129 130 //--------------------------------------- 131 /** @short open the underlying configuration. 132 133 @descr This method must be called every time 134 a (reaonly!) configuration is needed. Because 135 method works together with the member 136 m_xCFG, open it on demand and cache it 137 afterwards. 138 139 Note: A writable configuration access 140 must be created explicitly. Otherwise 141 we can't make sure that broken write requests 142 won't affect our read access ! 143 144 @return [com.sun.star.container.XNameAccess] 145 the configuration object 146 147 @throw [com.sun.star.uno.RuntimeException] 148 if config could not be opened successfully! 149 150 @threadsafe 151 */ 152 css::uno::Reference< css::container::XNameAccess > implts_getConfig(); 153 154 //--------------------------------------- 155 /** @short makes the real identification of the module. 156 157 @descr It checks for the optional but preferred interface 158 XModule first. If this module does not exists at the 159 given component it tries to use XServiceInfo instead. 160 161 Note: This method tries to locate a suitable module name. 162 Nothing else. Selecting the right component and throwing suitable 163 exceptions must be done outside. 164 165 @see identify() 166 167 @param xComponent 168 the module for identification. 169 170 @return The identifier of the given module. 171 Can be empty if given component is not a real module ! 172 173 @threadsafe 174 */ 175 ::rtl::OUString implts_identify(const css::uno::Reference< css::uno::XInterface >& xComponent); 176 }; 177 178 } // namespace framework 179 180 #endif // __FRAMEWORK_SERVICES_MODULEMANAGER_HXX_ 181