diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-08-24 05:05:37 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-08-24 05:05:37 +0000 |
commit | bb6d7df690687f1e066b09d72fb0a2204d12b5aa (patch) | |
tree | 51d475ecee60cffdfbdddcf8f56fc9907c88f93b /connectivity | |
parent | 7cd350d5407dab11869293b3eaa549c1bd567f17 (diff) |
#90015# code corrcetions for some speedup'sDColumns.cxx
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/dbase/DConnection.cxx | 6 | ||||
-rw-r--r-- | connectivity/source/drivers/dbase/DDatabaseMetaData.cxx | 219 | ||||
-rw-r--r-- | connectivity/source/drivers/dbase/DIndex.cxx | 13 | ||||
-rw-r--r-- | connectivity/source/drivers/dbase/DNoException.cxx | 6 | ||||
-rw-r--r-- | connectivity/source/drivers/dbase/DResultSet.cxx | 16 | ||||
-rw-r--r-- | connectivity/source/drivers/dbase/DTable.cxx | 229 |
6 files changed, 248 insertions, 241 deletions
diff --git a/connectivity/source/drivers/dbase/DConnection.cxx b/connectivity/source/drivers/dbase/DConnection.cxx index 2df7abd175e9..8ad239b1f803 100644 --- a/connectivity/source/drivers/dbase/DConnection.cxx +++ b/connectivity/source/drivers/dbase/DConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DConnection.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: fs $ $Date: 2001-06-25 16:07:30 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:05:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -136,7 +136,7 @@ Reference< XDatabaseMetaData > SAL_CALL ODbaseConnection::getMetaData( ) throw( { ::osl::MutexGuard aGuard( m_aMutex ); Reference< XTablesSupplier > xTab = m_xCatalog; - if(!m_xCatalog.get().is()) + if(!m_xCatalog.is()) { ODbaseCatalog *pCat = new ODbaseCatalog(this); xTab = pCat; diff --git a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx index 521af9bfe8cc..c08f5380678f 100644 --- a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx +++ b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DDatabaseMetaData.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: oj $ $Date: 2001-07-24 13:17:51 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:05:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -130,76 +130,75 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getTypeInfo( ) throw(S ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(); Reference< XResultSet > xRef = pResult; pResult->setTypeInfoMap(); - ORows aRows; - ORow aRow; - - aRow.push_back(ORowSetValue()); - aRow.push_back(ORowSetValue(::rtl::OUString::createFromAscii("CHAR"))); - aRow.push_back(ORowSetValue(DataType::CHAR)); - aRow.push_back(ORowSetValue((sal_Int32)254)); - aRow.push_back(ORowSetValue(::rtl::OUString::createFromAscii("'"))); - aRow.push_back(ORowSetValue(::rtl::OUString::createFromAscii("'"))); - aRow.push_back(ORowSetValue(::rtl::OUString::createFromAscii("length"))); - aRow.push_back(ORowSetValue((sal_Int32)ColumnValue::NULLABLE)); - aRow.push_back(ORowSetValue((sal_Int32)1)); - aRow.push_back(ORowSetValue((sal_Int32)ColumnSearch::FULL)); - aRow.push_back(ORowSetValue((sal_Int32)1)); - aRow.push_back(ORowSetValue((sal_Int32)0)); - aRow.push_back(ORowSetValue((sal_Int32)0)); - aRow.push_back(ORowSetValue()); - aRow.push_back(ORowSetValue((sal_Int32)0)); - aRow.push_back(ORowSetValue((sal_Int32)0)); - aRow.push_back(ORowSetValue()); - aRow.push_back(ORowSetValue()); - aRow.push_back(ORowSetValue((sal_Int32)10)); - - // bound row - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); - - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("VARCHAR")); - aRow[2] = ORowSetValue(DataType::VARCHAR); - aRow[4] = ORowSetValue(::rtl::OUString::createFromAscii("'")); - aRow[5] = ORowSetValue(::rtl::OUString::createFromAscii("'")); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("length")); - aRows.push_back(aRow); - - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("LONGVARCHAR")); - aRow[2] = ORowSetValue(DataType::LONGVARCHAR); - aRow[3] = ORowSetValue((sal_Int32)65535); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("DATE")); - aRow[2] = ORowSetValue(DataType::DATE); - aRow[3] = ORowSetValue((sal_Int32)10); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("BOOL")); - aRow[2] = ORowSetValue(DataType::BIT); - aRow[3] = ORowSetValue((sal_Int32)1); - aRow[4] = ORowSetValue(); - aRow[5] = ORowSetValue(); - aRow[6] = ORowSetValue(::rtl::OUString()); - aRow[9] = ORowSetValue((sal_Int32)ColumnSearch::BASIC); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("DECIMAL")); - aRow[2] = ORowSetValue(DataType::DECIMAL); - aRow[3] = ORowSetValue((sal_Int32)20); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("length,scale")); - aRow[15] = ORowSetValue((sal_Int32)15); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("NUMERIC")); - aRow[2] = ORowSetValue(DataType::NUMERIC); - aRow[3] = ORowSetValue((sal_Int32)20); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("length,scale")); - aRow[15] = ORowSetValue((sal_Int32)20); - aRows.push_back(aRow); + static ODatabaseMetaDataResultSet::ORows aRows; + if(aRows.empty()) + { + ODatabaseMetaDataResultSet::ORow aRow; + aRow.reserve(18); + + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"))); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::CHAR)); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)254)); + aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); + aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("length"))); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); + aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)ColumnSearch::FULL)); + aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::get0Value()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)10)); + + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::VARCHAR); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[6] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("length")); + aRows.push_back(aRow); + + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("LONGVARCHAR")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::LONGVARCHAR); + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)65535); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::DATE); + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)10); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOL")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::BIT); + aRow[3] = ODatabaseMetaDataResultSet::get1Value(); + aRow[4] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[6] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString()); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::DECIMAL); + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)20); + aRow[6] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("length,scale")); + aRow[15] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)15); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("NUMERIC")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::NUMERIC); + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)20); + aRow[6] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("length,scale")); + aRow[15] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)20); + aRows.push_back(aRow); + } pResult->setRows(aRows); return xRef; @@ -233,14 +232,10 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getColumns( if(!xNames.is()) throw SQLException(); - ORows aRows; - ORow aRow(19); - // bound row - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); + ODatabaseMetaDataResultSet::ORows aRows; + ODatabaseMetaDataResultSet::ORow aRow(19); - aRow[10] = (sal_Int32)10; + aRow[10] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)10); Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames()); const ::rtl::OUString* pTabBegin = aTabNames.getConstArray(); const ::rtl::OUString* pTabEnd = pTabBegin + aTabNames.getLength(); @@ -251,7 +246,7 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getColumns( Reference< XColumnsSupplier> xTable; ::cppu::extractInterface(xTable,xNames->getByName(*pTabBegin)); OSL_ENSURE(xTable.is(),"Table not found! Normallya exception had to be thrown here!"); - aRow[3] = *pTabBegin; + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(*pTabBegin); Reference< XNameAccess> xColumns = xTable->getColumns(); if(!xColumns.is()) @@ -266,43 +261,39 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getColumns( { if(match(columnNamePattern,*pBegin,'\0')) { - aRow[4] = *pBegin; + aRow[4] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(*pBegin); ::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin)); OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!"); - aRow[5] = getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))); - aRow[6] = getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))); - aRow[7] = getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))); - // aRow[8] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); - aRow[9] = getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))); - aRow[11] = getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))); - // aRow[12] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); - aRow[13] = getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))); - // aRow[14] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); - // aRow[15] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); - switch((sal_Int32)aRow[5]) + aRow[5] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))); + aRow[6] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))); + aRow[7] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))); + aRow[9] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); + aRow[11] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))); + aRow[13] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)))); + switch((sal_Int32)aRow[5]->getValue()) { case DataType::CHAR: case DataType::VARCHAR: - aRow[16] = (sal_Int32)254; + aRow[16] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)254); break; case DataType::LONGVARCHAR: - aRow[16] = (sal_Int32)65535; + aRow[16] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)65535); break; default: - aRow[16] = (sal_Int32)0; + aRow[16] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)0); } - aRow[17] = i; - switch(sal_Int32(aRow[11])) + aRow[17] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(i); + switch(sal_Int32(aRow[11]->getValue())) { case ColumnValue::NO_NULLS: - aRow[18] = ::rtl::OUString::createFromAscii("NO"); + aRow[18] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO")); break; case ColumnValue::NULLABLE: - aRow[18] = ::rtl::OUString::createFromAscii("YES"); + aRow[18] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES")); break; default: - aRow[18] = ::rtl::OUString(); + aRow[18] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString()); } aRows.push_back(aRow); } @@ -376,20 +367,16 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getIndexInfo( if(!xNames.is()) throw SQLException(); - ORows aRows; - ORow aRow(14); - // bound row - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); + ODatabaseMetaDataResultSet::ORows aRows; + ODatabaseMetaDataResultSet::ORow aRow(14); - aRow[5] = ::rtl::OUString(); - aRow[10] = ::rtl::OUString::createFromAscii("A"); + aRow[5] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString()); + aRow[10] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("A")); Reference< XIndexesSupplier> xTable; ::cppu::extractInterface(xTable,xNames->getByName(table)); - aRow[3] = table; - aRow[7] = (sal_Int32)3; + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(table); + aRow[7] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)3); Reference< XNameAccess> xIndexes = xTable->getIndexes(); if(!xIndexes.is()) @@ -407,8 +394,8 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getIndexInfo( if(unique && !getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE)))) continue; - aRow[4] = getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE))); - aRow[6] = *pBegin; + aRow[4] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE)))); + aRow[6] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(*pBegin); Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xIndex,UNO_QUERY); if(xTunnel.is()) @@ -416,8 +403,8 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getIndexInfo( ODbaseIndex* pIndex = (ODbaseIndex*)xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()); if(pIndex) { - aRow[11] = (sal_Int32)pIndex->getHeader().db_maxkeys; - aRow[12] = (sal_Int32)pIndex->getHeader().db_pagecount; + aRow[11] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)pIndex->getHeader().db_maxkeys); + aRow[12] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)pIndex->getHeader().db_pagecount); } } @@ -431,8 +418,8 @@ Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getIndexInfo( for(sal_Int32 j=1;pColBegin != pColEnd;++pColBegin,++j) { // xColumns->getByName(*pColBegin) >>= xColumn; - aRow[8] = j; - aRow[9] = *pColBegin; + aRow[8] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(j); + aRow[9] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(*pColBegin); aRows.push_back(aRow); } } diff --git a/connectivity/source/drivers/dbase/DIndex.cxx b/connectivity/source/drivers/dbase/DIndex.cxx index 46a08c6c536e..66a4e6fbb24f 100644 --- a/connectivity/source/drivers/dbase/DIndex.cxx +++ b/connectivity/source/drivers/dbase/DIndex.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DIndex.cxx,v $ * - * $Revision: 1.30 $ + * $Revision: 1.31 $ * - * last change: $Author: fs $ $Date: 2001-07-17 12:36:18 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:05:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -205,10 +205,11 @@ Sequence< sal_Int8 > ODbaseIndex::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 ODbaseIndex::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) { - if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - return (sal_Int64)this; - - return ODbaseIndex_BASE::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + ODbaseIndex_BASE::getSomething(rId); } //------------------------------------------------------------------ ONDXPagePtr ODbaseIndex::getRoot() diff --git a/connectivity/source/drivers/dbase/DNoException.cxx b/connectivity/source/drivers/dbase/DNoException.cxx index 5f416fa3b5d3..bbc9d52f5779 100644 --- a/connectivity/source/drivers/dbase/DNoException.cxx +++ b/connectivity/source/drivers/dbase/DNoException.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DNoException.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-06-29 08:28:41 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:05:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -673,7 +673,7 @@ SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& r memset(pEmptyData,0x00,nSize); rStream.Write((BYTE*)pEmptyData,nSize); rStream.Seek(nTell); - delete pEmptyData; + delete [] pEmptyData; } return rStream; } diff --git a/connectivity/source/drivers/dbase/DResultSet.cxx b/connectivity/source/drivers/dbase/DResultSet.cxx index 166704a3da8b..734dea21e691 100644 --- a/connectivity/source/drivers/dbase/DResultSet.cxx +++ b/connectivity/source/drivers/dbase/DResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DResultSet.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: oj $ $Date: 2001-07-04 14:27:34 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:05:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -129,10 +129,8 @@ sal_Bool SAL_CALL ODbaseResultSet::supportsService( const ::rtl::OUString& _rSer // ------------------------------------------------------------------------- Any SAL_CALL ODbaseResultSet::queryInterface( const Type & rType ) throw(RuntimeException) { - Any aRet = OResultSet::queryInterface(rType); - if(!aRet.hasValue()) - aRet = ODbaseResultSet_BASE::queryInterface(rType); - return aRet; + Any aRet = ODbaseResultSet_BASE::queryInterface(rType); + return aRet.hasValue() ? aRet : OResultSet::queryInterface(rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL ODbaseResultSet::getTypes( ) throw( RuntimeException) @@ -176,10 +174,6 @@ sal_Bool SAL_CALL ODbaseResultSet::moveRelativeToBookmark( const Any& bookmark, // ------------------------------------------------------------------------- sal_Int32 SAL_CALL ODbaseResultSet::compareBookmarks( const Any& first, const Any& second ) throw( SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - sal_Int32 nFirst,nSecond,nResult; first >>= nFirst; second >>= nSecond; @@ -235,7 +229,7 @@ sal_Bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_x sal_uInt32 nRec = pIter->First(); while (nRec != SQL_COLUMN_NOTFOUND) { - if (bOrderbyAscending[0]) + if (m_aOrderbyAscending[0]) m_pFileSet->push_back(nRec); else m_pFileSet->insert(m_pFileSet->begin(),nRec); diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx index 4defff7884c2..f6409d5c6909 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.60 $ + * $Revision: 1.61 $ * - * last change: $Author: oj $ $Date: 2001-08-10 11:05:34 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:05:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -233,10 +233,16 @@ void ODbaseTable::fillColumns() // Anzahl Felder: sal_Int32 nFieldCount = (m_aHeader.db_kopf - 1) / 32 - 1; + m_aColumns->reserve(nFieldCount); + m_aTypes.reserve(nFieldCount); + m_aPrecisions.reserve(nFieldCount); + m_aScales.reserve(nFieldCount); String aStrFieldName;aStrFieldName.AssignAscii("Column"); sal_Int32 nFieldCnt = 0; ::rtl::OUString aTypeName; + static const ::rtl::OUString sVARCHAR = ::rtl::OUString::createFromAscii("VARCHAR"); + sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); for (sal_Int32 i = 0; i < nFieldCount; i++) { @@ -252,7 +258,7 @@ void ODbaseTable::fillColumns() { case 'C': eType = DataType::VARCHAR; - aTypeName = ::rtl::OUString::createFromAscii("VARCHAR"); + aTypeName = sVARCHAR; break; case 'F': case 'N': @@ -284,23 +290,31 @@ void ODbaseTable::fillColumns() } - sal_Int32 nFlags = 0; - switch (aDBFColumn.db_typ) - { - case 'C': - case 'D': - case 'L': nFlags = ColumnSearch::FULL; break; - case 'F': - case 'N': nFlags = ColumnSearch::BASIC; break; - case 'M': nFlags = ColumnSearch::CHAR; break; - default: - nFlags = ColumnSearch::NONE; - - } - - sdbcx::OColumn* pColumn = new sdbcx::OColumn(aColumnName,aTypeName,::rtl::OUString(), - ColumnValue::NULLABLE,nPrecision,aDBFColumn.db_dez,eType,sal_False,sal_False,sal_False, - getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()); +// sal_Int32 nFlags = 0; +// switch (aDBFColumn.db_typ) +// { +// case 'C': +// case 'D': +// case 'L': nFlags = ColumnSearch::FULL; break; +// case 'F': +// case 'N': nFlags = ColumnSearch::BASIC; break; +// case 'M': nFlags = ColumnSearch::CHAR; break; +// default: +// nFlags = ColumnSearch::NONE; +// +// } + + sdbcx::OColumn* pColumn = new sdbcx::OColumn(aColumnName, + aTypeName, + ::rtl::OUString(), + ColumnValue::NULLABLE, + nPrecision, + aDBFColumn.db_dez, + eType, + sal_False, + sal_False, + sal_False, + bCase); Reference< XPropertySet> xCol = pColumn; m_aColumns->push_back(xCol); m_aTypes.push_back(eType); @@ -499,6 +513,7 @@ void ODbaseTable::refreshColumns() ::osl::MutexGuard aGuard( m_aMutex ); TStringVector aVector; + aVector.reserve(m_aColumns->size()); for(OSQLColumns::const_iterator aIter = m_aColumns->begin();aIter != m_aColumns->end();++aIter) aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName()); @@ -586,15 +601,11 @@ Sequence< Type > SAL_CALL ODbaseTable::getTypes( ) throw(RuntimeException) Any SAL_CALL ODbaseTable::queryInterface( const Type & rType ) throw(RuntimeException) { if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) || - // rType == ::getCppuType((const Reference<XAlterTable>*)0) || rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)) return Any(); - Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); - if(!aRet.hasValue()) - aRet = OTable_TYPEDEF::queryInterface(rType); - - return aRet; + Any aRet = OTable_TYPEDEF::queryInterface(rType); + return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); } //-------------------------------------------------------------------------- @@ -617,10 +628,11 @@ Sequence< sal_Int8 > ODbaseTable::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 ODbaseTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException) { - if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - return (sal_Int64)this; - - return ODbaseTable_BASE::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + ODbaseTable_BASE::getSomething(rId); } //------------------------------------------------------------------ sal_Bool ODbaseTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData) @@ -643,11 +655,6 @@ sal_Bool ODbaseTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols, sal_B OSQLColumns::const_iterator aIter = _rCols.begin(); for (sal_Int32 i = 1; aIter != _rCols.end();++aIter, i++) { - // pVal = (*_rRow)[i].getBodyPtr(); - Reference< XPropertySet> xColumn = *aIter; - - ::rtl::OUString aName; - xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aName; // Laengen je nach Datentyp: sal_Int32 nLen; sal_Int32 nType; @@ -658,8 +665,8 @@ sal_Bool ODbaseTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols, sal_B } else { - xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen; - xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType; + (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen; + (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType; } switch(nType) { @@ -668,14 +675,13 @@ sal_Bool ODbaseTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols, sal_B if(_bUseTableDefs) nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,m_aScales[i-1]); else - nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); + nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,getINT32((*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); break; // das Vorzeichen und das Komma case DataType::BIT: nLen = 1; break; case DataType::LONGVARCHAR: nLen = 10; break; case DataType::OTHER: nByteOffset += nLen; continue; - default: break; } // Ist die Variable ueberhaupt gebunden? @@ -700,10 +706,7 @@ sal_Bool ODbaseTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols, sal_B if (!aStr.Len()) // keine StringLaenge, dann NULL (*_rRow)[i].setNull(); else - { - ::rtl::OUString aStr2(aStr); - (*_rRow)[i] = aStr2; - } + (*_rRow)[i] = aStr; pData[nLen] = cLast; } else @@ -1267,8 +1270,8 @@ BOOL ODbaseTable::DeleteRow(const OSQLColumns& _rCols) // Einfach das Loesch-Flag setzen (egal, ob es schon gesetzt war // oder nicht): // Auf gewuenschten Record positionieren: - long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng; - m_pFileStream->Seek(nPos); + long nFilePos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng; + m_pFileStream->Seek(nFilePos); OValueRow aRow = new OValueVector(_rCols.size()); @@ -1280,21 +1283,22 @@ BOOL ODbaseTable::DeleteRow(const OSQLColumns& _rCols) ::comphelper::UStringMixEqual aCase(isCaseSensitive()); for (USHORT i = 0; i < m_pColumns->getCount(); i++) { - ::cppu::extractInterface(xCol,m_pColumns->getByIndex(i)); - OSL_ENSURE(xCol.is(),"ODbaseTable::DeleteRow column is null!"); - - if(xCol.is()) + Reference<XPropertySet> xIndex = isUniqueByColumnName(i); + if (xIndex.is()) { - xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; - Reference<XPropertySet> xIndex = isUniqueByColumnName(aColName); - if (xIndex.is()) + ::cppu::extractInterface(xCol,m_pColumns->getByIndex(i)); + OSL_ENSURE(xCol.is(),"ODbaseTable::DeleteRow column is null!"); + if(xCol.is()) { + xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; + Reference<XUnoTunnel> xTunnel(xIndex,UNO_QUERY); OSL_ENSURE(xTunnel.is(),"No TunnelImplementation!"); ODbaseIndex* pIndex = (ODbaseIndex*)xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()); OSL_ENSURE(pIndex,"ODbaseTable::DeleteRow: No Index returned!"); OSQLColumns::const_iterator aIter = _rCols.begin(); + sal_Int32 nPos = 1; for(;aIter != _rCols.end();++aIter,++nPos) { if(aCase(getString((*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME))),aColName)) @@ -1308,26 +1312,35 @@ BOOL ODbaseTable::DeleteRow(const OSQLColumns& _rCols) } } - m_pFileStream->Seek(nPos); + m_pFileStream->Seek(nFilePos); (*m_pFileStream) << (BYTE)'*'; // mark the row in the table as deleted m_pFileStream->Flush(); - return sal_True;; + return sal_True; } // ------------------------------------------------------------------------- -Reference<XPropertySet> ODbaseTable::isUniqueByColumnName(const ::rtl::OUString& _rColName) +Reference<XPropertySet> ODbaseTable::isUniqueByColumnName(sal_Int32 _nColumnPos) { if(!m_pIndexes) refreshIndexes(); - Reference<XPropertySet> xIndex; - for(sal_Int32 i=0;i<m_pIndexes->getCount();++i) + if(m_pIndexes->hasElements()) { - ::cppu::extractInterface(xIndex,m_pIndexes->getByIndex(i)); - if(xIndex.is() && getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE)))) + Reference<XPropertySet> xCol; + m_pColumns->getByIndex(_nColumnPos) >>= xCol; + OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!"); + ::rtl::OUString sColName; + xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sColName; + + Reference<XPropertySet> xIndex; + for(sal_Int32 i=0;i<m_pIndexes->getCount();++i) { - Reference<XNameAccess> xCols(Reference<XColumnsSupplier>(xIndex,UNO_QUERY)->getColumns()); - if(xCols->hasByName(_rColName)) - return xIndex; + ::cppu::extractInterface(xIndex,m_pIndexes->getByIndex(i)); + if(xIndex.is() && getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE)))) + { + Reference<XNameAccess> xCols(Reference<XColumnsSupplier>(xIndex,UNO_QUERY)->getColumns()); + if(xCols->hasByName(sColName)) + return xIndex; + } } } return Reference<XPropertySet>(); @@ -1349,31 +1362,36 @@ BOOL ODbaseTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Refer Reference<XPropertySet> xIndex; USHORT i; ::rtl::OUString aColName; - ::std::vector< Reference<XPropertySet> > aIndexedCols(m_pColumns->getCount()); + sal_Int32 nColumnCount = m_pColumns->getCount(); + ::std::vector< Reference<XPropertySet> > aIndexedCols(nColumnCount); ::comphelper::UStringMixEqual aCase(isCaseSensitive()); + Reference<XIndexAccess> xColumns = m_pColumns; // first search a key that exist already in the table - for (i = 0; i < m_pColumns->getCount(); i++) + for (i = 0; i < nColumnCount; ++i) { - m_pColumns->getByIndex(i) >>= xCol; - OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!"); - xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; - - sal_Int32 nPos = 0; - for(;nPos<_xCols->getCount();++nPos) + sal_Int32 nPos = i; + if(_xCols != xColumns) { - Reference<XPropertySet> xFindCol; - ::cppu::extractInterface(xFindCol,_xCols->getByIndex(nPos)); - OSL_ENSURE(xFindCol.is(),"ODbaseTable::UpdateBuffer column is null!"); - if(aCase(getString(xFindCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),aColName)) - break; + m_pColumns->getByIndex(i) >>= xCol; + OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!"); + xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; + + for(nPos = 0;nPos<_xCols->getCount();++nPos) + { + Reference<XPropertySet> xFindCol; + ::cppu::extractInterface(xFindCol,_xCols->getByIndex(nPos)); + OSL_ENSURE(xFindCol.is(),"ODbaseTable::UpdateBuffer column is null!"); + if(aCase(getString(xFindCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),aColName)) + break; + } + if (nPos >= _xCols->getCount()) + continue; } - if (nPos >= _xCols->getCount()) - continue; ++nPos; - xIndex = isUniqueByColumnName(aColName); + xIndex = isUniqueByColumnName(i); aIndexedCols[i] = xIndex; if (xIndex.is()) { @@ -1402,17 +1420,11 @@ BOOL ODbaseTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Refer // when we are here there is no double key in the table - for (i = 0; i < m_pColumns->getCount(); i++) + for (i = 0; i < nColumnCount; ++i) { - m_pColumns->getByIndex(i) >>= xCol; - OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!"); - xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; - // Laengen je nach Datentyp: - sal_Int32 nLen; - sal_Int32 nType; - nLen = m_aPrecisions[i]; - nType = m_aTypes[i]; + sal_Int32 nLen = m_aPrecisions[i]; + sal_Int32 nType = m_aTypes[i]; switch (nType) { @@ -1426,20 +1438,27 @@ BOOL ODbaseTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Refer } - sal_Int32 nPos = 0; - for(;nPos<_xCols->getCount();++nPos) + sal_Int32 nPos = i; + if(_xCols != xColumns) { - Reference<XPropertySet> xFindCol; - ::cppu::extractInterface(xFindCol,_xCols->getByIndex(nPos)); - if(aCase(getString(xFindCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),aColName)) - break; + m_pColumns->getByIndex(i) >>= xCol; + OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!"); + xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; + for(nPos = 0;nPos<_xCols->getCount();++nPos) + { + Reference<XPropertySet> xFindCol; + ::cppu::extractInterface(xFindCol,_xCols->getByIndex(nPos)); + if(aCase(getString(xFindCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),aColName)) + break; + } + if (nPos >= _xCols->getCount()) + { + nByteOffset += nLen; + continue; + } } - if (nPos >= _xCols->getCount()) - { - nByteOffset += nLen; - continue; - } + ++nPos; // the row values start at 1 // Ist die Variable ueberhaupt gebunden? @@ -1497,6 +1516,9 @@ BOOL ODbaseTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Refer double n = rRow[nPos]; + m_pColumns->getByIndex(i) >>= xCol; + OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!"); + xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; int nPrecision = (int)m_aPrecisions[i]; int nScale = (int)getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))); // ein const_cast, da GetFormatPrecision am SvNumberFormat nicht const ist, obwohl es das eigentlich @@ -1561,6 +1583,10 @@ BOOL ODbaseTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Refer } catch ( Exception& ) { + m_pColumns->getByIndex(i) >>= xCol; + OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!"); + xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName; + ::rtl::OUString sMsg = ::rtl::OUString::createFromAscii("Invalid value for column: "); sMsg += aColName; sMsg += ::rtl::OUString::createFromAscii("!"); @@ -1904,21 +1930,20 @@ void ODbaseTable::copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos) if(nPos) { aInsertRow = new OValueVector(_pNewTable->m_pColumns->getCount()); - for(OValueVector::iterator aInsertIter = aInsertRow->begin(); aInsertIter != aInsertRow->end();++aInsertIter) - aInsertIter->setBound(sal_True); + ::std::for_each(aInsertRow->begin(),aInsertRow->end(),TSetBound(sal_True)); } else aInsertRow = aRow; // we only have to bind the values which we need to copy into the new table - for(OValueVector::iterator aIter = aRow->begin(); aIter != aRow->end();++aIter) - aIter->setBound(sal_True); + ::std::for_each(aRow->begin(),aRow->end(),TSetBound(sal_True)); if(nPos && (nPos < (sal_Int32)aRow->size())) (*aRow)[nPos].setBound(sal_False); sal_Bool bOk = sal_True; sal_Int32 nCurPos; + OValueVector::iterator aIter; for(sal_uInt32 nRowPos = 0; nRowPos < m_aHeader.db_anz;++nRowPos) { if(bOk = seekRow(FILE_BOOKMARK,nRowPos+1,nCurPos)) |