2000-11-07 07:40:31 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 05:56:42 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 05:56:42 -05:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 05:56:42 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 05:56:42 -05:00
|
|
|
* $RCSfile: confprovider2.cxx,v $
|
|
|
|
* $Revision: 1.33 $
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 05:56:42 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 05:56:42 -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.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 05:56:42 -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).
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
2008-04-11 05:56:42 -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.
|
2000-11-07 07:40:31 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-16 08:56:39 -05:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_configmgr.hxx"
|
2002-05-17 07:22:13 -05:00
|
|
|
#include <stdio.h>
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
#include "confprovider2.hxx"
|
|
|
|
#include "apiaccessobj.hxx"
|
|
|
|
#include "confproviderimpl2.hxx"
|
2003-03-19 09:20:19 -06:00
|
|
|
#ifndef CONFIGMGR_API_FACTORY_HXX_
|
|
|
|
#include "confapifactory.hxx"
|
|
|
|
#endif
|
2000-11-07 07:40:31 -06:00
|
|
|
#include "bootstrap.hxx"
|
2003-03-19 09:20:19 -06:00
|
|
|
#include "bootstrapcontext.hxx"
|
|
|
|
#include "wrapexception.hxx"
|
2000-11-07 07:40:31 -06:00
|
|
|
#include "tracer.hxx"
|
|
|
|
#include <osl/mutex.hxx>
|
2002-10-28 07:43:35 -06:00
|
|
|
#include <rtl/ustrbuf.hxx>
|
2003-03-19 09:20:19 -06:00
|
|
|
#ifndef INCLUDED_ALGORITHM
|
2001-03-07 10:19:01 -06:00
|
|
|
#include <algorithm>
|
2003-03-19 09:20:19 -06:00
|
|
|
#define INCLUDED_ALGORITHM
|
2000-11-07 07:40:31 -06:00
|
|
|
#endif
|
|
|
|
#include <comphelper/sequence.hxx>
|
|
|
|
#include <cppuhelper/typeprovider.hxx>
|
|
|
|
#include <com/sun/star/beans/PropertyValue.hpp>
|
2002-10-28 07:43:35 -06:00
|
|
|
#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
#define THISREF() static_cast< ::cppu::OWeakObject* >(this)
|
|
|
|
|
|
|
|
namespace configmgr
|
|
|
|
{
|
|
|
|
namespace css = ::com::sun::star;
|
|
|
|
namespace uno = css::uno;
|
|
|
|
namespace lang = css::lang;
|
|
|
|
namespace beans = css::beans;
|
|
|
|
using ::rtl::OUString;
|
|
|
|
using ::vos::ORef;
|
|
|
|
using namespace osl;
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2003-03-19 09:20:19 -06:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
AsciiServiceName const aConfigProviderServices[] =
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
2000-11-09 07:23:05 -06:00
|
|
|
"com.sun.star.configuration.ConfigurationProvider",
|
2000-11-07 07:40:31 -06:00
|
|
|
0
|
|
|
|
};
|
2003-03-19 09:20:19 -06:00
|
|
|
AsciiServiceName const aAdminProviderServices[] =
|
2001-04-03 10:33:58 -05:00
|
|
|
{
|
|
|
|
"com.sun.star.configuration.AdministrationProvider",
|
|
|
|
0
|
|
|
|
};
|
2003-03-19 09:20:19 -06:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ServiceImplementationInfo const aConfigProviderInfo =
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
2000-11-10 15:45:40 -06:00
|
|
|
"com.sun.star.comp.configuration.ConfigurationProvider",
|
2003-03-19 09:20:19 -06:00
|
|
|
aConfigProviderServices,
|
2002-12-06 06:08:35 -06:00
|
|
|
0
|
2000-11-07 07:40:31 -06:00
|
|
|
};
|
2003-03-19 09:20:19 -06:00
|
|
|
ServiceImplementationInfo const aAdminProviderInfo =
|
|
|
|
{
|
|
|
|
"com.sun.star.comp.configuration.AdministrationProvider",
|
|
|
|
aAdminProviderServices,
|
|
|
|
aConfigProviderServices
|
|
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
AsciiServiceName const
|
|
|
|
aDefaultProviderServiceAndImplName = A_DefaultProviderServiceAndImplName;
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
AsciiServiceName const aDefaultProviderServices[] =
|
2001-04-03 10:33:58 -05:00
|
|
|
{
|
2003-03-19 09:20:19 -06:00
|
|
|
aDefaultProviderServiceAndImplName,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ServiceRegistrationInfo const aDefaultProviderInfo =
|
|
|
|
{
|
|
|
|
aDefaultProviderServiceAndImplName,
|
|
|
|
aDefaultProviderServices
|
|
|
|
};
|
|
|
|
SingletonRegistrationInfo const aDefaultProviderSingletonInfo =
|
|
|
|
{
|
|
|
|
A_DefaultProviderSingletonName,
|
|
|
|
aDefaultProviderServiceAndImplName,
|
|
|
|
aDefaultProviderServiceAndImplName,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
typedef uno::Reference< uno::XInterface > (OConfigurationProviderImpl::*CreatorFunc)(const uno::Sequence< uno::Any >& aArguments);
|
|
|
|
struct ServiceCreationInfo
|
|
|
|
{
|
|
|
|
ServiceRegistrationInfo const* info;
|
|
|
|
CreatorFunc create;
|
2001-04-03 10:33:58 -05:00
|
|
|
};
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
static sal_Int32 getCreateServiceDataCount()
|
|
|
|
{
|
2000-11-10 15:45:40 -06:00
|
|
|
return 2;
|
2007-11-23 07:06:13 -06:00
|
|
|
}
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2000-11-10 15:45:40 -06:00
|
|
|
static const ServiceCreationInfo* getCreateServiceData()
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
2000-11-10 15:45:40 -06:00
|
|
|
static ServiceCreationInfo const createServiceData[] =
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
2001-02-05 02:57:27 -06:00
|
|
|
{ &configapi::aCreateReadAccessSI, &OConfigurationProviderImpl::createReadAccess },
|
|
|
|
{ &configapi::aCreateUpdateAccessSI, &OConfigurationProviderImpl::createUpdateAccess },
|
2000-11-07 07:40:31 -06:00
|
|
|
};
|
2001-03-21 05:17:35 -06:00
|
|
|
OSL_ENSURE(sizeof(createServiceData)/sizeof(createServiceData[0]) == getCreateServiceDataCount(),
|
2000-11-07 07:40:31 -06:00
|
|
|
"getCreateServiceData : inconsistent data !");
|
|
|
|
return createServiceData;
|
|
|
|
}
|
2003-03-19 09:20:19 -06:00
|
|
|
//------------------------------------------------------------------------
|
2000-11-07 07:40:31 -06:00
|
|
|
}
|
|
|
|
|
2000-11-10 15:45:40 -06:00
|
|
|
static ServiceCreationInfo const* findCreationInfo( const OUString& aServiceSpecifier )
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
|
|
|
for (int i= 0; i<getCreateServiceDataCount(); ++i)
|
|
|
|
{
|
2000-11-10 15:45:40 -06:00
|
|
|
ServiceCreationInfo const& rCreationInfo = getCreateServiceData()[i];
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2002-12-06 06:08:35 -06:00
|
|
|
ServiceRegistrationInfo const* pInfo = rCreationInfo.info;
|
2000-11-07 07:40:31 -06:00
|
|
|
if (!pInfo)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (AsciiServiceName pImplName = pInfo->implementationName)
|
|
|
|
{
|
|
|
|
if (0 == aServiceSpecifier.compareToAscii(pImplName))
|
|
|
|
return &rCreationInfo;
|
|
|
|
}
|
|
|
|
|
2002-12-06 06:08:35 -06:00
|
|
|
if (AsciiServiceName const* pNames = pInfo->registeredServiceNames)
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
|
|
|
while(*pNames)
|
|
|
|
{
|
|
|
|
if (0 == aServiceSpecifier.compareToAscii(*pNames))
|
|
|
|
return &rCreationInfo;
|
|
|
|
|
|
|
|
++pNames;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// not found
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:45:49 -05:00
|
|
|
//#define ID_PREFETCH 1
|
|
|
|
static const int ID_PREFETCH=1;
|
|
|
|
static const int ID_ENABLEASYNC=2;
|
2001-02-08 05:03:27 -06:00
|
|
|
|
2004-11-15 06:34:33 -06:00
|
|
|
static inline
|
|
|
|
OUString getPrefetchPropName() { return OUString( RTL_CONSTASCII_USTRINGPARAM("PrefetchNodes") ); }
|
|
|
|
static inline
|
|
|
|
OUString getEnableAsyncPropName() { return OUString( RTL_CONSTASCII_USTRINGPARAM("EnableAsync") ); }
|
2000-11-10 15:45:40 -06:00
|
|
|
//=============================================================================
|
|
|
|
//= OConfigurationProvider
|
|
|
|
//=============================================================================
|
2001-04-03 10:33:58 -05:00
|
|
|
// service info export
|
2003-03-19 09:20:19 -06:00
|
|
|
const ServiceRegistrationInfo* getConfigurationProviderServiceInfo()
|
2001-04-03 10:33:58 -05:00
|
|
|
{
|
2003-03-19 09:20:19 -06:00
|
|
|
return getRegistrationInfo(&aConfigProviderInfo);
|
2001-04-03 10:33:58 -05:00
|
|
|
}
|
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
const ServiceRegistrationInfo* getAdminProviderServiceInfo()
|
2001-04-03 10:33:58 -05:00
|
|
|
{
|
2003-03-19 09:20:19 -06:00
|
|
|
return getRegistrationInfo(&aAdminProviderInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
const ServiceRegistrationInfo* getDefaultProviderServiceInfo()
|
|
|
|
{
|
|
|
|
return &aDefaultProviderInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SingletonRegistrationInfo* getDefaultProviderSingletonInfo()
|
|
|
|
{
|
|
|
|
return &aDefaultProviderSingletonInfo;
|
2001-04-03 10:33:58 -05:00
|
|
|
}
|
|
|
|
|
2000-11-10 15:45:40 -06:00
|
|
|
//-----------------------------------------------------------------------------
|
2003-03-19 09:20:19 -06:00
|
|
|
uno::Reference<uno::XInterface> SAL_CALL
|
|
|
|
getDefaultConfigProviderSingleton( CreationContext const& xContext )
|
2001-04-03 10:33:58 -05:00
|
|
|
{
|
2003-03-19 09:20:19 -06:00
|
|
|
OSL_ENSURE( xContext.is(), "ERROR: NULL context has no singletons" );
|
2001-04-03 10:33:58 -05:00
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
UnoContextTunnel aTunnel;
|
|
|
|
aTunnel.passthru( xContext );
|
2001-04-03 10:33:58 -05:00
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
uno::Reference<uno::XInterface> xResult;
|
2001-04-03 10:33:58 -05:00
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
if (xContext.is())
|
|
|
|
try
|
|
|
|
{
|
|
|
|
OUString aSingletonName = SINGLETON(A_DefaultProviderSingletonName);
|
|
|
|
uno::Any aResult = xContext->getValueByName(aSingletonName);
|
|
|
|
aResult >>= xResult;
|
|
|
|
}
|
|
|
|
catch (uno::Exception & )
|
|
|
|
{
|
|
|
|
// to do: really use the tunneled failure when that is set properly
|
|
|
|
if ( aTunnel.recoverFailure(true).hasValue() )
|
|
|
|
{
|
|
|
|
// have a failure, but can't recover it
|
|
|
|
// -> try to regenerate
|
|
|
|
instantiateDefaultProvider(xContext);
|
2001-04-03 10:33:58 -05:00
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
OSL_ENSURE(false, "Cannot recreate configuration backend instantiation failure - using generic error");
|
|
|
|
}
|
|
|
|
// cannot recover any failure
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
return xResult;
|
2001-04-03 10:33:58 -05:00
|
|
|
}
|
2003-03-19 09:20:19 -06:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
#define TUNNEL_ALL_EXCEPTIONS() \
|
|
|
|
WRAP_CONFIGBACKEND_CREATION_EXCEPTIONS1( UnoContextTunnel::tunnelFailure, true)
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// ------------------------------------------------------------------------
|
2001-04-03 10:33:58 -05:00
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
uno::Reference< uno::XInterface > SAL_CALL instantiateDefaultProvider( OProvider::CreationContext const & xTargetContext )
|
2001-04-03 10:33:58 -05:00
|
|
|
{
|
2003-03-19 09:20:19 -06:00
|
|
|
CreationContext xContext = UnoContextTunnel::recoverContext(xTargetContext);
|
|
|
|
|
|
|
|
ServiceImplementationInfo const * pProviderInfo =
|
|
|
|
ContextReader::testAdminService(xContext,true) ? &aAdminProviderInfo : &aConfigProviderInfo;
|
2001-04-03 10:33:58 -05:00
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
OConfigurationProvider* pNewProvider = new OConfigurationProvider(xContext,pProviderInfo);
|
|
|
|
uno::Reference< lang::XMultiServiceFactory > aRet( pNewProvider );
|
2001-04-03 10:33:58 -05:00
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
try
|
|
|
|
{
|
|
|
|
pNewProvider->connect();
|
|
|
|
}
|
|
|
|
TUNNEL_ALL_EXCEPTIONS()
|
2001-04-03 10:33:58 -05:00
|
|
|
|
2006-06-19 17:15:25 -05:00
|
|
|
return uno::Reference< uno::XInterface >( aRet, uno::UNO_QUERY );
|
2001-04-03 10:33:58 -05:00
|
|
|
}
|
|
|
|
|
2004-11-15 06:34:33 -06:00
|
|
|
//-----------------------------------------------------------------------------
|
2003-03-19 09:20:19 -06:00
|
|
|
//-----------------------------------------------------------------------------
|
2001-04-03 10:33:58 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
OConfigurationProvider::OConfigurationProvider(
|
2003-03-19 09:20:19 -06:00
|
|
|
CreationContext const & xContext,
|
2002-12-06 06:08:35 -06:00
|
|
|
const ServiceImplementationInfo* pServices
|
2001-04-03 10:33:58 -05:00
|
|
|
)
|
2004-11-15 06:34:33 -06:00
|
|
|
:OProvider(xContext,pServices)
|
|
|
|
,m_pImpl(NULL)
|
|
|
|
,m_bEnableAsync(false)
|
2000-11-10 15:45:40 -06:00
|
|
|
{
|
2004-11-15 06:34:33 -06:00
|
|
|
registerProperty(getPrefetchPropName(), ID_PREFETCH, 0,&m_aPrefetchNodes, ::getCppuType(&m_aPrefetchNodes));
|
|
|
|
registerProperty(getEnableAsyncPropName(), ID_ENABLEASYNC, 0, &m_bEnableAsync, ::getBooleanCppuType());
|
2000-11-10 15:45:40 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2001-02-15 10:25:17 -06:00
|
|
|
OConfigurationProvider::~OConfigurationProvider()
|
|
|
|
{
|
|
|
|
delete m_pImpl;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2003-03-19 09:20:19 -06:00
|
|
|
void OConfigurationProvider::connect() throw (uno::Exception)
|
2000-11-10 15:45:40 -06:00
|
|
|
{
|
2001-04-03 10:33:58 -05:00
|
|
|
OSL_ENSURE( m_pImpl == NULL, "Error: Configuration Provider already is connected");
|
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
std::auto_ptr<OConfigurationProviderImpl> pNewImpl( new OConfigurationProviderImpl(this, m_xContext) );
|
2001-04-03 10:33:58 -05:00
|
|
|
|
2003-03-19 09:20:19 -06:00
|
|
|
implConnect(*pNewImpl,ContextReader(m_xContext));
|
2001-04-03 10:33:58 -05:00
|
|
|
|
|
|
|
m_pImpl = pNewImpl.release();
|
2004-06-18 09:45:49 -05:00
|
|
|
if (m_pImpl)
|
|
|
|
{
|
2004-11-15 06:34:33 -06:00
|
|
|
sal_Bool isEnabled = m_pImpl->getDefaultOptions().isAsyncEnabled();
|
|
|
|
this->setPropertyValue( getEnableAsyncPropName(), uno::makeAny(isEnabled) );
|
2004-06-18 09:45:49 -05:00
|
|
|
}
|
2000-11-10 15:45:40 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2001-02-15 10:25:17 -06:00
|
|
|
void SAL_CALL OConfigurationProvider::disposing()
|
2000-11-10 15:45:40 -06:00
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
|
|
|
|
2000-11-10 15:45:40 -06:00
|
|
|
if (m_pImpl)
|
2001-02-15 10:25:17 -06:00
|
|
|
m_pImpl->dispose();
|
2000-11-10 15:45:40 -06:00
|
|
|
|
2001-02-15 10:25:17 -06:00
|
|
|
OProvider::disposing();
|
2000-11-10 15:45:40 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
uno::Reference< uno::XInterface > SAL_CALL OConfigurationProvider::createInstance( const OUString& aServiceSpecifier )
|
2000-11-07 07:40:31 -06:00
|
|
|
throw(uno::Exception, uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
2002-10-28 07:43:35 -06:00
|
|
|
// same as creating with empty sequence of arguments
|
|
|
|
return this->createInstanceWithArguments( aServiceSpecifier, uno::Sequence< uno::Any >() );
|
2000-11-07 07:40:31 -06:00
|
|
|
}
|
|
|
|
|
2000-11-10 15:45:40 -06:00
|
|
|
//-----------------------------------------------------------------------------
|
2000-11-07 07:40:31 -06:00
|
|
|
uno::Reference< uno::XInterface > SAL_CALL
|
2002-10-28 07:43:35 -06:00
|
|
|
OConfigurationProvider::createInstanceWithArguments( const OUString& aServiceSpecifier, const uno::Sequence< uno::Any >& aArguments )
|
2000-11-07 07:40:31 -06:00
|
|
|
throw(uno::Exception, uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
|
|
|
|
2001-02-15 10:25:17 -06:00
|
|
|
OSL_ENSURE(m_pImpl, "OConfigurationProvider: no implementation available");
|
2000-11-07 07:40:31 -06:00
|
|
|
|
2000-11-10 15:45:40 -06:00
|
|
|
if (ServiceCreationInfo const* pInfo = findCreationInfo(aServiceSpecifier))
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
|
|
|
// it's a known service name - try to create without args
|
2000-11-10 15:45:40 -06:00
|
|
|
if (CreatorFunc create = pInfo->create)
|
2000-11-07 07:40:31 -06:00
|
|
|
{
|
|
|
|
return (m_pImpl->*create)(aArguments);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-28 07:43:35 -06:00
|
|
|
rtl::OUStringBuffer sMsg;
|
|
|
|
sMsg.appendAscii("ConfigurationProvider: Cannot create view - ");
|
|
|
|
sMsg.append( aServiceSpecifier ) .appendAscii(" is not a valid configuration access service. ");
|
|
|
|
|
|
|
|
throw lang::ServiceNotRegisteredException(sMsg.makeStringAndClear(),*this);
|
2000-11-07 07:40:31 -06:00
|
|
|
}
|
|
|
|
|
2000-11-10 15:45:40 -06:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
uno::Sequence< OUString > SAL_CALL OConfigurationProvider::getAvailableServiceNames( )
|
2000-11-07 07:40:31 -06:00
|
|
|
throw(uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
|
|
|
|
2000-11-07 07:40:31 -06:00
|
|
|
sal_Int32 nCount = 0;
|
|
|
|
{
|
2001-02-15 10:25:17 -06:00
|
|
|
for (int i= 0; i< getCreateServiceDataCount(); ++i)
|
2000-12-08 12:36:49 -06:00
|
|
|
nCount += countServices(getCreateServiceData()[i].info);
|
2000-11-07 07:40:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
uno::Sequence< OUString > aNames(nCount);
|
|
|
|
if (nCount > 0)
|
|
|
|
{
|
|
|
|
sal_Int32 n = 0;
|
|
|
|
for (int i= 0; i<getCreateServiceDataCount(); ++i)
|
|
|
|
{
|
2002-12-06 06:08:35 -06:00
|
|
|
ServiceRegistrationInfo const* pInfo = getCreateServiceData()[i].info;
|
|
|
|
AsciiServiceName const* pNames = pInfo ? pInfo->registeredServiceNames : 0;
|
2000-11-07 07:40:31 -06:00
|
|
|
|
|
|
|
if (pNames)
|
|
|
|
{
|
|
|
|
while(*pNames)
|
|
|
|
{
|
|
|
|
aNames[n] = OUString::createFromAscii(*pNames);
|
|
|
|
++n;
|
|
|
|
++pNames;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return aNames;
|
|
|
|
}
|
2001-02-08 05:03:27 -06:00
|
|
|
|
2004-01-20 09:23:04 -06:00
|
|
|
// XLocalizable
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OConfigurationProvider::setLocale( const lang::Locale& eLocale )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
|
|
|
|
2004-01-20 09:23:04 -06:00
|
|
|
OSL_ENSURE(m_pImpl, "OConfigurationProvider: no implementation available");
|
|
|
|
|
|
|
|
m_pImpl->setDefaultLocale( eLocale );
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2007-11-23 07:06:13 -06:00
|
|
|
lang::Locale SAL_CALL OConfigurationProvider::getLocale()
|
2004-01-20 09:23:04 -06:00
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
|
|
|
|
2004-01-20 09:23:04 -06:00
|
|
|
OSL_ENSURE(m_pImpl, "OConfigurationProvider: no implementation available");
|
|
|
|
|
|
|
|
return m_pImpl->getDefaultOptions().getUnoLocale();
|
|
|
|
}
|
|
|
|
|
2004-06-18 09:45:49 -05:00
|
|
|
//XRefreshable
|
|
|
|
//-----------------------------------------------------------------------------
|
2007-11-23 07:06:13 -06:00
|
|
|
void SAL_CALL OConfigurationProvider::refresh()
|
|
|
|
throw (uno::RuntimeException)
|
2004-06-18 09:45:49 -05:00
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
|
|
|
|
2004-06-18 09:45:49 -05:00
|
|
|
OSL_ENSURE(m_pImpl, "OConfigurationProvider: no implementation available");
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
m_pImpl->refreshAll();
|
|
|
|
}
|
|
|
|
catch (uno::RuntimeException& ) { throw; }
|
|
|
|
catch (uno::Exception& e)
|
|
|
|
{
|
2004-11-15 06:34:33 -06:00
|
|
|
// FIXME: use getCaughtException()
|
2004-06-18 09:45:49 -05:00
|
|
|
throw lang::WrappedTargetRuntimeException(e.Message, *this, uno::makeAny(e));
|
|
|
|
}
|
|
|
|
//Broadcast the changes
|
|
|
|
uno::Reference< css::util::XRefreshListener > const * const pRefresh = 0;
|
2004-11-15 06:34:33 -06:00
|
|
|
cppu::OInterfaceContainerHelper * aInterfaceContainer=
|
|
|
|
getBroadcastHelper().getContainer (::getCppuType(pRefresh));
|
2004-06-18 09:45:49 -05:00
|
|
|
|
2004-11-15 06:34:33 -06:00
|
|
|
if(aInterfaceContainer)
|
2004-06-18 09:45:49 -05:00
|
|
|
{
|
2004-11-15 06:34:33 -06:00
|
|
|
lang::EventObject aEventObject(*this);
|
|
|
|
|
|
|
|
cppu::OInterfaceIteratorHelper aIterator(*aInterfaceContainer);
|
|
|
|
while(aIterator.hasMoreElements())
|
2004-06-18 09:45:49 -05:00
|
|
|
{
|
2004-11-15 06:34:33 -06:00
|
|
|
uno::Reference< uno::XInterface > xIface = aIterator.next();
|
2004-06-18 09:45:49 -05:00
|
|
|
uno::Reference< util::XRefreshListener > xRefresh (xIface, uno::UNO_QUERY);
|
|
|
|
if (xRefresh.is())
|
|
|
|
{
|
|
|
|
xRefresh->refreshed(aEventObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OConfigurationProvider::addRefreshListener(
|
|
|
|
const uno::Reference< util::XRefreshListener >& aListener )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
|
|
|
getBroadcastHelper().addListener(::getCppuType(&aListener), aListener);
|
2004-06-18 09:45:49 -05:00
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OConfigurationProvider::removeRefreshListener(
|
|
|
|
const uno::Reference< util::XRefreshListener >& aListener )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
|
|
|
getBroadcastHelper().removeListener(::getCppuType(&aListener), aListener);
|
2004-06-18 09:45:49 -05:00
|
|
|
}
|
|
|
|
//XFlushable
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OConfigurationProvider::flush( )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
2004-06-18 09:45:49 -05:00
|
|
|
OSL_ENSURE(m_pImpl, "OConfigurationProvider: no implementation available");
|
|
|
|
m_pImpl->flushAll();
|
2004-11-15 06:34:33 -06:00
|
|
|
|
2004-06-18 09:45:49 -05:00
|
|
|
//Broadcast the changes
|
2004-11-15 06:34:33 -06:00
|
|
|
uno::Reference< css::util::XFlushListener > const * const pFlush = 0;
|
|
|
|
cppu::OInterfaceContainerHelper * aInterfaceContainer=
|
|
|
|
getBroadcastHelper().getContainer(::getCppuType(pFlush));
|
2004-06-18 09:45:49 -05:00
|
|
|
|
2004-11-15 06:34:33 -06:00
|
|
|
if(aInterfaceContainer)
|
2004-06-18 09:45:49 -05:00
|
|
|
{
|
2004-11-15 06:34:33 -06:00
|
|
|
lang::EventObject aEventObject(*this);
|
|
|
|
|
|
|
|
cppu::OInterfaceIteratorHelper aIterator(*aInterfaceContainer);
|
|
|
|
while(aIterator.hasMoreElements())
|
2004-06-18 09:45:49 -05:00
|
|
|
{
|
2004-11-15 06:34:33 -06:00
|
|
|
uno::Reference< uno::XInterface > xIface = aIterator.next();
|
2004-06-18 09:45:49 -05:00
|
|
|
uno::Reference< util::XFlushListener > xFlush (xIface, uno::UNO_QUERY);
|
|
|
|
if (xFlush.is())
|
|
|
|
{
|
|
|
|
xFlush->flushed(aEventObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OConfigurationProvider::addFlushListener(
|
|
|
|
const uno::Reference< util::XFlushListener >& aListener )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
2004-11-15 06:34:33 -06:00
|
|
|
getBroadcastHelper().addListener(::getCppuType(&aListener), aListener);
|
2004-06-18 09:45:49 -05:00
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void SAL_CALL OConfigurationProvider::removeFlushListener(
|
|
|
|
const uno::Reference< util::XFlushListener >& aListener )
|
|
|
|
throw (uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
2004-11-15 06:34:33 -06:00
|
|
|
getBroadcastHelper().removeListener(::getCppuType(&aListener), aListener);
|
2004-06-18 09:45:49 -05:00
|
|
|
}
|
2001-02-08 05:03:27 -06:00
|
|
|
// XInterface
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
::com::sun::star::uno::Any SAL_CALL OConfigurationProvider::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
2001-02-08 05:03:27 -06:00
|
|
|
uno::Any aRet( OProvider::queryInterface(rType) );
|
|
|
|
if ( !aRet.hasValue() )
|
|
|
|
aRet = queryPropertyInterface(rType);
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
//XTypeProvider
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OConfigurationProvider::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
|
|
|
|
{
|
|
|
|
cppu::OTypeCollection aCollection(::getCppuType( (const uno::Reference< beans::XPropertySet > *)0 ),
|
|
|
|
::getCppuType( (const uno::Reference< beans::XFastPropertySet > *)0 ),
|
|
|
|
::getCppuType( (const uno::Reference< beans::XMultiPropertySet > *)0 ),
|
|
|
|
OProvider::getTypes());
|
|
|
|
return aCollection.getTypes();
|
|
|
|
}
|
|
|
|
|
|
|
|
// OPropertyArrayUsageHelper
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::cppu::IPropertyArrayHelper* OConfigurationProvider::createArrayHelper( ) const
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
2001-02-08 05:03:27 -06:00
|
|
|
uno::Sequence< beans::Property > aProps;
|
|
|
|
describeProperties(aProps);
|
|
|
|
return new ::cppu::OPropertyArrayHelper(aProps);
|
|
|
|
}
|
|
|
|
// -------------------------------------------------------------------------
|
|
|
|
::cppu::IPropertyArrayHelper & OConfigurationProvider::getInfoHelper()
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
2001-02-08 05:03:27 -06:00
|
|
|
return *const_cast<OConfigurationProvider*>(this)->getArrayHelper();
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2004-06-18 09:45:49 -05:00
|
|
|
|
|
|
|
|
2001-02-08 05:03:27 -06:00
|
|
|
void SAL_CALL OConfigurationProvider::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue)
|
|
|
|
throw (::com::sun::star::uno::Exception)
|
|
|
|
{
|
2007-11-23 07:06:13 -06:00
|
|
|
UnoApiLock aLock;
|
2001-02-08 05:03:27 -06:00
|
|
|
|
2007-11-23 07:06:13 -06:00
|
|
|
OProvider::setFastPropertyValue_NoBroadcast( nHandle, rValue );
|
2001-02-08 05:03:27 -06:00
|
|
|
|
2004-06-18 09:45:49 -05:00
|
|
|
switch(nHandle)
|
2001-07-05 11:05:51 -05:00
|
|
|
{
|
2004-06-18 09:45:49 -05:00
|
|
|
case ID_PREFETCH:
|
|
|
|
{
|
|
|
|
uno::Sequence< OUString > aNodeList;
|
|
|
|
rValue >>= aNodeList;
|
|
|
|
|
|
|
|
RequestOptions const aOptions = m_pImpl->getDefaultOptions();
|
|
|
|
|
|
|
|
for (sal_Int32 i = 0; i < aNodeList.getLength(); i++)
|
|
|
|
{
|
|
|
|
using namespace configuration;
|
|
|
|
AbsolutePath aModulePath = AbsolutePath::makeModulePath(aNodeList[i], AbsolutePath::NoValidate());
|
|
|
|
m_pImpl->fetchSubtree(aModulePath , aOptions);
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case ID_ENABLEASYNC:
|
|
|
|
{
|
2004-11-15 06:34:33 -06:00
|
|
|
//Forward to TreeManager
|
|
|
|
sal_Bool bAsync;
|
|
|
|
if (rValue >>= bAsync)
|
2004-06-18 09:45:49 -05:00
|
|
|
{
|
2004-11-15 06:34:33 -06:00
|
|
|
m_pImpl->enableAsync(bAsync);
|
|
|
|
if (!bAsync)
|
|
|
|
this->flush();
|
2004-06-18 09:45:49 -05:00
|
|
|
}
|
|
|
|
else
|
2004-11-15 06:34:33 -06:00
|
|
|
OSL_ENSURE(false, "Unexpected type of new property value");
|
2004-06-18 09:45:49 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
OSL_ENSURE(false, "OConfigurationProvider::setFastPropertyValue_NoBroadcast -unknown property");
|
|
|
|
}
|
|
|
|
|
2001-07-05 11:05:51 -05:00
|
|
|
}
|
2001-02-08 05:03:27 -06:00
|
|
|
}
|
|
|
|
|
2004-06-18 09:45:49 -05:00
|
|
|
|
2000-11-07 07:40:31 -06:00
|
|
|
} // namespace configmgr
|
|
|
|
|
|
|
|
|