diff options
22 files changed, 199 insertions, 126 deletions
diff --git a/connectivity/inc/connectivity/sdbcx/VCollection.hxx b/connectivity/inc/connectivity/sdbcx/VCollection.hxx index beaa698c2b1a..f44ad9a83c63 100644 --- a/connectivity/inc/connectivity/sdbcx/VCollection.hxx +++ b/connectivity/inc/connectivity/sdbcx/VCollection.hxx @@ -2,9 +2,9 @@ * * $RCSfile: VCollection.hxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: oj $ $Date: 2001-08-13 13:58:57 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:48 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -197,6 +197,7 @@ namespace connectivity void reFill(const TStringVector &_rVector); sal_Bool isCaseSensitive() const { return m_aNameMap.key_comp().isCaseSensitive(); } + void renameObject(const ::rtl::OUString _sOldName,const ::rtl::OUString _sNewName); // only the name is identical to ::cppu::OComponentHelper virtual void SAL_CALL disposing(void); diff --git a/connectivity/inc/connectivity/sdbcx/VTable.hxx b/connectivity/inc/connectivity/sdbcx/VTable.hxx index ce3e00f4258c..d0a556c5838b 100644 --- a/connectivity/inc/connectivity/sdbcx/VTable.hxx +++ b/connectivity/inc/connectivity/sdbcx/VTable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: VTable.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-04-30 10:13:37 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -142,6 +142,7 @@ namespace connectivity OCollection* m_pKeys; OCollection* m_pColumns; OCollection* m_pIndexes; + OCollection* m_pTables; // must hold his own container to notify him when renaming using OTableDescriptor_BASE::rBHelper; @@ -150,8 +151,10 @@ namespace connectivity // OPropertySetHelper virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); public: - OTable(sal_Bool _bCase); - OTable( sal_Bool _bCase, + OTable( OCollection* _pTables, + sal_Bool _bCase); + OTable( OCollection* _pTables, + sal_Bool _bCase, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description = ::rtl::OUString(), diff --git a/connectivity/source/drivers/adabas/BTable.cxx b/connectivity/source/drivers/adabas/BTable.cxx index 171178597303..957fe07271ff 100644 --- a/connectivity/source/drivers/adabas/BTable.cxx +++ b/connectivity/source/drivers/adabas/BTable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BTable.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: oj $ $Date: 2001-09-17 11:15:40 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -114,6 +114,7 @@ using namespace ::comphelper; using namespace connectivity::adabas; +using namespace connectivity; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::sdbcx; @@ -121,18 +122,24 @@ using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::container; using namespace ::com::sun::star::lang; -OAdabasTable::OAdabasTable( OAdabasConnection* _pConnection) : OTable_TYPEDEF(sal_True),m_pConnection(_pConnection) +OAdabasTable::OAdabasTable( sdbcx::OCollection* _pTables, + OAdabasConnection* _pConnection) + :OTable_TYPEDEF(_pTables,sal_True) + ,m_pConnection(_pConnection) { construct(); } // ------------------------------------------------------------------------- -OAdabasTable::OAdabasTable( OAdabasConnection* _pConnection, +OAdabasTable::OAdabasTable( sdbcx::OCollection* _pTables, + OAdabasConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description , const ::rtl::OUString& _SchemaName, const ::rtl::OUString& _CatalogName - ) : OTable_TYPEDEF(sal_True,_Name, + ) : OTable_TYPEDEF(_pTables, + sal_True, + _Name, _Type, _Description, _SchemaName, @@ -274,29 +281,32 @@ sal_Int64 OAdabasTable::getSomething( const Sequence< sal_Int8 > & rId ) throw ( void SAL_CALL OAdabasTable::rename( const ::rtl::OUString& newName ) throw(SQLException, ElementExistException, RuntimeException) { ::osl::MutexGuard aGuard(m_aMutex); - if ( + checkDisposed( #ifdef GCC ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed #else rBHelper.bDisposed #endif - ) - throw DisposedException(); + ); + Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData(); + OSL_ENSURE(xMeta.is(),"No Metadata!"); if(!isNew()) { - ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("RENAME TABLE "); - ::rtl::OUString sQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( ); + ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("RENAME TABLE "); + ::rtl::OUString sQuote = xMeta->getIdentifierQuoteString( ); const ::rtl::OUString& sDot = OAdabasCatalog::getDot(); - ::rtl::OUString aName,aSchema; - sal_Int32 nLen = newName.indexOf('.'); - aSchema = newName.copy(0,nLen); - aName = newName.copy(nLen+1); + ::rtl::OUString sNewName; + sal_Int32 nPos = 0; + if(nPos = newName.indexOf(sDot) != -1) + sNewName = newName.copy(nPos+1); + else + sNewName = newName; sSql += ::dbtools::quoteName(sQuote,m_SchemaName) + sDot + ::dbtools::quoteName(sQuote,m_Name) + ::rtl::OUString::createFromAscii(" TO ") - + ::dbtools::quoteName(sQuote,aSchema) + sDot + ::dbtools::quoteName(sQuote,aName); + + ::dbtools::quoteName(sQuote,sNewName); Reference< XStatement > xStmt = m_pConnection->createStatement( ); if(xStmt.is()) @@ -304,23 +314,23 @@ void SAL_CALL OAdabasTable::rename( const ::rtl::OUString& newName ) throw(SQLEx xStmt->execute(sSql); ::comphelper::disposeComponent(xStmt); } + OTable_TYPEDEF::rename(newName); } else - m_Name = newName; + ::dbtools::qualifiedNameComponents(xMeta,newName,m_CatalogName,m_SchemaName,m_Name); } // ------------------------------------------------------------------------- // XAlterTable void SAL_CALL OAdabasTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException) { ::osl::MutexGuard aGuard(m_aMutex); - if ( + checkDisposed( #ifdef GCC ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed #else rBHelper.bDisposed #endif - ) - throw DisposedException(); + ); if(m_pColumns && !m_pColumns->hasByName(colName)) throw NoSuchElementException(colName,*this); @@ -418,14 +428,13 @@ void SAL_CALL OAdabasTable::alterColumnByName( const ::rtl::OUString& colName, c void SAL_CALL OAdabasTable::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException) { ::osl::MutexGuard aGuard(m_aMutex); - if ( + checkDisposed( #ifdef GCC ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed #else rBHelper.bDisposed #endif - ) - throw DisposedException(); + ); Reference< XPropertySet > xOld; if(::cppu::extractInterface(xOld,m_pColumns->getByIndex(index)) && xOld.is()) diff --git a/connectivity/source/drivers/adabas/BTables.cxx b/connectivity/source/drivers/adabas/BTables.cxx index 83154f9e0477..b0ccc6839da1 100644 --- a/connectivity/source/drivers/adabas/BTables.cxx +++ b/connectivity/source/drivers/adabas/BTables.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BTables.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: oj $ $Date: 2001-08-13 13:58:56 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -138,7 +138,7 @@ Reference< XNamed > OTables::createObject(const ::rtl::OUString& _rName) Reference< XRow > xRow(xResult,UNO_QUERY); if(xResult->next()) // there can be only one table with this name { - OAdabasTable* pRet = new OAdabasTable( static_cast<OAdabasCatalog&>(m_rParent).getConnection(), + OAdabasTable* pRet = new OAdabasTable(this, static_cast<OAdabasCatalog&>(m_rParent).getConnection(), aName,xRow->getString(4),xRow->getString(5),aSchema); xRet = pRet; } @@ -160,7 +160,7 @@ void OTables::disposing(void) // ------------------------------------------------------------------------- Reference< XPropertySet > OTables::createEmptyObject() { - OAdabasTable* pNew = new OAdabasTable(static_cast<OAdabasCatalog&>(m_rParent).getConnection()); + OAdabasTable* pNew = new OAdabasTable(this,static_cast<OAdabasCatalog&>(m_rParent).getConnection()); return pNew; } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx index 6971a3991dd3..9ded893c86d6 100644 --- a/connectivity/source/drivers/ado/ATable.cxx +++ b/connectivity/source/drivers/ado/ATable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ATable.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,6 +74,9 @@ #ifndef _CONNECTIVITY_ADO_KEYS_HXX_ #include "ado/AKeys.hxx" #endif +#ifndef _CONNECTIVITY_ADO_ACONNECTION_HXX_ +#include "ado/AConnection.hxx" +#endif #ifndef _COM_SUN_STAR_SDBC_XROW_HPP_ #include <com/sun/star/sdbc/XRow.hpp> #endif @@ -120,8 +123,8 @@ using namespace com::sun::star::container; using namespace com::sun::star::lang; // ------------------------------------------------------------------------- -OAdoTable::OAdoTable(sal_Bool _bCase,OCatalog* _pCatalog,_ADOTable* _pTable) - : OTable_TYPEDEF(_bCase,::rtl::OUString(),::rtl::OUString()) +OAdoTable::OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog,_ADOTable* _pTable) + : OTable_TYPEDEF(_pTables,_bCase,::rtl::OUString(),::rtl::OUString()) ,m_pCatalog(_pCatalog) { construct(); @@ -130,8 +133,8 @@ OAdoTable::OAdoTable(sal_Bool _bCase,OCatalog* _pCatalog,_ADOTable* _pTable) } // ----------------------------------------------------------------------------- -OAdoTable::OAdoTable(sal_Bool _bCase,OCatalog* _pCatalog) - : OTable_TYPEDEF(_bCase) +OAdoTable::OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog) + : OTable_TYPEDEF(_pTables,_bCase) ,m_pCatalog(_pCatalog) { construct(); @@ -257,8 +260,10 @@ void SAL_CALL OAdoTable::rename( const ::rtl::OUString& newName ) throw(SQLExcep ::osl::MutexGuard aGuard(m_aMutex); checkDisposed(rBHelper.bDisposed); - m_aTable.put_Name(newName); + ADOS::ThrowException(*(m_pCatalog->getConnection()->getConnection()),*this); + + OTable_TYPEDEF::rename(newName); } // ------------------------------------------------------------------------- // XAlterTable diff --git a/connectivity/source/drivers/ado/ATables.cxx b/connectivity/source/drivers/ado/ATables.cxx index 8cf847b7668e..0fa9c5ef3793 100644 --- a/connectivity/source/drivers/ado/ATables.cxx +++ b/connectivity/source/drivers/ado/ATables.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ATables.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:40:04 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -109,7 +109,7 @@ Reference< XNamed > OTables::createObject(const ::rtl::OUString& _rName) ADOTable* pTable = NULL; m_pCollection->get_Item(OLEVariant(_rName),&pTable); - Reference< XNamed > xRet = new OAdoTable(isCaseSensitive(),m_pCatalog,pTable); + Reference< XNamed > xRet = new OAdoTable(this,isCaseSensitive(),m_pCatalog,pTable); return xRet; } @@ -121,7 +121,7 @@ void OTables::impl_refresh( ) throw(RuntimeException) // ------------------------------------------------------------------------- Reference< XPropertySet > OTables::createEmptyObject() { - OAdoTable* pNew = new OAdoTable(isCaseSensitive(),m_pCatalog); + OAdoTable* pNew = new OAdoTable(this,isCaseSensitive(),m_pCatalog); return pNew; } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx index 609b85afda38..12e050866c98 100644 --- a/connectivity/source/drivers/calc/CTable.cxx +++ b/connectivity/source/drivers/calc/CTable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CTable.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:18:05 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -550,8 +550,8 @@ void OCalcTable::fillColumns() } // ------------------------------------------------------------------------- -OCalcTable::OCalcTable(OCalcConnection* _pConnection) - :OCalcTable_BASE(_pConnection) +OCalcTable::OCalcTable(sdbcx::OCollection* _pTables,OCalcConnection* _pConnection) + :OCalcTable_BASE(_pTables,_pConnection) ,m_nStartCol(0) ,m_nStartRow(0) ,m_nDataCols(0) @@ -560,13 +560,13 @@ OCalcTable::OCalcTable(OCalcConnection* _pConnection) { } // ------------------------------------------------------------------------- -OCalcTable::OCalcTable(OCalcConnection* _pConnection, +OCalcTable::OCalcTable(sdbcx::OCollection* _pTables,OCalcConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description , const ::rtl::OUString& _SchemaName, const ::rtl::OUString& _CatalogName - ) : OCalcTable_BASE(_pConnection,_Name, + ) : OCalcTable_BASE(_pTables,_pConnection,_Name, _Type, _Description, _SchemaName, diff --git a/connectivity/source/drivers/calc/CTables.cxx b/connectivity/source/drivers/calc/CTables.cxx index fad18cc2b5cc..1ffa5cb0058a 100644 --- a/connectivity/source/drivers/calc/CTables.cxx +++ b/connectivity/source/drivers/calc/CTables.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CTables.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-08-13 13:58:56 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -111,7 +111,7 @@ namespace starutil = ::com::sun::star::util; Reference< XNamed > OCalcTables::createObject(const ::rtl::OUString& _rName) { ::rtl::OUString aName,aSchema; - OCalcTable* pRet = new OCalcTable((OCalcConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(), + OCalcTable* pRet = new OCalcTable(this,(OCalcConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(), _rName,::rtl::OUString::createFromAscii("TABLE")); Reference< XNamed > xRet = pRet; @@ -131,7 +131,7 @@ void OCalcTables::impl_refresh( ) throw(RuntimeException) // ------------------------------------------------------------------------- Reference< XPropertySet > OCalcTables::createEmptyObject() { - OCalcTable* pRet = new OCalcTable((OCalcConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection()); + OCalcTable* pRet = new OCalcTable(this,(OCalcConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection()); Reference< XPropertySet > xRet = pRet; return xRet; } diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 4352739afe43..e2067931483f 100644 --- a/connectivity/source/drivers/dbase/DTable.cxx +++ b/connectivity/source/drivers/dbase/DTable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DTable.cxx,v $ * - * $Revision: 1.63 $ + * $Revision: 1.64 $ * - * last change: $Author: oj $ $Date: 2001-09-19 11:03:04 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -326,8 +326,8 @@ void ODbaseTable::fillColumns() } } // ------------------------------------------------------------------------- -ODbaseTable::ODbaseTable(ODbaseConnection* _pConnection) - :ODbaseTable_BASE(_pConnection) +ODbaseTable::ODbaseTable(sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection) + :ODbaseTable_BASE(_pTables,_pConnection) ,m_pMemoStream(NULL) ,m_bWriteableMemo(sal_False) { @@ -338,13 +338,13 @@ ODbaseTable::ODbaseTable(ODbaseConnection* _pConnection) m_aHeader.db_slng = 0; } // ------------------------------------------------------------------------- -ODbaseTable::ODbaseTable(ODbaseConnection* _pConnection, +ODbaseTable::ODbaseTable(sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description , const ::rtl::OUString& _SchemaName, const ::rtl::OUString& _CatalogName - ) : ODbaseTable_BASE(_pConnection,_Name, + ) : ODbaseTable_BASE(_pTables,_pConnection,_Name, _Type, _Description, _SchemaName, @@ -1664,7 +1664,7 @@ void ODbaseTable::alterColumn(sal_Int32 index, String sTempName = createTempFile(); - pNewTable = new ODbaseTable(static_cast<ODbaseConnection*>(m_pConnection)); + pNewTable = new ODbaseTable(m_pTables,static_cast<ODbaseConnection*>(m_pConnection)); Reference<XPropertySet> xHoldTable = pNewTable; pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(::rtl::OUString(sTempName))); Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY); @@ -1751,6 +1751,8 @@ void SAL_CALL ODbaseTable::rename( const ::rtl::OUString& newName ) throw(::com: { ::osl::MutexGuard aGuard(m_aMutex); checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed); + if(m_pTables && m_pTables->hasByName(newName)) + throw ElementExistException(newName,*this); FileClose(); @@ -1776,23 +1778,36 @@ void SAL_CALL ODbaseTable::rename( const ::rtl::OUString& newName ) throw(::com: String sOldName = aURL.GetMainURL(INetURLObject::NO_DECODE); // ::utl::UCBContentHelper::MoveTo(sOldName,sNewName); Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>()); - aContent.setPropertyValue( rtl::OUString::createFromAscii( "Title" ),makeAny( ::rtl::OUString(sNewName) ) ); + Sequence< PropertyValue > aProps( 1 ); + aProps[0].Name = ::rtl::OUString::createFromAscii("Title"); + aProps[0].Handle = -1; // n/a + aProps[0].Value = makeAny( ::rtl::OUString(sNewName) ); + Sequence< Any > aValues; + aContent.executeCommand( rtl::OUString::createFromAscii( "setPropertyValues" ),makeAny(aProps) ) >>= aValues; + if(aValues.getLength() && aValues[0].hasValue()) + throw Exception(); + + // aContent.setPropertyValue( rtl::OUString::createFromAscii( "Title" ),makeAny( ::rtl::OUString(sNewName) ) ); } catch(Exception&) { - throw ElementExistException(); + throw ElementExistException(newName,*this); } - m_Name = newName; + + ODbaseTable_BASE::rename(newName); + construct(); if(m_pColumns) m_pColumns->refresh(); + + } // ----------------------------------------------------------------------------- void ODbaseTable::addColumn(const Reference< XPropertySet >& _xNewColumn) { String sTempName = createTempFile(); - ODbaseTable* pNewTable = new ODbaseTable(static_cast<ODbaseConnection*>(m_pConnection)); + ODbaseTable* pNewTable = new ODbaseTable(m_pTables,static_cast<ODbaseConnection*>(m_pConnection)); pNewTable->acquire(); pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(::rtl::OUString(sTempName))); { @@ -1862,7 +1877,7 @@ void ODbaseTable::dropColumn(sal_Int32 _nPos) { String sTempName = createTempFile(); - ODbaseTable* pNewTable = new ODbaseTable(static_cast<ODbaseConnection*>(m_pConnection)); + ODbaseTable* pNewTable = new ODbaseTable(m_pTables,static_cast<ODbaseConnection*>(m_pConnection)); pNewTable->acquire(); pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(::rtl::OUString(sTempName))); { diff --git a/connectivity/source/drivers/dbase/DTables.cxx b/connectivity/source/drivers/dbase/DTables.cxx index d892f4e7f565..556676ed6fbe 100644 --- a/connectivity/source/drivers/dbase/DTables.cxx +++ b/connectivity/source/drivers/dbase/DTables.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DTables.cxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: oj $ $Date: 2001-09-18 13:14:31 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:49 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,7 +110,7 @@ namespace starutil = ::com::sun::star::util; Reference< XNamed > ODbaseTables::createObject(const ::rtl::OUString& _rName) { ::rtl::OUString aName,aSchema; - ODbaseTable* pRet = new ODbaseTable((ODbaseConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(), + ODbaseTable* pRet = new ODbaseTable(this,(ODbaseConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(), _rName,::rtl::OUString::createFromAscii("TABLE")); Reference< XNamed > xRet = pRet; @@ -125,7 +125,7 @@ void ODbaseTables::impl_refresh( ) throw(RuntimeException) // ------------------------------------------------------------------------- Reference< XPropertySet > ODbaseTables::createEmptyObject() { - ODbaseTable* pRet = new ODbaseTable((ODbaseConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection()); + ODbaseTable* pRet = new ODbaseTable(this,(ODbaseConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection()); Reference< XPropertySet > xRet = pRet; return xRet; } diff --git a/connectivity/source/drivers/file/FTable.cxx b/connectivity/source/drivers/file/FTable.cxx index a5f3822a8647..637dd4a2233b 100644 --- a/connectivity/source/drivers/file/FTable.cxx +++ b/connectivity/source/drivers/file/FTable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FTable.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: oj $ $Date: 2001-09-19 11:03:04 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -94,7 +94,8 @@ using namespace ::com::sun::star::sdbcx; using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::container; -OFileTable::OFileTable(OConnection* _pConnection) : OTable_TYPEDEF(_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()) +OFileTable::OFileTable(sdbcx::OCollection* _pTables,OConnection* _pConnection) +: OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()) ,m_pConnection(_pConnection) ,m_nFilePos(0) ,m_nBufferSize(0) @@ -108,13 +109,13 @@ OFileTable::OFileTable(OConnection* _pConnection) : OTable_TYPEDEF(_pConnection- m_aColumns = new OSQLColumns(); } // ------------------------------------------------------------------------- -OFileTable::OFileTable( OConnection* _pConnection, +OFileTable::OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description , const ::rtl::OUString& _SchemaName, const ::rtl::OUString& _CatalogName - ) : OTable_TYPEDEF(_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers(), + ) : OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers(), _Name, _Type, _Description, diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx index 4641003ddebe..508d65a641a3 100644 --- a/connectivity/source/drivers/flat/ETable.cxx +++ b/connectivity/source/drivers/flat/ETable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ETable.cxx,v $ * - * $Revision: 1.34 $ + * $Revision: 1.35 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:01:55 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -377,18 +377,18 @@ void OFlatTable::fillColumns() m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN); } // ------------------------------------------------------------------------- -OFlatTable::OFlatTable(OFlatConnection* _pConnection) : OFlatTable_BASE(_pConnection) +OFlatTable::OFlatTable(sdbcx::OCollection* _pTables,OFlatConnection* _pConnection) : OFlatTable_BASE(_pTables,_pConnection) { } // ------------------------------------------------------------------------- -OFlatTable::OFlatTable(OFlatConnection* _pConnection, +OFlatTable::OFlatTable(sdbcx::OCollection* _pTables,OFlatConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description , const ::rtl::OUString& _SchemaName, const ::rtl::OUString& _CatalogName - ) : OFlatTable_BASE(_pConnection,_Name, + ) : OFlatTable_BASE(_pTables,_pConnection,_Name, _Type, _Description, _SchemaName, diff --git a/connectivity/source/drivers/flat/ETables.cxx b/connectivity/source/drivers/flat/ETables.cxx index 79e63296bbb4..f536ca6ededf 100644 --- a/connectivity/source/drivers/flat/ETables.cxx +++ b/connectivity/source/drivers/flat/ETables.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ETables.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:01:55 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -104,7 +104,7 @@ namespace starutil = ::com::sun::star::util; Reference< XNamed > OFlatTables::createObject(const ::rtl::OUString& _rName) { ::rtl::OUString aName,aSchema; - OFlatTable* pRet = new OFlatTable((OFlatConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(), + OFlatTable* pRet = new OFlatTable(this,(OFlatConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(), _rName,::rtl::OUString::createFromAscii("TABLE")); Reference< XNamed > xRet = pRet; diff --git a/connectivity/source/inc/adabas/BTable.hxx b/connectivity/source/inc/adabas/BTable.hxx index 3de796591f9f..94bf75859e74 100644 --- a/connectivity/source/inc/adabas/BTable.hxx +++ b/connectivity/source/inc/adabas/BTable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: BTable.hxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-07-06 08:12:36 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -96,8 +96,10 @@ namespace connectivity virtual void refreshIndexes(); public: - OAdabasTable( OAdabasConnection* _pConnection); - OAdabasTable( OAdabasConnection* _pConnection, + OAdabasTable( sdbcx::OCollection* _pTables, + OAdabasConnection* _pConnection); + OAdabasTable( sdbcx::OCollection* _pTables, + OAdabasConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description = ::rtl::OUString(), diff --git a/connectivity/source/inc/ado/ATable.hxx b/connectivity/source/inc/ado/ATable.hxx index 667e9646c327..2458f9f6de6b 100644 --- a/connectivity/source/inc/ado/ATable.hxx +++ b/connectivity/source/inc/ado/ATable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ATable.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-04-30 10:09:04 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -93,8 +93,8 @@ namespace connectivity virtual void refreshIndexes(); public: - OAdoTable(sal_Bool _bCase,OCatalog* _pCatalog,_ADOTable* _pTable); - OAdoTable(sal_Bool _bCase,OCatalog* _pCatalog); + OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog,_ADOTable* _pTable); + OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog); ::rtl::OUString SAL_CALL getName() { return m_Name; } diff --git a/connectivity/source/inc/calc/CTable.hxx b/connectivity/source/inc/calc/CTable.hxx index f9a607408c66..73f5e33a6645 100644 --- a/connectivity/source/inc/calc/CTable.hxx +++ b/connectivity/source/inc/calc/CTable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: CTable.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-04-30 10:09:03 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -117,8 +117,8 @@ namespace connectivity virtual void refreshIndexes(); public: - OCalcTable( OCalcConnection* _pConnection); - OCalcTable( OCalcConnection* _pConnection, + OCalcTable( sdbcx::OCollection* _pTables,OCalcConnection* _pConnection); + OCalcTable( sdbcx::OCollection* _pTables,OCalcConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description = ::rtl::OUString(), diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx index d7413e04306a..4ee6d1c26b9d 100644 --- a/connectivity/source/inc/dbase/DTable.hxx +++ b/connectivity/source/inc/dbase/DTable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: DTable.hxx,v $ * - * $Revision: 1.28 $ + * $Revision: 1.29 $ * - * last change: $Author: oj $ $Date: 2001-09-19 11:03:03 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:50 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -168,8 +168,8 @@ namespace connectivity virtual void refreshIndexes(); public: - ODbaseTable( ODbaseConnection* _pConnection); - ODbaseTable( ODbaseConnection* _pConnection, + ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection); + ODbaseTable( sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description = ::rtl::OUString(), diff --git a/connectivity/source/inc/file/FTable.hxx b/connectivity/source/inc/file/FTable.hxx index 013bd58a49c4..b1d624feee8e 100644 --- a/connectivity/source/inc/file/FTable.hxx +++ b/connectivity/source/inc/file/FTable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FTable.hxx,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: oj $ $Date: 2001-09-19 11:03:01 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -118,8 +118,8 @@ namespace connectivity }; public: - OFileTable( OConnection* _pConnection); - OFileTable( OConnection* _pConnection, + OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection); + OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description = ::rtl::OUString(), diff --git a/connectivity/source/inc/flat/ETable.hxx b/connectivity/source/inc/flat/ETable.hxx index 3ac570ef8f23..e0f976ede963 100644 --- a/connectivity/source/inc/flat/ETable.hxx +++ b/connectivity/source/inc/flat/ETable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: ETable.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:00:39 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -129,8 +129,8 @@ namespace connectivity public: // DECLARE_CTY_DEFAULTS( OFlatTable_BASE); - OFlatTable( OFlatConnection* _pConnection); - OFlatTable( OFlatConnection* _pConnection, + OFlatTable( sdbcx::OCollection* _pTables,OFlatConnection* _pConnection); + OFlatTable( sdbcx::OCollection* _pTables,OFlatConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description = ::rtl::OUString(), diff --git a/connectivity/source/inc/mozaddressbook/MABTable.hxx b/connectivity/source/inc/mozaddressbook/MABTable.hxx index 42a51b99eb05..e287afd86dfd 100644 --- a/connectivity/source/inc/mozaddressbook/MABTable.hxx +++ b/connectivity/source/inc/mozaddressbook/MABTable.hxx @@ -2,9 +2,9 @@ * * $RCSfile: MABTable.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: dkenny $ $Date: 2001-08-08 08:04:35 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -135,8 +135,8 @@ namespace connectivity public: // DECLARE_CTY_DEFAULTS( OMozabTable_BASE); - OMozabTable( OMozabConnection* _pConnection); - OMozabTable( OMozabConnection* _pConnection, + OMozabTable( sdbcx::OCollection* _pTables,OMozabConnection* _pConnection); + OMozabTable( sdbcx::OCollection* _pTables,OMozabConnection* _pConnection, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description = ::rtl::OUString(), diff --git a/connectivity/source/sdbcx/VCollection.cxx b/connectivity/source/sdbcx/VCollection.cxx index 422cefa77985..23f3b8db3f53 100644 --- a/connectivity/source/sdbcx/VCollection.cxx +++ b/connectivity/source/sdbcx/VCollection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VCollection.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: oj $ $Date: 2001-08-24 06:06:12 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -309,7 +309,7 @@ void SAL_CALL OCollection::dropByIndex( sal_Int32 index ) throw(SQLException, In // notify our container listeners ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(elementName), Any(), Any()); - // note that xExistent may be empty, in case somebody removed the data source while it is not alive at this moment + // note that xExistent may be empty, in case somebody removed the data source while it is not alive at this moment OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners); while (aListenerLoop.hasMoreElements()) static_cast<XContainerListener*>(aListenerLoop.next())->elementRemoved(aEvent); @@ -391,3 +391,29 @@ void OCollection::insertElement(const ::rtl::OUString& _sElementName,const Objec m_aElements.push_back(m_aNameMap.insert(m_aNameMap.begin(), ObjectMap::value_type(_sElementName,_xElement))); } // ----------------------------------------------------------------------------- +void OCollection::renameObject(const ::rtl::OUString _sOldName,const ::rtl::OUString _sNewName) +{ + + OSL_ENSURE(m_aNameMap.find(_sOldName) != m_aNameMap.end(),"Element doesn't exist"); + OSL_ENSURE(m_aNameMap.find(_sNewName) == m_aNameMap.end(),"Element already exists"); + OSL_ENSURE(_sNewName.getLength(),"New name must not be empty!"); + OSL_ENSURE(_sOldName.getLength(),"New name must not be empty!"); + + ObjectMap::iterator aIter = m_aNameMap.find(_sOldName); + if(aIter != m_aNameMap.end()) + { + ::std::vector< ObjectIter >::iterator aFind = ::std::find(m_aElements.begin(),m_aElements.end(),aIter); + if(m_aElements.end() != aFind) + { + (*aFind) = m_aNameMap.insert(m_aNameMap.begin(), ObjectMap::value_type(_sNewName,(*aFind)->second)); + m_aNameMap.erase(aIter); + + ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_sNewName), makeAny((*aFind)->second),makeAny(_sOldName)); + // note that xExistent may be empty, in case somebody removed the data source while it is not alive at this moment + OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners); + while (aListenerLoop.hasMoreElements()) + static_cast<XContainerListener*>(aListenerLoop.next())->elementReplaced(aEvent); + } + } +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/sdbcx/VTable.cxx b/connectivity/source/sdbcx/VTable.cxx index 83bc553ca5cb..fcae37ff055d 100644 --- a/connectivity/source/sdbcx/VTable.cxx +++ b/connectivity/source/sdbcx/VTable.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VTable.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: oj $ $Date: 2001-05-25 07:45:30 $ + * last change: $Author: oj $ $Date: 2001-09-25 13:12:51 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -126,15 +126,19 @@ sal_Bool SAL_CALL OTable::supportsService( const ::rtl::OUString& _rServiceName return pSupported != pEnd; } // ------------------------------------------------------------------------- -OTable::OTable(sal_Bool _bCase) : OTableDescriptor_BASE(m_aMutex) +OTable::OTable(OCollection* _pTables, + sal_Bool _bCase) + : OTableDescriptor_BASE(m_aMutex) ,ODescriptor(OTableDescriptor_BASE::rBHelper,_bCase,sal_True) ,m_pKeys(NULL) ,m_pColumns(NULL) ,m_pIndexes(NULL) + ,m_pTables(_pTables) { } // ----------------------------------------------------------------------------- -OTable::OTable( sal_Bool _bCase, +OTable::OTable( OCollection* _pTables, + sal_Bool _bCase, const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description,const ::rtl::OUString& _SchemaName, const ::rtl::OUString& _CatalogName) : OTableDescriptor_BASE(m_aMutex) @@ -146,6 +150,7 @@ OTable::OTable( sal_Bool _bCase, ,m_SchemaName(_SchemaName) ,m_Description(_Description) ,m_Type(_Type) + ,m_pTables(_pTables) { m_Name = _Name; } @@ -166,7 +171,7 @@ void OTable::construct() registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CATALOGNAME), PROPERTY_ID_CATALOGNAME,nAttrib,&m_CatalogName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME), PROPERTY_ID_SCHEMANAME, nAttrib,&m_SchemaName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION), PROPERTY_ID_DESCRIPTION,nAttrib,&m_Description, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); - registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib,&m_Type, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); + registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE), PROPERTY_ID_TYPE, nAttrib,&m_Type, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL))); } // ----------------------------------------------------------------------------- void SAL_CALL OTable::acquire() throw(::com::sun::star::uno::RuntimeException) @@ -215,6 +220,7 @@ void SAL_CALL OTable::disposing(void) if(m_pIndexes) m_pIndexes->disposing(); + m_pTables = NULL; } // ----------------------------------------------------------------------------- // XColumnsSupplier @@ -285,24 +291,29 @@ void SAL_CALL OTable::rename( const ::rtl::OUString& newName ) throw(SQLExceptio ::osl::MutexGuard aGuard(m_aMutex); checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed); + ::rtl::OUString sOldComposedName = getName(); + ::rtl::OUString sNewComposedName; + sal_Int32 nPos = sOldComposedName.lastIndexOf('.'); + if(nPos != -1) + { + sNewComposedName = sOldComposedName.copy(0,nPos); + sNewComposedName += ::rtl::OUString::createFromAscii(".") ; + sNewComposedName += newName; + } + else + sNewComposedName = newName; + m_pTables->renameObject(sOldComposedName,sNewComposedName); + m_Name = newName; } // ------------------------------------------------------------------------- // XAlterTable void SAL_CALL OTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException) { - ::osl::MutexGuard aGuard(m_aMutex); - checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed); - - } // ------------------------------------------------------------------------- void SAL_CALL OTable::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException) { - ::osl::MutexGuard aGuard(m_aMutex); - checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed); - - } // ------------------------------------------------------------------------- ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OTable::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) |