INTEGRATION: CWS cfgapi (1.9.94); FILE MERGED
2004/05/31 13:09:44 ssmith 1.9.94.2: #112742# removing compiler warnings 2004/05/04 12:58:59 ssmith 1.9.94.1: #112742# check if object is initialized
This commit is contained in:
parent
e5e8249668
commit
eb23861308
1 changed files with 113 additions and 47 deletions
|
@ -2,9 +2,9 @@
|
|||
*
|
||||
* $RCSfile: singlebackendadapter.cxx,v $
|
||||
*
|
||||
* $Revision: 1.9 $
|
||||
* $Revision: 1.10 $
|
||||
*
|
||||
* last change: $Author: rt $ $Date: 2003-04-17 13:18:18 $
|
||||
* last change: $Author: hr $ $Date: 2004-06-18 15:49:07 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
|
@ -77,7 +77,9 @@
|
|||
#ifndef _COM_SUN_STAR_CONFIGURATION_CANNOTLOADCONFIGURATIONEXCEPTION_HPP_
|
||||
#include <com/sun/star/configuration/CannotLoadConfigurationException.hpp>
|
||||
#endif
|
||||
|
||||
#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
|
||||
#include <com/sun/star/lang/DisposedException.hpp>
|
||||
#endif
|
||||
namespace configmgr { namespace backend {
|
||||
|
||||
//==============================================================================
|
||||
|
@ -114,14 +116,42 @@ void SAL_CALL SingleBackendAdapter::initialize(
|
|||
static inline OUString getSingleLayerDummyEntity()
|
||||
{ return OUString(RTL_CONSTASCII_USTRINGPARAM("*")); }
|
||||
//------------------------------------------------------------------------------
|
||||
bool SingleBackendAdapter::checkOkState()
|
||||
{
|
||||
if (!mBackend.is())
|
||||
{
|
||||
if(rBHelper.bDisposed)
|
||||
{
|
||||
throw lang::DisposedException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
|
||||
"SingleBackendAdapter: Backend already disposed")),*this);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw backenduno::BackendAccessException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
|
||||
"SingleBackendAdapter: Object was never Initialised")),*this,uno::Any() );
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// XBackendEntities
|
||||
rtl::OUString SAL_CALL
|
||||
SingleBackendAdapter::getOwnerEntity( )
|
||||
throw (uno::RuntimeException)
|
||||
{
|
||||
uno::Reference< backenduno::XBackendEntities > xEntities( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
if (mBackend.is())
|
||||
{
|
||||
uno::Reference< backenduno::XBackendEntities > xEntities( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
|
||||
return xEntities->getOwnerEntity();
|
||||
return xEntities->getOwnerEntity();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
|
||||
"SingleBackendAdapter: Object was never Initialised")),*this);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -129,8 +159,16 @@ rtl::OUString SAL_CALL
|
|||
SingleBackendAdapter::getAdminEntity( )
|
||||
throw (uno::RuntimeException)
|
||||
{
|
||||
uno::Reference< backenduno::XBackendEntities > xEntities( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
return xEntities->getAdminEntity();
|
||||
if (mBackend.is())
|
||||
{
|
||||
uno::Reference< backenduno::XBackendEntities > xEntities( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
return xEntities->getAdminEntity();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
|
||||
"SingleBackendAdapter: Object was never Initialised")),*this);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -138,8 +176,12 @@ sal_Bool SAL_CALL
|
|||
SingleBackendAdapter::supportsEntity( const rtl::OUString& aEntity )
|
||||
throw (backenduno::BackendAccessException, uno::RuntimeException)
|
||||
{
|
||||
uno::Reference< backenduno::XBackendEntities > xEntities( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
return xEntities->supportsEntity(aEntity);
|
||||
if (checkOkState())
|
||||
{
|
||||
uno::Reference< backenduno::XBackendEntities > xEntities( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
return xEntities->supportsEntity(aEntity);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -149,8 +191,12 @@ sal_Bool SAL_CALL
|
|||
lang::IllegalArgumentException,
|
||||
uno::RuntimeException)
|
||||
{
|
||||
uno::Reference< backenduno::XBackendEntities > xEntities( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
return xEntities->isEqualEntity(aEntity,aOtherEntity);
|
||||
if (checkOkState())
|
||||
{
|
||||
uno::Reference< backenduno::XBackendEntities > xEntities( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
return xEntities->isEqualEntity(aEntity,aOtherEntity);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -160,7 +206,11 @@ uno::Reference<backenduno::XSchema> SAL_CALL
|
|||
lang::IllegalArgumentException,
|
||||
uno::RuntimeException)
|
||||
{
|
||||
return mBackend->getComponentSchema(aComponent) ;
|
||||
if (checkOkState())
|
||||
{
|
||||
return mBackend->getComponentSchema(aComponent) ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -170,7 +220,11 @@ uno::Sequence<uno::Reference<backenduno::XLayer> > SAL_CALL
|
|||
lang::IllegalArgumentException,
|
||||
uno::RuntimeException)
|
||||
{
|
||||
return listLayers(aComponent, this->getOwnerEntity()) ;
|
||||
if (checkOkState())
|
||||
{
|
||||
return listLayers(aComponent, this->getOwnerEntity()) ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -181,7 +235,11 @@ uno::Reference<backenduno::XUpdateHandler> SAL_CALL
|
|||
lang::IllegalArgumentException,
|
||||
uno::RuntimeException)
|
||||
{
|
||||
return getUpdateHandler(aComponent, this->getOwnerEntity()) ;
|
||||
if (checkOkState())
|
||||
{
|
||||
return getUpdateHandler(aComponent, this->getOwnerEntity()) ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -192,27 +250,31 @@ uno::Sequence<uno::Reference<backenduno::XLayer> > SAL_CALL
|
|||
lang::IllegalArgumentException,
|
||||
uno::RuntimeException)
|
||||
{
|
||||
uno::Reference< backenduno::XMultiLayerStratum > xBackend( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
if (checkOkState())
|
||||
{
|
||||
uno::Reference< backenduno::XMultiLayerStratum > xBackend( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
|
||||
uno::Sequence<uno::Reference<backenduno::XLayer> > retCode =
|
||||
xBackend->getLayers(xBackend->listLayerIds(aComponent, aEntity),
|
||||
uno::Sequence<uno::Reference<backenduno::XLayer> > retCode =
|
||||
xBackend->getLayers(xBackend->listLayerIds(aComponent, aEntity),
|
||||
rtl::OUString()) ;
|
||||
|
||||
// There might be non-existent layers in the list if there's no
|
||||
// actual data associated to a given layer id. Hence we have to
|
||||
// compress the list.
|
||||
sal_Int32 maxLayer = 0 ;
|
||||
// There might be non-existent layers in the list if there's no
|
||||
// actual data associated to a given layer id. Hence we have to
|
||||
// compress the list.
|
||||
sal_Int32 maxLayer = 0 ;
|
||||
|
||||
for (sal_Int32 i = 0 ; i < retCode.getLength() ; ++ i)
|
||||
{
|
||||
if (retCode [i].is())
|
||||
for (sal_Int32 i = 0 ; i < retCode.getLength() ; ++ i)
|
||||
{
|
||||
if (i != maxLayer) { retCode [maxLayer] = retCode [i] ; }
|
||||
++ maxLayer ;
|
||||
if (retCode [i].is())
|
||||
{
|
||||
if (i != maxLayer) { retCode [maxLayer] = retCode [i] ; }
|
||||
++ maxLayer ;
|
||||
}
|
||||
}
|
||||
retCode.realloc(maxLayer) ;
|
||||
return retCode ;
|
||||
}
|
||||
retCode.realloc(maxLayer) ;
|
||||
return retCode ;
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
@ -224,31 +286,35 @@ uno::Reference<backenduno::XUpdateHandler> SAL_CALL
|
|||
lang::IllegalArgumentException,
|
||||
uno::RuntimeException)
|
||||
{
|
||||
uno::Reference< backenduno::XMultiLayerStratum > xBackend( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
if (checkOkState())
|
||||
{
|
||||
uno::Reference< backenduno::XMultiLayerStratum > xBackend( mBackend, uno::UNO_REF_QUERY_THROW );
|
||||
|
||||
uno::Sequence<uno::Any> arguments(1) ;
|
||||
uno::Sequence<uno::Any> arguments(1) ;
|
||||
|
||||
arguments [0] <<= xBackend->getUpdatableLayer(
|
||||
arguments [0] <<= xBackend->getUpdatableLayer(
|
||||
xBackend->getUpdateLayerId(aComponent,
|
||||
aEntity)) ;
|
||||
uno::Reference< uno::XInterface > xHandler;
|
||||
try
|
||||
{
|
||||
const rtl::OUString kUpdateMerger(RTL_CONSTASCII_USTRINGPARAM(
|
||||
"com.sun.star.configuration.backend.LayerUpdateMerger")) ;
|
||||
uno::Reference< uno::XInterface > xHandler;
|
||||
try
|
||||
{
|
||||
const rtl::OUString kUpdateMerger(RTL_CONSTASCII_USTRINGPARAM(
|
||||
"com.sun.star.configuration.backend.LayerUpdateMerger")) ;
|
||||
|
||||
xHandler = mFactory->createInstanceWithArguments(kUpdateMerger, arguments);
|
||||
}
|
||||
catch (uno::RuntimeException & )
|
||||
{throw;}
|
||||
catch (uno::Exception & e)
|
||||
{
|
||||
const rtl::OUString sMessage(RTL_CONSTASCII_USTRINGPARAM(
|
||||
"Configuration SingleBackendAdapter: Cannot create UpdateMerger - error message: ")) ;
|
||||
throw uno::RuntimeException(sMessage.concat(e.Message),*this);
|
||||
}
|
||||
xHandler = mFactory->createInstanceWithArguments(kUpdateMerger, arguments);
|
||||
}
|
||||
catch (uno::RuntimeException & )
|
||||
{throw;}
|
||||
catch (uno::Exception & e)
|
||||
{
|
||||
const rtl::OUString sMessage(RTL_CONSTASCII_USTRINGPARAM(
|
||||
"Configuration SingleBackendAdapter: Cannot create UpdateMerger - error message: ")) ;
|
||||
throw uno::RuntimeException(sMessage.concat(e.Message),*this);
|
||||
}
|
||||
|
||||
return uno::Reference<backenduno::XUpdateHandler>(xHandler, uno::UNO_REF_QUERY_THROW) ;
|
||||
return uno::Reference<backenduno::XUpdateHandler>(xHandler, uno::UNO_REF_QUERY_THROW) ;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in a new issue