User: obo Date: 2006/07/10 07:39:27 Modified: dba/connectivity/source/sdbcx/VCollection.cxx
Log: INTEGRATION: CWS qiq (1.38.20); FILE MERGED 2006/06/30 13:18:00 fs 1.38.20.3: during #i51143#: PROPERTY_ID_HY0000 superseded by StandardSQLState.SQL_GENERAL_ERROR 2006/06/27 15:11:49 fs 1.38.20.2: RESYNC: (1.38-1.39); FILE MERGED 2006/06/16 11:32:40 fs 1.38.20.1: during #i51143#: refactored VCollection: - createEmptyObject now named createDescriptor - cloneObject removed - appendObject now returns the newly created object (previously done via a subsequent call to cloneObject) File Changes: Directory: /dba/connectivity/source/sdbcx/ ========================================== File [changed]: VCollection.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/sdbcx/VCollection.cxx?r1=1.39&r2=1.40 Delta lines: +57 -47 --------------------- --- VCollection.cxx 20 Jun 2006 02:09:50 -0000 1.39 +++ VCollection.cxx 10 Jul 2006 14:39:25 -0000 1.40 @@ -40,6 +40,9 @@ #ifndef _CONNECTIVITY_SDBCX_DESCRIPTOR_HXX_ #include "connectivity/sdbcx/VDescriptor.hxx" #endif +#ifndef _DBHELPER_DBEXCEPTION_HXX_ +#include "connectivity/dbexception.hxx" +#endif #ifndef _COMPHELPER_ENUMHELPER_HXX_ #include <comphelper/enumhelper.hxx> #endif @@ -49,9 +52,15 @@ #ifndef _COMPHELPER_TYPES_HXX_ #include <comphelper/types.hxx> #endif +#ifndef _COMPHELPER_PROPERTY_HXX_ +#include <comphelper/property.hxx> +#endif #ifndef CONNECTIVITY_CONNECTION_HXX #include "TConnection.hxx" #endif +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif using namespace connectivity::sdbcx; using namespace connectivity; @@ -341,7 +350,14 @@ ::osl::MutexGuard aGuard(m_rMutex); if ( !m_pElements->exists(aName) ) - throw NoSuchElementException(aName,static_cast<XTypeProvider*>(this)); + { + ::rtl::OUStringBuffer aMessage; + aMessage.appendAscii( "There is no element named '" ); + aMessage.append( aName ); + aMessage.appendAscii( "'." ); + // TODO: resource + throw NoSuchElementException( aMessage.makeStringAndClear(), static_cast< XTypeProvider* >( this ) ); + } return makeAny(getObject(m_pElements->findColumn(aName))); } @@ -373,7 +389,7 @@ { ::osl::MutexGuard aGuard(m_rMutex); - return createEmptyObject(); + return createDescriptor(); } // ----------------------------------------------------------------------------- ::rtl::OUString OCollection::getNameForObject(const ObjectType& _xObject) @@ -387,38 +403,29 @@ // XAppend void SAL_CALL OCollection::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) { - ::osl::MutexGuard aGuard(m_rMutex); - - ObjectType xName(descriptor,UNO_QUERY); - if(xName.is()) - { + ::osl::ClearableMutexGuard aGuard(m_rMutex); - ::rtl::OUString sName = getNameForObject(xName); + ::rtl::OUString sName = getNameForObject( descriptor ); if ( m_pElements->exists(sName) ) throw ElementExistException(sName,static_cast<XTypeProvider*>(this)); - appendObject(descriptor); - ObjectType xNewName = cloneObject(descriptor); + ObjectType xNewlyCreated = appendObject( sName, descriptor ); + if ( !xNewlyCreated.is() ) + throw RuntimeException(); - ODescriptor* pDescriptor = ODescriptor::getImplementation( xNewName ); + ODescriptor* pDescriptor = ODescriptor::getImplementation( xNewlyCreated ); if ( pDescriptor ) pDescriptor->setNew( sal_False ); - if(xNewName.is()) - { - sName = getNameForObject(xNewName); - if ( !m_pElements->exists(sName) ) // this may happen when the drived class included it itself - m_pElements->insert(sName,xNewName); + sName = getNameForObject( xNewlyCreated ); + if ( !m_pElements->exists( sName ) ) // this may happen when the drived class included it itself + m_pElements->insert( sName, xNewlyCreated ); + // notify our container listeners - ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(sName), makeAny(xNewName), Any()); - OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners); - while (aListenerLoop.hasMoreElements()) - static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent); - } - else - throw SQLException(); - } + ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(sName), makeAny(xNewlyCreated), Any()); + aGuard.clear(); + m_aContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); } // ------------------------------------------------------------------------- // XDrop @@ -466,7 +473,7 @@ sal_Int32 SAL_CALL OCollection::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException) { if ( !m_pElements->exists(columnName) ) - throw SQLException(::rtl::OUString::createFromAscii("Unknown column name!"),static_cast<XTypeProvider*>(this),OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_HY0000),1000,makeAny(NoSuchElementException(columnName,static_cast<XTypeProvider*>(this))) ); + ::dbtools::throwGenericSQLException( ::rtl::OUString::createFromAscii( "Unknown column name." ), static_cast<XTypeProvider*>(this) ); return m_pElements->findColumn(columnName) + 1; // because columns start at one } @@ -585,19 +592,22 @@ m_pElements->disposeElements(); } // ----------------------------------------------------------------------------- -Reference< XPropertySet > OCollection::createEmptyObject() +Reference< XPropertySet > OCollection::createDescriptor() { OSL_ASSERT(!"Need to be overloaded when used!"); throw SQLException(); } // ----------------------------------------------------------------------------- -void OCollection::appendObject( const Reference< XPropertySet >& /*descriptor*/ ) +ObjectType OCollection::cloneDescriptor( const ObjectType& _descriptor ) { + ObjectType xNewDescriptor( createDescriptor() ); + ::comphelper::copyProperties( _descriptor, xNewDescriptor ); + return xNewDescriptor; } // ----------------------------------------------------------------------------- -ObjectType OCollection::cloneObject(const Reference< XPropertySet >& _xDescriptor) +ObjectType OCollection::appendObject( const ::rtl::OUString& /*_rForName*/, const Reference< XPropertySet >& descriptor ) { - return _xDescriptor.is() ? createObject(getNameForObject(_xDescriptor)) : sdbcx::ObjectType(); + return cloneDescriptor( descriptor ); } // ----------------------------------------------------------------------------- void OCollection::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString /*_sElementName*/) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
