16d739b60SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 36d739b60SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 46d739b60SAndrew Rist * or more contributor license agreements. See the NOTICE file 56d739b60SAndrew Rist * distributed with this work for additional information 66d739b60SAndrew Rist * regarding copyright ownership. The ASF licenses this file 76d739b60SAndrew Rist * to you under the Apache License, Version 2.0 (the 86d739b60SAndrew Rist * "License"); you may not use this file except in compliance 96d739b60SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 116d739b60SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 136d739b60SAndrew Rist * Unless required by applicable law or agreed to in writing, 146d739b60SAndrew Rist * software distributed under the License is distributed on an 156d739b60SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 166d739b60SAndrew Rist * KIND, either express or implied. See the License for the 176d739b60SAndrew Rist * specific language governing permissions and limitations 186d739b60SAndrew Rist * under the License. 19cdf0e10cSrcweir * 206d739b60SAndrew Rist *************************************************************/ 216d739b60SAndrew Rist 226d739b60SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_framework.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "services/modulemanager.hxx" 28cdf0e10cSrcweir #include "services/frame.hxx" 29cdf0e10cSrcweir 30cdf0e10cSrcweir //_______________________________________________ 31cdf0e10cSrcweir // own includes 32cdf0e10cSrcweir #include <threadhelp/readguard.hxx> 33cdf0e10cSrcweir #include <threadhelp/writeguard.hxx> 34cdf0e10cSrcweir #include <services.h> 35cdf0e10cSrcweir 36cdf0e10cSrcweir //_______________________________________________ 37cdf0e10cSrcweir // interface includes 38cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 39cdf0e10cSrcweir #include <com/sun/star/frame/XController.hpp> 40cdf0e10cSrcweir #include <com/sun/star/frame/XModel.hpp> 41cdf0e10cSrcweir #include <com/sun/star/frame/XModule.hpp> 42cdf0e10cSrcweir #include <comphelper/configurationhelper.hxx> 43cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx> 44cdf0e10cSrcweir #include <comphelper/sequenceasvector.hxx> 45cdf0e10cSrcweir #include <comphelper/enumhelper.hxx> 46cdf0e10cSrcweir 47cdf0e10cSrcweir //_______________________________________________ 48cdf0e10cSrcweir // other includes 49cdf0e10cSrcweir #include <rtl/logfile.hxx> 50cdf0e10cSrcweir 51cdf0e10cSrcweir namespace framework 52cdf0e10cSrcweir { 53cdf0e10cSrcweir 54cdf0e10cSrcweir static const ::rtl::OUString CFGPATH_FACTORIES = ::rtl::OUString::createFromAscii("/org.openoffice.Setup/Office/Factories"); 55cdf0e10cSrcweir static const ::rtl::OUString MODULEPROP_IDENTIFIER = ::rtl::OUString::createFromAscii("ooSetupFactoryModuleIdentifier" ); 56cdf0e10cSrcweir 57cdf0e10cSrcweir /*----------------------------------------------- 58cdf0e10cSrcweir 04.12.2003 09:32 59cdf0e10cSrcweir -----------------------------------------------*/ 60cdf0e10cSrcweir DEFINE_XINTERFACE_7(ModuleManager , 61cdf0e10cSrcweir OWeakObject , 62cdf0e10cSrcweir DIRECT_INTERFACE(css::lang::XTypeProvider ), 63cdf0e10cSrcweir DIRECT_INTERFACE(css::lang::XServiceInfo ), 64cdf0e10cSrcweir DIRECT_INTERFACE(css::container::XNameReplace ), 65cdf0e10cSrcweir DIRECT_INTERFACE(css::container::XNameAccess ), 66cdf0e10cSrcweir DIRECT_INTERFACE(css::container::XElementAccess ), 67cdf0e10cSrcweir DIRECT_INTERFACE(css::container::XContainerQuery), 68cdf0e10cSrcweir DIRECT_INTERFACE(css::frame::XModuleManager )) 69cdf0e10cSrcweir 70cdf0e10cSrcweir /*----------------------------------------------- 71cdf0e10cSrcweir 04.12.2003 09:32 72cdf0e10cSrcweir -----------------------------------------------*/ 73cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_7(ModuleManager , 74cdf0e10cSrcweir css::lang::XTypeProvider , 75cdf0e10cSrcweir css::lang::XServiceInfo , 76cdf0e10cSrcweir css::container::XNameReplace , 77cdf0e10cSrcweir css::container::XNameAccess , 78cdf0e10cSrcweir css::container::XElementAccess , 79cdf0e10cSrcweir css::container::XContainerQuery, 80cdf0e10cSrcweir css::frame::XModuleManager ) 81cdf0e10cSrcweir 82cdf0e10cSrcweir /*----------------------------------------------- 83cdf0e10cSrcweir 04.12.2003 09:35 84cdf0e10cSrcweir -----------------------------------------------*/ 85cdf0e10cSrcweir DEFINE_XSERVICEINFO_ONEINSTANCESERVICE(ModuleManager , 86cdf0e10cSrcweir ::cppu::OWeakObject , 87cdf0e10cSrcweir SERVICENAME_MODULEMANAGER , 88cdf0e10cSrcweir IMPLEMENTATIONNAME_MODULEMANAGER) 89cdf0e10cSrcweir 90cdf0e10cSrcweir /*----------------------------------------------- 91cdf0e10cSrcweir 04.12.2003 09:35 92cdf0e10cSrcweir -----------------------------------------------*/ 93cdf0e10cSrcweir DEFINE_INIT_SERVICE( 94cdf0e10cSrcweir ModuleManager, 95cdf0e10cSrcweir { 96cdf0e10cSrcweir /*Attention 97cdf0e10cSrcweir I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance() 98cdf0e10cSrcweir to create a new instance of this class by our own supported service factory. 99cdf0e10cSrcweir see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations! 100cdf0e10cSrcweir */ 101cdf0e10cSrcweir } 102cdf0e10cSrcweir ) 103cdf0e10cSrcweir 104cdf0e10cSrcweir /*----------------------------------------------- 105cdf0e10cSrcweir 04.12.2003 09:30 106cdf0e10cSrcweir -----------------------------------------------*/ 107cdf0e10cSrcweir ModuleManager::ModuleManager(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR) 108cdf0e10cSrcweir : ThreadHelpBase( ) 109cdf0e10cSrcweir , m_xSMGR (xSMGR) 110cdf0e10cSrcweir { 111cdf0e10cSrcweir } 112cdf0e10cSrcweir 113cdf0e10cSrcweir /*----------------------------------------------- 114cdf0e10cSrcweir 10.12.2003 11:59 115cdf0e10cSrcweir -----------------------------------------------*/ 116cdf0e10cSrcweir ModuleManager::~ModuleManager() 117cdf0e10cSrcweir { 118cdf0e10cSrcweir if (m_xCFG.is()) 119cdf0e10cSrcweir m_xCFG.clear(); 120cdf0e10cSrcweir } 121cdf0e10cSrcweir 122cdf0e10cSrcweir /*----------------------------------------------- 123cdf0e10cSrcweir 10.12.2003 11:02 124cdf0e10cSrcweir -----------------------------------------------*/ 125cdf0e10cSrcweir ::rtl::OUString SAL_CALL ModuleManager::identify(const css::uno::Reference< css::uno::XInterface >& xModule) 126cdf0e10cSrcweir throw(css::lang::IllegalArgumentException, 127cdf0e10cSrcweir css::frame::UnknownModuleException, 128cdf0e10cSrcweir css::uno::RuntimeException ) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir // valid parameter? 131cdf0e10cSrcweir css::uno::Reference< css::frame::XFrame > xFrame (xModule, css::uno::UNO_QUERY); 132cdf0e10cSrcweir css::uno::Reference< css::awt::XWindow > xWindow (xModule, css::uno::UNO_QUERY); 133cdf0e10cSrcweir css::uno::Reference< css::frame::XController > xController(xModule, css::uno::UNO_QUERY); 134cdf0e10cSrcweir css::uno::Reference< css::frame::XModel > xModel (xModule, css::uno::UNO_QUERY); 135cdf0e10cSrcweir 136cdf0e10cSrcweir if ( 137cdf0e10cSrcweir (!xFrame.is() ) && 138cdf0e10cSrcweir (!xWindow.is() ) && 139cdf0e10cSrcweir (!xController.is()) && 140cdf0e10cSrcweir (!xModel.is() ) 141cdf0e10cSrcweir ) 142cdf0e10cSrcweir { 143cdf0e10cSrcweir throw css::lang::IllegalArgumentException( 144cdf0e10cSrcweir ::rtl::OUString::createFromAscii("Given module is not a frame nor a window, controller or model."), 145cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >(this), 146cdf0e10cSrcweir 1); 147cdf0e10cSrcweir } 148cdf0e10cSrcweir 149cdf0e10cSrcweir if (xFrame.is()) 150cdf0e10cSrcweir { 151cdf0e10cSrcweir xController = xFrame->getController(); 152cdf0e10cSrcweir xWindow = xFrame->getComponentWindow(); 153cdf0e10cSrcweir } 154cdf0e10cSrcweir if (xController.is()) 155cdf0e10cSrcweir xModel = xController->getModel(); 156cdf0e10cSrcweir 157cdf0e10cSrcweir // modules are implemented by the deepest component in hierarchy ... 158cdf0e10cSrcweir // Means: model -> controller -> window 159cdf0e10cSrcweir // No fallbacks to higher components are allowed ! 160cdf0e10cSrcweir // Note : A frame provides access to module components only ... but it's not a module by himself. 161cdf0e10cSrcweir 162cdf0e10cSrcweir ::rtl::OUString sModule; 163cdf0e10cSrcweir if (xModel.is()) 164cdf0e10cSrcweir sModule = implts_identify(xModel); 165cdf0e10cSrcweir else 166cdf0e10cSrcweir if (xController.is()) 167cdf0e10cSrcweir sModule = implts_identify(xController); 168cdf0e10cSrcweir else 169cdf0e10cSrcweir if (xWindow.is()) 170cdf0e10cSrcweir sModule = implts_identify(xWindow); 171cdf0e10cSrcweir 172cdf0e10cSrcweir if (sModule.getLength() < 1) 173cdf0e10cSrcweir throw css::frame::UnknownModuleException( 17407a3d7f1SPedro Giffuni ::rtl::OUString::createFromAscii("Can't find suitable module for the given component."), 175cdf0e10cSrcweir static_cast< ::cppu::OWeakObject* >(this)); 176cdf0e10cSrcweir 177cdf0e10cSrcweir return sModule; 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir /*----------------------------------------------- 181cdf0e10cSrcweir 08.03.2007 09:55 182cdf0e10cSrcweir -----------------------------------------------*/ 183cdf0e10cSrcweir void SAL_CALL ModuleManager::replaceByName(const ::rtl::OUString& sName , 184cdf0e10cSrcweir const css::uno::Any& aValue) 185cdf0e10cSrcweir throw (css::lang::IllegalArgumentException , 186cdf0e10cSrcweir css::container::NoSuchElementException, 187cdf0e10cSrcweir css::lang::WrappedTargetException , 188cdf0e10cSrcweir css::uno::RuntimeException ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir ::comphelper::SequenceAsHashMap lProps(aValue); 191cdf0e10cSrcweir if (lProps.empty() ) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir throw css::lang::IllegalArgumentException( 194cdf0e10cSrcweir ::rtl::OUString::createFromAscii("No properties given to replace part of module."), 195cdf0e10cSrcweir static_cast< css::container::XNameAccess* >(this), 196cdf0e10cSrcweir 2); 197cdf0e10cSrcweir } 198cdf0e10cSrcweir 199cdf0e10cSrcweir // SAFE -> ---------------------------------- 200cdf0e10cSrcweir ReadGuard aReadLock(m_aLock); 201cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 202cdf0e10cSrcweir aReadLock.unlock(); 203cdf0e10cSrcweir // <- SAFE ---------------------------------- 204cdf0e10cSrcweir 205cdf0e10cSrcweir // get access to the element 206cdf0e10cSrcweir // Note: Dont use impl_getConfig() method here. Because it creates a readonly access only, further 207cdf0e10cSrcweir // it cache it as a member of this module manager instance. If we change some props there ... but dont 20807a3d7f1SPedro Giffuni // flush changes (because an error occurred) we will read them later. If we use a different config access 209*9f813b30Smseidel // we can close it without a flush ... and our read data won't be affected .-) 210cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > xCfg = ::comphelper::ConfigurationHelper::openConfig( 211cdf0e10cSrcweir xSMGR, 212cdf0e10cSrcweir CFGPATH_FACTORIES, 213cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_STANDARD); 214cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xModules (xCfg, css::uno::UNO_QUERY_THROW); 215cdf0e10cSrcweir css::uno::Reference< css::container::XNameReplace > xModule ; 216cdf0e10cSrcweir 217cdf0e10cSrcweir xModules->getByName(sName) >>= xModule; 218cdf0e10cSrcweir if (!xModule.is()) 219cdf0e10cSrcweir { 220cdf0e10cSrcweir throw css::uno::RuntimeException( 221cdf0e10cSrcweir ::rtl::OUString::createFromAscii("Was not able to get write access to the requested module entry inside configuration."), 222cdf0e10cSrcweir static_cast< css::container::XNameAccess* >(this)); 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir ::comphelper::SequenceAsHashMap::const_iterator pProp; 226cdf0e10cSrcweir for ( pProp = lProps.begin(); 227cdf0e10cSrcweir pProp != lProps.end() ; 228cdf0e10cSrcweir ++pProp ) 229cdf0e10cSrcweir { 230cdf0e10cSrcweir const ::rtl::OUString& sPropName = pProp->first; 231cdf0e10cSrcweir const css::uno::Any& aPropValue = pProp->second; 232cdf0e10cSrcweir 233cdf0e10cSrcweir // let "NoSuchElementException" out ! We support the same API ... 234cdf0e10cSrcweir // and without a flush() at the end all changed data before will be ignored ! 235cdf0e10cSrcweir xModule->replaceByName(sPropName, aPropValue); 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir ::comphelper::ConfigurationHelper::flush(xCfg); 239cdf0e10cSrcweir } 240cdf0e10cSrcweir 241cdf0e10cSrcweir /*----------------------------------------------- 242cdf0e10cSrcweir 10.12.2003 12:05 243cdf0e10cSrcweir -----------------------------------------------*/ 244cdf0e10cSrcweir css::uno::Any SAL_CALL ModuleManager::getByName(const ::rtl::OUString& sName) 245cdf0e10cSrcweir throw(css::container::NoSuchElementException, 246cdf0e10cSrcweir css::lang::WrappedTargetException , 247cdf0e10cSrcweir css::uno::RuntimeException ) 248cdf0e10cSrcweir { 249cdf0e10cSrcweir // get access to the element 250cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCFG = implts_getConfig(); 251cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xModule; 252cdf0e10cSrcweir xCFG->getByName(sName) >>= xModule; 253cdf0e10cSrcweir if (!xModule.is()) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir throw css::uno::RuntimeException( 256cdf0e10cSrcweir ::rtl::OUString::createFromAscii("Was not able to get write access to the requested module entry inside configuration."), 257cdf0e10cSrcweir static_cast< css::container::XNameAccess* >(this)); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir // convert it to seq< PropertyValue > 261cdf0e10cSrcweir const css::uno::Sequence< ::rtl::OUString > lPropNames = xModule->getElementNames(); 262cdf0e10cSrcweir ::comphelper::SequenceAsHashMap lProps ; 263cdf0e10cSrcweir sal_Int32 c = lPropNames.getLength(); 264cdf0e10cSrcweir sal_Int32 i = 0; 265cdf0e10cSrcweir 266cdf0e10cSrcweir lProps[MODULEPROP_IDENTIFIER] <<= sName; 267cdf0e10cSrcweir for (i=0; i<c; ++i) 268cdf0e10cSrcweir { 269cdf0e10cSrcweir const ::rtl::OUString& sPropName = lPropNames[i]; 270cdf0e10cSrcweir lProps[sPropName] = xModule->getByName(sPropName); 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir return css::uno::makeAny(lProps.getAsConstPropertyValueList()); 274cdf0e10cSrcweir } 275cdf0e10cSrcweir 276cdf0e10cSrcweir /*----------------------------------------------- 277cdf0e10cSrcweir 10.12.2003 11:58 278cdf0e10cSrcweir -----------------------------------------------*/ 279cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > SAL_CALL ModuleManager::getElementNames() 280cdf0e10cSrcweir throw(css::uno::RuntimeException) 281cdf0e10cSrcweir { 282cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCFG = implts_getConfig(); 283cdf0e10cSrcweir return xCFG->getElementNames(); 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir /*----------------------------------------------- 287cdf0e10cSrcweir 10.12.2003 11:57 288cdf0e10cSrcweir -----------------------------------------------*/ 289cdf0e10cSrcweir sal_Bool SAL_CALL ModuleManager::hasByName(const ::rtl::OUString& sName) 290cdf0e10cSrcweir throw(css::uno::RuntimeException) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCFG = implts_getConfig(); 293cdf0e10cSrcweir return xCFG->hasByName(sName); 294cdf0e10cSrcweir } 295cdf0e10cSrcweir 296cdf0e10cSrcweir /*----------------------------------------------- 297cdf0e10cSrcweir 10.12.2003 11:35 298cdf0e10cSrcweir -----------------------------------------------*/ 299cdf0e10cSrcweir css::uno::Type SAL_CALL ModuleManager::getElementType() 300cdf0e10cSrcweir throw(css::uno::RuntimeException) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir return ::getCppuType((const css::uno::Sequence< css::beans::PropertyValue >*)0); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir /*----------------------------------------------- 306cdf0e10cSrcweir 10.12.2003 11:56 307cdf0e10cSrcweir -----------------------------------------------*/ 308cdf0e10cSrcweir sal_Bool SAL_CALL ModuleManager::hasElements() 309cdf0e10cSrcweir throw(css::uno::RuntimeException) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > xCFG = implts_getConfig(); 312cdf0e10cSrcweir return xCFG->hasElements(); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir 315cdf0e10cSrcweir /*----------------------------------------------- 316cdf0e10cSrcweir 07.03.2007 12:55 317cdf0e10cSrcweir -----------------------------------------------*/ 318cdf0e10cSrcweir css::uno::Reference< css::container::XEnumeration > SAL_CALL ModuleManager::createSubSetEnumerationByQuery(const ::rtl::OUString&) 319cdf0e10cSrcweir throw(css::uno::RuntimeException) 320cdf0e10cSrcweir { 321cdf0e10cSrcweir return css::uno::Reference< css::container::XEnumeration >(); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir 324cdf0e10cSrcweir /*----------------------------------------------- 325cdf0e10cSrcweir 07.03.2007 12:55 326cdf0e10cSrcweir -----------------------------------------------*/ 327cdf0e10cSrcweir css::uno::Reference< css::container::XEnumeration > SAL_CALL ModuleManager::createSubSetEnumerationByProperties(const css::uno::Sequence< css::beans::NamedValue >& lProperties) 328cdf0e10cSrcweir throw(css::uno::RuntimeException) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir ::comphelper::SequenceAsHashMap lSearchProps (lProperties); 331cdf0e10cSrcweir css::uno::Sequence< ::rtl::OUString > lModules = getElementNames(); 332cdf0e10cSrcweir sal_Int32 c = lModules.getLength(); 333cdf0e10cSrcweir sal_Int32 i = 0; 334cdf0e10cSrcweir ::comphelper::SequenceAsVector< css::uno::Any > lResult ; 335cdf0e10cSrcweir 336cdf0e10cSrcweir for (i=0; i<c; ++i) 337cdf0e10cSrcweir { 338cdf0e10cSrcweir try 339cdf0e10cSrcweir { 340cdf0e10cSrcweir const ::rtl::OUString& sModule = lModules[i]; 341cdf0e10cSrcweir ::comphelper::SequenceAsHashMap lModuleProps = getByName(sModule); 342cdf0e10cSrcweir 343cdf0e10cSrcweir if (lModuleProps.match(lSearchProps)) 344cdf0e10cSrcweir lResult.push_back(css::uno::makeAny(lModuleProps.getAsConstPropertyValueList())); 345cdf0e10cSrcweir } 346cdf0e10cSrcweir catch(const css::uno::Exception&) 347cdf0e10cSrcweir {} 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir ::comphelper::OAnyEnumeration* pEnum = new ::comphelper::OAnyEnumeration(lResult.getAsConstList()); 351cdf0e10cSrcweir css::uno::Reference< css::container::XEnumeration > xEnum(static_cast< css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY_THROW); 352cdf0e10cSrcweir return xEnum; 353cdf0e10cSrcweir } 354cdf0e10cSrcweir 355cdf0e10cSrcweir /*----------------------------------------------- 356cdf0e10cSrcweir 14.12.2003 09:45 357cdf0e10cSrcweir -----------------------------------------------*/ 358cdf0e10cSrcweir css::uno::Reference< css::container::XNameAccess > ModuleManager::implts_getConfig() 359cdf0e10cSrcweir throw(css::uno::RuntimeException) 360cdf0e10cSrcweir { 361cdf0e10cSrcweir // SAFE -> ---------------------------------- 362cdf0e10cSrcweir ReadGuard aReadLock(m_aLock); 363cdf0e10cSrcweir if (m_xCFG.is()) 364cdf0e10cSrcweir return m_xCFG; 365cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR; 366cdf0e10cSrcweir aReadLock.unlock(); 367cdf0e10cSrcweir // <- SAFE ---------------------------------- 368cdf0e10cSrcweir 369cdf0e10cSrcweir css::uno::Reference< css::uno::XInterface > xCfg; 370cdf0e10cSrcweir try 371cdf0e10cSrcweir { 372cdf0e10cSrcweir xCfg = ::comphelper::ConfigurationHelper::openConfig( 373cdf0e10cSrcweir xSMGR, 374cdf0e10cSrcweir CFGPATH_FACTORIES, 375cdf0e10cSrcweir ::comphelper::ConfigurationHelper::E_READONLY); 376cdf0e10cSrcweir } 377cdf0e10cSrcweir catch(const css::uno::RuntimeException& exRun) 378cdf0e10cSrcweir { throw exRun; } 379cdf0e10cSrcweir catch(const css::uno::Exception&) 380cdf0e10cSrcweir { xCfg.clear(); } 381cdf0e10cSrcweir 382cdf0e10cSrcweir // SAFE -> ---------------------------------- 383cdf0e10cSrcweir WriteGuard aWriteLock(m_aLock); 384cdf0e10cSrcweir m_xCFG = css::uno::Reference< css::container::XNameAccess >(xCfg, css::uno::UNO_QUERY_THROW); 385cdf0e10cSrcweir return m_xCFG; 386cdf0e10cSrcweir // <- SAFE ---------------------------------- 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir /*----------------------------------------------- 390cdf0e10cSrcweir 30.01.2004 07:54 391cdf0e10cSrcweir -----------------------------------------------*/ 392cdf0e10cSrcweir ::rtl::OUString ModuleManager::implts_identify(const css::uno::Reference< css::uno::XInterface >& xComponent) 393cdf0e10cSrcweir { 394cdf0e10cSrcweir // Search for an optional (!) interface XModule first. 39506fea5ebSmseidel // It's used to overrule an existing service name. Used e.g. by our database form designer 39606fea5ebSmseidel // which uses a writer module internally. 397cdf0e10cSrcweir css::uno::Reference< css::frame::XModule > xModule(xComponent, css::uno::UNO_QUERY); 398cdf0e10cSrcweir if (xModule.is()) 399cdf0e10cSrcweir return xModule->getIdentifier(); 400cdf0e10cSrcweir 401cdf0e10cSrcweir // detect modules in a generic way ... 402cdf0e10cSrcweir // comparing service names with configured entries ... 403cdf0e10cSrcweir css::uno::Reference< css::lang::XServiceInfo > xInfo(xComponent, css::uno::UNO_QUERY); 404cdf0e10cSrcweir if (!xInfo.is()) 405cdf0e10cSrcweir return ::rtl::OUString(); 406cdf0e10cSrcweir 407cdf0e10cSrcweir const css::uno::Sequence< ::rtl::OUString > lKnownModules = getElementNames(); 408cdf0e10cSrcweir const ::rtl::OUString* pKnownModules = lKnownModules.getConstArray(); 409cdf0e10cSrcweir sal_Int32 c = lKnownModules.getLength(); 410cdf0e10cSrcweir sal_Int32 i = 0; 411cdf0e10cSrcweir 412cdf0e10cSrcweir for (i=0; i<c; ++i) 413cdf0e10cSrcweir { 414cdf0e10cSrcweir if (xInfo->supportsService(pKnownModules[i])) 415cdf0e10cSrcweir return pKnownModules[i]; 416cdf0e10cSrcweir } 417cdf0e10cSrcweir 418cdf0e10cSrcweir return ::rtl::OUString(); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir } // namespace framework 422