summaryrefslogtreecommitdiff
path: root/dbaccess/source/core/dataaccess/definitioncontainer.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/core/dataaccess/definitioncontainer.cxx')
-rw-r--r--dbaccess/source/core/dataaccess/definitioncontainer.cxx109
1 files changed, 22 insertions, 87 deletions
diff --git a/dbaccess/source/core/dataaccess/definitioncontainer.cxx b/dbaccess/source/core/dataaccess/definitioncontainer.cxx
index 33ce2782a1dd..f7645349e79d 100644
--- a/dbaccess/source/core/dataaccess/definitioncontainer.cxx
+++ b/dbaccess/source/core/dataaccess/definitioncontainer.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,55 +29,25 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_dbaccess.hxx"
-#ifndef _DBA_CORE_DEFINITIONCONTAINER_HXX_
#include "definitioncontainer.hxx"
-#endif
-#ifndef DBACCESS_SHARED_DBASTRINGS_HRC
#include "dbastrings.hrc"
-#endif
-#ifndef _DBASHARED_APITOOLS_HXX_
#include "apitools.hxx"
-#endif
-#ifndef _DBA_CORE_RESOURCE_HXX_
#include "core_resource.hxx"
-#endif
-#ifndef _DBA_CORE_RESOURCE_HRC_
#include "core_resource.hrc"
-#endif
-#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
-#endif
-#ifndef TOOLS_DIAGNOSE_EX_H
#include <tools/diagnose_ex.h>
-#endif
-#ifndef _COMPHELPER_SEQUENCE_HXX_
+#include <osl/diagnose.h>
#include <comphelper/sequence.hxx>
-#endif
-#ifndef _COMPHELPER_ENUMHELPER_HXX_
#include <comphelper/enumhelper.hxx>
-#endif
-#ifndef _COMPHELPER_EXTRACT_HXX_
#include <comphelper/extract.hxx>
-#endif
-#ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
#include <com/sun/star/lang/XComponent.hpp>
-#endif
-#ifndef _COM_SUN_STAR_UCB_COMMANDINFO_HPP_
#include <com/sun/star/ucb/CommandInfo.hpp>
-#endif
-#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
-#endif
-#ifndef _COM_SUN_STAR_SDB_ERRORCONDITION_HPP_
#include <com/sun/star/sdb/ErrorCondition.hpp>
-#endif
-#ifndef _COMPHELPER_TYPES_HXX_
#include <comphelper/types.hxx>
-#endif
-#ifndef _UCBHELPER_CONTENTIDENTIFIER_HXX
#include <ucbhelper/contentidentifier.hxx>
-#endif
+#include <o3tl/compat_functional.hxx>
using namespace ::com::sun::star::uno;
@@ -91,15 +62,12 @@ using namespace ::comphelper;
using namespace ::cppu;
using namespace ::com::sun::star::ucb;
-//........................................................................
namespace dbaccess
{
-//........................................................................
//==========================================================================
//= ODefinitionContainer_Impl
//==========================================================================
-//--------------------------------------------------------------------------
void ODefinitionContainer_Impl::erase( TContentPtr _pDefinition )
{
NamedDefinitions::iterator aPos = find( _pDefinition );
@@ -107,28 +75,26 @@ void ODefinitionContainer_Impl::erase( TContentPtr _pDefinition )
m_aDefinitions.erase( aPos );
}
-//--------------------------------------------------------------------------
ODefinitionContainer_Impl::const_iterator ODefinitionContainer_Impl::find( TContentPtr _pDefinition ) const
{
return ::std::find_if(
m_aDefinitions.begin(),
m_aDefinitions.end(),
- ::std::compose1(
+ ::o3tl::compose1(
::std::bind2nd( ::std::equal_to< TContentPtr >(), _pDefinition ),
- ::std::select2nd< NamedDefinitions::value_type >()
+ ::o3tl::select2nd< NamedDefinitions::value_type >()
)
);
}
-//--------------------------------------------------------------------------
ODefinitionContainer_Impl::iterator ODefinitionContainer_Impl::find( TContentPtr _pDefinition )
{
return ::std::find_if(
m_aDefinitions.begin(),
m_aDefinitions.end(),
- ::std::compose1(
+ ::o3tl::compose1(
::std::bind2nd( ::std::equal_to< TContentPtr >(), _pDefinition ),
- ::std::select2nd< NamedDefinitions::value_type >()
+ ::o3tl::select2nd< NamedDefinitions::value_type >()
)
);
}
@@ -137,7 +103,7 @@ ODefinitionContainer_Impl::iterator ODefinitionContainer_Impl::find( TContentPtr
//= ODefinitionContainer
//==========================================================================
DBG_NAME(ODefinitionContainer)
-//--------------------------------------------------------------------------
+
ODefinitionContainer::ODefinitionContainer( const Reference< XMultiServiceFactory >& _xORB
, const Reference< XInterface >& _xParentContainer
, const TContentPtr& _pImpl
@@ -165,14 +131,13 @@ ODefinitionContainer::ODefinitionContainer( const Reference< XMultiServiceFact
DBG_CTOR(ODefinitionContainer, NULL);
}
-//--------------------------------------------------------------------------
void SAL_CALL ODefinitionContainer::disposing()
{
OContentHelper::disposing();
MutexGuard aGuard(m_aMutex);
- // say our listeners goobye
+ // say goodbye to our listeners
EventObject aEvt(*this);
m_aApproveListeners.disposeAndClear(aEvt);
m_aContainerListeners.disposeAndClear(aEvt);
@@ -197,7 +162,6 @@ void SAL_CALL ODefinitionContainer::disposing()
m_aDocumentMap.clear();
}
-//--------------------------------------------------------------------------
ODefinitionContainer::~ODefinitionContainer()
{
DBG_DTOR(ODefinitionContainer, NULL);
@@ -206,12 +170,11 @@ ODefinitionContainer::~ODefinitionContainer()
IMPLEMENT_FORWARD_XINTERFACE2( ODefinitionContainer,OContentHelper,ODefinitionContainer_Base)
IMPLEMENT_TYPEPROVIDER2(ODefinitionContainer,OContentHelper,ODefinitionContainer_Base);
// XServiceInfo
-//--------------------------------------------------------------------------
::rtl::OUString SAL_CALL ODefinitionContainer::getImplementationName( ) throw(RuntimeException)
{
return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ODefinitionContainer"));
}
-//--------------------------------------------------------------------------
+
Sequence< ::rtl::OUString > SAL_CALL ODefinitionContainer::getSupportedServiceNames( ) throw(RuntimeException)
{
Sequence< ::rtl::OUString > aReturn(2);
@@ -221,7 +184,6 @@ Sequence< ::rtl::OUString > SAL_CALL ODefinitionContainer::getSupportedServiceNa
}
// XNameContainer
-//--------------------------------------------------------------------------
void SAL_CALL ODefinitionContainer::insertByName( const ::rtl::OUString& _rName, const Any& aElement ) throw(IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException)
{
ResettableMutexGuard aGuard(m_aMutex);
@@ -235,7 +197,6 @@ void SAL_CALL ODefinitionContainer::insertByName( const ::rtl::OUString& _rName,
notifyByName( aGuard, _rName, xNewElement, NULL, E_INSERTED, ContainerListemers );
}
-//--------------------------------------------------------------------------
void SAL_CALL ODefinitionContainer::removeByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
{
ResettableMutexGuard aGuard(m_aMutex);
@@ -260,7 +221,6 @@ void SAL_CALL ODefinitionContainer::removeByName( const ::rtl::OUString& _rName
}
// XNameReplace
-//--------------------------------------------------------------------------
void SAL_CALL ODefinitionContainer::replaceByName( const ::rtl::OUString& _rName, const Any& aElement ) throw(IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException)
{
ResettableMutexGuard aGuard(m_aMutex);
@@ -280,7 +240,6 @@ void SAL_CALL ODefinitionContainer::replaceByName( const ::rtl::OUString& _rName
disposeComponent(xOldElement);
}
-// -----------------------------------------------------------------------------
namespace
{
typedef Reference< XVeto > ( SAL_CALL XContainerApproveListener::*ContainerApprovalMethod )( const ContainerEvent& );
@@ -319,7 +278,6 @@ namespace
};
}
-// -----------------------------------------------------------------------------
void ODefinitionContainer::notifyByName( ResettableMutexGuard& _rGuard, const ::rtl::OUString& _rName,
const Reference< XContent >& _xNewElement, const Reference< XContent >& _xOldElement,
ContainerOperation _eOperation, ListenerType _eType )
@@ -362,43 +320,36 @@ void ODefinitionContainer::notifyByName( ResettableMutexGuard& _rGuard, const ::
_rGuard.reset();
}
-//--------------------------------------------------------------------------
void SAL_CALL ODefinitionContainer::addContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
{
if (_rxListener.is())
m_aContainerListeners.addInterface(_rxListener);
}
-//--------------------------------------------------------------------------
void SAL_CALL ODefinitionContainer::removeContainerListener( const Reference< XContainerListener >& _rxListener ) throw(RuntimeException)
{
if (_rxListener.is())
m_aContainerListeners.removeInterface(_rxListener);
}
-//--------------------------------------------------------------------------
void SAL_CALL ODefinitionContainer::addContainerApproveListener( const Reference< XContainerApproveListener >& _Listener ) throw (RuntimeException)
{
if ( _Listener.is() )
m_aApproveListeners.addInterface( _Listener );
}
-//--------------------------------------------------------------------------
void SAL_CALL ODefinitionContainer::removeContainerApproveListener( const Reference< XContainerApproveListener >& _Listener ) throw (RuntimeException)
{
if ( _Listener.is() )
m_aApproveListeners.removeInterface( _Listener );
}
-
// XElementAccess
-//--------------------------------------------------------------------------
Type SAL_CALL ODefinitionContainer::getElementType( ) throw (RuntimeException)
{
return ::getCppuType( static_cast< Reference< XContent >* >(NULL) );
}
-//--------------------------------------------------------------------------
sal_Bool SAL_CALL ODefinitionContainer::hasElements( ) throw (RuntimeException)
{
MutexGuard aGuard(m_aMutex);
@@ -406,14 +357,12 @@ sal_Bool SAL_CALL ODefinitionContainer::hasElements( ) throw (RuntimeException)
}
// XEnumerationAccess
-//--------------------------------------------------------------------------
Reference< XEnumeration > SAL_CALL ODefinitionContainer::createEnumeration( ) throw(RuntimeException)
{
MutexGuard aGuard(m_aMutex);
return new ::comphelper::OEnumerationByIndex(static_cast<XIndexAccess*>(this));
}
-//--------------------------------------------------------------------------
// XIndexAccess
sal_Int32 SAL_CALL ODefinitionContainer::getCount( ) throw(RuntimeException)
{
@@ -421,7 +370,6 @@ sal_Int32 SAL_CALL ODefinitionContainer::getCount( ) throw(RuntimeException)
return m_aDocuments.size();
}
-//--------------------------------------------------------------------------
Any SAL_CALL ODefinitionContainer::getByIndex( sal_Int32 _nIndex ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException)
{
MutexGuard aGuard(m_aMutex);
@@ -442,7 +390,6 @@ Any SAL_CALL ODefinitionContainer::getByIndex( sal_Int32 _nIndex ) throw(IndexOu
return makeAny(xProp);
}
-//--------------------------------------------------------------------------
Any SAL_CALL ODefinitionContainer::getByName( const ::rtl::OUString& _rName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
{
MutexGuard aGuard(m_aMutex);
@@ -450,7 +397,6 @@ Any SAL_CALL ODefinitionContainer::getByName( const ::rtl::OUString& _rName ) th
return makeAny( implGetByName( _rName, sal_True ) );
}
-//--------------------------------------------------------------------------
Reference< XContent > ODefinitionContainer::implGetByName(const ::rtl::OUString& _rName, sal_Bool _bReadIfNeccessary) throw (NoSuchElementException)
{
Documents::iterator aMapPos = m_aDocumentMap.find(_rName);
@@ -472,7 +418,6 @@ Reference< XContent > ODefinitionContainer::implGetByName(const ::rtl::OUString&
return xProp;
}
-//--------------------------------------------------------------------------
Sequence< ::rtl::OUString > SAL_CALL ODefinitionContainer::getElementNames( ) throw(RuntimeException)
{
MutexGuard aGuard(m_aMutex);
@@ -491,7 +436,6 @@ Sequence< ::rtl::OUString > SAL_CALL ODefinitionContainer::getElementNames( ) t
return aNames;
}
-//--------------------------------------------------------------------------
sal_Bool SAL_CALL ODefinitionContainer::hasByName( const ::rtl::OUString& _rName ) throw(RuntimeException)
{
MutexGuard aGuard(m_aMutex);
@@ -499,7 +443,6 @@ sal_Bool SAL_CALL ODefinitionContainer::hasByName( const ::rtl::OUString& _rName
return checkExistence(_rName);
}
-//--------------------------------------------------------------------------
void SAL_CALL ODefinitionContainer::disposing( const EventObject& _rSource ) throw(RuntimeException)
{
MutexGuard aGuard(m_aMutex);
@@ -518,7 +461,6 @@ void SAL_CALL ODefinitionContainer::disposing( const EventObject& _rSource ) thr
}
}
-//--------------------------------------------------------------------------
void ODefinitionContainer::implRemove(const ::rtl::OUString& _rName)
{
// from the object maps
@@ -534,7 +476,6 @@ void ODefinitionContainer::implRemove(const ::rtl::OUString& _rName)
}
}
-//--------------------------------------------------------------------------
namespace
{
bool lcl_ensureName( const Reference< XContent >& _rxContent, const ::rtl::OUString& _rName )
@@ -542,7 +483,6 @@ namespace
if ( !_rxContent.is() )
return true;
- // ..........................................................
// obtain the current name. If it's the same as the new one,
// don't do anything
try
@@ -558,10 +498,9 @@ namespace
}
catch( const Exception& )
{
- OSL_ENSURE( sal_False, "lcl_ensureName: caught an exception while obtaining the current name!" );
+ OSL_FAIL( "lcl_ensureName: caught an exception while obtaining the current name!" );
}
- // ..........................................................
// set the new name
Reference< XRename > xRename( _rxContent, UNO_QUERY );
OSL_ENSURE( xRename.is(), "lcl_ensureName: invalid content (not renameable)!" );
@@ -574,12 +513,12 @@ namespace
}
catch( const Exception& )
{
- OSL_ENSURE( sal_False, "lcl_ensureName: caught an exception!" );
+ OSL_FAIL( "lcl_ensureName: caught an exception!" );
}
return false;
}
}
-//--------------------------------------------------------------------------
+
void ODefinitionContainer::implAppend(const ::rtl::OUString& _rName, const Reference< XContent >& _rxNewObject)
{
MutexGuard aGuard(m_aMutex);
@@ -593,11 +532,11 @@ void ODefinitionContainer::implAppend(const ::rtl::OUString& _rName, const Refer
ODefinitionContainer_Impl::const_iterator aFind = rDefinitions.find( _rName );
if ( aFind == rDefinitions.end() )
{
- // ensure that the new object thas the proper name.
+ // ensure that the new object has the proper name.
// Somebody could create an object with name "foo", and insert it as "bar"
// into a container. In this case, we need to ensure that the object name
// is also "bar"
- // #i44786# / 2005-03-11 / frank.schoenheit@sun.com
+ // #i44786#
lcl_ensureName( _rxNewObject, _rName );
::rtl::Reference< OContentHelper > pContent = OContentHelper::getImplementation( _rxNewObject );
@@ -619,14 +558,13 @@ void ODefinitionContainer::implAppend(const ::rtl::OUString& _rName, const Refer
}
catch(Exception&)
{
- DBG_ERROR("ODefinitionContainer::implAppend: caught something !");
+ OSL_FAIL("ODefinitionContainer::implAppend: caught something !");
}
}
-//--------------------------------------------------------------------------
void ODefinitionContainer::implReplace(const ::rtl::OUString& _rName, const Reference< XContent >& _rxNewObject)
{
- DBG_ASSERT(checkExistence(_rName), "ODefinitionContainer::implReplace : invalid name !");
+ OSL_ENSURE(checkExistence(_rName), "ODefinitionContainer::implReplace : invalid name !");
Documents::iterator aFind = m_aDocumentMap.find(_rName);
removeObjectListener(aFind->second);
@@ -634,7 +572,6 @@ void ODefinitionContainer::implReplace(const ::rtl::OUString& _rName, const Refe
addObjectListener(aFind->second);
}
-// -----------------------------------------------------------------------------
void ODefinitionContainer::approveNewObject(const ::rtl::OUString& _sName,const Reference< XContent >& _rxObject) const
{
// check the arguments
@@ -675,7 +612,6 @@ void ODefinitionContainer::approveNewObject(const ::rtl::OUString& _sName,const
*this );
}
-// -----------------------------------------------------------------------------
// XPropertyChangeListener
void SAL_CALL ODefinitionContainer::propertyChange( const PropertyChangeEvent& evt ) throw (RuntimeException)
{
@@ -701,7 +637,7 @@ void SAL_CALL ODefinitionContainer::propertyChange( const PropertyChangeEvent& e
m_bInPropertyChange = sal_False;
}
}
-// -----------------------------------------------------------------------------
+
// XVetoableChangeListener
void SAL_CALL ODefinitionContainer::vetoableChange( const PropertyChangeEvent& aEvent ) throw (PropertyVetoException, RuntimeException)
{
@@ -715,7 +651,7 @@ void SAL_CALL ODefinitionContainer::vetoableChange( const PropertyChangeEvent& a
throw PropertyVetoException();
}
}
-// -----------------------------------------------------------------------------
+
void ODefinitionContainer::addObjectListener(const Reference< XContent >& _xNewObject)
{
OSL_ENSURE(_xNewObject.is(),"ODefinitionContainer::addObjectListener: Object is null!");
@@ -726,7 +662,7 @@ void ODefinitionContainer::addObjectListener(const Reference< XContent >& _xNewO
xProp->addVetoableChangeListener(PROPERTY_NAME, this);
}
}
-// -----------------------------------------------------------------------------
+
void ODefinitionContainer::removeObjectListener(const Reference< XContent >& _xNewObject)
{
Reference<XPropertySet> xProp(_xNewObject,UNO_QUERY);
@@ -736,13 +672,12 @@ void ODefinitionContainer::removeObjectListener(const Reference< XContent >& _xN
xProp->removeVetoableChangeListener(PROPERTY_NAME, this);
}
}
-// -----------------------------------------------------------------------------
+
sal_Bool ODefinitionContainer::checkExistence(const ::rtl::OUString& _rName)
{
return m_aDocumentMap.find(_rName) != m_aDocumentMap.end();
}
-//........................................................................
}
// namespace dbaccess
-//........................................................................
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */