2010-10-12 08:53:47 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2004-02-25 10:49:14 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 02:55:32 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-02-25 10:49:14 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2004-02-25 10:49:14 -06:00
|
|
|
*
|
2008-04-11 02:55:32 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-02-25 10:49:14 -06:00
|
|
|
*
|
2008-04-11 02:55:32 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-02-25 10:49:14 -06:00
|
|
|
*
|
2008-04-11 02:55:32 -05:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-02-25 10:49:14 -06:00
|
|
|
*
|
2008-04-11 02:55:32 -05:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-02-25 10:49:14 -06:00
|
|
|
*
|
2008-04-11 02:55:32 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-02-25 10:49:14 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 08:11:01 -05:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_framework.hxx"
|
|
|
|
|
2004-02-25 10:49:14 -06:00
|
|
|
#include "services/modulemanager.hxx"
|
|
|
|
#include "services/frame.hxx"
|
|
|
|
|
|
|
|
//_______________________________________________
|
|
|
|
// own includes
|
|
|
|
#include <threadhelp/readguard.hxx>
|
|
|
|
#include <threadhelp/writeguard.hxx>
|
|
|
|
#include <services.h>
|
|
|
|
|
|
|
|
//_______________________________________________
|
|
|
|
// interface includes
|
|
|
|
#include <com/sun/star/frame/XFrame.hpp>
|
|
|
|
#include <com/sun/star/frame/XController.hpp>
|
|
|
|
#include <com/sun/star/frame/XModel.hpp>
|
2007-04-16 10:44:41 -05:00
|
|
|
#include <com/sun/star/frame/XModule.hpp>
|
|
|
|
#include <comphelper/configurationhelper.hxx>
|
|
|
|
#include <comphelper/sequenceashashmap.hxx>
|
|
|
|
#include <comphelper/sequenceasvector.hxx>
|
|
|
|
#include <comphelper/enumhelper.hxx>
|
|
|
|
|
|
|
|
//_______________________________________________
|
|
|
|
// other includes
|
2009-09-07 23:57:32 -05:00
|
|
|
#include <rtl/logfile.hxx>
|
2007-04-16 10:44:41 -05:00
|
|
|
|
2004-02-25 10:49:14 -06:00
|
|
|
namespace framework
|
|
|
|
{
|
|
|
|
|
2010-11-20 05:20:55 -06:00
|
|
|
static const ::rtl::OUString CFGPATH_FACTORIES (RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Setup/Office/Factories"));
|
|
|
|
static const ::rtl::OUString MODULEPROP_IDENTIFIER(RTL_CONSTASCII_USTRINGPARAM("ooSetupFactoryModuleIdentifier"));
|
2007-04-16 10:44:41 -05:00
|
|
|
|
2004-02-25 10:49:14 -06:00
|
|
|
/*-----------------------------------------------
|
|
|
|
04.12.2003 09:32
|
|
|
|
-----------------------------------------------*/
|
2007-04-16 10:44:41 -05:00
|
|
|
DEFINE_XINTERFACE_7(ModuleManager ,
|
|
|
|
OWeakObject ,
|
|
|
|
DIRECT_INTERFACE(css::lang::XTypeProvider ),
|
|
|
|
DIRECT_INTERFACE(css::lang::XServiceInfo ),
|
|
|
|
DIRECT_INTERFACE(css::container::XNameReplace ),
|
|
|
|
DIRECT_INTERFACE(css::container::XNameAccess ),
|
|
|
|
DIRECT_INTERFACE(css::container::XElementAccess ),
|
|
|
|
DIRECT_INTERFACE(css::container::XContainerQuery),
|
|
|
|
DIRECT_INTERFACE(css::frame::XModuleManager ))
|
2004-02-25 10:49:14 -06:00
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
04.12.2003 09:32
|
|
|
|
-----------------------------------------------*/
|
2007-04-16 10:44:41 -05:00
|
|
|
DEFINE_XTYPEPROVIDER_7(ModuleManager ,
|
|
|
|
css::lang::XTypeProvider ,
|
|
|
|
css::lang::XServiceInfo ,
|
|
|
|
css::container::XNameReplace ,
|
|
|
|
css::container::XNameAccess ,
|
|
|
|
css::container::XElementAccess ,
|
|
|
|
css::container::XContainerQuery,
|
|
|
|
css::frame::XModuleManager )
|
2004-02-25 10:49:14 -06:00
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
04.12.2003 09:35
|
|
|
|
-----------------------------------------------*/
|
2005-02-16 09:31:23 -06:00
|
|
|
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE(ModuleManager ,
|
2007-04-16 10:44:41 -05:00
|
|
|
::cppu::OWeakObject ,
|
|
|
|
SERVICENAME_MODULEMANAGER ,
|
|
|
|
IMPLEMENTATIONNAME_MODULEMANAGER)
|
2004-02-25 10:49:14 -06:00
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
04.12.2003 09:35
|
|
|
|
-----------------------------------------------*/
|
|
|
|
DEFINE_INIT_SERVICE(
|
|
|
|
ModuleManager,
|
|
|
|
{
|
|
|
|
/*Attention
|
|
|
|
I think we don't need any mutex or lock here ... because we are called by our own static method impl_createInstance()
|
|
|
|
to create a new instance of this class by our own supported service factory.
|
|
|
|
see macro DEFINE_XSERVICEINFO_MULTISERVICE and "impl_initService()" for further informations!
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
04.12.2003 09:30
|
|
|
|
-----------------------------------------------*/
|
|
|
|
ModuleManager::ModuleManager(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR)
|
|
|
|
: ThreadHelpBase( )
|
|
|
|
, m_xSMGR (xSMGR)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
10.12.2003 11:59
|
|
|
|
-----------------------------------------------*/
|
|
|
|
ModuleManager::~ModuleManager()
|
|
|
|
{
|
|
|
|
if (m_xCFG.is())
|
|
|
|
m_xCFG.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
10.12.2003 11:02
|
|
|
|
-----------------------------------------------*/
|
|
|
|
::rtl::OUString SAL_CALL ModuleManager::identify(const css::uno::Reference< css::uno::XInterface >& xModule)
|
|
|
|
throw(css::lang::IllegalArgumentException,
|
2005-03-01 12:39:00 -06:00
|
|
|
css::frame::UnknownModuleException,
|
2004-02-25 10:49:14 -06:00
|
|
|
css::uno::RuntimeException )
|
|
|
|
{
|
|
|
|
// valid parameter?
|
|
|
|
css::uno::Reference< css::frame::XFrame > xFrame (xModule, css::uno::UNO_QUERY);
|
2007-04-16 10:44:41 -05:00
|
|
|
css::uno::Reference< css::awt::XWindow > xWindow (xModule, css::uno::UNO_QUERY);
|
2004-02-25 10:49:14 -06:00
|
|
|
css::uno::Reference< css::frame::XController > xController(xModule, css::uno::UNO_QUERY);
|
|
|
|
css::uno::Reference< css::frame::XModel > xModel (xModule, css::uno::UNO_QUERY);
|
|
|
|
|
|
|
|
if (
|
|
|
|
(!xFrame.is() ) &&
|
2007-04-16 10:44:41 -05:00
|
|
|
(!xWindow.is() ) &&
|
2004-02-25 10:49:14 -06:00
|
|
|
(!xController.is()) &&
|
|
|
|
(!xModel.is() )
|
|
|
|
)
|
|
|
|
{
|
|
|
|
throw css::lang::IllegalArgumentException(
|
2010-11-20 05:20:55 -06:00
|
|
|
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Given module is not a frame nor a window, controller or model.")),
|
2004-02-25 10:49:14 -06:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this),
|
|
|
|
1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xFrame.is())
|
2007-04-16 10:44:41 -05:00
|
|
|
{
|
2004-02-25 10:49:14 -06:00
|
|
|
xController = xFrame->getController();
|
2007-04-16 10:44:41 -05:00
|
|
|
xWindow = xFrame->getComponentWindow();
|
|
|
|
}
|
2004-02-25 10:49:14 -06:00
|
|
|
if (xController.is())
|
|
|
|
xModel = xController->getModel();
|
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
// modules are implemented by the deepest component in hierarchy ...
|
|
|
|
// Means: model -> controller -> window
|
|
|
|
// No fallbacks to higher components are allowed !
|
|
|
|
// Note : A frame provides access to module components only ... but it's not a module by himself.
|
|
|
|
|
|
|
|
::rtl::OUString sModule;
|
2004-02-25 10:49:14 -06:00
|
|
|
if (xModel.is())
|
2007-04-16 10:44:41 -05:00
|
|
|
sModule = implts_identify(xModel);
|
|
|
|
else
|
|
|
|
if (xController.is())
|
|
|
|
sModule = implts_identify(xController);
|
|
|
|
else
|
|
|
|
if (xWindow.is())
|
|
|
|
sModule = implts_identify(xWindow);
|
2004-02-25 10:49:14 -06:00
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
if (sModule.getLength() < 1)
|
2005-03-01 12:39:00 -06:00
|
|
|
throw css::frame::UnknownModuleException(
|
2010-11-20 05:20:55 -06:00
|
|
|
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Cant find suitable module for the given component.")),
|
2004-02-25 10:49:14 -06:00
|
|
|
static_cast< ::cppu::OWeakObject* >(this));
|
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
return sModule;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
08.03.2007 09:55
|
|
|
|
-----------------------------------------------*/
|
|
|
|
void SAL_CALL ModuleManager::replaceByName(const ::rtl::OUString& sName ,
|
|
|
|
const css::uno::Any& aValue)
|
|
|
|
throw (css::lang::IllegalArgumentException ,
|
|
|
|
css::container::NoSuchElementException,
|
|
|
|
css::lang::WrappedTargetException ,
|
|
|
|
css::uno::RuntimeException )
|
|
|
|
{
|
|
|
|
::comphelper::SequenceAsHashMap lProps(aValue);
|
2009-09-07 23:57:32 -05:00
|
|
|
if (lProps.empty() )
|
2007-04-16 10:44:41 -05:00
|
|
|
{
|
|
|
|
throw css::lang::IllegalArgumentException(
|
2010-11-20 05:20:55 -06:00
|
|
|
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("No properties given to replace part of module.")),
|
2007-04-16 10:44:41 -05:00
|
|
|
static_cast< css::container::XNameAccess* >(this),
|
|
|
|
2);
|
|
|
|
}
|
|
|
|
|
2004-02-25 10:49:14 -06:00
|
|
|
// SAFE -> ----------------------------------
|
|
|
|
ReadGuard aReadLock(m_aLock);
|
2007-04-16 10:44:41 -05:00
|
|
|
css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
|
2004-02-25 10:49:14 -06:00
|
|
|
aReadLock.unlock();
|
|
|
|
// <- SAFE ----------------------------------
|
2007-04-16 10:44:41 -05:00
|
|
|
|
|
|
|
// get access to the element
|
|
|
|
// Note: Dont use impl_getConfig() method here. Because it creates a readonly access only, further
|
|
|
|
// it cache it as a member of this module manager instance. If we change some props there ... but dont
|
2010-12-03 22:16:21 -06:00
|
|
|
// flush changes (because an error occurred) we will read them later. If we use a different config access
|
2007-04-16 10:44:41 -05:00
|
|
|
// we can close it without a flush ... and our read data wont be affected .-)
|
|
|
|
css::uno::Reference< css::uno::XInterface > xCfg = ::comphelper::ConfigurationHelper::openConfig(
|
|
|
|
xSMGR,
|
|
|
|
CFGPATH_FACTORIES,
|
|
|
|
::comphelper::ConfigurationHelper::E_STANDARD);
|
|
|
|
css::uno::Reference< css::container::XNameAccess > xModules (xCfg, css::uno::UNO_QUERY_THROW);
|
|
|
|
css::uno::Reference< css::container::XNameReplace > xModule ;
|
|
|
|
|
|
|
|
xModules->getByName(sName) >>= xModule;
|
|
|
|
if (!xModule.is())
|
|
|
|
{
|
|
|
|
throw css::uno::RuntimeException(
|
2010-11-20 05:20:55 -06:00
|
|
|
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Was not able to get write access to the requested module entry inside configuration.")),
|
2007-04-16 10:44:41 -05:00
|
|
|
static_cast< css::container::XNameAccess* >(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
::comphelper::SequenceAsHashMap::const_iterator pProp;
|
|
|
|
for ( pProp = lProps.begin();
|
|
|
|
pProp != lProps.end() ;
|
|
|
|
++pProp )
|
|
|
|
{
|
|
|
|
const ::rtl::OUString& sPropName = pProp->first;
|
|
|
|
const css::uno::Any& aPropValue = pProp->second;
|
|
|
|
|
|
|
|
// let "NoSuchElementException" out ! We support the same API ...
|
|
|
|
// and without a flush() at the end all changed data before will be ignored !
|
|
|
|
xModule->replaceByName(sPropName, aPropValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
::comphelper::ConfigurationHelper::flush(xCfg);
|
2004-02-25 10:49:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
10.12.2003 12:05
|
|
|
|
-----------------------------------------------*/
|
|
|
|
css::uno::Any SAL_CALL ModuleManager::getByName(const ::rtl::OUString& sName)
|
|
|
|
throw(css::container::NoSuchElementException,
|
|
|
|
css::lang::WrappedTargetException ,
|
|
|
|
css::uno::RuntimeException )
|
|
|
|
{
|
|
|
|
// get access to the element
|
2007-04-16 10:44:41 -05:00
|
|
|
css::uno::Reference< css::container::XNameAccess > xCFG = implts_getConfig();
|
|
|
|
css::uno::Reference< css::container::XNameAccess > xModule;
|
2009-09-07 23:57:32 -05:00
|
|
|
xCFG->getByName(sName) >>= xModule;
|
2007-04-16 10:44:41 -05:00
|
|
|
if (!xModule.is())
|
2004-02-25 10:49:14 -06:00
|
|
|
{
|
2007-04-16 10:44:41 -05:00
|
|
|
throw css::uno::RuntimeException(
|
2010-11-20 05:20:55 -06:00
|
|
|
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Was not able to get write access to the requested module entry inside configuration.")),
|
2004-02-25 10:49:14 -06:00
|
|
|
static_cast< css::container::XNameAccess* >(this));
|
|
|
|
}
|
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
// convert it to seq< PropertyValue >
|
|
|
|
const css::uno::Sequence< ::rtl::OUString > lPropNames = xModule->getElementNames();
|
|
|
|
::comphelper::SequenceAsHashMap lProps ;
|
|
|
|
sal_Int32 c = lPropNames.getLength();
|
|
|
|
sal_Int32 i = 0;
|
2004-02-25 10:49:14 -06:00
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
lProps[MODULEPROP_IDENTIFIER] <<= sName;
|
|
|
|
for (i=0; i<c; ++i)
|
2004-02-25 10:49:14 -06:00
|
|
|
{
|
2007-04-16 10:44:41 -05:00
|
|
|
const ::rtl::OUString& sPropName = lPropNames[i];
|
|
|
|
lProps[sPropName] = xModule->getByName(sPropName);
|
2004-02-25 10:49:14 -06:00
|
|
|
}
|
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
return css::uno::makeAny(lProps.getAsConstPropertyValueList());
|
2004-02-25 10:49:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
10.12.2003 11:58
|
|
|
|
-----------------------------------------------*/
|
|
|
|
css::uno::Sequence< ::rtl::OUString > SAL_CALL ModuleManager::getElementNames()
|
|
|
|
throw(css::uno::RuntimeException)
|
|
|
|
{
|
2007-04-16 10:44:41 -05:00
|
|
|
css::uno::Reference< css::container::XNameAccess > xCFG = implts_getConfig();
|
2004-02-25 10:49:14 -06:00
|
|
|
return xCFG->getElementNames();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
10.12.2003 11:57
|
|
|
|
-----------------------------------------------*/
|
|
|
|
sal_Bool SAL_CALL ModuleManager::hasByName(const ::rtl::OUString& sName)
|
|
|
|
throw(css::uno::RuntimeException)
|
|
|
|
{
|
2007-04-16 10:44:41 -05:00
|
|
|
css::uno::Reference< css::container::XNameAccess > xCFG = implts_getConfig();
|
2004-02-25 10:49:14 -06:00
|
|
|
return xCFG->hasByName(sName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
10.12.2003 11:35
|
|
|
|
-----------------------------------------------*/
|
|
|
|
css::uno::Type SAL_CALL ModuleManager::getElementType()
|
|
|
|
throw(css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return ::getCppuType((const css::uno::Sequence< css::beans::PropertyValue >*)0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
10.12.2003 11:56
|
|
|
|
-----------------------------------------------*/
|
|
|
|
sal_Bool SAL_CALL ModuleManager::hasElements()
|
|
|
|
throw(css::uno::RuntimeException)
|
|
|
|
{
|
2007-04-16 10:44:41 -05:00
|
|
|
css::uno::Reference< css::container::XNameAccess > xCFG = implts_getConfig();
|
2004-02-25 10:49:14 -06:00
|
|
|
return xCFG->hasElements();
|
|
|
|
}
|
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
/*-----------------------------------------------
|
|
|
|
07.03.2007 12:55
|
|
|
|
-----------------------------------------------*/
|
|
|
|
css::uno::Reference< css::container::XEnumeration > SAL_CALL ModuleManager::createSubSetEnumerationByQuery(const ::rtl::OUString&)
|
|
|
|
throw(css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
return css::uno::Reference< css::container::XEnumeration >();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
07.03.2007 12:55
|
|
|
|
-----------------------------------------------*/
|
|
|
|
css::uno::Reference< css::container::XEnumeration > SAL_CALL ModuleManager::createSubSetEnumerationByProperties(const css::uno::Sequence< css::beans::NamedValue >& lProperties)
|
|
|
|
throw(css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
::comphelper::SequenceAsHashMap lSearchProps (lProperties);
|
|
|
|
css::uno::Sequence< ::rtl::OUString > lModules = getElementNames();
|
|
|
|
sal_Int32 c = lModules.getLength();
|
|
|
|
sal_Int32 i = 0;
|
|
|
|
::comphelper::SequenceAsVector< css::uno::Any > lResult ;
|
|
|
|
|
|
|
|
for (i=0; i<c; ++i)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const ::rtl::OUString& sModule = lModules[i];
|
|
|
|
::comphelper::SequenceAsHashMap lModuleProps = getByName(sModule);
|
|
|
|
|
|
|
|
if (lModuleProps.match(lSearchProps))
|
|
|
|
lResult.push_back(css::uno::makeAny(lModuleProps.getAsConstPropertyValueList()));
|
|
|
|
}
|
|
|
|
catch(const css::uno::Exception&)
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
|
|
|
|
::comphelper::OAnyEnumeration* pEnum = new ::comphelper::OAnyEnumeration(lResult.getAsConstList());
|
|
|
|
css::uno::Reference< css::container::XEnumeration > xEnum(static_cast< css::container::XEnumeration* >(pEnum), css::uno::UNO_QUERY_THROW);
|
|
|
|
return xEnum;
|
|
|
|
}
|
|
|
|
|
2004-02-25 10:49:14 -06:00
|
|
|
/*-----------------------------------------------
|
|
|
|
14.12.2003 09:45
|
|
|
|
-----------------------------------------------*/
|
2007-04-16 10:44:41 -05:00
|
|
|
css::uno::Reference< css::container::XNameAccess > ModuleManager::implts_getConfig()
|
2004-02-25 10:49:14 -06:00
|
|
|
throw(css::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
// SAFE -> ----------------------------------
|
2007-04-16 10:44:41 -05:00
|
|
|
ReadGuard aReadLock(m_aLock);
|
2004-02-25 10:49:14 -06:00
|
|
|
if (m_xCFG.is())
|
|
|
|
return m_xCFG;
|
2007-04-16 10:44:41 -05:00
|
|
|
css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = m_xSMGR;
|
|
|
|
aReadLock.unlock();
|
|
|
|
// <- SAFE ----------------------------------
|
2004-02-25 10:49:14 -06:00
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
css::uno::Reference< css::uno::XInterface > xCfg;
|
2004-02-25 10:49:14 -06:00
|
|
|
try
|
|
|
|
{
|
2007-04-16 10:44:41 -05:00
|
|
|
xCfg = ::comphelper::ConfigurationHelper::openConfig(
|
|
|
|
xSMGR,
|
|
|
|
CFGPATH_FACTORIES,
|
|
|
|
::comphelper::ConfigurationHelper::E_READONLY);
|
2004-02-25 10:49:14 -06:00
|
|
|
}
|
2007-04-16 10:44:41 -05:00
|
|
|
catch(const css::uno::RuntimeException& exRun)
|
|
|
|
{ throw exRun; }
|
2004-02-25 10:49:14 -06:00
|
|
|
catch(const css::uno::Exception&)
|
2007-04-16 10:44:41 -05:00
|
|
|
{ xCfg.clear(); }
|
2004-02-25 10:49:14 -06:00
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
// SAFE -> ----------------------------------
|
|
|
|
WriteGuard aWriteLock(m_aLock);
|
|
|
|
m_xCFG = css::uno::Reference< css::container::XNameAccess >(xCfg, css::uno::UNO_QUERY_THROW);
|
2004-02-25 10:49:14 -06:00
|
|
|
return m_xCFG;
|
|
|
|
// <- SAFE ----------------------------------
|
|
|
|
}
|
|
|
|
|
|
|
|
/*-----------------------------------------------
|
|
|
|
30.01.2004 07:54
|
|
|
|
-----------------------------------------------*/
|
2007-04-16 10:44:41 -05:00
|
|
|
::rtl::OUString ModuleManager::implts_identify(const css::uno::Reference< css::uno::XInterface >& xComponent)
|
2004-02-25 10:49:14 -06:00
|
|
|
{
|
2007-04-16 10:44:41 -05:00
|
|
|
// Search for an optional (!) interface XModule first.
|
|
|
|
// Its used to overrule an existing service name. Used e.g. by our database form designer
|
|
|
|
// which uses a writer module internaly.
|
|
|
|
css::uno::Reference< css::frame::XModule > xModule(xComponent, css::uno::UNO_QUERY);
|
|
|
|
if (xModule.is())
|
|
|
|
return xModule->getIdentifier();
|
|
|
|
|
|
|
|
// detect modules in a generic way ...
|
|
|
|
// comparing service names with configured entries ...
|
|
|
|
css::uno::Reference< css::lang::XServiceInfo > xInfo(xComponent, css::uno::UNO_QUERY);
|
|
|
|
if (!xInfo.is())
|
|
|
|
return ::rtl::OUString();
|
|
|
|
|
2004-02-25 10:49:14 -06:00
|
|
|
const css::uno::Sequence< ::rtl::OUString > lKnownModules = getElementNames();
|
|
|
|
const ::rtl::OUString* pKnownModules = lKnownModules.getConstArray();
|
|
|
|
sal_Int32 c = lKnownModules.getLength();
|
2007-04-16 10:44:41 -05:00
|
|
|
sal_Int32 i = 0;
|
2004-02-25 10:49:14 -06:00
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
for (i=0; i<c; ++i)
|
2004-02-25 10:49:14 -06:00
|
|
|
{
|
2007-04-16 10:44:41 -05:00
|
|
|
if (xInfo->supportsService(pKnownModules[i]))
|
|
|
|
return pKnownModules[i];
|
2004-02-25 10:49:14 -06:00
|
|
|
}
|
|
|
|
|
2007-04-16 10:44:41 -05:00
|
|
|
return ::rtl::OUString();
|
2004-02-25 10:49:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace framework
|
2010-10-12 08:53:47 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|