#92883# fix the descriptor handling

This commit is contained in:
Ocke Janssen
2001-10-12 11:02:56 +00:00
parent 865166838f
commit 251039c87c
14 changed files with 149 additions and 190 deletions

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: CIndexes.cxx,v $ * $RCSfile: CIndexes.cxx,v $
* *
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* last change: $Author: fs $ $Date: 2001-03-15 08:29:16 $ * last change: $Author: oj $ $Date: 2001-10-12 11:58:44 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -166,10 +166,8 @@ Reference< XPropertySet > OIndexes::createEmptyObject()
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// XAppend // XAppend
void SAL_CALL OIndexes::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) void OIndexes::appendObject( const Reference< XPropertySet >& descriptor )
{ {
::osl::MutexGuard aGuard(m_rMutex);
if(m_xIndexes.is()) if(m_xIndexes.is())
{ {
Reference<XAppend> xData( m_xIndexes,UNO_QUERY); Reference<XAppend> xData( m_xIndexes,UNO_QUERY);
@@ -242,33 +240,31 @@ void SAL_CALL OIndexes::appendByDescriptor( const Reference< XPropertySet >& des
Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
xStmt->execute(aSql); xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
} }
} }
OCollection_TYPE::appendByDescriptor(descriptor);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// XDrop // XDrop
void SAL_CALL OIndexes::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) void OIndexes::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
{ {
::osl::MutexGuard aGuard(m_rMutex);
if(m_xIndexes.is()) if(m_xIndexes.is())
{ {
Reference<XDrop> xData( m_xIndexes,UNO_QUERY); Reference<XDrop> xData( m_xIndexes,UNO_QUERY);
xData->dropByName(elementName); if(xData.is())
xData->dropByName(_sElementName);
} }
else else
{ {
ObjectMap::iterator aIter = m_aNameMap.find(elementName); ObjectMap::iterator aIter = m_aNameMap.find(_sElementName);
if( aIter == m_aNameMap.end())
throw NoSuchElementException(elementName,*this);
if(!m_pTable->isNew()) if(!m_pTable->isNew())
{ {
::rtl::OUString aName,aSchema; ::rtl::OUString aName,aSchema;
sal_Int32 nLen = elementName.indexOf('.'); sal_Int32 nLen = _sElementName.indexOf('.');
if(nLen != -1) if(nLen != -1)
aSchema = elementName.copy(0,nLen); aSchema = _sElementName.copy(0,nLen);
aName = elementName.copy(nLen+1); aName = _sElementName.copy(nLen+1);
::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX "); ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX ");
::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( ); ::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
@@ -292,24 +288,6 @@ void SAL_CALL OIndexes::dropByName( const ::rtl::OUString& elementName ) throw(S
xStmt->execute(aSql); xStmt->execute(aSql);
} }
} }
OCollection_TYPE::dropByName(elementName);
}
// -------------------------------------------------------------------------
void SAL_CALL OIndexes::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
{
::osl::MutexGuard aGuard(m_rMutex);
if(m_xIndexes.is())
{
Reference<XDrop> xData( m_xIndexes,UNO_QUERY);
xData->dropByIndex(index);
OCollection_TYPE::dropByIndex(index);
}
else
{
if (index < 0 || index >= getCount())
throw IndexOutOfBoundsException();
dropByName(m_aElements[index]->first);
}
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void SAL_CALL OIndexes::disposing(void) void SAL_CALL OIndexes::disposing(void)
@@ -320,5 +298,13 @@ void SAL_CALL OIndexes::disposing(void)
OCollection_TYPE::disposing(); OCollection_TYPE::disposing();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Reference< XNamed > OIndexes::cloneObject(const Reference< XPropertySet >& _xDescriptor)
{
Reference< XNamed > xName(_xDescriptor,UNO_QUERY);
OSL_ENSURE(xName.is(),"Must be a XName interface here !");
return xName.is() ? createObject(xName->getName()) : Reference< XNamed >();
}
// -----------------------------------------------------------------------------

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: CIndexes.hxx,v $ * $RCSfile: CIndexes.hxx,v $
* *
* $Revision: 1.4 $ * $Revision: 1.5 $
* *
* last change: $Author: oj $ $Date: 2001-02-14 13:18:24 $ * last change: $Author: oj $ $Date: 2001-10-12 11:58:44 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -82,6 +82,9 @@ namespace dbaccess
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName);
virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject();
virtual void appendObject( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > cloneObject(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
public: public:
OIndexes(ODBTable* _pTable, OIndexes(ODBTable* _pTable,
::osl::Mutex& _rMutex, ::osl::Mutex& _rMutex,
@@ -93,11 +96,6 @@ namespace dbaccess
{} {}
virtual void SAL_CALL disposing(void); virtual void SAL_CALL disposing(void);
// XAppend
virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
// XDrop
virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
}; };
} }

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: CRowSetDataColumn.cxx,v $ * $RCSfile: CRowSetDataColumn.cxx,v $
* *
* $Revision: 1.22 $ * $Revision: 1.23 $
* *
* last change: $Author: oj $ $Date: 2001-09-20 12:59:25 $ * last change: $Author: oj $ $Date: 2001-10-12 11:58:44 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -266,8 +266,25 @@ void ORowSetDataColumn::fireValueChange(const ORowSetValue& _rOldValue)
fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False ); fire(&nHandle, &aNew, &m_aOldValue, 1, sal_False );
} }
} }
// -----------------------------------------------------------------------------
// ------------------------------------------------------------------------- DBG_NAME(ORowSetDataColumns )
ORowSetDataColumns::ORowSetDataColumns(
sal_Bool _bCase,
const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,
::cppu::OWeakObject& _rParent,
::osl::Mutex& _rMutex,
const ::std::vector< ::rtl::OUString> &_rVector
) : connectivity::sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector)
,m_aColumns(_rColumns)
{
DBG_CTOR(ORowSetDataColumns ,NULL);
}
// -----------------------------------------------------------------------------
ORowSetDataColumns::~ORowSetDataColumns()
{
DBG_DTOR(ORowSetDataColumns ,NULL);
}
// -----------------------------------------------------------------------------
Reference< ::com::sun::star::container::XNamed > ORowSetDataColumns::createObject(const ::rtl::OUString& _rName) Reference< ::com::sun::star::container::XNamed > ORowSetDataColumns::createObject(const ::rtl::OUString& _rName)
{ {
Reference< ::com::sun::star::container::XNamed > xNamed; Reference< ::com::sun::star::container::XNamed > xNamed;
@@ -294,5 +311,9 @@ void ORowSetDataColumns::assign(const ::vos::ORef< ::connectivity::OSQLColumns>&
reFill(_rVector); reFill(_rVector);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void ORowSetDataColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
{
}
// -----------------------------------------------------------------------------

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: CRowSetDataColumn.hxx,v $ * $RCSfile: CRowSetDataColumn.hxx,v $
* *
* $Revision: 1.8 $ * $Revision: 1.9 $
* *
* last change: $Author: oj $ $Date: 2001-08-24 06:25:57 $ * last change: $Author: oj $ $Date: 2001-10-12 11:58:44 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -131,11 +131,7 @@ namespace dbaccess
::vos::ORef< ::connectivity::OSQLColumns> m_aColumns; ::vos::ORef< ::connectivity::OSQLColumns> m_aColumns;
protected: protected:
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName);
virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException) {} virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject()
{
return NULL;
}
public: public:
ORowSetDataColumns( ORowSetDataColumns(
sal_Bool _bCase, sal_Bool _bCase,
@@ -143,12 +139,8 @@ namespace dbaccess
::cppu::OWeakObject& _rParent, ::cppu::OWeakObject& _rParent,
::osl::Mutex& _rMutex, ::osl::Mutex& _rMutex,
const ::std::vector< ::rtl::OUString> &_rVector const ::std::vector< ::rtl::OUString> &_rVector
) : connectivity::sdbcx::OCollection(_rParent,_bCase,_rMutex,_rVector) );
,m_aColumns(_rColumns) virtual ~ORowSetDataColumns();
{
}
~ORowSetDataColumns()
{}
// only the name is identical to ::cppu::OComponentHelper // only the name is identical to ::cppu::OComponentHelper
virtual void SAL_CALL disposing(void); virtual void SAL_CALL disposing(void);
void assign(const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,const ::std::vector< ::rtl::OUString> &_rVector); void assign(const ::vos::ORef< ::connectivity::OSQLColumns>& _rColumns,const ::std::vector< ::rtl::OUString> &_rVector);

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: RowSetBase.cxx,v $ * $RCSfile: RowSetBase.cxx,v $
* *
* $Revision: 1.49 $ * $Revision: 1.50 $
* *
* last change: $Author: oj $ $Date: 2001-08-27 09:14:30 $ * last change: $Author: oj $ $Date: 2001-10-12 11:58:44 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -133,20 +133,21 @@ namespace dbaccess
class OEmptyCollection : public sdbcx::OCollection class OEmptyCollection : public sdbcx::OCollection
{ {
protected: protected:
virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException) virtual void impl_refresh() throw(RuntimeException);
{ virtual Reference< XNamed > createObject(const ::rtl::OUString& _rName);
}
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName)
{
return ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed >();
}
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject()
{
return ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >();
}
public: public:
OEmptyCollection(::cppu::OWeakObject& _rParent,::osl::Mutex& _rMutex) : OCollection(_rParent,sal_True,_rMutex,::std::vector< ::rtl::OUString>()){} OEmptyCollection(::cppu::OWeakObject& _rParent,::osl::Mutex& _rMutex) : OCollection(_rParent,sal_True,_rMutex,::std::vector< ::rtl::OUString>()){}
}; };
// -----------------------------------------------------------------------------
void OEmptyCollection::impl_refresh() throw(RuntimeException)
{
}
// -----------------------------------------------------------------------------
Reference< XNamed > OEmptyCollection::createObject(const ::rtl::OUString& _rName)
{
return Reference< XNamed >();
}
// -----------------------------------------------------------------------------
// ========================================================================= // =========================================================================
// = ORowSetBase // = ORowSetBase

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: column.cxx,v $ * $RCSfile: column.cxx,v $
* *
* $Revision: 1.33 $ * $Revision: 1.34 $
* *
* last change: $Author: oj $ $Date: 2001-09-20 12:56:18 $ * last change: $Author: oj $ $Date: 2001-10-12 11:58:44 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -996,10 +996,8 @@ Sequence< Type > SAL_CALL OColumns::getTypes( ) throw(RuntimeException)
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// XAppend // XAppend
void SAL_CALL OColumns::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) void OColumns::appendObject( const Reference< XPropertySet >& descriptor )
{ {
::osl::MutexGuard aGuard(m_rMutex);
Reference<XAppend> xAppend(m_xDrvColumns,UNO_QUERY); Reference<XAppend> xAppend(m_xDrvColumns,UNO_QUERY);
if(xAppend.is()) if(xAppend.is())
{ {
@@ -1080,19 +1078,15 @@ void SAL_CALL OColumns::appendByDescriptor( const Reference< XPropertySet >& des
} }
else if(m_pTable && !m_pTable->isNew() && !m_bAddColumn) else if(m_pTable && !m_pTable->isNew() && !m_bAddColumn)
throw SQLException(); throw SQLException();
OColumns_BASE::appendByDescriptor(descriptor);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// XDrop // XDrop
void SAL_CALL OColumns::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) void OColumns::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
{ {
::osl::MutexGuard aGuard(m_rMutex);
Reference<XDrop> xDrop(m_xDrvColumns,UNO_QUERY); Reference<XDrop> xDrop(m_xDrvColumns,UNO_QUERY);
if(xDrop.is()) if(xDrop.is())
{ {
xDrop->dropByName(elementName); xDrop->dropByName(_sElementName);
} }
else if(m_pTable && !m_pTable->isNew() && m_bDropColumn) else if(m_pTable && !m_pTable->isNew() && m_bDropColumn)
{ {
@@ -1112,23 +1106,25 @@ void SAL_CALL OColumns::dropByName( const ::rtl::OUString& elementName ) throw(S
aSql += aComposedName; aSql += aComposedName;
aSql += ::rtl::OUString::createFromAscii(" DROP "); aSql += ::rtl::OUString::createFromAscii(" DROP ");
aSql += ::dbtools::quoteName( aQuote,elementName); aSql += ::dbtools::quoteName( aQuote,_sElementName);
Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( ); Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
if(xStmt.is()) if(xStmt.is())
xStmt->execute(aSql); xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
} }
else if(m_pTable && !m_pTable->isNew() && !m_bDropColumn) else if(m_pTable && !m_pTable->isNew() && !m_bDropColumn)
throw SQLException(); throw SQLException();
OColumns_BASE::dropByName(elementName);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void SAL_CALL OColumns::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException) Reference< XNamed > OColumns::cloneObject(const Reference< XPropertySet >& _xDescriptor)
{ {
::osl::MutexGuard aGuard(m_rMutex); Reference<XPropertySet> xProp = createEmptyObject();
if (index < 0 || index >= getCount()) Reference< XNamed > xName(xProp,UNO_QUERY);
throw IndexOutOfBoundsException(); OSL_ENSURE(xName.is(),"Must be a XName interface here !");
if(xProp.is())
dropByName(m_aElements[index]->first); ::comphelper::copyProperties(_xDescriptor,xProp);
return xName;
} }
// -----------------------------------------------------------------------------

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: definitioncolumn.cxx,v $ * $RCSfile: definitioncolumn.cxx,v $
* *
* $Revision: 1.11 $ * $Revision: 1.12 $
* *
* last change: $Author: oj $ $Date: 2001-09-20 12:56:18 $ * last change: $Author: oj $ $Date: 2001-10-12 11:58:44 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: table.cxx,v $ * $RCSfile: table.cxx,v $
* *
* $Revision: 1.35 $ * $Revision: 1.36 $
* *
* last change: $Author: oj $ $Date: 2001-09-28 07:47:23 $ * last change: $Author: oj $ $Date: 2001-10-12 11:58:44 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -740,9 +740,7 @@ Sequence< sal_Int8 > ODBTable::getUnoTunnelImplementationId()
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Reference< XPropertySet > ODBTable::createEmptyObject() Reference< XPropertySet > ODBTable::createEmptyObject()
{ {
OTableColumnDescriptor* pRet = new OTableColumnDescriptor(); return new OTableColumnDescriptor();
Reference< XPropertySet > xRet = pRet;
return xRet;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: tablecontainer.cxx,v $ * $RCSfile: tablecontainer.cxx,v $
* *
* $Revision: 1.38 $ * $Revision: 1.39 $
* *
* last change: $Author: oj $ $Date: 2001-10-08 07:26:26 $ * last change: $Author: oj $ $Date: 2001-10-12 11:58:44 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -551,15 +551,11 @@ Reference< XPropertySet > OTableContainer::createEmptyObject()
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// XAppend // XAppend
void SAL_CALL OTableContainer::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) void OTableContainer::appendObject( const Reference< XPropertySet >& descriptor )
{ {
::osl::MutexGuard aGuard(m_rMutex);
// append the new table with a create stmt // append the new table with a create stmt
::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME));
ObjectMap::iterator aIter = m_aNameMap.find(aName); if(m_xMasterTables.is() && m_xMasterTables->hasByName(aName))
if( aIter != m_aNameMap.end())
throw ElementExistException(aName,*this);
else if(m_xMasterTables.is() && m_xMasterTables->hasByName(aName))
{ {
String sMessage(DBACORE_RESSTRING(RID_STR_TABLE_IS_FILTERED)); String sMessage(DBACORE_RESSTRING(RID_STR_TABLE_IS_FILTERED));
sMessage.SearchAndReplaceAscii("$name$", aName); sMessage.SearchAndReplaceAscii("$name$", aName);
@@ -778,7 +774,7 @@ void SAL_CALL OTableContainer::appendByDescriptor( const Reference< XPropertySet
Reference< XStatement > xStmt = m_xConnection->createStatement( ); Reference< XStatement > xStmt = m_xConnection->createStatement( );
if(xStmt.is()) if(xStmt.is())
xStmt->execute(aSql); xStmt->execute(aSql);
OCollection::appendByDescriptor(descriptor); ::comphelper::disposeComponent(xStmt);
} }
// create a new config entry // create a new config entry
if(m_aTablesConfig.isValid()) if(m_aTablesConfig.isValid())
@@ -817,18 +813,16 @@ void SAL_CALL OTableContainer::appendByDescriptor( const Reference< XPropertySet
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// XDrop // XDrop
void SAL_CALL OTableContainer::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) void OTableContainer::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
{ {
::osl::MutexGuard aGuard(m_rMutex);
ObjectMap::iterator aIter = m_aNameMap.find(elementName);
if( aIter == m_aNameMap.end())
throw NoSuchElementException(elementName,*this);
Reference< XDrop > xDrop(m_xMasterTables,UNO_QUERY); Reference< XDrop > xDrop(m_xMasterTables,UNO_QUERY);
if(xDrop.is()) if(xDrop.is())
xDrop->dropByName(elementName); xDrop->dropByName(_sElementName);
else else
{ {
ObjectIter aIter = m_aElements[_nPos];
if(!aIter->second.is()) // we want to drop a object which isn't loaded yet so we must load it
aIter->second = createObject(_sElementName);
::rtl::OUString sCatalog,sSchema,sTable,sComposedName; ::rtl::OUString sCatalog,sSchema,sTable,sComposedName;
Reference<XPropertySet> xTable(aIter->second.get(),UNO_QUERY); Reference<XPropertySet> xTable(aIter->second.get(),UNO_QUERY);
@@ -851,20 +845,10 @@ void SAL_CALL OTableContainer::dropByName( const ::rtl::OUString& elementName )
Reference< XStatement > xStmt = m_xConnection->createStatement( ); Reference< XStatement > xStmt = m_xConnection->createStatement( );
if(xStmt.is()) if(xStmt.is())
xStmt->execute(aSql); xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
OCollection::dropByName(elementName);
} }
// we don't need to call dropByName when we have xMasterTables // we don't need to call dropByName when we have xMasterTables
}
// -----------------------------------------------------------------------------
void SAL_CALL OTableContainer::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
{
::osl::MutexGuard aGuard(m_rMutex);
if (index < 0 || index >= getCount())
throw IndexOutOfBoundsException();
dropByName((*m_aElements[index]).first);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
void SAL_CALL OTableContainer::acquire() throw(RuntimeException) void SAL_CALL OTableContainer::acquire() throw(RuntimeException)
@@ -884,10 +868,7 @@ void SAL_CALL OTableContainer::elementInserted( const ContainerEvent& Event ) th
if((Event.Accessor >>= sName) && !hasByName(sName)) if((Event.Accessor >>= sName) && !hasByName(sName))
{ {
if(!m_xMasterTables.is() || m_xMasterTables->hasByName(sName)) if(!m_xMasterTables.is() || m_xMasterTables->hasByName(sName))
{ insertElement(sName,createObject(sName));
Reference<XPropertySet> xProp(createObject(sName),UNO_QUERY);
OCollection::appendByDescriptor(xProp);
}
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@@ -898,9 +879,7 @@ void SAL_CALL OTableContainer::elementRemoved( const ContainerEvent& Event ) thr
if((Event.Accessor >>= sName) && hasByName(sName)) if((Event.Accessor >>= sName) && hasByName(sName))
{ {
if(!m_xMasterTables.is() || !m_xMasterTables->hasByName(sName)) if(!m_xMasterTables.is() || !m_xMasterTables->hasByName(sName))
{ ;
OCollection::dropByName(sName);
}
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@@ -986,4 +965,11 @@ void OTableContainer::setNewConfigNode(const ::utl::OConfigurationTreeRoot& _aCo
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Reference< XNamed > OTableContainer::cloneObject(const Reference< XPropertySet >& _xDescriptor)
{
Reference< XNamed > xName(_xDescriptor,UNO_QUERY);
OSL_ENSURE(xName.is(),"Must be a XName interface here !");
return xName.is() ? createObject(xName->getName()) : Reference< XNamed >();
}
// -----------------------------------------------------------------------------

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: viewcontainer.cxx,v $ * $RCSfile: viewcontainer.cxx,v $
* *
* $Revision: 1.9 $ * $Revision: 1.10 $
* *
* last change: $Author: oj $ $Date: 2001-10-08 07:26:26 $ * last change: $Author: oj $ $Date: 2001-10-12 11:58:44 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -349,14 +349,10 @@ Reference< XPropertySet > OViewContainer::createEmptyObject()
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// XAppend // XAppend
void SAL_CALL OViewContainer::appendByDescriptor( const Reference< XPropertySet >& descriptor ) throw(SQLException, ElementExistException, RuntimeException) void OViewContainer::appendObject( const Reference< XPropertySet >& descriptor )
{ {
::osl::MutexGuard aGuard(m_rMutex);
// append the new table with a create stmt // append the new table with a create stmt
::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME)); ::rtl::OUString aName = getString(descriptor->getPropertyValue(PROPERTY_NAME));
ObjectMap::iterator aIter = m_aNameMap.find(aName);
if( aIter != m_aNameMap.end() || (m_xMasterViews.is() && m_xMasterViews->hasByName(aName)))
throw ElementExistException(aName,*this);
Reference<XAppend> xAppend(m_xMasterViews,UNO_QUERY); Reference<XAppend> xAppend(m_xMasterViews,UNO_QUERY);
Reference< XPropertySet > xProp = descriptor; Reference< XPropertySet > xProp = descriptor;
@@ -392,24 +388,21 @@ void SAL_CALL OViewContainer::appendByDescriptor( const Reference< XPropertySet
Reference< XStatement > xStmt = m_xConnection->createStatement( ); Reference< XStatement > xStmt = m_xConnection->createStatement( );
if(xStmt.is()) if(xStmt.is())
xStmt->execute(aSql); xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
} }
OCollection::appendByDescriptor(xProp);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// XDrop // XDrop
void SAL_CALL OViewContainer::dropByName( const ::rtl::OUString& elementName ) throw(SQLException, NoSuchElementException, RuntimeException) void OViewContainer::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
{ {
::osl::MutexGuard aGuard(m_rMutex);
ObjectMap::iterator aIter = m_aNameMap.find(elementName);
if( aIter == m_aNameMap.end())
throw NoSuchElementException(elementName,*this);
Reference< XDrop > xDrop(m_xMasterViews,UNO_QUERY); Reference< XDrop > xDrop(m_xMasterViews,UNO_QUERY);
if(xDrop.is()) if(xDrop.is())
xDrop->dropByName(elementName); xDrop->dropByName(_sElementName);
else else
{ {
ObjectIter aIter = m_aElements[_nPos];
if(!aIter->second.is()) // we want to drop a object which isn't loaded yet so we must load it
aIter->second = createObject(_sElementName);
::rtl::OUString sCatalog,sSchema,sTable,sComposedName; ::rtl::OUString sCatalog,sSchema,sTable,sComposedName;
Reference<XPropertySet> xTable(aIter->second.get(),UNO_QUERY); Reference<XPropertySet> xTable(aIter->second.get(),UNO_QUERY);
@@ -432,17 +425,8 @@ void SAL_CALL OViewContainer::dropByName( const ::rtl::OUString& elementName ) t
Reference< XStatement > xStmt = m_xConnection->createStatement( ); Reference< XStatement > xStmt = m_xConnection->createStatement( );
if(xStmt.is()) if(xStmt.is())
xStmt->execute(aSql); xStmt->execute(aSql);
::comphelper::disposeComponent(xStmt);
} }
OCollection::dropByName(elementName);
}
// -----------------------------------------------------------------------------
void SAL_CALL OViewContainer::dropByIndex( sal_Int32 index ) throw(SQLException, IndexOutOfBoundsException, RuntimeException)
{
::osl::MutexGuard aGuard(m_rMutex);
if (index < 0 || index >= getCount())
throw IndexOutOfBoundsException();
dropByName((*m_aElements[index]).first);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SAL_CALL OViewContainer::elementInserted( const ContainerEvent& Event ) throw (RuntimeException) void SAL_CALL OViewContainer::elementInserted( const ContainerEvent& Event ) throw (RuntimeException)
@@ -450,18 +434,11 @@ void SAL_CALL OViewContainer::elementInserted( const ContainerEvent& Event ) thr
::osl::MutexGuard aGuard(m_rMutex); ::osl::MutexGuard aGuard(m_rMutex);
::rtl::OUString sName; ::rtl::OUString sName;
if((Event.Accessor >>= sName) && !hasByName(sName) && m_xMasterViews.is() && m_xMasterViews->hasByName(sName)) if((Event.Accessor >>= sName) && !hasByName(sName) && m_xMasterViews.is() && m_xMasterViews->hasByName(sName))
{ insertElement(sName,createObject(sName));
Reference<XPropertySet> xProp(createObject(sName),UNO_QUERY);
OCollection::appendByDescriptor(xProp);
}
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SAL_CALL OViewContainer::elementRemoved( const ContainerEvent& Event ) throw (RuntimeException) void SAL_CALL OViewContainer::elementRemoved( const ContainerEvent& Event ) throw (RuntimeException)
{ {
::osl::MutexGuard aGuard(m_rMutex);
::rtl::OUString sName;
if((Event.Accessor >>= sName) && hasByName(sName) && m_xMasterViews.is() && !m_xMasterViews->hasByName(sName))
OCollection::dropByName(sName);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void SAL_CALL OViewContainer::disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException) void SAL_CALL OViewContainer::disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
@@ -472,5 +449,12 @@ void SAL_CALL OViewContainer::elementReplaced( const ContainerEvent& Event ) thr
{ {
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
Reference< XNamed > OViewContainer::cloneObject(const Reference< XPropertySet >& _xDescriptor)
{
Reference< XNamed > xName(_xDescriptor,UNO_QUERY);
OSL_ENSURE(xName.is(),"Must be a XName interface here !");
return xName.is() ? createObject(xName->getName()) : Reference< XNamed >();
}
// -----------------------------------------------------------------------------

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: column.hxx,v $ * $RCSfile: column.hxx,v $
* *
* $Revision: 1.16 $ * $Revision: 1.17 $
* *
* last change: $Author: oj $ $Date: 2001-09-20 12:56:18 $ * last change: $Author: oj $ $Date: 2001-10-12 12:01:30 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -334,6 +334,9 @@ namespace dbaccess
virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject();
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > cloneObject(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
virtual void appendObject( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
public: public:
/** flag which determines whether the container is filled or not /** flag which determines whether the container is filled or not
@@ -414,12 +417,6 @@ namespace dbaccess
const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& _rxNumberFormats const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier >& _rxNumberFormats
); );
// XAppend
virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
// XDrop
virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
void append(const ::rtl::OUString& rName, OColumn*); void append(const ::rtl::OUString& rName, OColumn*);
void clearColumns(); void clearColumns();
// only the name is identical to ::cppu::OComponentHelper // only the name is identical to ::cppu::OComponentHelper

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: tablecontainer.hxx,v $ * $RCSfile: tablecontainer.hxx,v $
* *
* $Revision: 1.16 $ * $Revision: 1.17 $
* *
* last change: $Author: oj $ $Date: 2001-10-08 07:26:28 $ * last change: $Author: oj $ $Date: 2001-10-12 12:01:30 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -150,6 +150,10 @@ namespace dbaccess
virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject();
virtual void appendObject( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > cloneObject(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
public: public:
/** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type> /** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type>
interface.<BR> interface.<BR>
@@ -167,7 +171,7 @@ namespace dbaccess
sal_Bool _bCase, sal_Bool _bCase,
IWarningsContainer* _pWarningsContainer = NULL IWarningsContainer* _pWarningsContainer = NULL
); );
~OTableContainer(); virtual ~OTableContainer();
/** late ctor. The container will fill itself with the data got by the connection meta data, considering the /** late ctor. The container will fill itself with the data got by the connection meta data, considering the
filters given (the connection is the parent object you passed in the ctor). filters given (the connection is the parent object you passed in the ctor).
@@ -204,11 +208,6 @@ namespace dbaccess
virtual void SAL_CALL addFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw(::com::sun::star::uno::RuntimeException){} virtual void SAL_CALL addFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw(::com::sun::star::uno::RuntimeException){}
virtual void SAL_CALL removeFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw(::com::sun::star::uno::RuntimeException){} virtual void SAL_CALL removeFlushListener( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XFlushListener >& l ) throw(::com::sun::star::uno::RuntimeException){}
// XAppend
virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
// XDrop
virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
// XEventListener // XEventListener
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
// XContainerListener // XContainerListener

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: viewcontainer.hxx,v $ * $RCSfile: viewcontainer.hxx,v $
* *
* $Revision: 1.5 $ * $Revision: 1.6 $
* *
* last change: $Author: oj $ $Date: 2001-10-08 07:26:28 $ * last change: $Author: oj $ $Date: 2001-10-12 12:01:30 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -149,6 +149,9 @@ namespace dbaccess
virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException); virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName); virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > createObject(const ::rtl::OUString& _rName);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject(); virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > createEmptyObject();
virtual void appendObject( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor );
virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed > cloneObject(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xDescriptor);
virtual void dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName);
public: public:
/** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type> /** ctor of the container. The parent has to support the <type scope="com::sun::star::sdbc">XConnection</type>
interface.<BR> interface.<BR>
@@ -189,11 +192,6 @@ namespace dbaccess
// ::com::sun::star::lang::XServiceInfo // ::com::sun::star::lang::XServiceInfo
DECLARE_SERVICE_INFO(); DECLARE_SERVICE_INFO();
// XAppend
virtual void SAL_CALL appendByDescriptor( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException);
// XDrop
virtual void SAL_CALL dropByName( const ::rtl::OUString& elementName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL dropByIndex( sal_Int32 index ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, ::com::sun::star::uno::RuntimeException);
// XEventListener // XEventListener
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
// XContainerListener // XContainerListener

View File

@@ -2,9 +2,9 @@
* *
* $RCSfile: querycontroller.cxx,v $ * $RCSfile: querycontroller.cxx,v $
* *
* $Revision: 1.61 $ * $Revision: 1.62 $
* *
* last change: $Author: oj $ $Date: 2001-10-08 07:32:34 $ * last change: $Author: oj $ $Date: 2001-10-12 12:02:56 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
@@ -1175,7 +1175,10 @@ void OQueryController::doSaveAsDoc(sal_Bool _bSaveAs)
{ {
Reference<XAppend> xAppend(xElements,UNO_QUERY); Reference<XAppend> xAppend(xElements,UNO_QUERY);
if(xAppend.is()) if(xAppend.is())
{
xAppend->appendByDescriptor(xProp); xAppend->appendByDescriptor(xProp);
xElements->getByName(m_sName) >>= xProp;
}
else else
{ {
Reference<XNameContainer> xCont(xElements,UNO_QUERY); Reference<XNameContainer> xCont(xElements,UNO_QUERY);