2000-11-10 21:42:54 +00:00
/*************************************************************************
*
2008-04-11 11:08:01 +00:00
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER .
2000-11-10 21:42:54 +00:00
*
2008-04-11 11:08:01 +00:00
* Copyright 2008 by Sun Microsystems , Inc .
2000-11-10 21:42:54 +00:00
*
2008-04-11 11:08:01 +00:00
* OpenOffice . org - a multi - platform office productivity suite
2000-11-10 21:42:54 +00:00
*
2008-04-11 11:08:01 +00:00
* $ RCSfile : providerimpl . cxx , v $
2008-06-16 12:32:08 +00:00
* $ Revision : 1.69 $
2000-11-10 21:42:54 +00:00
*
2008-04-11 11:08:01 +00:00
* This file is part of OpenOffice . org .
2000-11-10 21:42:54 +00:00
*
2008-04-11 11:08:01 +00: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-10 21:42:54 +00:00
*
2008-04-11 11:08:01 +00: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-10 21:42:54 +00:00
*
2008-04-11 11:08:01 +00: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-10 21:42:54 +00:00
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2006-09-16 13:59:38 +00:00
// MARKER(update_precomp.py): autogen include statement, do not remove
# include "precompiled_configmgr.hxx"
2000-11-10 21:42:54 +00:00
# include <stdio.h>
2000-12-19 10:14:08 +00:00
# include "providerimpl.hxx"
# include "options.hxx"
2000-11-10 21:42:54 +00:00
# include "apifactoryimpl.hxx"
# include "apitreeimplobj.hxx"
# include "apitreeaccess.hxx"
# include "roottree.hxx"
# include "noderef.hxx"
# include "objectregistry.hxx"
2000-12-03 10:45:59 +00:00
# include "bootstrap.hxx"
2002-03-15 10:50:25 +00:00
# include "cachefactory.hxx"
2000-11-10 21:42:54 +00:00
# include "provider.hxx"
2002-03-28 07:20:59 +00:00
# include "treeprovider.hxx"
# include "treemanager.hxx"
2002-02-11 12:47:56 +00:00
# include "treeaccessor.hxx"
# include "groupnodeaccess.hxx"
# include "valuenodeaccess.hxx"
2000-11-10 21:42:54 +00:00
# include "tracer.hxx"
2000-12-19 10:14:08 +00:00
# include <osl/interlck.h>
2000-11-10 21:42:54 +00:00
# include <com/sun/star/beans/PropertyValue.hpp>
2002-10-10 08:23:25 +00:00
# include <com/sun/star/lang/DisposedException.hpp>
2002-10-28 13:41:43 +00:00
# include <com/sun/star/lang/Locale.hpp>
# include <rtl/ustrbuf.hxx>
2001-08-01 11:16:00 +00:00
# include <rtl/logfile.hxx>
2002-10-14 13:19:28 +00:00
# define RTL_LOGFILE_OU2A(rtlOUString) (::rtl::OUStringToOString((rtlOUString), RTL_TEXTENCODING_ASCII_US).getStr())
2000-11-10 21:42:54 +00:00
namespace configmgr
{
namespace css = : : com : : sun : : star ;
namespace uno = css : : uno ;
namespace beans = css : : beans ;
using : : rtl : : OUString ;
using configapi : : NodeElement ;
using configuration : : RootTree ;
namespace configapi
{
2000-11-20 00:30:48 +00:00
2000-11-10 21:42:54 +00:00
class ApiProviderInstances
{
ObjectRegistryHolder m_aObjectRegistry ;
ReadOnlyObjectFactory m_aReaderFactory ;
UpdateObjectFactory m_aWriterFactory ;
ApiProvider m_aReaderProvider ;
ApiProvider m_aWriterProvider ;
public :
2001-04-19 14:46:27 +00:00
ApiProviderInstances ( OProviderImpl & rProviderImpl )
2000-11-10 21:42:54 +00:00
: m_aObjectRegistry ( new ObjectRegistry ( ) )
, m_aReaderFactory ( m_aReaderProvider , m_aObjectRegistry )
, m_aWriterFactory ( m_aWriterProvider , m_aObjectRegistry )
, m_aReaderProvider ( m_aReaderFactory , rProviderImpl )
, m_aWriterProvider ( m_aWriterFactory , rProviderImpl )
{
}
~ ApiProviderInstances ( )
{ }
2001-04-19 14:46:27 +00:00
ApiProvider & getReaderProvider ( ) { return m_aReaderProvider ; }
ApiProvider & getWriterProvider ( ) { return m_aWriterProvider ; }
Factory & getReaderFactory ( ) { return m_aReaderFactory ; }
Factory & getWriterFactory ( ) { return m_aWriterFactory ; }
2000-11-10 21:42:54 +00:00
} ;
}
2002-03-15 10:50:25 +00:00
//=============================================================================
2000-11-10 21:42:54 +00:00
//=============================================================================
//= OProviderImpl
//=============================================================================
//-----------------------------------------------------------------------------
2002-06-12 15:28:27 +00:00
OProviderImpl : : OProviderImpl ( OProvider * _pProvider , CreationContext const & _xContext )
2004-03-23 09:22:48 +00:00
: m_pProvider ( _pProvider )
, m_xTypeConverter ( )
, m_aDefaultOptions ( )
, m_pNewProviders ( NULL )
2002-10-10 08:23:25 +00:00
, m_aTreeManagerMutex ( )
, m_pTreeManager ( NULL )
2000-11-10 21:42:54 +00:00
{
2003-03-19 15:20:19 +00:00
OSL_ENSURE ( _xContext . is ( ) , " OProviderImpl : NULL context ! " ) ;
uno : : Reference < lang : : XMultiComponentFactory > xFactory = _xContext - > getServiceManager ( ) ;
OSL_ENSURE ( xFactory . is ( ) , " OProviderImpl : missing service factory ! " ) ;
2002-03-28 07:20:59 +00:00
m_xTypeConverter = m_xTypeConverter . query (
2003-03-19 15:20:19 +00:00
xFactory - > createInstanceWithContext ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " com.sun.star.script.Converter " ) ) ,
_xContext ) ) ;
2001-02-15 16:25:17 +00:00
2003-03-19 15:20:19 +00:00
OSL_ENSURE ( m_xTypeConverter . is ( ) , " Module::Module : could not create an instance of the type converter ! " ) ;
2002-06-12 15:28:27 +00:00
}
2001-04-03 15:33:58 +00:00
//-----------------------------------------------------------------------------
2002-10-10 08:23:25 +00:00
rtl : : Reference < TreeManager > OProviderImpl : : maybeGetTreeManager ( ) const CFG_NOTHROW ( )
{
osl : : MutexGuard aGuard ( m_aTreeManagerMutex ) ;
rtl : : Reference < TreeManager > xResult ( m_pTreeManager ) ;
return xResult ;
}
//-----------------------------------------------------------------------------
rtl : : Reference < TreeManager > OProviderImpl : : getTreeManager ( ) const CFG_UNO_THROW_RTE ( )
{
osl : : MutexGuard aGuard ( m_aTreeManagerMutex ) ;
if ( m_pTreeManager = = NULL )
{
OUString sMsg = OUString : : createFromAscii ( " OProviderImpl: No cache available - provider was already disposed. " ) ;
throw com : : sun : : star : : lang : : DisposedException ( sMsg , static_cast < lang : : XMultiServiceFactory * > ( m_pProvider ) ) ;
}
rtl : : Reference < TreeManager > xResult ( m_pTreeManager ) ;
return xResult ;
}
//-----------------------------------------------------------------------------
void OProviderImpl : : setTreeManager ( TreeManager * pTreeManager ) CFG_UNO_THROW_RTE ( )
{
osl : : MutexGuard aGuard ( m_aTreeManagerMutex ) ;
OSL_PRECOND ( m_pTreeManager = = NULL , " OProviderImpl: TreeManager is already set " ) ;
OSL_PRECOND ( pTreeManager ! = NULL , " OProviderImpl: Trying to set a NULL TreeManager " ) ;
if ( pTreeManager = = NULL )
{
OUString sMsg = OUString : : createFromAscii ( " OProviderImpl: No cache available - cache creation failed. " ) ;
throw com : : sun : : star : : uno : : RuntimeException ( sMsg , NULL ) ;
}
( m_pTreeManager = pTreeManager ) - > acquire ( ) ;
}
//-----------------------------------------------------------------------------
void OProviderImpl : : clearTreeManager ( ) CFG_NOTHROW ( )
{
osl : : ClearableMutexGuard aGuard ( m_aTreeManagerMutex ) ;
if ( TreeManager * pTM = m_pTreeManager )
{
m_pTreeManager = NULL ;
pTM - > release ( ) ;
}
}
//-----------------------------------------------------------------------------
2003-03-19 15:20:19 +00:00
bool OProviderImpl : : initSession ( const ContextReader & _rSettings )
2001-04-03 15:33:58 +00:00
{
2002-06-12 15:28:27 +00:00
bool bNeedProfile = false ;
2002-10-10 08:23:25 +00:00
rtl : : Reference < TreeManager > xNewTreeManager ;
2002-06-12 15:28:27 +00:00
if ( _rSettings . isUnoBackend ( ) )
{
this - > implInitFromSettings ( _rSettings , bNeedProfile ) ;
2003-03-19 15:20:19 +00:00
xNewTreeManager = CacheFactory : : instance ( ) . createCacheManager ( _rSettings . getBaseContext ( ) ) ;
2002-06-12 15:28:27 +00:00
}
else
{
2002-12-13 09:27:09 +00:00
throw com : : sun : : star : : uno : : RuntimeException ( OUString : : createFromAscii ( " OProviderImpl: Only UNO Backends Supported " ) , NULL ) ;
2002-06-12 15:28:27 +00:00
}
2000-11-20 00:30:48 +00:00
2002-10-10 08:23:25 +00:00
setTreeManager ( xNewTreeManager . get ( ) ) ;
OSL_ASSERT ( xNewTreeManager . get ( ) ) ;
2000-11-20 00:30:48 +00:00
// put out of line to get rid of the order dependency (and to have a acquired configuration)
2001-04-19 14:46:27 +00:00
m_pNewProviders = new configapi : : ApiProviderInstances ( * this ) ;
2000-11-30 07:54:09 +00:00
2001-04-03 15:33:58 +00:00
// now complete our state from the user's profile, if necessary
if ( bNeedProfile )
2000-11-30 07:54:09 +00:00
try
{
2001-06-18 09:48:00 +00:00
static : : rtl : : OUString ssUserProfile ( RTL_CONSTASCII_USTRINGPARAM ( " org.openoffice.Setup " ) ) ;
2001-07-05 16:05:51 +00:00
AbsolutePath aProfileModule = AbsolutePath : : makeModulePath ( ssUserProfile , AbsolutePath : : NoValidate ( ) ) ;
2002-02-11 12:47:56 +00:00
2003-03-19 15:20:19 +00:00
data : : NodeAccess aProfileTree = xNewTreeManager - > requestSubtree ( aProfileModule , m_aDefaultOptions ) ;
2002-02-11 12:47:56 +00:00
if ( aProfileTree . isValid ( ) )
2003-03-19 15:20:19 +00:00
{
2002-02-11 12:47:56 +00:00
implInitFromProfile ( aProfileTree ) ;
2001-04-03 15:33:58 +00:00
2003-03-19 15:20:19 +00:00
// should we clean this up ?
// xNewTreeManager->releaseSubtree(aProfileModule, xTempOptions);
}
2001-04-03 15:33:58 +00:00
}
2001-11-09 10:23:57 +00:00
catch ( uno : : Exception & e )
2001-04-03 15:33:58 +00:00
{
// could not read profile
2006-06-19 22:16:41 +00:00
( void ) e ;
2004-03-09 10:28:12 +00:00
CFG_TRACE_ERROR_NI ( " Provider bootstrapping: Caught an exception trying to get 'Setup' data: %s " , OUSTRING2ASCII ( e . Message ) ) ;
2001-04-03 15:33:58 +00:00
}
2002-06-12 15:28:27 +00:00
return true ;
2001-04-03 15:33:58 +00:00
}
//-----------------------------------------------------------------------------
// these can be overridden. default does nothing
2003-03-19 15:20:19 +00:00
void OProviderImpl : : initFromSettings ( const ContextReader & , bool & )
2001-04-03 15:33:58 +00:00
{
}
//-----------------------------------------------------------------------------
2002-02-11 12:47:56 +00:00
void OProviderImpl : : initFromProfile ( data : : NodeAccess const & )
2001-04-03 15:33:58 +00:00
{
}
//-----------------------------------------------------------------------------
// these implement the base class behavior
2003-03-19 15:20:19 +00:00
void OProviderImpl : : implInitFromSettings ( const ContextReader & _rSettings , bool & rNeedProfile )
2001-04-03 15:33:58 +00:00
{
bool bIntrinsicNeedProfile = true ;
if ( _rSettings . hasLocale ( ) )
{
bIntrinsicNeedProfile = false ;
rtl : : OUString sDefaultLocale = _rSettings . getLocale ( ) ;
2004-01-20 15:23:58 +00:00
m_aDefaultOptions . setIsoLocale ( sDefaultLocale ) ;
2003-03-19 15:20:19 +00:00
}
else if ( _rSettings . isAdminService ( ) )
{
bIntrinsicNeedProfile = false ;
m_aDefaultOptions . setAllLocales ( ) ;
2001-04-03 15:33:58 +00:00
}
2001-06-22 11:42:25 +00:00
else
2003-03-19 15:20:19 +00:00
OSL_ASSERT ( ! m_aDefaultOptions . hasLocale ( ) ) ;
2001-06-22 11:42:25 +00:00
if ( _rSettings . hasAsyncSetting ( ) )
{
2003-03-19 15:20:19 +00:00
m_aDefaultOptions . enableAsync ( ! ! _rSettings . getAsyncSetting ( ) ) ;
2001-06-22 11:42:25 +00:00
}
2001-04-03 15:33:58 +00:00
2004-06-18 14:46:38 +00:00
2001-04-03 15:33:58 +00:00
// call the template method
this - > initFromSettings ( _rSettings , rNeedProfile ) ;
if ( bIntrinsicNeedProfile )
rNeedProfile = true ; // to get locale
}
//-----------------------------------------------------------------------------
2002-02-11 12:47:56 +00:00
void OProviderImpl : : implInitFromProfile ( data : : NodeAccess const & aProfile )
2001-04-03 15:33:58 +00:00
{
2002-02-11 12:47:56 +00:00
OSL_ASSERT ( aProfile . isValid ( ) ) ;
data : : GroupNodeAccess aProfileNode ( aProfile ) ;
OSL_ASSERT ( aProfileNode . isValid ( ) ) ;
2001-04-03 15:33:58 +00:00
2001-06-22 11:42:25 +00:00
// read the default locale for the user
2003-03-19 15:20:19 +00:00
if ( ! m_aDefaultOptions . hasLocale ( ) )
2001-06-22 11:42:25 +00:00
{
2002-02-11 12:47:56 +00:00
using configuration : : Name ;
using configuration : : makeNodeName ;
static Name ssSubGroup = makeNodeName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " L10N " ) ) , Name : : NoValidate ( ) ) ;
static Name ssLocale = makeNodeName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( " ooLocale " ) ) , Name : : NoValidate ( ) ) ;
2001-06-18 09:48:00 +00:00
2002-02-11 12:47:56 +00:00
data : : GroupNodeAccess aL10NNode ( aProfileNode . getChildNode ( ssSubGroup ) ) ;
if ( aL10NNode . isValid ( ) )
2000-11-30 07:54:09 +00:00
{
2002-02-11 12:47:56 +00:00
data : : ValueNodeAccess aValue ( aL10NNode . getChildNode ( ssLocale ) ) ;
if ( aValue . isValid ( ) )
2000-11-30 07:54:09 +00:00
{
2001-06-22 11:42:25 +00:00
rtl : : OUString sDefaultLocale ;
2002-02-11 12:47:56 +00:00
if ( aValue . getValue ( ) > > = sDefaultLocale )
2001-06-22 11:42:25 +00:00
{
2004-01-20 15:23:58 +00:00
m_aDefaultOptions . setIsoLocale ( sDefaultLocale ) ;
2001-06-22 11:42:25 +00:00
}
else
OSL_ENSURE ( false , " Could not extract locale parameter into string " ) ;
2000-11-30 07:54:09 +00:00
}
}
}
2001-04-03 15:33:58 +00:00
// call the template method
2002-02-11 12:47:56 +00:00
this - > initFromProfile ( aProfile ) ;
2004-01-20 15:23:58 +00:00
// last fallback, if there is no locale - even in ooLocale
m_aDefaultOptions . ensureLocaleSet ( ) ;
}
//-----------------------------------------------------------------------------
void OProviderImpl : : setDefaultLocale ( RequestOptions : : Locale const & aLocale )
{
m_aDefaultOptions . setLocale ( aLocale ) ;
// ensure that the locale is never cleared to 'empty'
m_aDefaultOptions . ensureLocaleSet ( ) ;
2000-11-10 21:42:54 +00:00
}
//-----------------------------------------------------------------------------
OProviderImpl : : ~ OProviderImpl ( )
{
2007-11-23 13:08:41 +00:00
UnoApiLock aLock ; // hmm...
2002-10-10 08:23:25 +00:00
clearTreeManager ( ) ;
2001-02-15 16:25:17 +00:00
delete m_pNewProviders ;
2000-11-10 21:42:54 +00:00
}
2001-01-26 06:54:22 +00:00
// --------------------------------- disposing ---------------------------------
2001-02-15 16:25:17 +00:00
void SAL_CALL OProviderImpl : : dispose ( ) throw ( )
2001-01-26 06:54:22 +00:00
{
2001-11-09 10:23:57 +00:00
try
{
2002-10-10 08:23:25 +00:00
rtl : : Reference < TreeManager > xTM = maybeGetTreeManager ( ) ;
if ( xTM . is ( ) )
xTM - > dispose ( ) ;
2002-07-11 15:55:23 +00:00
2002-10-10 08:23:25 +00:00
clearTreeManager ( ) ;
2001-11-09 10:23:57 +00:00
}
catch ( uno : : Exception & e )
{
2006-06-19 22:16:41 +00:00
( void ) e ;
2001-11-09 10:23:57 +00:00
CFG_TRACE_ERROR ( " Disposing the TreeManager or closing the session caused an exception: %s " , OUSTRING2ASCII ( e . Message ) ) ;
2002-10-10 08:23:25 +00:00
clearTreeManager ( ) ;
2001-11-09 10:23:57 +00:00
}
2001-01-26 06:54:22 +00:00
}
2000-12-04 08:20:27 +00:00
//-----------------------------------------------------------------------------
// access to the raw notifications
2002-10-10 08:23:25 +00:00
IConfigBroadcaster * OProviderImpl : : getNotifier ( ) CFG_NOTHROW ( )
{
rtl : : Reference < TreeManager > xTM = maybeGetTreeManager ( ) ;
return xTM . is ( ) ? xTM - > getBroadcaster ( ) : NULL ;
}
2000-12-04 08:20:27 +00:00
2001-09-28 11:44:40 +00:00
// DefaultProvider access
2000-11-10 21:42:54 +00:00
//-----------------------------------------------------------------------------
2002-10-10 08:23:25 +00:00
rtl : : Reference < IConfigDefaultProvider > OProviderImpl : : getDefaultProvider ( ) const CFG_UNO_THROW_RTE ( )
2001-09-28 11:44:40 +00:00
{
2002-10-10 08:23:25 +00:00
return getTreeManager ( ) . get ( ) ;
2001-09-28 11:44:40 +00:00
}
2000-11-20 00:30:48 +00:00
2002-02-11 12:47:56 +00:00
// TemplateManager access
2001-09-28 11:44:40 +00:00
//-----------------------------------------------------------------------------
2002-10-10 08:23:25 +00:00
rtl : : Reference < IConfigTemplateManager > OProviderImpl : : getTemplateProvider ( ) const CFG_UNO_THROW_RTE ( )
2000-11-10 21:42:54 +00:00
{
2002-10-10 08:23:25 +00:00
return getTreeManager ( ) . get ( ) ;
2000-11-10 21:42:54 +00:00
}
2000-12-04 08:20:27 +00:00
// ITreeProvider /ITreeManager
2000-11-10 21:42:54 +00:00
//-----------------------------------------------------------------------------
2003-03-19 15:20:19 +00:00
data : : NodeAccess OProviderImpl : : requestSubtree ( AbsolutePath const & aSubtreePath ,
RequestOptions const & _aOptions
) CFG_UNO_THROW_ALL ( )
2000-11-10 21:42:54 +00:00
{
2002-10-10 08:23:25 +00:00
rtl : : Reference < TreeManager > xTreeManager = getTreeManager ( ) ;
2007-11-23 13:08:41 +00:00
data : : NodeAccess aTree ( NULL ) ;
2001-07-05 16:05:51 +00:00
try
{
2003-03-19 15:20:19 +00:00
aTree = xTreeManager - > requestSubtree ( aSubtreePath , _aOptions ) ;
2001-07-05 16:05:51 +00:00
}
catch ( uno : : Exception & e )
{
2003-03-19 15:20:19 +00:00
: : rtl : : OUString sMessage = getErrorMessage ( aSubtreePath , _aOptions ) ;
2001-07-05 16:05:51 +00:00
// append the error message given by the tree provider
sMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " \n \n The backend returned the following error: \n " ) ) ;
sMessage + = e . Message ;
throw lang : : WrappedTargetException ( sMessage , getProviderInstance ( ) , uno : : makeAny ( e ) ) ;
}
2002-02-11 12:47:56 +00:00
if ( ! aTree . isValid ( ) )
2001-07-05 16:05:51 +00:00
{
2003-03-19 15:20:19 +00:00
: : rtl : : OUString sMessage = getErrorMessage ( aSubtreePath , _aOptions ) ;
2001-07-05 16:05:51 +00:00
sMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " \n \n No backend error message available \n " ) ) ;
throw uno : : Exception ( sMessage , getProviderInstance ( ) ) ;
}
2002-02-11 12:47:56 +00:00
return aTree ;
2000-11-10 21:42:54 +00:00
}
//-----------------------------------------------------------------------------
2007-11-23 13:08:41 +00:00
void OProviderImpl : : updateTree ( TreeChangeList & aChanges ) CFG_UNO_THROW_ALL ( )
2000-12-04 08:20:27 +00:00
{
2007-11-23 13:08:41 +00:00
getTreeManager ( ) - > updateTree ( aChanges ) ;
2000-12-04 08:20:27 +00:00
}
//-----------------------------------------------------------------------------
2003-03-19 15:20:19 +00:00
void OProviderImpl : : releaseSubtree ( AbsolutePath const & aSubtreePath , RequestOptions const & _aOptions ) CFG_NOTHROW ( )
2000-11-10 21:42:54 +00:00
{
2002-10-10 08:23:25 +00:00
rtl : : Reference < TreeManager > xTM = maybeGetTreeManager ( ) ;
if ( xTM . is ( ) )
2003-03-19 15:20:19 +00:00
xTM - > releaseSubtree ( aSubtreePath , _aOptions ) ;
2000-11-10 21:42:54 +00:00
}
2000-12-14 15:12:44 +00:00
//-----------------------------------------------------------------------------
2003-03-19 15:20:19 +00:00
void OProviderImpl : : disposeData ( RequestOptions const & _aOptions ) CFG_NOTHROW ( )
2000-12-14 15:12:44 +00:00
{
2002-10-10 08:23:25 +00:00
rtl : : Reference < TreeManager > xTM = maybeGetTreeManager ( ) ;
if ( xTM . is ( ) )
2003-03-19 15:20:19 +00:00
xTM - > disposeData ( _aOptions ) ;
2000-12-14 15:12:44 +00:00
}
2000-11-10 21:42:54 +00:00
//-----------------------------------------------------------------------------
2007-11-23 13:08:41 +00:00
void OProviderImpl : : saveAndNotifyUpdate ( TreeChangeList const & aChanges ) CFG_UNO_THROW_ALL ( )
2000-11-10 21:42:54 +00:00
{
2007-11-23 13:08:41 +00:00
getTreeManager ( ) - > saveAndNotifyUpdate ( aChanges ) ;
2000-11-10 21:42:54 +00:00
}
2001-02-08 11:03:27 +00:00
//-----------------------------------------------------------------------------
2003-03-19 15:20:19 +00:00
void OProviderImpl : : fetchSubtree ( AbsolutePath const & aSubtreePath , RequestOptions const & _aOptions ) CFG_NOTHROW ( )
2001-02-08 11:03:27 +00:00
{
2002-10-10 08:23:25 +00:00
rtl : : Reference < TreeManager > xTM = maybeGetTreeManager ( ) ;
if ( xTM . is ( ) )
2003-03-19 15:20:19 +00:00
xTM - > fetchSubtree ( aSubtreePath , _aOptions ) ;
2001-02-08 11:03:27 +00:00
}
2001-09-28 11:44:40 +00:00
//-----------------------------------------------------------------------------
2007-11-23 13:08:41 +00:00
sal_Bool OProviderImpl : : fetchDefaultData ( AbsolutePath const & aSubtreePath , RequestOptions const & _aOptions ) CFG_UNO_THROW_ALL ( )
2001-09-28 11:44:40 +00:00
{
2007-11-23 13:08:41 +00:00
return getTreeManager ( ) - > fetchDefaultData ( aSubtreePath , _aOptions ) ;
2001-09-28 11:44:40 +00:00
}
2004-06-18 14:46:38 +00:00
//-----------------------------------------------------------------------------------
void OProviderImpl : : refreshAll ( ) CFG_UNO_THROW_ALL ( )
{
m_pTreeManager - > refreshAll ( ) ;
}
//-----------------------------------------------------------------------------------
void OProviderImpl : : flushAll ( ) CFG_NOTHROW ( )
{
m_pTreeManager - > flushAll ( ) ;
}
//-----------------------------------------------------------------------------------
void OProviderImpl : : enableAsync ( const sal_Bool & bEnableAsync ) CFG_NOTHROW ( )
{
m_pTreeManager - > enableAsync ( bEnableAsync ) ;
}
2000-12-04 08:20:27 +00:00
// IInterface
2000-11-10 21:42:54 +00:00
//-----------------------------------------------------------------------------
void SAL_CALL OProviderImpl : : acquire ( ) throw ( )
{
m_pProvider - > acquire ( ) ;
}
//-----------------------------------------------------------------------------
void SAL_CALL OProviderImpl : : release ( ) throw ( )
{
m_pProvider - > release ( ) ;
}
//-----------------------------------------------------------------------------
uno : : XInterface * OProviderImpl : : getProviderInstance ( )
{
return static_cast < com : : sun : : star : : lang : : XMultiServiceFactory * > ( m_pProvider ) ;
}
//-----------------------------------------------------------------------------------
2003-03-19 15:20:19 +00:00
OUString OProviderImpl : : getErrorMessage ( AbsolutePath const & _rAccessor , RequestOptions const & _aOptions )
2000-11-10 21:42:54 +00:00
{
2001-07-05 16:05:51 +00:00
OUString const sAccessor = _rAccessor . toString ( ) ;
2000-11-10 21:42:54 +00:00
2000-11-30 07:54:09 +00:00
CFG_TRACE_ERROR ( " config provider: the cache manager could not provide the tree (neither from the cache nor from the session) " ) ;
2000-12-04 18:34:56 +00:00
: : rtl : : OUString sMessage ;
2003-03-19 15:20:19 +00:00
: : rtl : : OUString sEntity ( _aOptions . getEntity ( ) ) ;
: : rtl : : OUString sLocale ( _aOptions . getLocale ( ) ) ;
CFG_TRACE_INFO_NI ( " config provider: the entity we tried this for is \" %s \" , the locale \" %s \" , the path \" %s \" " , OUSTRING2ASCII ( sEntity ) , OUSTRING2ASCII ( sLocale ) , OUSTRING2ASCII ( sAccessor ) ) ;
2001-07-05 16:05:51 +00:00
sMessage + = sAccessor ;
2000-11-30 07:54:09 +00:00
2003-03-19 15:20:19 +00:00
if ( sEntity . getLength ( ) )
2000-11-30 07:54:09 +00:00
{
2003-03-19 15:20:19 +00:00
sMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " (and for entity " ) ) ;
sMessage + = sEntity ;
2000-11-30 07:54:09 +00:00
sMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " ) " ) ) ;
}
if ( sLocale . getLength ( ) )
{
sMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " (and for locale " ) ) ;
sMessage + = sLocale ;
sMessage + = : : rtl : : OUString ( RTL_CONSTASCII_USTRINGPARAM ( " ) " ) ) ;
}
sMessage + = : : rtl : : OUString : : createFromAscii ( " could not be created. Unable to retrieve the node from the configuration server. " ) ;
return sMessage ;
}
2000-11-10 21:42:54 +00:00
// actual factory methods
//-----------------------------------------------------------------------------------
2003-03-19 15:20:19 +00:00
NodeElement * OProviderImpl : : buildReadAccess ( OUString const & _rAccessor , RequestOptions const & _aOptions , sal_Int32 nMinLevels ) CFG_UNO_THROW_ALL ( )
2000-11-10 21:42:54 +00:00
{
CFG_TRACE_INFO ( " config provider: requesting the tree from the cache manager " ) ;
2001-07-05 16:05:51 +00:00
OSL_ASSERT ( sal_Int16 ( nMinLevels ) = = nMinLevels ) ;
2002-10-14 13:19:28 +00:00
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog , " configmgr::OProviderImpl " , " jb99855 " , " configmgr::OProviderImpl::buildReadAccess() " ) ;
RTL_LOGFILE_CONTEXT_TRACE1 ( aLog , " request path: %s " , RTL_LOGFILE_OU2A ( _rAccessor ) ) ;
2000-11-10 21:42:54 +00:00
try
{
2001-07-05 16:05:51 +00:00
using namespace configuration ;
2000-11-10 21:42:54 +00:00
2001-07-05 16:05:51 +00:00
AbsolutePath aAccessorPath = AbsolutePath : : parse ( _rAccessor ) ;
2000-11-10 21:42:54 +00:00
2003-03-19 15:20:19 +00:00
data : : NodeAccess aTree = this - > requestSubtree ( aAccessorPath , _aOptions ) ;
2000-11-10 21:42:54 +00:00
2002-10-14 13:19:28 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " data loaded " ) ;
2003-03-19 15:20:19 +00:00
TreeDepth nDepth = ( nMinLevels = = treeop : : ALL_LEVELS ) ? C_TreeDepthAll : TreeDepth ( nMinLevels ) ;
2000-11-10 21:42:54 +00:00
2002-10-14 13:19:28 +00:00
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog2 , " configmgr::OProviderImpl " , " jb99855 " , " configmgr: createReadOnlyTree() " ) ;
2001-07-05 16:05:51 +00:00
RootTree aRootTree ( createReadOnlyTree (
2007-11-23 13:08:41 +00:00
aAccessorPath , aTree , nDepth ,
2003-03-19 15:20:19 +00:00
TemplateProvider ( this - > getTemplateProvider ( ) , _aOptions )
2001-07-05 16:05:51 +00:00
) ) ;
2003-03-19 15:20:19 +00:00
return m_pNewProviders - > getReaderFactory ( ) . makeAccessRoot ( aRootTree , _aOptions ) ;
2001-07-05 16:05:51 +00:00
}
catch ( configuration : : Exception & e )
{
configapi : : ExceptionMapper ec ( e ) ;
ec . setContext ( this - > getProviderInstance ( ) ) ;
//ec.unhandled();
throw lang : : WrappedTargetException ( ec . message ( ) , ec . context ( ) , uno : : Any ( ) ) ;
}
2000-11-10 21:42:54 +00:00
}
//-----------------------------------------------------------------------------------
2003-03-19 15:20:19 +00:00
NodeElement * OProviderImpl : : buildUpdateAccess ( OUString const & _rAccessor , RequestOptions const & _aOptions ,
2001-11-09 10:23:57 +00:00
sal_Int32 nMinLevels ) CFG_UNO_THROW_ALL ( )
2000-11-10 21:42:54 +00:00
{
CFG_TRACE_INFO ( " config provider: requesting the tree from the cache manager " ) ;
2001-07-05 16:05:51 +00:00
OSL_ASSERT ( sal_Int16 ( nMinLevels ) = = nMinLevels ) ;
2002-10-14 13:19:28 +00:00
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog , " configmgr::OProviderImpl " , " jb99855 " , " configmgr: buildUpdateAccess() " ) ;
RTL_LOGFILE_CONTEXT_TRACE1 ( aLog , " request path: %s " , RTL_LOGFILE_OU2A ( _rAccessor ) ) ;
2000-11-10 21:42:54 +00:00
try
{
2001-07-05 16:05:51 +00:00
using namespace configuration ;
2000-11-10 21:42:54 +00:00
2001-07-05 16:05:51 +00:00
AbsolutePath aAccessorPath = AbsolutePath : : parse ( _rAccessor ) ;
2000-11-10 21:42:54 +00:00
2003-03-19 15:20:19 +00:00
data : : NodeAccess aTree = requestSubtree ( aAccessorPath , _aOptions ) ;
2000-11-10 21:42:54 +00:00
2002-10-14 13:19:28 +00:00
RTL_LOGFILE_CONTEXT_TRACE ( aLog , " data loaded " ) ;
2003-03-19 15:20:19 +00:00
TreeDepth nDepth = ( nMinLevels = = treeop : : ALL_LEVELS ) ? C_TreeDepthAll : TreeDepth ( nMinLevels ) ;
2000-11-10 21:42:54 +00:00
2002-10-14 13:19:28 +00:00
RTL_LOGFILE_CONTEXT_AUTHOR ( aLog2 , " configmgr::OProviderImpl " , " jb99855 " , " createUpdatableTree() " ) ;
2001-07-05 16:05:51 +00:00
RootTree aRootTree ( createUpdatableTree (
2007-11-23 13:08:41 +00:00
aAccessorPath , aTree , nDepth ,
2003-03-19 15:20:19 +00:00
TemplateProvider ( this - > getTemplateProvider ( ) , _aOptions )
2001-07-05 16:05:51 +00:00
) ) ;
2000-11-10 21:42:54 +00:00
2003-03-19 15:20:19 +00:00
return m_pNewProviders - > getWriterFactory ( ) . makeAccessRoot ( aRootTree , _aOptions ) ;
2001-07-05 16:05:51 +00:00
}
catch ( configuration : : Exception & e )
{
configapi : : ExceptionMapper ec ( e ) ;
ec . setContext ( this - > getProviderInstance ( ) ) ;
//ec.unhandled();
throw lang : : WrappedTargetException ( ec . message ( ) , ec . context ( ) , uno : : Any ( ) ) ;
}
2000-11-10 21:42:54 +00:00
}
//=============================================================================
//= OProvider::FactoryArguments
//=============================================================================
2001-05-28 14:33:37 +00:00
sal_Char const * const OProviderImpl : : FactoryArguments : : asciiArgumentNames [ ] =
2000-11-10 21:42:54 +00:00
{
2003-03-19 15:20:19 +00:00
" nodepath " , // ARG_NODEPATH, // requested node path
" depth " , // ARG_DEPTH, // depth of the tree
" user " , // ARG_USER_DEPRECATED, // name of the user - only for admin
" locale " , // ARG_LOCALE, // desired locale
" nocache " , // ARG_NOCACHE_OBSOLETE, // cache disabling
" lazywrite " , // ARG_ASYNC_DEPRECATED, // lasy write data
" enableasync " , // ARG_ASYNC, // lasy write data
" entity " , // ARG_ENTITY, // name of the entity to be manipulated - only for admin
2004-06-18 14:46:38 +00:00
" reload " , //ARG_REFRESH // refresh component
2003-03-19 15:20:19 +00:00
2001-05-28 14:33:37 +00:00
} ;
OProviderImpl : : FactoryArguments : : Argument
OProviderImpl : : FactoryArguments : : lookupArgument ( const rtl : : OUString & rName )
2001-11-09 10:23:57 +00:00
CFG_NOTHROW ( )
2001-05-28 14:33:37 +00:00
{
OUString sCheck ( rName . toAsciiLowerCase ( ) ) ;
typedef sal_Char const * const * ArgNameIter ;
ArgNameIter const pFirst = asciiArgumentNames ;
ArgNameIter const pLast = pFirst + _arg_count ;
ArgNameIter it = pFirst ;
for ( ; it ! = pLast ; + + it )
2000-11-10 21:42:54 +00:00
{
2001-05-28 14:33:37 +00:00
if ( 0 = = sCheck . compareToAscii ( * it ) )
{
break ;
}
2000-11-10 21:42:54 +00:00
}
2001-05-28 14:33:37 +00:00
OSL_ASSERT ( Argument ( pLast - pFirst ) = = ARG_NOT_FOUND ) ;
return static_cast < Argument > ( it - pFirst ) ;
2000-11-10 21:42:54 +00:00
}
2002-10-28 13:41:43 +00:00
//-----------------------------------------------------------------------------------
bool OProviderImpl : : FactoryArguments : : extractOneArgument (
OUString const & aName , uno : : Any const & aValue ,
2001-05-28 14:33:37 +00:00
OUString & /* [out] */ _rNodeAccessor ,
sal_Int32 & /* [out] */ _nLevels ,
2003-03-19 15:20:19 +00:00
RequestOptions & /* [in/out] */ _rOptions )
2001-11-09 10:23:57 +00:00
CFG_NOTHROW ( )
2001-05-28 14:33:37 +00:00
{
2002-10-28 13:41:43 +00:00
switch ( lookupArgument ( aName ) )
2000-11-10 21:42:54 +00:00
{
2001-05-28 14:33:37 +00:00
case ARG_NODEPATH :
2000-11-10 21:42:54 +00:00
{
2001-05-28 14:33:37 +00:00
OUString sStringVal ;
2002-10-28 13:41:43 +00:00
if ( aValue > > = sStringVal )
2001-05-28 14:33:37 +00:00
_rNodeAccessor = sStringVal ;
else
return false ;
}
break ;
case ARG_DEPTH :
{
2006-11-21 16:23:20 +00:00
sal_Int32 nIntVal = 0 ;
2002-10-28 13:41:43 +00:00
if ( aValue > > = nIntVal )
2001-05-28 14:33:37 +00:00
_nLevels = nIntVal ;
else
return false ;
}
break ;
2003-03-19 15:20:19 +00:00
case ARG_ENTITY :
case ARG_USER_DEPRECATED :
2001-05-28 14:33:37 +00:00
{
OUString sStringVal ;
2002-10-28 13:41:43 +00:00
if ( aValue > > = sStringVal )
2003-03-19 15:20:19 +00:00
_rOptions . setEntity ( sStringVal ) ;
2001-05-28 14:33:37 +00:00
else
return false ;
}
break ;
case ARG_LOCALE :
{
OUString sStringVal ;
2002-10-28 13:41:43 +00:00
if ( aValue > > = sStringVal )
2001-05-28 14:33:37 +00:00
{
2004-01-20 15:23:58 +00:00
_rOptions . setIsoLocale ( sStringVal ) ;
2001-05-28 14:33:37 +00:00
break ;
}
2002-10-28 13:41:43 +00:00
2001-05-28 14:33:37 +00:00
lang : : Locale aLocale ;
2002-10-28 13:41:43 +00:00
if ( aValue > > = aLocale )
2000-11-10 21:42:54 +00:00
{
2004-01-20 15:23:58 +00:00
_rOptions . setLocale ( aLocale ) ;
2001-05-28 14:33:37 +00:00
break ;
2000-11-10 21:42:54 +00:00
}
2001-05-28 14:33:37 +00:00
return false ;
2000-11-10 21:42:54 +00:00
}
2001-05-28 14:33:37 +00:00
2003-03-19 15:20:19 +00:00
case ARG_NOCACHE_OBSOLETE :
2000-11-10 21:42:54 +00:00
{
2001-05-28 14:33:37 +00:00
sal_Bool bBoolVal ;
2002-10-28 13:41:43 +00:00
if ( aValue > > = bBoolVal )
2003-03-19 15:20:19 +00:00
OSL_ENSURE ( false , " ConfigurationProvider: Parameter \" nocache \" is obsolete and has no effect " ) ;
2001-05-28 14:33:37 +00:00
else
return false ;
2000-11-10 21:42:54 +00:00
}
2001-05-28 14:33:37 +00:00
break ;
case ARG_ASYNC :
2003-03-19 15:20:19 +00:00
case ARG_ASYNC_DEPRECATED :
2000-11-13 13:37:07 +00:00
{
2006-08-29 10:14:11 +00:00
sal_Bool bBoolVal = sal_False ;
2002-10-28 13:41:43 +00:00
if ( aValue > > = bBoolVal )
2003-03-19 15:20:19 +00:00
_rOptions . enableAsync ( ! ! bBoolVal ) ;
2001-05-28 14:33:37 +00:00
else
return false ;
2000-11-13 13:37:07 +00:00
}
2001-05-28 14:33:37 +00:00
break ;
2004-06-18 14:46:38 +00:00
case ARG_REFRESH :
{
2006-08-29 10:14:11 +00:00
sal_Bool bBoolVal = sal_False ;
2004-06-18 14:46:38 +00:00
if ( aValue > > = bBoolVal )
_rOptions . forceRefresh ( ! ! bBoolVal ) ;
else
return false ;
}
break ;
2001-05-28 14:33:37 +00:00
case ARG_NOT_FOUND :
{
rtl : : OString sMessage ( RTL_CONSTASCII_STRINGPARAM ( " Unknown argument \" " ) ) ;
2002-10-28 13:41:43 +00:00
sMessage + = rtl : : OUStringToOString ( aName , RTL_TEXTENCODING_ASCII_US ) ;
2001-05-28 14:33:37 +00:00
sMessage + = rtl : : OString ( RTL_CONSTASCII_STRINGPARAM ( " \" ! \n - Parameter will be ignored - \n " ) ) ;
CFG_TRACE_WARNING ( " provider: %s " , sMessage . getStr ( ) ) ;
# ifdef DBG_UTIL
OSL_ENSURE ( false , sMessage . getStr ( ) ) ;
# endif
}
break ;
default :
CFG_TRACE_ERROR ( " Known argument is not handled " ) ;
OSL_ENSURE ( false , " Known argument is not handled " ) ;
break ;
2000-11-10 21:42:54 +00:00
}
return true ;
}
2001-05-28 14:33:37 +00:00
//-----------------------------------------------------------------------------------
static
2002-10-28 13:41:43 +00:00
void failInvalidArg ( uno : : Any const & aArg , sal_Int32 _nArg = - 1 )
2001-11-09 10:23:57 +00:00
CFG_THROW1 ( lang : : IllegalArgumentException )
2001-05-28 14:33:37 +00:00
{
OSL_ENSURE ( sal_Int16 ( _nArg ) = = _nArg , " Argument number out of range. Raising imprecise exception. " ) ;
2002-10-28 13:41:43 +00:00
rtl : : OUStringBuffer sMessage ;
sMessage . appendAscii ( " Configuration Provider: An argument " ) ;
sMessage . appendAscii ( " has the wrong type. " ) ;
sMessage . appendAscii ( " \n - Expected a NamedValue or PropertyValue " ) ;
sMessage . appendAscii ( " \n - Found type " ) . append ( aArg . getValueType ( ) . getTypeName ( ) ) ;
throw lang : : IllegalArgumentException ( sMessage . makeStringAndClear ( ) ,
uno : : Reference < uno : : XInterface > ( ) ,
sal_Int16 ( _nArg + 1 ) ) ;
}
//-----------------------------------------------------------------------------------
static
void failInvalidArgValue ( OUString const & aName , uno : : Any const & aValue , sal_Int32 _nArg = - 1 )
CFG_THROW1 ( lang : : IllegalArgumentException )
{
OSL_ENSURE ( sal_Int16 ( _nArg ) = = _nArg , " Argument number out of range. Raising imprecise exception. " ) ;
rtl : : OUStringBuffer sMessage ;
sMessage . appendAscii ( " Configuration Provider: The argument " ) . append ( aName ) ;
sMessage . appendAscii ( " has the wrong type. " ) ;
sMessage . appendAscii ( " \n - Found type " ) . append ( aValue . getValueType ( ) . getTypeName ( ) ) ;
throw lang : : IllegalArgumentException ( sMessage . makeStringAndClear ( ) ,
uno : : Reference < uno : : XInterface > ( ) ,
sal_Int16 ( _nArg + 1 ) ) ;
2001-05-28 14:33:37 +00:00
}
//-----------------------------------------------------------------------------------
static
bool extractLegacyArguments ( const uno : : Sequence < uno : : Any > & _rArgs ,
OUString & /* [out] */ _rNodeAccessor ,
sal_Int32 & /* [out] */ _nLevels )
2006-06-19 22:16:41 +00:00
CFG_THROW1 ( lang : : IllegalArgumentException )
2001-05-28 14:33:37 +00:00
{
2002-10-28 13:41:43 +00:00
OSL_ASSERT ( _rArgs . getLength ( ) ! = 0 ) ;
2001-05-28 14:33:37 +00:00
2002-10-28 13:41:43 +00:00
// compatibility : formerly, you could specify the node path as first arg and the (optional) depth
// as second arg
if ( ! ( _rArgs [ 0 ] > > = _rNodeAccessor ) )
return false ;
2001-05-28 14:33:37 +00:00
2002-10-28 13:41:43 +00:00
switch ( _rArgs . getLength ( ) )
{
case 1 :
// valid single argument
return true ;
2001-05-28 14:33:37 +00:00
2002-10-28 13:41:43 +00:00
case 2 :
// valid second argument
if ( _rArgs [ 1 ] > > = _nLevels )
2001-05-28 14:33:37 +00:00
return true ;
2002-10-28 13:41:43 +00:00
break ;
default :
if ( _rArgs [ 1 ] > > = _nLevels )
{
// valid second argument, but too many arguments altogether
throw lang : : IllegalArgumentException (
OUString ( RTL_CONSTASCII_USTRINGPARAM (
" Configuration Provider: Too many arguments. "
" Additional arguments are not supported when passing the node path as string (deprecated convention). " ) ) ,
uno : : Reference < uno : : XInterface > ( ) ,
sal_Int16 ( 3 )
) ;
2001-05-28 14:33:37 +00:00
}
2002-10-28 13:41:43 +00:00
break ;
}
// here we have an invalid second argument
if ( _rArgs [ 1 ] . getValueTypeClass ( ) ! = uno : : TypeClass_STRUCT )
{
// completely invalid second argument
failInvalidArgValue ( OUString : : createFromAscii ( " <depth> " ) , _rArgs [ 1 ] , 1 ) ;
}
// Assume PropertyValue or NamedValue,
// which should be handled consistently by caller
return false ;
2001-05-28 14:33:37 +00:00
}
2000-11-10 21:42:54 +00:00
//-----------------------------------------------------------------------------------
2001-05-28 14:33:37 +00:00
void OProviderImpl : : FactoryArguments : : extractArgs ( const uno : : Sequence < uno : : Any > & _rArgs ,
OUString & /* [out] */ _rNodeAccessor ,
sal_Int32 & /* [out] */ _nLevels ,
2003-03-19 15:20:19 +00:00
RequestOptions & /* [in/out] */ _aOptions )
2001-11-09 10:23:57 +00:00
CFG_THROW1 ( lang : : IllegalArgumentException )
2001-05-28 14:33:37 +00:00
{
2007-11-23 13:08:41 +00:00
UnoApiLock aLock ;
2003-03-19 15:20:19 +00:00
_nLevels = treeop : : ALL_LEVELS ; // setting a fallback
2001-05-28 14:33:37 +00:00
2004-03-23 09:22:48 +00:00
// the args have to be a sequence of property or named values
2002-10-28 13:41:43 +00:00
beans : : NamedValue aNV ;
beans : : PropertyValue aPV ;
2001-05-28 14:33:37 +00:00
for ( sal_Int32 i = 0 ; i < _rArgs . getLength ( ) ; + + i )
2000-11-10 21:42:54 +00:00
{
2002-10-28 13:41:43 +00:00
if ( _rArgs [ i ] > > = aPV )
2000-11-10 21:42:54 +00:00
{
2003-03-19 15:20:19 +00:00
if ( ! extractOneArgument ( aPV . Name , aPV . Value , _rNodeAccessor , _nLevels , _aOptions ) )
2002-10-28 13:41:43 +00:00
failInvalidArgValue ( aPV . Name , aPV . Value , i ) ;
}
else if ( _rArgs [ i ] > > = aNV )
{
2003-03-19 15:20:19 +00:00
if ( ! extractOneArgument ( aNV . Name , aNV . Value , _rNodeAccessor , _nLevels , _aOptions ) )
2002-10-28 13:41:43 +00:00
failInvalidArgValue ( aNV . Name , aNV . Value , i ) ;
2001-05-28 14:33:37 +00:00
}
else
{
if ( i = = 0 ) // try compatibility format
if ( extractLegacyArguments ( _rArgs , _rNodeAccessor , _nLevels ) )
break ;
2000-11-10 21:42:54 +00:00
2002-10-28 13:41:43 +00:00
failInvalidArg ( _rArgs [ i ] , i ) ;
2001-05-28 14:33:37 +00:00
OSL_ASSERT ( false ) ;
2000-11-10 21:42:54 +00:00
}
}
2001-05-28 14:33:37 +00:00
if ( _rNodeAccessor . getLength ( ) = = 0 )
2000-11-10 21:42:54 +00:00
{
2001-05-28 14:33:37 +00:00
OUString sMessage ( RTL_CONSTASCII_USTRINGPARAM ( " Configuration Provider: Missing argument: no nodepath was provided " ) ) ;
2002-10-28 13:41:43 +00:00
throw lang : : IllegalArgumentException ( sMessage , uno : : Reference < uno : : XInterface > ( ) , 0 ) ;
2000-11-10 21:42:54 +00:00
}
2000-12-19 10:14:08 +00:00
}
2004-06-18 14:46:38 +00:00
//-----------------------------------------------------------------------------------
2000-11-13 12:14:49 +00:00
2000-11-10 21:42:54 +00:00
} // namespace configmgr