diff options
author | Ocke Janssen <oj@openoffice.org> | 2001-08-24 05:19:41 +0000 |
---|---|---|
committer | Ocke Janssen <oj@openoffice.org> | 2001-08-24 05:19:41 +0000 |
commit | 2d7388c15291c6b0ca4ea29837c7c1b92ad23a53 (patch) | |
tree | 162ed438d04c164f892a2936a4ff2828d07ab820 | |
parent | bb6d7df690687f1e066b09d72fb0a2204d12b5aa (diff) |
#90015# code corrcetions for some speedup's
88 files changed, 1939 insertions, 1989 deletions
diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx index 1924d58b6b69..6f6d249b871d 100644 --- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx +++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FDatabaseMetaDataResultSet.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: oj $ $Date: 2001-07-16 06:17:16 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:02:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -69,6 +69,9 @@ #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_ #include <com/sun/star/sdbc/DataType.hpp> #endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNSEARCH_HPP_ +#include <com/sun/star/sdbc/ColumnSearch.hpp> +#endif #ifndef _COM_SUN_STAR_SDBC_KEYRULE_HPP_ #include <com/sun/star/sdbc/KeyRule.hpp> #endif @@ -169,9 +172,7 @@ void SAL_CALL ODatabaseMetaDataResultSet::release() throw(RuntimeException) Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OPropertySetHelper::queryInterface(rType); - if(!aRet.hasValue()) - aRet = ODatabaseMetaDataResultSet_BASE::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(RuntimeException) @@ -199,11 +200,7 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString sal_Int32 i = 1; for(;i<=nLen;++i) if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) : -#if SUPD > 630 columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)) -#else - columnName.equalsIgnoreCase(xMeta->getColumnName(i)) -#endif ) break; return i; @@ -217,151 +214,54 @@ void ODatabaseMetaDataResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com: // ------------------------------------------------------------------------- Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return NULL; - - checkIndex(columnIndex ); - - - m_nColPos = columnIndex; return NULL; } // ------------------------------------------------------------------------- Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - - if(m_aRowsIter == m_aRows.end()) - return NULL; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; - return NULL; } // ------------------------------------------------------------------------- sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return sal_False; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return 0; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return Sequence< sal_Int8 >(); - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; -; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- ::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return ::com::sun::star::util::Date(0,0,0); - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; -; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return 0.0; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; -; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - - if(m_aRowsIter == m_aRows.end()) - return 0.0; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; -; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - - if(m_aRowsIter == m_aRows.end()) - return 0; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; -; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- @@ -378,18 +278,7 @@ sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, Ru sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return sal_Int64(); - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; -; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- @@ -407,16 +296,6 @@ Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData // ------------------------------------------------------------------------- Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return NULL; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; - return NULL; } @@ -424,98 +303,36 @@ Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 col Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return NULL; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; - return NULL; } // ------------------------------------------------------------------------- Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return NULL; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; - return NULL; } // ------------------------------------------------------------------------- Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return NULL; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; - return NULL; } // ------------------------------------------------------------------------- Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return Any(); - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; - return (*m_aRowsIter)[columnIndex].makeAny(); + return getValue(columnIndex).makeAny(); } // ------------------------------------------------------------------------- sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return 0; - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- ::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - - if(m_aRowsIter == m_aRows.end()) - return ::rtl::OUString(); - - checkIndex(columnIndex ); - - - - m_nColPos = columnIndex; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- @@ -523,39 +340,14 @@ sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) ::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - if(m_aRowsIter == m_aRows.end()) - return ::com::sun::star::util::Time(0,0,0,0); - - checkIndex(columnIndex ); - - m_nColPos = columnIndex; - -; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- ::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - - - if(m_aRowsIter == m_aRows.end()) - return ::com::sun::star::util::DateTime(0,0,0,0,0,0,0); - - checkIndex(columnIndex ); - - - m_nColPos = columnIndex; -; - - return (*m_aRowsIter)[columnIndex]; + return getValue(columnIndex); } // ------------------------------------------------------------------------- @@ -693,22 +485,16 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, Ru if(m_aRowsIter == m_aRows.end()) return sal_True; - return (*m_aRowsIter)[m_nColPos].isNull(); + return (*m_aRowsIter)[m_nColPos]->getValue().isNull(); } // ------------------------------------------------------------------------- void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - } // ------------------------------------------------------------------------- void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); - } // ------------------------------------------------------------------------- void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException) @@ -858,5 +644,109 @@ Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDat return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); } // ----------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ORowSetValueDecorator& ODatabaseMetaDataResultSet::ORowSetValueDecorator::operator=(const ORowSetValue& _aValue) +{ + m_aValue = _aValue; + return *this; +} +// ----------------------------------------------------------------------------- +const ORowSetValue& ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed ); + + if(m_aRowsIter != m_aRows.end() && (*m_aRowsIter)[columnIndex].isValid()) + { + checkIndex(columnIndex ); + m_nColPos = columnIndex; + + return *(*m_aRowsIter)[columnIndex]; + } + return m_aEmptyValue; +} +// ----------------------------------------------------------------------------- +/// return an empty ORowSetValueDecorator +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getEmptyValue() +{ + static ORowSetValueDecoratorRef aEmptyValueRef = new ORowSetValueDecorator(); + return aEmptyValueRef; +} +// ----------------------------------------------------------------------------- +/// return an ORowSetValueDecorator with 0 as value +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get0Value() +{ + static ORowSetValueDecoratorRef a0ValueRef = new ORowSetValueDecorator((sal_Int32)0); + return a0ValueRef; +} +// ----------------------------------------------------------------------------- +/// return an ORowSetValueDecorator with 1 as value +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::get1Value() +{ + static ORowSetValueDecoratorRef a1ValueRef = new ORowSetValueDecorator((sal_Int32)1); + return a1ValueRef; +} +// ----------------------------------------------------------------------------- +/// return an ORowSetValueDecorator with ColumnSearch::BASIC as value +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getBasicValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(ColumnSearch::BASIC); + return aValueRef; +} +// ----------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getSelectValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("SELECT")); + return aValueRef; +} +// ----------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getInsertValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("INSERT")); + return aValueRef; +} +// ----------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDeleteValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DELETE")); + return aValueRef; +} +// ----------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getUpdateValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("UPDATE")); + return aValueRef; +} +// ----------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getCreateValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CREATE")); + return aValueRef; +} +// ----------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getReadValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("READ")); + return aValueRef; +} +// ----------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getAlterValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("ALTER")); + return aValueRef; +} +// ----------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getDropValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DROP")); + return aValueRef; +} +// ----------------------------------------------------------------------------- +ODatabaseMetaDataResultSet::ORowSetValueDecoratorRef ODatabaseMetaDataResultSet::getQuoteValue() +{ + static ORowSetValueDecoratorRef aValueRef = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("'")); + return aValueRef; +} +// ----------------------------------------------------------------------------- + diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 1f6a74841238..6f908802b1aa 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FValue.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-08-06 06:21:03 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:02:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -343,9 +343,13 @@ ORowSetValue& ORowSetValue::operator=(const ORowSetValue& _rRH) m_aValue.m_bBool = _rRH.m_aValue.m_bBool; break; case DataType::TINYINT: + m_aValue.m_nInt8 = _rRH.m_aValue.m_nInt8; + break; case DataType::SMALLINT: + m_aValue.m_nInt16 = _rRH.m_aValue.m_nInt16; + break; case DataType::INTEGER: - m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32; + m_aValue.m_nInt32 = _rRH.m_aValue.m_nInt32; break; default: (*(Any*)m_aValue.m_pValue) = (*(Any*)_rRH.m_aValue.m_pValue); diff --git a/connectivity/source/commontools/TConnection.cxx b/connectivity/source/commontools/TConnection.cxx index e22adfc61ec8..070747bad9c5 100644 --- a/connectivity/source/commontools/TConnection.cxx +++ b/connectivity/source/commontools/TConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TConnection.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:42:00 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:02:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,10 +74,10 @@ using namespace::osl; //XUnoTunnel sal_Int64 SAL_CALL OMetaConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException) { - if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - return (sal_Int64)this; - - return 0; + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : sal_Int64(0); } // ----------------------------------------------------------------------------- Sequence< sal_Int8 > OMetaConnection::getUnoTunnelImplementationId() diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 222b9bcd831c..f1b3346d82cb 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbtools.cxx,v $ * - * $Revision: 1.38 $ + * $Revision: 1.39 $ * - * last change: $Author: fs $ $Date: 2001-08-06 15:56:13 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:02:18 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1586,10 +1586,10 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams, _xParams->setBoolean(parameterIndex,::cppu::any2bool(x)); break; case DataType::TINYINT: - _xParams->setByte(parameterIndex,::comphelper::getINT32(x)); + _xParams->setByte(parameterIndex,(sal_Int8)::comphelper::getINT32(x)); break; case DataType::SMALLINT: - _xParams->setShort(parameterIndex,::comphelper::getINT32(x)); + _xParams->setShort(parameterIndex,(sal_Int16)::comphelper::getINT32(x)); break; case DataType::INTEGER: _xParams->setInt(parameterIndex,::comphelper::getINT32(x)); @@ -1664,9 +1664,8 @@ void checkDisposed(sal_Bool _bThrow) throw ( DisposedException ) const ::rtl::OUString& _rVal, const ::comphelper::UStringMixEqual& _rCase) { - while (__first != __last && !_rCase(getString((*__first)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),_rVal)) - ++__first; - return __first; + ::rtl::OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME); + return find(__first,__last,sName,_rVal,_rCase); } // ------------------------------------------------------------------------- OSQLColumns::const_iterator findRealName( OSQLColumns::const_iterator __first, @@ -1674,9 +1673,8 @@ void checkDisposed(sal_Bool _bThrow) throw ( DisposedException ) const ::rtl::OUString& _rVal, const ::comphelper::UStringMixEqual& _rCase) { - while (__first != __last && !_rCase(getString((*__first)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME))),_rVal)) - ++__first; - return __first; + ::rtl::OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME); + return find(__first,__last,sRealName,_rVal,_rCase); } // ------------------------------------------------------------------------- OSQLColumns::const_iterator find( OSQLColumns::const_iterator __first, @@ -1685,7 +1683,7 @@ void checkDisposed(sal_Bool _bThrow) throw ( DisposedException ) const ::rtl::OUString& _rVal, const ::comphelper::UStringMixEqual& _rCase) { - while (__first != __last && !_rCase(getString(Reference<XPropertySet>((*__first),UNO_QUERY)->getPropertyValue(_rProp)),_rVal)) + while (__first != __last && !_rCase(getString((*__first)->getPropertyValue(_rProp)),_rVal)) ++__first; return __first; } @@ -1697,6 +1695,9 @@ void checkDisposed(sal_Bool _bThrow) throw ( DisposedException ) /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.38 2001/08/06 15:56:13 fs + * #90664# TransferFormComponentProperties: properly check for formatted fields + * * Revision 1.37 2001/08/06 14:49:22 fs * #87690# +connectRowset * diff --git a/connectivity/source/cpool/ZDriverWrapper.cxx b/connectivity/source/cpool/ZDriverWrapper.cxx index e47da7eb0887..106ac748384b 100644 --- a/connectivity/source/cpool/ZDriverWrapper.cxx +++ b/connectivity/source/cpool/ZDriverWrapper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ZDriverWrapper.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: fs $ $Date: 2001-06-19 10:53:59 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:10:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -123,9 +123,7 @@ namespace connectivity Any SAL_CALL ODriverWrapper::queryInterface( const Type& _rType ) throw (RuntimeException) { Any aReturn = ODriverWrapper_BASE::queryInterface(_rType); - if (!aReturn.hasValue() && m_xDriverAggregate.is()) - aReturn = m_xDriverAggregate->queryAggregation(_rType); - return aReturn; + return aReturn.hasValue() ? aReturn : (m_xDriverAggregate.is() ? m_xDriverAggregate->queryAggregation(_rType) : aReturn); } //-------------------------------------------------------------------- @@ -175,6 +173,9 @@ namespace connectivity /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.2 2001/06/19 10:53:59 fs + * #88434# overload queryInterface to delegate calls to the aggregate + * * Revision 1.1 2001/05/25 10:56:17 fs * initial checkin - driver rerouting it's connect through the connection pool * diff --git a/connectivity/source/drivers/adabas/BCatalog.cxx b/connectivity/source/drivers/adabas/BCatalog.cxx index 5fcdbdaa0866..848745f8a6d6 100644 --- a/connectivity/source/drivers/adabas/BCatalog.cxx +++ b/connectivity/source/drivers/adabas/BCatalog.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BCatalog.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-08-02 10:41:53 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:12:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -99,12 +99,12 @@ OAdabasCatalog::OAdabasCatalog(SQLHANDLE _aConnectionHdl, OAdabasConnection* _pC ,m_aConnectionHdl(_aConnectionHdl) ,m_xMetaData(m_pConnection->getMetaData( )) { - osl_incrementInterlockedCount( &m_refCount ); - refreshTables(); - refreshViews(); - refreshGroups(); - refreshUsers(); - osl_decrementInterlockedCount( &m_refCount ); +// osl_incrementInterlockedCount( &m_refCount ); +// refreshTables(); +// refreshViews(); +// refreshGroups(); +// refreshUsers(); +// osl_decrementInterlockedCount( &m_refCount ); } // ------------------------------------------------------------------------- void OAdabasCatalog::refreshTables() diff --git a/connectivity/source/drivers/adabas/BConnection.cxx b/connectivity/source/drivers/adabas/BConnection.cxx index f9cbe7325480..3ae9e5631183 100644 --- a/connectivity/source/drivers/adabas/BConnection.cxx +++ b/connectivity/source/drivers/adabas/BConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BConnection.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-05-21 14:29:40 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:12:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -220,7 +220,7 @@ void OAdabasConnection::disposing() { ::osl::MutexGuard aGuard(m_aMutex); - Reference< XComponent > xComp2(m_xCatalog.get(), UNO_QUERY); + Reference< XComponent > xComp2(m_xCatalog, UNO_QUERY); if(xComp2.is()) xComp2->dispose(); @@ -232,14 +232,9 @@ void OAdabasConnection::disposing() ::com::sun::star::uno::Reference< XTablesSupplier > OAdabasConnection::createCatalog() { ::osl::MutexGuard aGuard( m_aMutex ); - Reference< XTablesSupplier > xTab = m_xCatalog; - if(!m_xCatalog.get().is()) - { - OAdabasCatalog *pCat = new OAdabasCatalog(m_aConnectionHandle,this); - xTab = pCat; - m_xCatalog = xTab; - } - return xTab; + if(!m_xCatalog.is()) + m_xCatalog = new OAdabasCatalog(m_aConnectionHandle,this); + return m_xCatalog; } // -------------------------------------------------------------------------------- Reference< XDatabaseMetaData > SAL_CALL OAdabasConnection::getMetaData( ) throw(SQLException, RuntimeException) @@ -289,10 +284,11 @@ Reference< XPreparedStatement > SAL_CALL OAdabasConnection::prepareStatement( co // ----------------------------------------------------------------------------- sal_Int64 SAL_CALL OAdabasConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException) { - if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - return (sal_Int64)this; - - return OConnection_BASE2::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OConnection_BASE2::getSomething(rId); } // ----------------------------------------------------------------------------- Sequence< sal_Int8 > OAdabasConnection::getUnoTunnelImplementationId() diff --git a/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx b/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx index b22f86ddcda9..2dbae006897e 100644 --- a/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx +++ b/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BDatabaseMetaData.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-08-02 10:41:53 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:12:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,81 +92,79 @@ Reference< XResultSet > SAL_CALL OAdabasDatabaseMetaData::getTypeInfo( ) throw( ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(); Reference< XResultSet > xNewRes = pResult; pResult->setTypeInfoMap(); - static ORows aRows; - if(!aRows.size()) + static ::connectivity::ODatabaseMetaDataResultSet::ORows aRows; + if(aRows.empty()) { + aRows.reserve(19); Reference< XResultSet > xRes = OAdabasDatabaseMetaData_BASE::getTypeInfo(); if(xRes.is()) { - ORow aRow(19); - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); + ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(19); Reference< XRow> xRow(xRes,UNO_QUERY); while(xRes->next()) { sal_Int32 nPos = 1; - aRow[nPos++] = xRow->getString (1); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getString (1)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getInt (2); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getInt (2)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getInt (3); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getInt (3)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getString (4); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getString (4)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getString (5); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getString (5)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getString (6); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getString (6)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getInt (7); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getInt (7)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getBoolean (8); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getBoolean (8)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getShort (9); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getShort (9)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getBoolean (10); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getBoolean (10)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getInt (11); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getInt (11)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getBoolean (12); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getBoolean (12)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getString (13); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getString (13)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getShort (14); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getShort (14)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getShort (15); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getShort (15)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getInt (16); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getInt (16)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = xRow->getInt (17); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(xRow->getInt (17)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); - aRow[nPos++] = (sal_Int16)xRow->getInt(18); + aRow[nPos-1]->setNull(); + aRow[nPos++] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int16)xRow->getInt(18)); if(xRow->wasNull()) - aRow[nPos-1].setNull(); + aRow[nPos-1]->setNull(); // we have to fix some incorrect entries - if(!aRow[2].isNull()) + if(!aRow[2]->getValue().isNull()) { - switch((sal_Int32)aRow[2]) + switch((sal_Int32)aRow[2]->getValue()) { case DataType::FLOAT: // aRow[3] = sal_Int32(15); @@ -175,11 +173,11 @@ Reference< XResultSet > SAL_CALL OAdabasDatabaseMetaData::getTypeInfo( ) throw( // aRow[3] = sal_Int32(16); // break; case DataType::DOUBLE: - aRow[2] = DataType::DOUBLE; - aRow[3] = sal_Int32(18); + aRow[2]->setValue(DataType::DOUBLE); + aRow[3]->setValue(sal_Int32(18)); break; case DataType::TIMESTAMP: - aRow[3] = sal_Int32(27); + aRow[3]->setValue(sal_Int32(27)); break; default: break; diff --git a/connectivity/source/drivers/adabas/BDriver.cxx b/connectivity/source/drivers/adabas/BDriver.cxx index 7701259ccf14..d32df41a27b8 100644 --- a/connectivity/source/drivers/adabas/BDriver.cxx +++ b/connectivity/source/drivers/adabas/BDriver.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BDriver.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: fs $ $Date: 2001-06-14 09:15:25 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:12:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -204,9 +204,7 @@ Sequence< ::rtl::OUString > SAL_CALL ODriver::getSupportedServiceNames( ) throw Any SAL_CALL ODriver::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = ::cppu::queryInterface(rType, static_cast<XDataDefinitionSupplier*>(this)); - if(aRet.hasValue()) - return aRet; - return ODriver_BASE::queryInterface(rType); + return aRet.hasValue() ? aRet : ODriver_BASE::queryInterface(rType); } //------------------------------------------------------------------ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ) throw( ::com::sun::star::uno::Exception ) diff --git a/connectivity/source/drivers/adabas/BIndexes.cxx b/connectivity/source/drivers/adabas/BIndexes.cxx index 465beeb25313..6e91aa6f791a 100644 --- a/connectivity/source/drivers/adabas/BIndexes.cxx +++ b/connectivity/source/drivers/adabas/BIndexes.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BIndexes.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: oj $ $Date: 2001-08-13 13:58:56 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:12:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -179,7 +179,8 @@ void SAL_CALL OIndexes::appendByDescriptor( const Reference< XPropertySet >& des Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY); Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY); Reference< XPropertySet > xColProp; - for(sal_Int32 i=0;i<xColumns->getCount();++i) + sal_Int32 nCount = xColumns->getCount(); + for(sal_Int32 i=0;i<nCount;++i) { xColumns->getByIndex(i) >>= xColProp; aSql = aSql + aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote; diff --git a/connectivity/source/drivers/adabas/BTable.cxx b/connectivity/source/drivers/adabas/BTable.cxx index b54ff3051890..576db53e31ee 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.22 $ + * $Revision: 1.23 $ * - * last change: $Author: oj $ $Date: 2001-08-01 06:20:31 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:12:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -263,10 +263,11 @@ Sequence< sal_Int8 > OAdabasTable::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OAdabasTable::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 OTable_TYPEDEF::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OTable_TYPEDEF::getSomething(rId); } // ------------------------------------------------------------------------- // XRename diff --git a/connectivity/source/drivers/adabas/BUser.cxx b/connectivity/source/drivers/adabas/BUser.cxx index 06f3a9f9fc59..3d7ab1272dd5 100644 --- a/connectivity/source/drivers/adabas/BUser.cxx +++ b/connectivity/source/drivers/adabas/BUser.cxx @@ -2,9 +2,9 @@ * * $RCSfile: BUser.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-07-17 07:23:54 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:12:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -109,26 +109,19 @@ OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection, construct(); } // ------------------------------------------------------------------------- -Any SAL_CALL OAdabasUser::queryInterface( const Type & rType ) throw(RuntimeException) -{ -// if(rType == ::getCppuType((const ::com::sun::star::uno::Reference< XGroupsSupplier>*)0)) -// return Any(); - - return OUser_TYPEDEF::queryInterface(rType); -} -// ------------------------------------------------------------------------- void OAdabasUser::refreshGroups() { if(!m_pConnection) return; TStringVector aVector; - Reference< XStatement > xStmt = m_pConnection->createStatement( ); + aVector.reserve(7); // we don't know the excatly count of users but this should fit the normal need + Reference< XStatement > xStmt = m_pConnection->createStatement( ); ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT GROUPNAME FROM DOMAIN.USERS WHERE GROUPNAME IS NOT NULL AND GROUPNAME <> ' ' AND USERNAME = '"); aSql += getName( ); aSql += ::rtl::OUString::createFromAscii("'"); - Reference< XResultSet > xResult = xStmt->executeQuery(aSql); + Reference< XResultSet > xResult = xStmt->executeQuery(aSql); if(xResult.is()) { Reference< XRow > xRow(xResult,UNO_QUERY); diff --git a/connectivity/source/drivers/ado/ACallableStatement.cxx b/connectivity/source/drivers/ado/ACallableStatement.cxx index 7ee2cdd83214..cd5373d79a5a 100644 --- a/connectivity/source/drivers/ado/ACallableStatement.cxx +++ b/connectivity/source/drivers/ado/ACallableStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ACallableStatement.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: oj $ $Date: 2001-04-30 10:11:26 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -91,9 +91,7 @@ OCallableStatement::OCallableStatement( OConnection* _pConnection,const OTypeInf Any SAL_CALL OCallableStatement::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OPreparedStatement::queryInterface(rType); - if(!aRet.hasValue()) - aRet = ::cppu::queryInterface(rType,static_cast< XRow*>(this)); - return aRet; + return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< XRow*>(this)); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx index d8dda9e3ee00..70f1b004e678 100644 --- a/connectivity/source/drivers/ado/AColumn.cxx +++ b/connectivity/source/drivers/ado/AColumn.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AColumn.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: oj $ $Date: 2001-05-22 07:40:32 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -147,10 +147,11 @@ Sequence< sal_Int8 > OAdoColumn::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OAdoColumn::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 OColumn_ADO::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OColumn_ADO::getSomething(rId); } // ------------------------------------------------------------------------- void OAdoColumn::construct() diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx index 5832269f041b..099f8a6296e2 100644 --- a/connectivity/source/drivers/ado/AConnection.cxx +++ b/connectivity/source/drivers/ado/AConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AConnection.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: oj $ $Date: 2001-05-17 09:13:23 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -560,10 +560,11 @@ void OConnection::disposing() // ----------------------------------------------------------------------------- sal_Int64 SAL_CALL OConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException) { - if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - return (sal_Int64)this; - - return OConnection_BASE::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OConnection_BASE::getSomething(rId); } // ----------------------------------------------------------------------------- Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId() diff --git a/connectivity/source/drivers/ado/ADatabaseMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx index 4bb4c1fb971e..66bef0cc5990 100644 --- a/connectivity/source/drivers/ado/ADatabaseMetaData.cxx +++ b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ADatabaseMetaData.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-05-23 09:15:43 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -435,34 +435,33 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(); xRef = pResult; pResult->setTablePrivilegesMap(); - ORows aRows; - ORow aRow(8); - aRow[0] = ORowSetValue(); - aRow[1] = ORowSetValue(); - aRow[2] = ORowSetValue(tableNamePattern); - aRow[3] = ORowSetValue(); - aRow[4] = ORowSetValue(); - aRow[5] = ORowSetValue(getUserName()); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("SELECT")); - aRow[7] = ORowSetValue(::rtl::OUString::createFromAscii("NO")); - // bound row - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); + ::connectivity::ODatabaseMetaDataResultSet::ORows aRows; + ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8); + aRows.reserve(8); + + aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[2] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(tableNamePattern); + aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue(); + aRow[5] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(getUserName()); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue(); + aRow[7] = new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO")); + aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("INSERT")); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue(); aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("DELETE")); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue(); aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("UPDATE")); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue(); aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("CREATE")); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue(); aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("READ")); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue(); aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("ALTER")); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue(); aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("DROP")); + aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue(); aRows.push_back(aRow); pResult->setRows(aRows); } diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx index e5deed645407..9f6a68571091 100644 --- a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ADatabaseMetaDataResultSet.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: oj $ $Date: 2001-07-30 09:11:52 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -163,9 +163,7 @@ void ODatabaseMetaDataResultSet::disposing(void) Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OPropertySetHelper::queryInterface(rType); - if(!aRet.hasValue()) - aRet = ODatabaseMetaDataResultSet_BASE::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType); } // ------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/ado/AGroup.cxx b/connectivity/source/drivers/ado/AGroup.cxx index 2b42dc6fbe35..668ce6e1a56d 100644 --- a/connectivity/source/drivers/ado/AGroup.cxx +++ b/connectivity/source/drivers/ado/AGroup.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AGroup.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-08-02 10:49:41 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -175,10 +175,11 @@ Sequence< sal_Int8 > OAdoGroup::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OAdoGroup::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 OGroup_ADO::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OGroup_ADO::getSomething(rId); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/AIndex.cxx b/connectivity/source/drivers/ado/AIndex.cxx index 478a988a0f40..1191f8f8c104 100644 --- a/connectivity/source/drivers/ado/AIndex.cxx +++ b/connectivity/source/drivers/ado/AIndex.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AIndex.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: oj $ $Date: 2001-08-02 10:49:41 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -163,10 +163,11 @@ Sequence< sal_Int8 > OAdoIndex::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OAdoIndex::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 OIndex_ADO::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OIndex_ADO::getSomething(rId); } // ------------------------------------------------------------------------- void SAL_CALL OAdoIndex::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) diff --git a/connectivity/source/drivers/ado/AKey.cxx b/connectivity/source/drivers/ado/AKey.cxx index 0b5e6383f9af..6e3094885497 100644 --- a/connectivity/source/drivers/ado/AKey.cxx +++ b/connectivity/source/drivers/ado/AKey.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AKey.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: oj $ $Date: 2001-08-02 10:49:41 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -154,10 +154,11 @@ Sequence< sal_Int8 > OAdoKey::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OAdoKey::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 OKey_ADO::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OKey_ADO::getSomething(rId); } // ------------------------------------------------------------------------- void OAdoKey::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception) diff --git a/connectivity/source/drivers/ado/APreparedStatement.cxx b/connectivity/source/drivers/ado/APreparedStatement.cxx index 0e518285d4d8..f174206a8dd8 100644 --- a/connectivity/source/drivers/ado/APreparedStatement.cxx +++ b/connectivity/source/drivers/ado/APreparedStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: APreparedStatement.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-05-17 07:26:59 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -119,13 +119,11 @@ OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const OTypeInf Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OStatement_Base::queryInterface(rType); - if(!aRet.hasValue()) - aRet = ::cppu::queryInterface( rType, + return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType, static_cast< XPreparedStatement*>(this), static_cast< XParameters*>(this), static_cast< XPreparedBatchExecution*>(this), static_cast< XResultSetMetaDataSupplier*>(this)); - return aRet; } // ------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx index 81c98a324bb9..88581eb0666f 100644 --- a/connectivity/source/drivers/ado/AResultSet.cxx +++ b/connectivity/source/drivers/ado/AResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AResultSet.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-07-30 08:52:12 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -208,9 +208,7 @@ void OResultSet::disposing(void) Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OPropertySetHelper::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OResultSet_BASE::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType); } // ------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/ado/AStatement.cxx b/connectivity/source/drivers/ado/AStatement.cxx index 356a1f54f73e..0e9dae69ecc8 100644 --- a/connectivity/source/drivers/ado/AStatement.cxx +++ b/connectivity/source/drivers/ado/AStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AStatement.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:48:07 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -175,9 +175,7 @@ void SAL_CALL OStatement_Base::release() throw(RuntimeException) Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OStatement_BASE::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OPropertySetHelper::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType); } // ------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OStatement_Base::getTypes( ) throw(::com::sun::star::uno::RuntimeException) @@ -385,9 +383,7 @@ Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLEx Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this)); - if(!aRet.hasValue()) - aRet = OStatement_Base::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx index dbd00d22dcd6..6971a3991dd3 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.19 $ + * $Revision: 1.20 $ * - * last change: $Author: oj $ $Date: 2001-08-02 10:41:52 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -244,10 +244,11 @@ Sequence< sal_Int8 > OAdoTable::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OAdoTable::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 OTable_TYPEDEF::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OTable_TYPEDEF::getSomething(rId); } // ------------------------------------------------------------------------- // XRename diff --git a/connectivity/source/drivers/ado/AUser.cxx b/connectivity/source/drivers/ado/AUser.cxx index a59c91cda785..c117d3300bc7 100644 --- a/connectivity/source/drivers/ado/AUser.cxx +++ b/connectivity/source/drivers/ado/AUser.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AUser.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: oj $ $Date: 2001-08-02 10:41:52 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -164,10 +164,11 @@ Sequence< sal_Int8 > OAdoUser::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OAdoUser::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 OUser_TYPEDEF::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OUser_TYPEDEF::getSomething(rId); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/ado/AView.cxx b/connectivity/source/drivers/ado/AView.cxx index e26125a84c57..560dfa80382b 100644 --- a/connectivity/source/drivers/ado/AView.cxx +++ b/connectivity/source/drivers/ado/AView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: AView.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2001-05-23 09:13:09 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:13:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -142,10 +142,11 @@ Sequence< sal_Int8 > OAdoView::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OAdoView::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 OView_ADO::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OView_ADO::getSomething(rId); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/calc/CConnection.cxx b/connectivity/source/drivers/calc/CConnection.cxx index 7bd6abdcbcac..cc9b1151e65a 100644 --- a/connectivity/source/drivers/calc/CConnection.cxx +++ b/connectivity/source/drivers/calc/CConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CConnection.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-07-16 09:58:39 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:18:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -215,7 +215,7 @@ Reference< XDatabaseMetaData > SAL_CALL OCalcConnection::getMetaData( ) throw(S { ::osl::MutexGuard aGuard( m_aMutex ); Reference< XTablesSupplier > xTab = m_xCatalog; - if(!m_xCatalog.get().is()) + if(!m_xCatalog.is()) { OCalcCatalog *pCat = new OCalcCatalog(this); xTab = pCat; diff --git a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx index 942545719e5d..4828de53d6a0 100644 --- a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx +++ b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CDatabaseMetaData.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:40:01 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:18:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -147,72 +147,75 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTypeInfo( ) throw(SQ ::osl::MutexGuard aGuard( m_aMutex ); ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); - Reference< XResultSet > xRef = pResult; + Reference< XResultSet > xRef = pResult; pResult->setTypeInfoMap(); - ORows aRows; - ORow aRow; - - aRow.push_back(ORowSetValue()); - aRow.push_back(ORowSetValue(::rtl::OUString::createFromAscii("VARCHAR"))); - aRow.push_back(ORowSetValue(DataType::VARCHAR)); - aRow.push_back(ORowSetValue((sal_Int32)65535)); - aRow.push_back(ORowSetValue(::rtl::OUString::createFromAscii("'"))); - aRow.push_back(ORowSetValue(::rtl::OUString::createFromAscii("'"))); - aRow.push_back(ORowSetValue()); - aRow.push_back(ORowSetValue((sal_Int32)ColumnValue::NULLABLE)); - aRow.push_back(ORowSetValue((sal_Int32)1)); - aRow.push_back(ORowSetValue((sal_Int32)ColumnSearch::CHAR)); - 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("DECIMAL")); - aRow[2] = ORowSetValue(DataType::DECIMAL); - aRow[3] = ORowSetValue((sal_Int32)0); - aRow[9] = ORowSetValue(ColumnSearch::BASIC); - aRow[15] = ORowSetValue((sal_Int32)0); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("BOOL")); - aRow[2] = ORowSetValue(DataType::BIT); - aRow[3] = ORowSetValue((sal_Int32)20); - aRow[9] = ORowSetValue(ColumnSearch::BASIC); - aRow[15] = ORowSetValue((sal_Int32)15); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("DATE")); - aRow[2] = ORowSetValue(DataType::DATE); - aRow[3] = ORowSetValue((sal_Int32)0); - aRow[9] = ORowSetValue(ColumnSearch::BASIC); - aRow[15] = ORowSetValue((sal_Int32)0); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("TIME")); - aRow[2] = ORowSetValue(DataType::TIME); - aRow[3] = ORowSetValue((sal_Int32)0); - aRow[9] = ORowSetValue(ColumnSearch::BASIC); - aRow[15] = ORowSetValue((sal_Int32)0); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("TIMESTAMP")); - aRow[2] = ORowSetValue(DataType::TIMESTAMP); - aRow[3] = ORowSetValue((sal_Int32)0); - aRow[9] = ORowSetValue(ColumnSearch::BASIC); - aRow[15] = ORowSetValue((sal_Int32)0); - aRows.push_back(aRow); + + static ODatabaseMetaDataResultSet::ORows aRows; + if(aRows.empty()) + { + ODatabaseMetaDataResultSet::ORow aRow; + + aRows.reserve(6); + aRow.reserve(18); + + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR"))); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::VARCHAR)); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)65535)); + aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); + aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue()); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); // ORowSetValue((sal_Int32)ColumnValue::NULLABLE) + aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR)); + 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("DECIMAL")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::DECIMAL); + aRow[3] = ODatabaseMetaDataResultSet::get0Value(); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOL")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::BIT); + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)20); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[15] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)15); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::DATE); + aRow[3] = ODatabaseMetaDataResultSet::get0Value(); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIME")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::TIME); + aRow[3] = ODatabaseMetaDataResultSet::get0Value(); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::TIMESTAMP); + aRow[3] = ODatabaseMetaDataResultSet::get0Value(); + aRow[9] = ODatabaseMetaDataResultSet::getBasicValue(); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + aRows.push_back(aRow); + } pResult->setRows(aRows); return xRef; @@ -249,13 +252,11 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::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); - aRow[10] = (sal_Int32)10; + ODatabaseMetaDataResultSet::ORows aRows; + ODatabaseMetaDataResultSet::ORow aRow(19); + + 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(); @@ -266,7 +267,7 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getColumns( Reference< XColumnsSupplier> xTable; xNames->getByName(*pTabBegin) >>= xTable; 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()) @@ -281,43 +282,43 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getColumns( { if(match(columnNamePattern,*pBegin,'\0')) { - aRow[4] = *pBegin; + aRow[4] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator( *pBegin); xColumns->getByName(*pBegin) >>= xColumn; OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!"); - aRow[5] = ::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))); - aRow[6] = ::comphelper::getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))); - aRow[7] = ::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))); + aRow[5] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))); + aRow[6] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::comphelper::getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))); + aRow[7] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))); // aRow[8] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); - aRow[9] = ::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))); - aRow[11] = ::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))); + aRow[9] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))); + aRow[11] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))); // aRow[12] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)); - aRow[13] = ::comphelper::getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))); + aRow[13] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::comphelper::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])) + 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); } @@ -341,7 +342,7 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getVersionColumns( ::osl::MutexGuard aGuard( m_aMutex ); ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); - Reference< XResultSet > xRef = pResult; + Reference< XResultSet > xRef = pResult; pResult->setVersionColumnsMap(); return xRef; } @@ -401,11 +402,9 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getIndexInfo( if(!xNames.is()) throw SQLException(); - ORows aRows; ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); Reference< XResultSet > xRef = pResult; pResult->setIndexInfoMap(); - pResult->setRows(aRows); return xRef; } @@ -628,21 +627,18 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables( throw SQLException(); Sequence< ::rtl::OUString > aSheetNames = xSheets->getElementNames(); - ORows aRows; + ODatabaseMetaDataResultSet::ORows aRows; sal_Int32 nSheetCount = aSheetNames.getLength(); for (sal_Int32 nSheet=0; nSheet<nSheetCount; nSheet++) { ::rtl::OUString aName = aSheetNames[nSheet]; if ( !lcl_IsEmptyOrHidden( xSheets, aName ) ) { - ORow aRow(3); - aRow.push_back(ORowSetValue(aName)); - aRow.push_back(ORowSetValue(aTable)); - aRow.push_back(ORowSetValue()); - // bound row - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); + ODatabaseMetaDataResultSet::ORow aRow(3); + aRow.reserve(6); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(aName)); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(aTable)); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRows.push_back(aRow); } } @@ -663,14 +659,11 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables( ::rtl::OUString aName = aDBNames[nRange]; if ( !lcl_IsUnnamed( xRanges, aName ) ) { - ORow aRow(3); - aRow.push_back(ORowSetValue(aName)); - aRow.push_back(ORowSetValue(aTable)); - aRow.push_back(ORowSetValue()); - // bound row - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); + ODatabaseMetaDataResultSet::ORow aRow(3); + aRow.reserve(6); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(aName)); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(aTable)); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); aRows.push_back(aRow); } } @@ -681,4 +674,6 @@ Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables( return xRef; } +// ----------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/calc/CResultSet.cxx b/connectivity/source/drivers/calc/CResultSet.cxx index 8686bdae9f1c..3101f22dadb2 100644 --- a/connectivity/source/drivers/calc/CResultSet.cxx +++ b/connectivity/source/drivers/calc/CResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CResultSet.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-07-16 09:58:39 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:18:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -120,9 +120,7 @@ sal_Bool SAL_CALL OCalcResultSet::supportsService( const ::rtl::OUString& _rServ Any SAL_CALL OCalcResultSet::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OResultSet::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OCalcResultSet_BASE::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : OCalcResultSet_BASE::queryInterface(rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL OCalcResultSet::getTypes( ) throw( RuntimeException) diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx index fa037628a2c0..609b85afda38 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.14 $ + * $Revision: 1.15 $ * - * last change: $Author: oj $ $Date: 2001-05-31 06:11:58 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:18:05 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -738,10 +738,7 @@ Any SAL_CALL OCalcTable::queryInterface( const Type & rType ) throw(RuntimeExcep return Any(); Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); - if(aRet.hasValue()) - return aRet; - - return OTable_TYPEDEF::queryInterface(rType); + return aRet.hasValue() ? aRet : OTable_TYPEDEF::queryInterface(rType); } //-------------------------------------------------------------------------- @@ -764,10 +761,11 @@ Sequence< sal_Int8 > OCalcTable::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OCalcTable::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 OCalcTable_BASE::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OCalcTable_BASE::getSomething(rId); } //------------------------------------------------------------------ sal_Int32 OCalcTable::getCurrentLastPos() const diff --git a/connectivity/source/drivers/dbase/DColumns.cxx b/connectivity/source/drivers/dbase/DColumns.cxx index 5077aca7a74e..387c15aa7d88 100644 --- a/connectivity/source/drivers/dbase/DColumns.cxx +++ b/connectivity/source/drivers/dbase/DColumns.cxx @@ -2,9 +2,9 @@ * * $RCSfile: DColumns.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-05-30 10:44:15 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:19:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -105,9 +105,7 @@ void ODbaseColumns::impl_refresh() throw(RuntimeException) // ------------------------------------------------------------------------- Reference< XPropertySet > ODbaseColumns::createEmptyObject() { - sdbcx::OColumn* pRet = new sdbcx::OColumn(isCaseSensitive()); - Reference< XPropertySet > xRet = pRet; - return xRet; + return new sdbcx::OColumn(isCaseSensitive()); } // ----------------------------------------------------------------------------- // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx index 0c9cf985018e..87735cb813b4 100644 --- a/connectivity/source/drivers/file/FConnection.cxx +++ b/connectivity/source/drivers/file/FConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FConnection.cxx,v $ * - * $Revision: 1.31 $ + * $Revision: 1.32 $ * - * last change: $Author: oj $ $Date: 2001-07-30 08:52:11 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -432,7 +432,8 @@ void OConnection::disposing() m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>(); m_xDir = NULL; m_xContent = NULL; - m_xCatalog = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>(); + ::comphelper::disposeComponent(m_xCatalog); + m_xCatalog = ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier>(); dispose_ChildImpl(); OConnection_BASE::disposing(); @@ -442,7 +443,7 @@ void OConnection::disposing() { ::osl::MutexGuard aGuard( m_aMutex ); Reference< XTablesSupplier > xTab = m_xCatalog; - if(!m_xCatalog.get().is()) + if(!m_xCatalog.is()) { xTab = new OFileCatalog(this); m_xCatalog = xTab; @@ -470,10 +471,10 @@ void OConnection::disposing() // ----------------------------------------------------------------------------- sal_Int64 SAL_CALL OConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException) { - if (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) - return (sal_Int64)this; - - return 0; + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : sal_Int64(0); } // ----------------------------------------------------------------------------- Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId() diff --git a/connectivity/source/drivers/file/FDatabaseMetaData.cxx b/connectivity/source/drivers/file/FDatabaseMetaData.cxx index f349590d54f7..598a9180e87a 100644 --- a/connectivity/source/drivers/file/FDatabaseMetaData.cxx +++ b/connectivity/source/drivers/file/FDatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FDatabaseMetaData.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: oj $ $Date: 2001-07-30 08:52:11 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -224,7 +224,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( Reference<XRow> xRow(xResultSet,UNO_QUERY); String aFilenameExtension = m_pConnection->getExtension(); - ORows aRows; + ODatabaseMetaDataResultSet::ORows aRows; // scan the directory for tables ::rtl::OUString aName; INetURLObject aURL; @@ -234,7 +234,8 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( aName = xRow->getString(1); aURL.SetSmartProtocol(INET_PROT_FILE); aURL.SetSmartURL(aName); - ORow aRow(3); + ODatabaseMetaDataResultSet::ORow aRow(3); + aRow.reserve(6); sal_Bool bNewRow = sal_False; if (aFilenameExtension.Len()) { @@ -244,7 +245,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( sal_Unicode nChar = aName.toChar(); if(match(tableNamePattern,aName.getStr(),'\0') && (nChar < '0' || nChar > '9')) { - aRow.push_back(ORowSetValue(aName)); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(aName)); bNewRow = sal_True; } } @@ -259,7 +260,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( sal_Unicode nChar = aURL.getBase().GetChar(0); if(match(tableNamePattern,aURL.getBase().GetBuffer(),'\0') && (nChar < '0' || nChar > '9')) { - aRow.push_back(ORowSetValue(::rtl::OUString(aURL.getBase()))); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString(aURL.getBase()))); bNewRow = sal_True; } break; @@ -273,12 +274,9 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables( } if(bNewRow) { - aRow.push_back(ORowSetValue(aTable)); - aRow.push_back(ORowSetValue()); - // bound row - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(aTable)); + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRows.push_back(aRow); } } @@ -432,7 +430,7 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); Reference< XResultSet > xRef = pResult; pResult->setTablePrivilegesMap(); - ORows aRows; + ODatabaseMetaDataResultSet::ORows aRows; Reference< ::com::sun::star::sdbcx::XTablesSupplier > xTabSup = m_pConnection->createCatalog(); @@ -446,22 +444,11 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( { if(match(tableNamePattern,pBegin->getStr(),'\0')) { - static ORow aRow(8); - // aRow[0] = ORowSetValue(); - // aRow[1] = ORowSetValue(); - aRow[2] = ORowSetValue(*pBegin); - // aRow[3] = ORowSetValue(); - // aRow[4] = ORowSetValue(); - // aRow[5] = ORowSetValue(); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("SELECT")); - aRow[7] = ORowSetValue(::rtl::OUString::createFromAscii("NO")); - // bound row - if(!aRow.begin()->isBound()) - { - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); - } + static ODatabaseMetaDataResultSet::ORow aRow(8); + + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(*pBegin); + aRow[6] = ODatabaseMetaDataResultSet::getSelectValue(); + aRow[7] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO")); aRows.push_back(aRow); Reference< XPropertySet> xTable; @@ -476,22 +463,22 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges( { if(!pTable->isReadOnly()) { - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("INSERT")); + aRow[6] = ODatabaseMetaDataResultSet::getInsertValue(); aRows.push_back(aRow); if(!m_pConnection->showDeleted()) { - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("DELETE")); + aRow[6] = ODatabaseMetaDataResultSet::getDeleteValue(); aRows.push_back(aRow); } - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("UPDATE")); + aRow[6] = ODatabaseMetaDataResultSet::getUpdateValue(); aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("CREATE")); + aRow[6] = ODatabaseMetaDataResultSet::getCreateValue(); aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("READ")); + aRow[6] = ODatabaseMetaDataResultSet::getReadValue(); aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("ALTER")); + aRow[6] = ODatabaseMetaDataResultSet::getAlterValue(); aRows.push_back(aRow); - aRow[6] = ORowSetValue(::rtl::OUString::createFromAscii("DROP")); + aRow[6] = ODatabaseMetaDataResultSet::getDropValue(); aRows.push_back(aRow); } } @@ -709,15 +696,14 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLE ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(); Reference< XResultSet > xRef = pResult; pResult->setTableTypes(); - ORows aRows; - ORow aRow; - aRow.push_back(ORowSetValue()); - aRow.push_back(ORowSetValue(::rtl::OUString::createFromAscii("TABLE"))); - // bound row - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); - aRows.push_back(aRow); + static ODatabaseMetaDataResultSet::ORows aRows; + if(aRows.empty()) + { + ODatabaseMetaDataResultSet::ORow aRow; + aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("TABLE"))); + aRows.push_back(aRow); + } pResult->setRows(aRows); return xRef; } diff --git a/connectivity/source/drivers/file/FNoException.cxx b/connectivity/source/drivers/file/FNoException.cxx index 540914620d9e..0117eb0c238b 100644 --- a/connectivity/source/drivers/file/FNoException.cxx +++ b/connectivity/source/drivers/file/FNoException.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FNoException.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2001-05-23 09:17:04 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -70,6 +70,9 @@ #ifndef _CONNECTIVITY_FILE_FRESULTSET_HXX_ #include "file/FResultSet.hxx" #endif +#ifndef _CONNECTIVITY_FILE_OPREPAREDSTATEMENT_HXX_ +#include "file/FPreparedStatement.hxx" +#endif #ifndef _CONNECTIVITY_FILE_VALUE_HXX_ #include "FValue.hxx" #endif @@ -134,7 +137,7 @@ sal_Bool OResultSet::isCount() const ); } // ----------------------------------------------------------------------------- -void OResultSet::scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes) +void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes) { DBG_ASSERT(pParseNode != NULL,"OResultSet: interner Fehler: ungueltiger ParseNode"); @@ -172,7 +175,7 @@ connectivity::file::OFILEKeyCompare(const void * elem1, const void * elem2) // oder alle Columns gleich. for (UINT16 i = 0; i < SQL_ORDERBYKEYS && pIndex->eKeyType[i] != SQL_ORDERBYKEY_NONE; i++) { - const int nGreater = (pIndex->bAscending[i]) ? 1 : -1; + const int nGreater = (pIndex->m_aAscending[i]) ? 1 : -1; const int nLess = - nGreater; // Vergleich (je nach Datentyp): @@ -256,16 +259,17 @@ OFILESortIndex * OFILESortIndex::pCurrentIndex; CharSet OFILESortIndex::eCurrentCharSet; //------------------------------------------------------------------ OFILESortIndex::OFILESortIndex(const OKeyType eKeyType2[], // Genau 3 Eintraege! - const BOOL bAscending2[], // Genau 3 Eintraege! + const ::std::vector<sal_Int16>& _aAscending, // Genau 3 Eintraege! INT32 nMaxNumberOfRows, rtl_TextEncoding eSet) // Obere Schranke fuer die Anzahl indizierbarer Zeilen : nMaxCount(nMaxNumberOfRows), nCount(0), - bFrozen(FALSE), eCharSet(eSet) + bFrozen(FALSE), + eCharSet(eSet), + m_aAscending(_aAscending) { for (int j = 0; j < SQL_ORDERBYKEYS; j++) { eKeyType[j] = eKeyType2[j]; - bAscending[j] = bAscending2[j]; } #if defined MAX_KEYSET_SIZE @@ -396,11 +400,11 @@ OFILEKeyValue* OResultSet::GetOrderbyKeyValue(OValueRow _rRow) UINT32 nBookmarkValue = Abs((sal_Int32)(*_rRow)[0]); OFILEKeyValue* pKeyValue = new OFILEKeyValue((UINT32)nBookmarkValue); - for (int i = 0; i < sizeof m_nOrderbyColumnNumber / sizeof (* m_nOrderbyColumnNumber); i++) + for (int i = 0; i < m_aOrderbyColumnNumber.size(); ++i) { - if (m_nOrderbyColumnNumber[i] == SQL_COLUMN_NOTFOUND) break; + if (m_aOrderbyColumnNumber[i] == SQL_COLUMN_NOTFOUND) break; - ORowSetValue xKey = (*_rRow)[m_nOrderbyColumnNumber[i]]; + ORowSetValue xKey = (*_rRow)[m_aOrderbyColumnNumber[i]]; switch (xKey.getTypeKind()) { case ::com::sun::star::sdbc::DataType::VARCHAR: diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx index a6f9fb329f65..633eeb1a6e19 100644 --- a/connectivity/source/drivers/file/FPreparedStatement.cxx +++ b/connectivity/source/drivers/file/FPreparedStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FPreparedStatement.cxx,v $ * - * $Revision: 1.22 $ + * $Revision: 1.23 $ * - * last change: $Author: oj $ $Date: 2001-07-30 08:52:11 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -61,6 +61,9 @@ #include <stdio.h> +#ifndef _CONNECTIVITY_SDBCX_COLUMN_HXX_ +#include "connectivity/sdbcx/VColumn.hxx" +#endif #ifndef _OSL_DIAGNOSE_H_ #include <osl/diagnose.h> #endif @@ -91,9 +94,15 @@ #ifndef _CONNECTIVITY_DBTOOLS_HXX_ #include "connectivity/dbtools.hxx" #endif - +#ifndef _COMPHELPER_TYPES_HXX_ +#include <comphelper/types.hxx> +#endif +#ifndef _COM_SUN_STAR_SDBC_COLUMNVALUE_HPP_ +#include <com/sun/star/sdbc/ColumnValue.hpp> +#endif using namespace connectivity; +using namespace comphelper; using namespace ::dbtools; using namespace connectivity::file; using namespace com::sun::star::uno; @@ -109,69 +118,71 @@ IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbc.driver.file.Prepare OPreparedStatement::OPreparedStatement( OConnection* _pConnection) : OStatement_BASE2( _pConnection ) ,m_pResultSet(NULL) - ,m_pTable(NULL) + ,m_pEvaluationKeySet(NULL) { } // ------------------------------------------------------------------------- void OPreparedStatement::disposing() { + ::osl::MutexGuard aGuard(m_aMutex); + + if(m_pResultSet) + m_pResultSet->release(); + clearMyResultSet(); + OStatement_BASE2::disposing(); - ::osl::MutexGuard aGuard(m_aMutex); m_xMetaData = NULL; - if(m_aRow.isValid()) + if(m_aParameterRow.isValid()) { - m_aRow->clear(); - m_aRow = NULL; + m_aParameterRow->clear(); + m_aParameterRow = NULL; } - - if(m_pTable) + if(m_aEvaluateRow.isValid()) { - m_pTable->release(); - m_pTable = NULL; + m_aEvaluateRow->clear(); + m_aEvaluateRow = NULL; } + delete m_pEvaluationKeySet; + m_xParamColumns = NULL; } // ------------------------------------------------------------------------- void OPreparedStatement::construct(const ::rtl::OUString& sql) throw(SQLException, RuntimeException) { - ::rtl::OUString aErr; - m_pParseTree = m_aParser.parseTree(aErr,sql); - if(m_pParseTree) - { - m_aSQLIterator.setParseTree(m_pParseTree); - m_aSQLIterator.traverseAll(); - const OSQLTables& xTabs = m_aSQLIterator.getTables(); - if(xTabs.begin() == xTabs.end()) - throw SQLException(::rtl::OUString::createFromAscii("Driver does not support this function!"),*this,::rtl::OUString::createFromAscii("IM001"),0,Any()); + OStatement_Base::construct(sql); - // at this moment we support only one table per select statement - Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xTabs.begin()->second,UNO_QUERY); - if(xTunnel.is()) - { - if(m_pTable) - m_pTable->release(); - m_pTable = (OFileTable*)xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()); - if(m_pTable) - m_pTable->acquire(); - } + m_aParameterRow = new OValueVector(); + m_aParameterRow->push_back(sal_Int32(0)); + m_xParamColumns = new OSQLColumns(); - m_aRow = new OValueVector(); - m_aRow->push_back(sal_Int32(0)); - } - else - throw SQLException(aErr,*this,::rtl::OUString(),0,Any()); + Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); + // set the binding of the resultrow + m_aEvaluateRow = new OValueVector(xNames->getCount()); + + (*m_aEvaluateRow)[0].setBound(sal_True); + ::std::for_each(m_aEvaluateRow->begin()+1,m_aEvaluateRow->end(),TSetBound(sal_False)); + + // describe all parameters need for the resultset + describeParameter(); + + OResultSet::setBoundedColumns(m_aEvaluateRow,m_xParamColumns,xNames,sal_False,m_xDBMetaData,m_aColMapping); + + GetAssignValues(); + + m_pResultSet = createResultSet(); + m_pResultSet->acquire(); + m_xResultSet = Reference<XResultSet>(m_pResultSet); + initializeResultSet(m_pResultSet); } // ------------------------------------------------------------------------- Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OStatement_BASE2::queryInterface(rType); - if(!aRet.hasValue()) - aRet = ::cppu::queryInterface( rType, + return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType, static_cast< XPreparedStatement*>(this), static_cast< XParameters*>(this), static_cast< XResultSetMetaDataSupplier*>(this)); - return aRet; } // ------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) @@ -310,7 +321,10 @@ void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 s ::osl::MutexGuard aGuard( m_aMutex ); checkAndResizeParameters(parameterIndex); - (*m_aRow)[parameterIndex].setNull(); + if(m_aAssignValues.isValid()) + (*m_aAssignValues)[m_aParameterIndexes[parameterIndex]].setNull(); + else + (*m_aParameterRow)[parameterIndex].setNull(); } // ------------------------------------------------------------------------- @@ -395,8 +409,8 @@ void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, Runtim ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OStatement_BASE::rBHelper.bDisposed); - m_aRow->clear(); - m_aRow->push_back(sal_Int32(0)); + m_aParameterRow->clear(); + m_aParameterRow->push_back(sal_Int32(0)); } // ------------------------------------------------------------------------- OResultSet* OPreparedStatement::createResultSet() @@ -406,18 +420,22 @@ OResultSet* OPreparedStatement::createResultSet() // ----------------------------------------------------------------------------- Reference<XResultSet> OPreparedStatement::initResultSet() { - ::comphelper::disposeComponent(m_xResultSet.get()); - m_pResultSet = createResultSet(); + m_pResultSet->clear(); Reference<XResultSet> xRs(m_pResultSet); - m_xResultSet = xRs; - if(m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT || m_aSQLIterator.getStatementType() == SQL_STATEMENT_UPDATE) - m_pResultSet->describeParameter(); - m_pResultSet->setParameterRow(m_aRow); + +// UINT16 nCount = m_aAssignValues.isValid() ? m_aAssignValues->size() : 1; // 1 ist wichtig fr die Kriterien +// for (UINT16 j = 1; j < nCount; ++j) +// { +// UINT32 nParameter = (*m_aAssignValues).getParameterIndex(j); +// if (nParameter != SQL_NO_PARAMETER) +// (*m_aAssignValues)[j] = (*m_aParameterRow)[(UINT16)nParameter]; +// } + m_pResultSet->OpenImpl(); + return xRs; } // ----------------------------------------------------------------------------- -// ----------------------------------------------------------------------------- void SAL_CALL OPreparedStatement::acquire() throw(::com::sun::star::uno::RuntimeException) { OStatement_BASE2::acquire(); @@ -431,10 +449,10 @@ void SAL_CALL OPreparedStatement::release() throw(::com::sun::star::uno::Runtime void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex) { ::connectivity::checkDisposed(OStatement_BASE::rBHelper.bDisposed); - if (parameterIndex < 1) + if(m_aAssignValues.isValid() && (parameterIndex < 1 || parameterIndex >= m_aParameterIndexes.size())) throwInvalidIndexException(*this); - else if ((sal_Int32)(*m_aRow).size() <= parameterIndex) - (*m_aRow).resize(parameterIndex+1); + else if ((sal_Int32)(*m_aParameterRow).size() <= parameterIndex) + (*m_aParameterRow).resize(parameterIndex+1); } // ----------------------------------------------------------------------------- void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x) @@ -442,7 +460,436 @@ void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const ORowSetVal ::osl::MutexGuard aGuard( m_aMutex ); checkAndResizeParameters(parameterIndex); - (*m_aRow)[parameterIndex] = x; + if(m_aAssignValues.isValid()) + (*m_aAssignValues)[m_aParameterIndexes[parameterIndex]] = x; + else + (*m_aParameterRow)[parameterIndex] = x; } // ----------------------------------------------------------------------------- +void OPreparedStatement::GetAssignValues() +{ + if (m_pParseTree == NULL) + { + ::dbtools::throwFunctionSequenceException(*this); + return; + } + + if (SQL_ISRULE(m_pParseTree,select_statement)) + // Keine zu setzenden Werte bei SELECT + return; + else if (SQL_ISRULE(m_pParseTree,insert_statement)) + { + // Row fuer die zu setzenden Werte anlegen (Referenz durch new) + if(m_aAssignValues.isValid()) + m_aAssignValues->clear(); + sal_Int32 nCount = Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount(); + m_aAssignValues = new OAssignValues(nCount); + m_aParameterIndexes.resize(nCount+1,SQL_NO_PARAMETER); + + // Liste der Columns-Namen, die in der column_commalist vorkommen (mit ; getrennt): + ::std::vector<String> aColumnNameList; + + OSL_ENSURE(m_pParseTree->count() >= 4,"OResultSet: Fehler im Parse Tree"); + + OSQLParseNode * pOptColumnCommalist = m_pParseTree->getChild(3); + OSL_ENSURE(pOptColumnCommalist != NULL,"OResultSet: Fehler im Parse Tree"); + OSL_ENSURE(SQL_ISRULE(pOptColumnCommalist,opt_column_commalist),"OResultSet: Fehler im Parse Tree"); + if (pOptColumnCommalist->count() == 0) + { + const Sequence< ::rtl::OUString>& aNames = m_xColNames->getElementNames(); + const ::rtl::OUString* pBegin = aNames.getConstArray(); + aColumnNameList.insert(aColumnNameList.begin(),::std::vector<String>::const_iterator(pBegin),::std::vector<String>::const_iterator(pBegin + aNames.getLength())); + } + else + { + OSL_ENSURE(pOptColumnCommalist->count() == 3,"OResultSet: Fehler im Parse Tree"); + + OSQLParseNode * pColumnCommalist = pOptColumnCommalist->getChild(1); + OSL_ENSURE(pColumnCommalist != NULL,"OResultSet: Fehler im Parse Tree"); + OSL_ENSURE(SQL_ISRULE(pColumnCommalist,column_commalist),"OResultSet: Fehler im Parse Tree"); + OSL_ENSURE(pColumnCommalist->count() > 0,"OResultSet: Fehler im Parse Tree"); + + // Alle Columns in der column_commalist ... + for (sal_uInt32 i = 0; i < pColumnCommalist->count(); i++) + { + OSQLParseNode * pCol = pColumnCommalist->getChild(i); + OSL_ENSURE(pCol != NULL,"OResultSet: Fehler im Parse Tree"); + aColumnNameList.push_back(pCol->getTokenValue()); + } + } + if(!aColumnNameList.size()) + throwFunctionSequenceException(*this); + + // Werte ... + OSQLParseNode * pValuesOrQuerySpec = m_pParseTree->getChild(4); + OSL_ENSURE(pValuesOrQuerySpec != NULL,"OResultSet: pValuesOrQuerySpec darf nicht NULL sein!"); + OSL_ENSURE(SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec),"OResultSet: ! SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec)"); + OSL_ENSURE(pValuesOrQuerySpec->count() > 0,"OResultSet: pValuesOrQuerySpec->count() <= 0"); + + // nur "VALUES" ist erlaubt ... + if (! SQL_ISTOKEN(pValuesOrQuerySpec->getChild(0),VALUES)) + throwFunctionSequenceException(*this); + + OSL_ENSURE(pValuesOrQuerySpec->count() == 2,"OResultSet: pValuesOrQuerySpec->count() != 2"); + + // Liste von Werten + OSQLParseNode * pInsertAtomCommalist = pValuesOrQuerySpec->getChild(1); + OSL_ENSURE(pInsertAtomCommalist != NULL,"OResultSet: pInsertAtomCommalist darf nicht NULL sein!"); + OSL_ENSURE(pInsertAtomCommalist->count() > 0,"OResultSet: pInsertAtomCommalist <= 0"); + + String aColumnName; + OSQLParseNode * pRow_Value_Const; + xub_StrLen nIndex=0; + for (sal_uInt32 i = 0; i < pInsertAtomCommalist->count(); i++) + { + pRow_Value_Const = pInsertAtomCommalist->getChild(i); // row_value_constructor + if(pRow_Value_Const->count() == 3) // '(' row_value_const_list ')' + { + pRow_Value_Const = pRow_Value_Const->getChild(1); // row_value_const_list + OSL_ENSURE(pRow_Value_Const != NULL,"OResultSet: pRow_Value_Const darf nicht NULL sein!"); + if(SQL_ISRULE(pRow_Value_Const,parameter)) + { + if(pRow_Value_Const->count() == aColumnNameList.size()) + ParseAssignValues(aColumnNameList,pRow_Value_Const,nIndex++); // kann nur ein Columnname vorhanden sein pro Schleife + else + { +// aStatus.Set(SQL_STAT_ERROR, +// String::CreateFromAscii("S1000"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_SYNTAX_ERROR))), +// 0, String() ); + throwFunctionSequenceException(*this); + } + } + else + { + if(pRow_Value_Const->count() == aColumnNameList.size()) + { + for (sal_uInt32 j = 0; j < pRow_Value_Const->count(); ++j) + ParseAssignValues(aColumnNameList,pRow_Value_Const->getChild(j),nIndex++); + } + else + { +// aStatus.Set(SQL_STAT_ERROR, +// String::CreateFromAscii("S1000"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_SYNTAX_ERROR))), +// 0, String() ); + throwFunctionSequenceException(*this); + } + + } + } + else + { + // aStatus.SetStatementTooComplex(); + throwFunctionSequenceException(*this); + } + } + } + else if (SQL_ISRULE(m_pParseTree,update_statement_searched)) + { + if(m_aAssignValues.isValid()) + m_aAssignValues->clear(); + sal_Int32 nCount = Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount(); + m_aAssignValues = new OAssignValues(nCount); + m_aParameterIndexes.resize(nCount+1,SQL_NO_PARAMETER); + + OSL_ENSURE(m_pParseTree->count() >= 4,"OResultSet: Fehler im Parse Tree"); + + OSQLParseNode * pAssignmentCommalist = m_pParseTree->getChild(3); + OSL_ENSURE(pAssignmentCommalist != NULL,"OResultSet: pAssignmentCommalist == NULL"); + OSL_ENSURE(SQL_ISRULE(pAssignmentCommalist,assignment_commalist),"OResultSet: Fehler im Parse Tree"); + OSL_ENSURE(pAssignmentCommalist->count() > 0,"OResultSet: pAssignmentCommalist->count() <= 0"); + + // Alle Zuweisungen (Kommaliste) bearbeiten ... + ::std::vector< String> aList(1); + for (sal_uInt32 i = 0; i < pAssignmentCommalist->count(); i++) + { + OSQLParseNode * pAssignment = pAssignmentCommalist->getChild(i); + OSL_ENSURE(pAssignment != NULL,"OResultSet: pAssignment == NULL"); + OSL_ENSURE(SQL_ISRULE(pAssignment,assignment),"OResultSet: Fehler im Parse Tree"); + OSL_ENSURE(pAssignment->count() == 3,"OResultSet: pAssignment->count() != 3"); + + OSQLParseNode * pCol = pAssignment->getChild(0); + OSL_ENSURE(pCol != NULL,"OResultSet: pCol == NULL"); + + OSQLParseNode * pComp = pAssignment->getChild(1); + OSL_ENSURE(pComp != NULL,"OResultSet: pComp == NULL"); + OSL_ENSURE(pComp->getNodeType() == SQL_NODE_EQUAL,"OResultSet: pComp->getNodeType() != SQL_NODE_COMPARISON"); + if (pComp->getTokenValue().toChar() != '=') + { + // aStatus.SetInvalidStatement(); + throwFunctionSequenceException(*this); + } + + OSQLParseNode * pVal = pAssignment->getChild(2); + OSL_ENSURE(pVal != NULL,"OResultSet: pVal == NULL"); + aList[0] = pCol->getTokenValue(); + ParseAssignValues(aList,pVal,0); + } + + } +} +// ------------------------------------------------------------------------- +void OPreparedStatement::ParseAssignValues(const ::std::vector< String>& aColumnNameList,OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex) +{ + OSL_ENSURE(nIndex <= aColumnNameList.size(),"SdbFileCursor::ParseAssignValues: nIndex > aColumnNameList.GetTokenCount()"); + String aColumnName(aColumnNameList[nIndex]); + OSL_ENSURE(aColumnName.Len() > 0,"OResultSet: Column-Name nicht gefunden"); + OSL_ENSURE(pRow_Value_Constructor_Elem != NULL,"OResultSet: pRow_Value_Constructor_Elem darf nicht NULL sein!"); + + if (pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_STRING || + pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_INTNUM || + pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_APPROXNUM) + { + // Wert setzen: + SetAssignValue(aColumnName, pRow_Value_Constructor_Elem->getTokenValue()); + } + else if (SQL_ISTOKEN(pRow_Value_Constructor_Elem,NULL)) + { + // NULL setzen + SetAssignValue(aColumnName, String(), TRUE); + } + else if (SQL_ISRULE(pRow_Value_Constructor_Elem,parameter)) + { + // Parameter hinzufuegen, Typ ... entsprechend der Column, der der Wert zugewiesen wird + Reference<XPropertySet> xCol; + m_xColNames->getByName(aColumnName) >>= xCol; + sal_Int32 nParameter = -1; + if(m_xParamColumns.isValid()) + { + OSQLColumns::const_iterator aIter = find(m_xParamColumns->begin(),m_xParamColumns->end(),aColumnName,::comphelper::UStringMixEqual(m_pTable->isCaseSensitive())); + if(aIter != m_xParamColumns->end()) + nParameter = m_xParamColumns->size() - (m_xParamColumns->end() - aIter) + 1;// +1 because the rows start at 1 + } + if(nParameter == -1) + nParameter = AddParameter(pRow_Value_Constructor_Elem,xCol); + // Nr. des Parameters in der Variablen merken: + SetAssignValue(aColumnName, String(), TRUE, nParameter); + } + else + { + // aStatus.SetStatementTooComplex(); + throwFunctionSequenceException(*this); + } +} +//------------------------------------------------------------------ +void OPreparedStatement::SetAssignValue(const String& aColumnName, + const String& aValue, + BOOL bSetNull, + UINT32 nParameter) +{ + Reference<XPropertySet> xCol; + m_xColNames->getByName(aColumnName) >>= xCol; + sal_Int32 nId = Reference<XColumnLocate>(m_xColNames,UNO_QUERY)->findColumn(aColumnName); + // Kommt diese Column ueberhaupt in der Datei vor? + + if (!xCol.is()) + { + // Diese Column gibt es nicht! +// aStatus.Set(SQL_STAT_ERROR, +// String::CreateFromAscii("S0022"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_COLUMN_NOT_FOUND))), +// 0, String() ); + throwFunctionSequenceException(*this); + } + + // Value an die Row mit den zuzuweisenden Werten binden: + // const ODbVariantRef& xValue = (*aAssignValues)[pFileColumn->GetId()]; + + // Alles geprueft und wir haben den Namen der Column. + // Jetzt eine Value allozieren, den Wert setzen und die Value an die Row binden. + if (bSetNull) + (*m_aAssignValues)[nId].setNull(); + else + { + switch (getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))) + { + // Kriterium je nach Typ als String oder double in die Variable packen ... + case DataType::CHAR: + case DataType::VARCHAR: + (*m_aAssignValues)[nId] = aValue; + // Zeichensatz ist bereits konvertiert, da ja das gesamte Statement konvertiert wurde + break; + + case DataType::BIT: + { + if (aValue.EqualsIgnoreCaseAscii("TRUE") || aValue.GetChar(0) == '1') + (*m_aAssignValues)[nId] = sal_True; + else if (aValue.EqualsIgnoreCaseAscii("FALSE") || aValue.GetChar(0) == '0') + (*m_aAssignValues)[nId] = sal_False; + else + { + // aStatus.Set(SQL_STAT_ERROR); // nyi: genauer! + throwFunctionSequenceException(*this); + } + } + break; + case DataType::TINYINT: + case DataType::SMALLINT: + case DataType::INTEGER: + case DataType::DECIMAL: + case DataType::NUMERIC: + case DataType::REAL: + case DataType::DOUBLE: + case DataType::DATE: + case DataType::TIME: + case DataType::TIMESTAMP: + { + (*m_aAssignValues)[nId] = aValue; // .ToDouble +// try +// { +// double n = xValue->toDouble(); +// xValue->setDouble(n); +// } +// catch ( ... ) +// { +// aStatus.SetDriverNotCapableError(); +// } + } break; + default: + throwFunctionSequenceException(*this); + } + } + + // Parameter-Nr. merken (als User Data) + // SQL_NO_PARAMETER = kein Parameter. + m_aAssignValues->setParameterIndex(nId,nParameter); + if(nParameter != SQL_NO_PARAMETER) + m_aParameterIndexes[nParameter] = nId; +} + +//------------------------------------------------------------------ +UINT32 OPreparedStatement::AddParameter(OSQLParseNode * pParameter, const Reference<XPropertySet>& _xCol) +{ + + // Nr. des neu hinzuzufuegenden Parameters: + UINT32 nParameter = m_xParamColumns->size()+1; + + OSL_ENSURE(SQL_ISRULE(pParameter,parameter),"OResultSet::AddParameter: Argument ist kein Parameter"); + OSL_ENSURE(pParameter->count() > 0,"OResultSet: Fehler im Parse Tree"); + OSQLParseNode * pMark = pParameter->getChild(0); + + ::rtl::OUString sParameterName; +// if (SQL_ISPUNCTUATION(pMark,"?")) +// aParameterName = '?'; +// else if (SQL_ISPUNCTUATION(pMark,":")) +// aParameterName = pParameter->getChild(1)->getTokenValue(); +// else if (SQL_ISPUNCTUATION(pMark,"[")) +// aParameterName = pParameter->getChild(1)->getTokenValue(); +// else +// { +// OSL_ASSERT("OResultSet: Fehler im Parse Tree"); +// } + + // Parameter-Column aufsetzen: + sal_Int32 eType = DataType::VARCHAR; + UINT32 nPrecision = 255; + sal_Int32 nScale = 0; + sal_Int32 nNullable = ColumnValue::NULLABLE; + + if (_xCol.is()) + { + // Typ, Precision, Scale ... der angegebenen Column verwenden, + // denn dieser Column wird der Wert zugewiesen bzw. mit dieser + // Column wird der Wert verglichen. + eType = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))); + nPrecision = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))); + nScale = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))); + nNullable = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))); + _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sParameterName; + } + + Reference<XPropertySet> xParaColumn = new connectivity::sdbcx::OColumn(sParameterName + ,::rtl::OUString() + ,::rtl::OUString() + ,nNullable + ,nPrecision + ,nScale + ,eType + ,sal_False + ,sal_False + ,sal_False + ,m_aSQLIterator.isCaseSensitive()); + m_xParamColumns->push_back(xParaColumn); + return nParameter; +} +// ----------------------------------------------------------------------------- +void OPreparedStatement::describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable) +{ + Reference<XPropertySet> xProp; + if(SQL_ISRULE(_pNode,column_ref)) + { + ::rtl::OUString sColumnName,sTableRange; + m_aSQLIterator.getColumnRange(_pNode,sColumnName,sTableRange); + if(sColumnName.getLength()) + { + Reference<XNameAccess> xNameAccess = _xTable->getColumns(); + if(xNameAccess->hasByName(sColumnName)) + xNameAccess->getByName(sColumnName) >>= xProp; + AddParameter(_pParameter,xProp); + } + } + // else + // AddParameter(_pParameter,xProp); +} +// ------------------------------------------------------------------------- +void OPreparedStatement::describeParameter() +{ + ::std::vector< OSQLParseNode*> aParseNodes; + scanParameter(m_pParseTree,aParseNodes); + if(aParseNodes.size()) + { + m_xParamColumns = new OSQLColumns(); + const OSQLTables& xTabs = m_aSQLIterator.getTables(); + if(xTabs.size()) + { + OSQLTable xTable = xTabs.begin()->second; + ::std::vector< OSQLParseNode*>::const_iterator aIter = aParseNodes.begin(); + for (;aIter != aParseNodes.end();++aIter ) + { + describeColumn(*aIter,(*aIter)->getParent()->getChild(0),xTable); + } + } + } +} +// ----------------------------------------------------------------------------- +void OPreparedStatement::initializeResultSet(OResultSet* _pResult) +{ + OStatement_Base::initializeResultSet(_pResult); + m_pResultSet->setParameterColumns(m_xParamColumns); + m_pResultSet->setParameterRow(m_aParameterRow); + m_pResultSet->setAssignValues(m_aAssignValues); + m_pResultSet->setEvaluationRow(m_aEvaluateRow); + + // Parameter substituieren (AssignValues und Kriterien): + if (!m_xParamColumns->empty()) + { + // Zunchst AssignValues + USHORT nParaCount=0; // gibt die aktuelle Anzahl der bisher gesetzen Parameter an + + // Nach zu substituierenden Parametern suchen: + UINT16 nCount = m_aAssignValues.isValid() ? m_aAssignValues->size() : 1; // 1 ist wichtig fr die Kriterien + for (UINT16 j = 1; j < nCount; j++) + { + UINT32 nParameter = (*m_aAssignValues).getParameterIndex(j); + if (nParameter == SQL_NO_PARAMETER) + continue; // dieser AssignValue ist kein Parameter + + ++nParaCount; // ab hier ist der Parameter gueltig + // Parameter ersetzen. Wenn Parameter nicht verfuegbar, + // Value auf NULL setzen. + // (*m_aAssignValues)[j] = (*m_aParameterRow)[(UINT16)nParameter]; + } + + if (m_aParameterRow.isValid() && nParaCount < m_aParameterRow->size()) + { + m_pSQLAnalyzer->bindParameterRow(m_aParameterRow); + } + } + + m_pEvaluationKeySet = m_pSQLAnalyzer->bindResultRow(m_aEvaluateRow); // Werte im Code des Compilers setzen + m_pResultSet->setEvaluationKeySet(m_pEvaluationKeySet); +} +// ----------------------------------------------------------------------------- + diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx index ea6910ed6468..529f273ace89 100644 --- a/connectivity/source/drivers/file/FResultSet.cxx +++ b/connectivity/source/drivers/file/FResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FResultSet.cxx,v $ * - * $Revision: 1.70 $ + * $Revision: 1.71 $ * - * last change: $Author: hr $ $Date: 2001-08-14 11:56:02 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -136,6 +136,7 @@ #include <comphelper/types.hxx> #endif + using namespace ::comphelper; using namespace connectivity; using namespace connectivity::file; @@ -157,6 +158,7 @@ using namespace com::sun::star::container; #endif //------------------------------------------------------------------------------ IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.drivers.file.ResultSet","com.sun.star.sdbc.ResultSet"); +DBG_NAME(OResultSet ) // ------------------------------------------------------------------------- OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIterator) : OResultSet_BASE(m_aMutex) ,::comphelper::OPropertyContainer(OResultSet_BASE::rBHelper) @@ -187,15 +189,11 @@ OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIte ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding()) ,m_nCurrentPosition(0) ,m_bShowDeleted(pStmt->getOwnConnection()->showDeleted()) + ,m_pSQLAnalyzer(NULL) { + DBG_CTOR(OResultSet ,NULL); osl_incrementInterlockedCount( &m_refCount ); - - for (int jj = 0; jj < sizeof m_nOrderbyColumnNumber / sizeof (* m_nOrderbyColumnNumber); jj++) - { - m_nOrderbyColumnNumber[jj] = SQL_COLUMN_NOTFOUND; - bOrderbyAscending[jj] = TRUE; - } m_nResultSetConcurrency = isCount() ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE; construct(); osl_decrementInterlockedCount( &m_refCount ); @@ -204,7 +202,9 @@ OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIte // ------------------------------------------------------------------------- OResultSet::~OResultSet() { - delete m_pSQLAnalyzer; + osl_incrementInterlockedCount( &m_refCount ); + disposing(); + DBG_DTOR(OResultSet ,NULL); } // ------------------------------------------------------------------------- void OResultSet::construct() @@ -226,39 +226,32 @@ void OResultSet::disposing(void) m_xColNames = NULL; m_xColumns = NULL; m_xParamColumns = NULL; + m_xColsIdx = NULL; - if(m_pSQLAnalyzer) - m_pSQLAnalyzer->dispose(); if(m_pTable) { m_pTable->release(); m_pTable = NULL; } + clear(); +} +// ----------------------------------------------------------------------------- +void OResultSet::clear() +{ DELETEZ(m_pFileSet); - DELETEZ(m_pEvaluationKeySet); DELETEZ(m_pSortIndex); - if(m_aRow.isValid()) - m_aRow->clear(); - if(m_aEvaluateRow.isValid()) - m_aEvaluateRow->clear(); if(m_aInsertRow.isValid()) m_aInsertRow->clear(); - if(m_aAssignValues.isValid()) - m_aAssignValues->clear(); - m_aBookmarksPositions.clear(); - m_aBookmarks.clear(); + ::std::vector<TInt2IntMap::iterator>().swap(m_aBookmarksPositions); + TInt2IntMap().swap(m_aBookmarks); } // ------------------------------------------------------------------------- Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - Any aRet = OPropertySetHelper::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OResultSet_BASE::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw(RuntimeException) @@ -310,17 +303,11 @@ void OResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc // ------------------------------------------------------------------------- Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - return NULL; } // ------------------------------------------------------------------------- Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - return NULL; } @@ -502,17 +489,21 @@ void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException) void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException) { - { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - } - dispose(); +// { +// ::osl::MutexGuard aGuard( m_aMutex ); +// checkDisposed(OResultSet_BASE::rBHelper.bDisposed); +// +// } +// dispose(); + ::osl::MutexGuard aGuard( m_aMutex ); + clear(); } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); return SkipDeleted(OFileTable::FILE_FIRST,1,sal_True); } // ------------------------------------------------------------------------- @@ -520,21 +511,29 @@ sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException) sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException) { // here I know definitely that I stand on the last record + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); return SkipDeleted(OFileTable::FILE_LAST,1,sal_True); } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); return SkipDeleted(OFileTable::FILE_ABSOLUTE,row,sal_True); } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); return SkipDeleted(OFileTable::FILE_RELATIVE,row,sal_True); } // ------------------------------------------------------------------------- sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException) { + ::osl::MutexGuard aGuard( m_aMutex ); + checkDisposed(OResultSet_BASE::rBHelper.bDisposed); return SkipDeleted(OFileTable::FILE_PRIOR,0,sal_True); } // ------------------------------------------------------------------------- @@ -714,7 +713,6 @@ void SAL_CALL OResultSet::deleteRow() throw(SQLException, RuntimeException) } } // ------------------------------------------------------------------------- - void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -746,8 +744,6 @@ void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeExcepti if(m_pTable->isReadOnly()) throw SQLException(::rtl::OUString::createFromAscii("Table is readonly!"),*this,OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_HY0000),1000,Any()); - Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); - m_bInserted = sal_True; OValueVector::iterator aIter = m_aInsertRow->begin()+1; @@ -941,7 +937,7 @@ again: } else { - m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), sal_True,TRUE); + m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), sal_True,bRetrieveData || m_pSQLAnalyzer->hasRestriction()); if ((!m_bShowDeleted && m_aEvaluateRow->isDeleted()) || (m_pSQLAnalyzer->hasRestriction() && //!bShowDeleted && m_aEvaluateRow->isDeleted() ||// keine Anzeige von geloeschten Stzen @@ -1142,7 +1138,7 @@ BOOL OResultSet::Move(OFileTable::FilePosition eCursorPosition, INT32 nOffset, B } } else - bOK = ExecuteRow(OFileTable::FILE_NEXT,1,FALSE,TRUE, bRetrieveData); + bOK = ExecuteRow(OFileTable::FILE_NEXT,1,FALSE,TRUE, FALSE);//bRetrieveData); } if (bOK) @@ -1158,7 +1154,8 @@ BOOL OResultSet::Move(OFileTable::FilePosition eCursorPosition, INT32 nOffset, B //m_pFileSet->Freeze(); m_pFileSet->setFrozen(); - DELETEZ(m_pEvaluationKeySet); + // DELETEZ(m_pEvaluationKeySet); + m_pEvaluationKeySet = NULL; // aStatus.Set(SQL_STAT_NO_DATA_FOUND); goto Error; } @@ -1251,9 +1248,6 @@ Error: //------------------------------------------------------------------ BOOL OResultSet::SkipDeleted(OFileTable::FilePosition eCursorPosition, INT32 nOffset, BOOL bRetrieveData) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False; OSL_ENSURE(eCursorPosition != OFileTable::FILE_BOOKMARK,"OResultSet::SkipDeleted can't be called for BOOKMARK"); @@ -1385,7 +1379,7 @@ sal_Bool OResultSet::moveAbsolute(sal_Int32 _nOffset,sal_Bool _bRetrieveData) } else { - bDataFound = Move(OFileTable::FILE_FIRST, 1, _bRetrieveData); + bDataFound = Move(OFileTable::FILE_FIRST, 1, _bRetrieveData ); if(bDataFound && (m_bShowDeleted || !m_aRow->isDeleted())) { ++nCurPos; @@ -1426,108 +1420,73 @@ sal_Bool OResultSet::moveAbsolute(sal_Int32 _nOffset,sal_Bool _bRetrieveData) // ------------------------------------------------------------------------- BOOL OResultSet::OpenImpl() { - m_pSQLAnalyzer = createAnalyzer(); - const OSQLTables& xTabs = m_aSQLIterator.getTables(); - if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is()) - throwGenericSQLException( ::rtl::OUString::createFromAscii("The statement is invalid."), - static_cast<XWeak*>(this), - makeAny(m_aSQLIterator.getWarning()) - ); - - OSQLTable xTable = xTabs.begin()->second; - m_xColumns = m_aSQLIterator.getSelectColumns(); - - m_xColNames = xTable->getColumns(); - - Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); - - m_aRow = new OValueVector(xNames->getCount()); - m_aEvaluateRow = new OValueVector(xNames->getCount()); - m_aInsertRow = new OValueVector(xNames->getCount()); - - (*m_aRow)[0].setBound(sal_True); - (*m_aEvaluateRow)[0].setBound(sal_True); - (*m_aInsertRow)[0].setBound(sal_True); - // unbound all values so that we only update the really needed columns - OValueVector::iterator aInsertIter = m_aInsertRow->begin()+1; - for(;aInsertIter != m_aInsertRow->end();++aInsertIter) - aInsertIter->setBound(sal_False); - - if(m_aAssignValues.isValid()) - m_aAssignValues->clear(); - m_aAssignValues = new OAssignValues(); + OSL_ENSURE(m_pSQLAnalyzer,"No analyzer set with setSqlAnalyzer!"); + if(!m_pTable) + { + const OSQLTables& xTabs = m_aSQLIterator.getTables(); + if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is()) + throwGenericSQLException( ::rtl::OUString::createFromAscii("The statement is invalid."), + static_cast<XWeak*>(this), + makeAny(m_aSQLIterator.getWarning()) + ); + + OSQLTable xTable = xTabs.begin()->second; + m_xColumns = m_aSQLIterator.getSelectColumns(); + + m_xColNames = xTable->getColumns(); + m_xColsIdx = Reference<XIndexAccess>(m_xColNames,UNO_QUERY); + doTableSpecials(xTable); + } - if(!m_xParamColumns.isValid()) - m_xParamColumns = new OSQLColumns(); + sal_Int32 nColumnCount = m_xColsIdx->getCount(); - OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::OpenImpl: Analyzer isn't set!"); - m_pSQLAnalyzer->clean(); + initializeRow(m_aRow,nColumnCount); + initializeRow(m_aEvaluateRow,nColumnCount); + initializeRow(m_aInsertRow,nColumnCount); - doTableSpecials(xTable); - OSL_ENSURE(m_pTable,"We need a table object!"); - Reference<XIndexesSupplier> xIndexSup(xTable,UNO_QUERY); - if(xIndexSup.is()) - m_pSQLAnalyzer->setIndexes(xIndexSup->getIndexes()); m_nResultSetConcurrency = (m_pTable->isReadOnly() || isCount()) ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE; - GetAssignValues(); // assign values and describe parameter columns - m_pSQLAnalyzer->setParameterColumns(m_xParamColumns); - anylizeSQL(); - if (m_xParamColumns->size()) - m_pSQLAnalyzer->describeParam(m_xParamColumns); - - sal_Int32 i=0; - // initialize the column index map (mapping select columns to table columns) - m_aColMapping.resize(m_xColumns->size() + 1); - for (i=0; i<(sal_Int32)m_aColMapping.size(); ++i) - m_aColMapping[i] = i; - - // now check which columns are bound - setBoundedColumns(m_aRow,m_xColumns,xNames,sal_True); - // Parameter substituieren (AssignValues und Kriterien): - if (m_xParamColumns->size()) - { - // Zunchst AssignValues - USHORT nParaCount=0; // gibt die aktuelle Anzahl der bisher gesetzen Parameter an +// if(m_aParameterRow.isValid()) +// m_xParamColumns->reserve(m_aParameterRow->size()); - // Nach zu substituierenden Parametern suchen: - UINT16 nCount = m_aAssignValues.isValid() ? m_aAssignValues->size() : 1; // 1 ist wichtig fr die Kriterien - for (UINT16 j = 1; j < nCount; j++) - { -// if ((*m_aAssignValues)[j].isNull()) -// continue; - - UINT32 nParameter = (*m_aAssignValues).getParameterIndex(j); - if (nParameter == SQL_NO_PARAMETER) - continue; // dieser AssignValue ist kein Parameter - - ++nParaCount; // ab hier ist der Parameter gueltig - // Parameter ersetzen. Wenn Parameter nicht verfuegbar, - // Value auf NULL setzen. - (*m_aAssignValues)[j] = (*m_aParameterRow)[(UINT16)nParameter]; - } + // sal_Int32 i=0; - if (m_aParameterRow.isValid() && nParaCount < m_aParameterRow->size()) - { - setBoundedColumns(m_aEvaluateRow,m_xParamColumns,xNames,sal_False); - m_pSQLAnalyzer->bindParameterRow(m_aParameterRow); - } - } +// // Parameter substituieren (AssignValues und Kriterien): +// if (m_xParamColumns.isValid() && !m_xParamColumns->empty()) +// { +// // Zunchst AssignValues +// USHORT nParaCount=0; // gibt die aktuelle Anzahl der bisher gesetzen Parameter an +// +// // Nach zu substituierenden Parametern suchen: +// UINT16 nCount = m_aAssignValues.isValid() ? m_aAssignValues->size() : 1; // 1 ist wichtig fr die Kriterien +// for (UINT16 j = 1; j < nCount; j++) +// { +// UINT32 nParameter = (*m_aAssignValues).getParameterIndex(j); +// if (nParameter == SQL_NO_PARAMETER) +// continue; // dieser AssignValue ist kein Parameter +// +// ++nParaCount; // ab hier ist der Parameter gueltig +// // Parameter ersetzen. Wenn Parameter nicht verfuegbar, +// // Value auf NULL setzen. +// (*m_aAssignValues)[j] = (*m_aParameterRow)[(UINT16)nParameter]; +// } +// +// if (m_aParameterRow.isValid() && nParaCount < m_aParameterRow->size()) +// { +// // setBoundedColumns(m_aEvaluateRow,m_xParamColumns,xNames,sal_False); +// m_pSQLAnalyzer->bindParameterRow(m_aParameterRow); +// } +// } // Neuen Index aufbauen: DELETEZ(m_pFileSet); - DELETEZ(m_pEvaluationKeySet); - - // if (!aEvaluateRow.Is()) - { - // aEvaluateRow = new ODbRow(*aFileColumns, FALSE); - // (*aEvaluateRow)[0] = new ODbVariant(); + // DELETEZ(m_pEvaluationKeySet); // Row zur Auswertung binden, wenn Preprocessing erfolg, dann bereits ein Keyset - m_pEvaluationKeySet = m_pSQLAnalyzer->bindResultRow(m_aEvaluateRow); // Werte im Code des Compilers setzen + // m_pEvaluationKeySet = m_pSQLAnalyzer->bindResultRow(m_aEvaluateRow); // Werte im Code des Compilers setzen // (Verbindung zur ResultRow herstellen) - } + // An den Anfang positionieren m_nRowPos = -1; @@ -1577,7 +1536,8 @@ BOOL OResultSet::OpenImpl() // Ergebnis von COUNT(*) in m_nRowCountResult merken. // nRowCount, also die Anzahl der Rows in der Ergebnismenge, ist bei dieser // Anfrage = 1! - DELETEZ(m_pEvaluationKeySet); + m_pEvaluationKeySet = NULL; + // DELETEZ(m_pEvaluationKeySet); } } else @@ -1591,8 +1551,8 @@ BOOL OResultSet::OpenImpl() { if(!IsSorted()) { - m_nOrderbyColumnNumber[0] = m_aColMapping[1]; - bOrderbyAscending[0] = FALSE; + m_aOrderbyColumnNumber[0] = m_aColMapping[1]; + m_aOrderbyAscending[0] = 0; } else bWasSorted = TRUE; @@ -1602,17 +1562,17 @@ BOOL OResultSet::OpenImpl() // if (!HasRestriction() && !IsSorted() && bShowDeleted) // SetRowCount(MaxRowCount()); - OSL_ENSURE(sizeof m_nOrderbyColumnNumber / sizeof (* m_nOrderbyColumnNumber) == SQL_ORDERBYKEYS,"Maximale Anzahl der ORDER BY Columns muss derzeit genau 3 sein!"); + OSL_ENSURE(m_aOrderbyColumnNumber.size() == SQL_ORDERBYKEYS,"Maximale Anzahl der ORDER BY Columns muss derzeit genau 3 sein!"); OKeyType eKeyType[SQL_ORDERBYKEYS]; OValueVector::iterator aRowIter = m_aRow->begin()+1; for (int i = 0; i < SQL_ORDERBYKEYS; i++) { - if (m_nOrderbyColumnNumber[i] == SQL_COLUMN_NOTFOUND) + if (m_aOrderbyColumnNumber[i] == SQL_COLUMN_NOTFOUND) eKeyType[i] = SQL_ORDERBYKEY_NONE; else { - OSL_ENSURE((sal_Int32)m_aRow->size() > m_nOrderbyColumnNumber[i],"Invalid Index"); - switch ((m_aRow->begin()+m_nOrderbyColumnNumber[i])->getTypeKind()) + OSL_ENSURE((sal_Int32)m_aRow->size() > m_aOrderbyColumnNumber[i],"Invalid Index"); + switch ((m_aRow->begin()+m_aOrderbyColumnNumber[i])->getTypeKind()) { case DataType::CHAR: case DataType::VARCHAR: @@ -1640,7 +1600,7 @@ BOOL OResultSet::OpenImpl() OSL_ASSERT("OFILECursor::Execute: Datentyp nicht implementiert"); break; } - (*m_aEvaluateRow)[m_nOrderbyColumnNumber[i]].setBound(sal_True); + (*m_aEvaluateRow)[m_aOrderbyColumnNumber[i]].setBound(sal_True); } } @@ -1648,19 +1608,21 @@ BOOL OResultSet::OpenImpl() // dabei den "Key", nach dem sortiert werden soll, in den Index eintragen: if (IsSorted()) { - if (!m_pSQLAnalyzer->hasRestriction() && m_nOrderbyColumnNumber[1] == SQL_COLUMN_NOTFOUND) + if (!m_pSQLAnalyzer->hasRestriction() && m_aOrderbyColumnNumber[1] == SQL_COLUMN_NOTFOUND) { // Ist nur ein Feld fuer die Sortierung angegeben // Und diese Feld ist indiziert, dann den Index ausnutzen - Reference<XIndexesSupplier> xIndexSup(xTable,UNO_QUERY); + Reference<XIndexesSupplier> xIndexSup; + m_pTable->queryInterface(::getCppuType((const Reference<XIndexesSupplier>*)0)) >>= xIndexSup; + // Reference<XIndexesSupplier> xIndexSup(m_pTable,UNO_QUERY); Reference<XIndexAccess> xIndexes; if(xIndexSup.is()) { xIndexes = Reference<XIndexAccess>(xIndexSup->getIndexes(),UNO_QUERY); Reference<XPropertySet> xColProp; - if(m_nOrderbyColumnNumber[0] < xIndexes->getCount()) + if(m_aOrderbyColumnNumber[0] < xIndexes->getCount()) { - ::cppu::extractInterface(xColProp,xIndexes->getByIndex(m_nOrderbyColumnNumber[0])); + ::cppu::extractInterface(xColProp,xIndexes->getByIndex(m_aOrderbyColumnNumber[0])); // iterate through the indexes to find the matching column for(sal_Int32 i=0;i<xIndexes->getCount();++i) { @@ -1680,7 +1642,7 @@ BOOL OResultSet::OpenImpl() } m_pSortIndex = new OFILESortIndex(eKeyType, - bOrderbyAscending, + m_aOrderbyAscending, nMaxRowCount,m_nTextEncoding); sal_Bool bOK = sal_True; @@ -1703,7 +1665,8 @@ BOOL OResultSet::OpenImpl() } // Sortiertes Keyset erzeugen - DELETEZ(m_pEvaluationKeySet); + // DELETEZ(m_pEvaluationKeySet); + m_pEvaluationKeySet = NULL; if(m_pFileSet) delete m_pFileSet; m_pFileSet = m_pSortIndex->CreateKeySet(); @@ -1722,6 +1685,8 @@ BOOL OResultSet::OpenImpl() // Aber Achtung: es wird davon ausgegangen, das die FilePositionen als Folge 1..n // abgelegt werden! { + if(m_pTable->getCurrentLastPos() > 0) + m_pFileSet->reserve(m_pTable->getCurrentLastPos() ); for (sal_Int32 i = 0; i < m_pTable->getCurrentLastPos(); i++) m_pFileSet->push_back(i + 1); } @@ -1736,9 +1701,7 @@ BOOL OResultSet::OpenImpl() aRowIter != m_aRow->end(); ++aRowIter,++aSearchIter) aSearchIter->setBound(aRowIter->isBound()); - // ODbRowRef aSearchRow = new ODbRow(*aFileRow); // nach dieser wird gesucht - // const ODbRow &rSearchRow = *aSearchRow, - // &rFileRow = *aFileRow; + INT32 nPos; UINT16 nMaxRow = m_pFileSet->size(); if (nMaxRow) @@ -1798,7 +1761,7 @@ BOOL OResultSet::OpenImpl() if (!bWasSorted) { - m_nOrderbyColumnNumber[0] = SQL_COLUMN_NOTFOUND; + m_aOrderbyColumnNumber[0] = SQL_COLUMN_NOTFOUND; sort(m_pFileSet->begin(),m_pFileSet->end()); } } @@ -1844,14 +1807,16 @@ BOOL OResultSet::OpenImpl() // Ergebnis von COUNT(*) in nRowCountResult merken. // nRowCount, also die Anzahl der Rows in der Ergebnismenge, ist bei dieser // Anfrage = 1! - DELETEZ(m_pEvaluationKeySet); + // DELETEZ(m_pEvaluationKeySet); + m_pEvaluationKeySet = NULL; } // SetRowCount(1); break; case SQL_STATEMENT_INSERT: m_nRowCountResult = 0; - if(!m_pTable->InsertRow(m_aAssignValues.getBody(), TRUE,Reference<XIndexAccess>(m_xColNames,UNO_QUERY))) + OSL_ENSURE(m_aAssignValues.isValid(),"No assign values set!"); + if(!m_pTable->InsertRow(m_aAssignValues.getBody(), TRUE,m_xColsIdx)) { m_nFilePos = 0; return sal_False; @@ -1866,84 +1831,6 @@ BOOL OResultSet::OpenImpl() return sal_True; } -//------------------------------------------------------------------ -void OResultSet::anylizeSQL() -{ - OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::anylizeSQL: Analyzer isn't set!"); - // start analysing the statement - m_pSQLAnalyzer->setOrigColumns(m_xColNames); - m_pSQLAnalyzer->start(m_pParseTree); - - const OSQLParseNode* pOrderbyClause = m_aSQLIterator.getOrderTree(); - if(pOrderbyClause) - { - OSQLParseNode * pOrderingSpecCommalist = pOrderbyClause->getChild(2); - OSL_ENSURE(SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OResultSet: Fehler im Parse Tree"); - - for (sal_uInt32 m = 0; m < pOrderingSpecCommalist->count(); m++) - { - OSQLParseNode * pOrderingSpec = pOrderingSpecCommalist->getChild(m); - OSL_ENSURE(SQL_ISRULE(pOrderingSpec,ordering_spec),"OResultSet: Fehler im Parse Tree"); - OSL_ENSURE(pOrderingSpec->count() == 2,"OResultSet: Fehler im Parse Tree"); - - OSQLParseNode * pColumnRef = pOrderingSpec->getChild(0); - if(!SQL_ISRULE(pColumnRef,column_ref)) - { - // aStatus.SetStatementTooComplex(); - return; - } - OSQLParseNode * pAscendingDescending = pOrderingSpec->getChild(1); - setOrderbyColumn((UINT16)m,pColumnRef,pAscendingDescending); - } - } -} - - -//------------------------------------------------------------------ -void OResultSet::setOrderbyColumn(UINT16 nOrderbyColumnNo, - OSQLParseNode* pColumnRef, - OSQLParseNode* pAscendingDescending) -{ - if (nOrderbyColumnNo >= (sizeof m_nOrderbyColumnNumber / sizeof (* m_nOrderbyColumnNumber))) - { - // aStatus.SetStatementTooComplex(); - return; - } - - ::rtl::OUString aColumnName; - if (pColumnRef->count() == 1) - aColumnName = pColumnRef->getChild(0)->getTokenValue(); - else if (pColumnRef->count() == 3) - { - // Nur die Table Range-Variable darf hier vorkommen: -// if (!(pColumnRef->getChild(0)->getTokenValue() == aTableRange)) -// { -// aStatus.Set(SQL_STAT_ERROR, -// String::CreateFromAscii("S1000"), -// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_INVALID_RANGE_VAR))), -// 0, String() ); - // return; - // } - pColumnRef->getChild(2)->parseNodeToStr(aColumnName,m_xDBMetaData,NULL,sal_False,sal_False); - } - else - { - // aStatus.SetStatementTooComplex(); - return; - } - - Reference<XColumnLocate> xColLocate(m_xColNames,UNO_QUERY); - if(!xColLocate.is()) - return; - // Alles geprueft und wir haben den Namen der Column. - // Die wievielte Column ist das? - m_nOrderbyColumnNumber[nOrderbyColumnNo] = xColLocate->findColumn(aColumnName); - - // Ascending or Descending? - bOrderbyAscending[nOrderbyColumnNo] = (SQL_ISTOKEN(pAscendingDescending,DESC)) ? - FALSE : TRUE; -} - //-------------------------------------------------------------------------- Sequence< sal_Int8 > OResultSet::getUnoTunnelImplementationId() { @@ -1964,428 +1851,29 @@ Sequence< sal_Int8 > OResultSet::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OResultSet::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 0; -} -//------------------------------------------------------------------ -void OResultSet::GetAssignValues() -{ - if (m_pParseTree == NULL) - { - ::dbtools::throwFunctionSequenceException(*this); - return; - } - - if (SQL_ISRULE(m_pParseTree,select_statement)) - // Keine zu setzenden Werte bei SELECT - return; - else if (SQL_ISRULE(m_pParseTree,insert_statement)) - { - // Row fuer die zu setzenden Werte anlegen (Referenz durch new) - if(m_aAssignValues.isValid()) - m_aAssignValues->clear(); - m_aAssignValues = new OAssignValues(Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount()); - - // Liste der Columns-Namen, die in der column_commalist vorkommen (mit ; getrennt): - ::std::vector<String> aColumnNameList; - - OSL_ENSURE(m_pParseTree->count() >= 4,"OResultSet: Fehler im Parse Tree"); - - OSQLParseNode * pOptColumnCommalist = m_pParseTree->getChild(3); - OSL_ENSURE(pOptColumnCommalist != NULL,"OResultSet: Fehler im Parse Tree"); - OSL_ENSURE(SQL_ISRULE(pOptColumnCommalist,opt_column_commalist),"OResultSet: Fehler im Parse Tree"); - if (pOptColumnCommalist->count() == 0) - { - const Sequence< ::rtl::OUString>& aNames = m_xColNames->getElementNames(); - const ::rtl::OUString* pBegin = aNames.getConstArray(); - aColumnNameList.insert(aColumnNameList.begin(),::std::vector<String>::const_iterator(pBegin),::std::vector<String>::const_iterator(pBegin + aNames.getLength())); - } - else - { - OSL_ENSURE(pOptColumnCommalist->count() == 3,"OResultSet: Fehler im Parse Tree"); - - OSQLParseNode * pColumnCommalist = pOptColumnCommalist->getChild(1); - OSL_ENSURE(pColumnCommalist != NULL,"OResultSet: Fehler im Parse Tree"); - OSL_ENSURE(SQL_ISRULE(pColumnCommalist,column_commalist),"OResultSet: Fehler im Parse Tree"); - OSL_ENSURE(pColumnCommalist->count() > 0,"OResultSet: Fehler im Parse Tree"); - - // Alle Columns in der column_commalist ... - for (sal_uInt32 i = 0; i < pColumnCommalist->count(); i++) - { - OSQLParseNode * pCol = pColumnCommalist->getChild(i); - OSL_ENSURE(pCol != NULL,"OResultSet: Fehler im Parse Tree"); - aColumnNameList.push_back(pCol->getTokenValue()); - } - } - if(!aColumnNameList.size()) - throwFunctionSequenceException(*this); - - // Werte ... - OSQLParseNode * pValuesOrQuerySpec = m_pParseTree->getChild(4); - OSL_ENSURE(pValuesOrQuerySpec != NULL,"OResultSet: pValuesOrQuerySpec darf nicht NULL sein!"); - OSL_ENSURE(SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec),"OResultSet: ! SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec)"); - OSL_ENSURE(pValuesOrQuerySpec->count() > 0,"OResultSet: pValuesOrQuerySpec->count() <= 0"); - - // nur "VALUES" ist erlaubt ... - if (! SQL_ISTOKEN(pValuesOrQuerySpec->getChild(0),VALUES)) - throwFunctionSequenceException(*this); - - OSL_ENSURE(pValuesOrQuerySpec->count() == 2,"OResultSet: pValuesOrQuerySpec->count() != 2"); - - // Liste von Werten - OSQLParseNode * pInsertAtomCommalist = pValuesOrQuerySpec->getChild(1); - OSL_ENSURE(pInsertAtomCommalist != NULL,"OResultSet: pInsertAtomCommalist darf nicht NULL sein!"); - OSL_ENSURE(pInsertAtomCommalist->count() > 0,"OResultSet: pInsertAtomCommalist <= 0"); - - String aColumnName; - OSQLParseNode * pRow_Value_Const; - xub_StrLen nIndex=0; - for (sal_uInt32 i = 0; i < pInsertAtomCommalist->count(); i++) - { - pRow_Value_Const = pInsertAtomCommalist->getChild(i); // row_value_constructor - if(pRow_Value_Const->count() == 3) // '(' row_value_const_list ')' - { - pRow_Value_Const = pRow_Value_Const->getChild(1); // row_value_const_list - OSL_ENSURE(pRow_Value_Const != NULL,"OResultSet: pRow_Value_Const darf nicht NULL sein!"); - if(SQL_ISRULE(pRow_Value_Const,parameter)) - { - if(pRow_Value_Const->count() == aColumnNameList.size()) - ParseAssignValues(aColumnNameList,pRow_Value_Const,nIndex++); // kann nur ein Columnname vorhanden sein pro Schleife - else - { -// aStatus.Set(SQL_STAT_ERROR, -// String::CreateFromAscii("S1000"), -// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_SYNTAX_ERROR))), -// 0, String() ); - throwFunctionSequenceException(*this); - } - } - else - { - if(pRow_Value_Const->count() == aColumnNameList.size()) - { - for (sal_uInt32 j = 0; j < pRow_Value_Const->count(); ++j) - ParseAssignValues(aColumnNameList,pRow_Value_Const->getChild(j),nIndex++); - } - else - { -// aStatus.Set(SQL_STAT_ERROR, -// String::CreateFromAscii("S1000"), -// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_SYNTAX_ERROR))), -// 0, String() ); - throwFunctionSequenceException(*this); - } - - } - } - else - { - // aStatus.SetStatementTooComplex(); - throwFunctionSequenceException(*this); - } - } - } - else if (SQL_ISRULE(m_pParseTree,update_statement_positioned) || - SQL_ISRULE(m_pParseTree,update_statement_searched)) - { - if(m_aAssignValues.isValid()) - m_aAssignValues->clear(); - m_aAssignValues = new OAssignValues(Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount()); - - OSL_ENSURE(m_pParseTree->count() >= 4,"OResultSet: Fehler im Parse Tree"); - - OSQLParseNode * pAssignmentCommalist = m_pParseTree->getChild(3); - OSL_ENSURE(pAssignmentCommalist != NULL,"OResultSet: pAssignmentCommalist == NULL"); - OSL_ENSURE(SQL_ISRULE(pAssignmentCommalist,assignment_commalist),"OResultSet: Fehler im Parse Tree"); - OSL_ENSURE(pAssignmentCommalist->count() > 0,"OResultSet: pAssignmentCommalist->count() <= 0"); - - // Alle Zuweisungen (Kommaliste) bearbeiten ... - ::std::vector< String> aList(1); - for (sal_uInt32 i = 0; i < pAssignmentCommalist->count(); i++) - { - OSQLParseNode * pAssignment = pAssignmentCommalist->getChild(i); - OSL_ENSURE(pAssignment != NULL,"OResultSet: pAssignment == NULL"); - OSL_ENSURE(SQL_ISRULE(pAssignment,assignment),"OResultSet: Fehler im Parse Tree"); - OSL_ENSURE(pAssignment->count() == 3,"OResultSet: pAssignment->count() != 3"); - - OSQLParseNode * pCol = pAssignment->getChild(0); - OSL_ENSURE(pCol != NULL,"OResultSet: pCol == NULL"); - - OSQLParseNode * pComp = pAssignment->getChild(1); - OSL_ENSURE(pComp != NULL,"OResultSet: pComp == NULL"); - OSL_ENSURE(pComp->getNodeType() == SQL_NODE_EQUAL,"OResultSet: pComp->getNodeType() != SQL_NODE_COMPARISON"); - if (pComp->getTokenValue().toChar() != '=') - { - // aStatus.SetInvalidStatement(); - throwFunctionSequenceException(*this); - } - - OSQLParseNode * pVal = pAssignment->getChild(2); - OSL_ENSURE(pVal != NULL,"OResultSet: pVal == NULL"); - aList[0] = pCol->getTokenValue(); - ParseAssignValues(aList,pVal,0); - } - - } -} -// ------------------------------------------------------------------------- -void OResultSet::ParseAssignValues(const ::std::vector< String>& aColumnNameList,OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex) -{ - OSL_ENSURE(nIndex <= aColumnNameList.size(),"SdbFileCursor::ParseAssignValues: nIndex > aColumnNameList.GetTokenCount()"); - String aColumnName(aColumnNameList[nIndex]); - OSL_ENSURE(aColumnName.Len() > 0,"OResultSet: Column-Name nicht gefunden"); - OSL_ENSURE(pRow_Value_Constructor_Elem != NULL,"OResultSet: pRow_Value_Constructor_Elem darf nicht NULL sein!"); - - if (pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_STRING || - pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_INTNUM || - pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_APPROXNUM) - { - // Wert setzen: - SetAssignValue(aColumnName, pRow_Value_Constructor_Elem->getTokenValue()); - } - else if (SQL_ISTOKEN(pRow_Value_Constructor_Elem,NULL)) - { - // NULL setzen - SetAssignValue(aColumnName, String(), TRUE); - } - else if (SQL_ISRULE(pRow_Value_Constructor_Elem,parameter)) - { - // Parameter hinzufuegen, Typ ... entsprechend der Column, der der Wert zugewiesen wird - Reference<XPropertySet> xCol; - m_xColNames->getByName(aColumnName) >>= xCol; - sal_Int32 nParameter = -1; - if(m_xParamColumns.isValid()) - { - OSQLColumns::const_iterator aIter = find(m_xParamColumns->begin(),m_xParamColumns->end(),aColumnName,::comphelper::UStringMixEqual(m_pTable->isCaseSensitive())); - if(aIter != m_xParamColumns->end()) - nParameter = m_xParamColumns->size() - (m_xParamColumns->end() - aIter) +1;// +1 because the rows start at 1 - } - if(nParameter == -1) - nParameter = AddParameter(pRow_Value_Constructor_Elem,xCol); - // Nr. des Parameters in der Variablen merken: - SetAssignValue(aColumnName, String(), TRUE, nParameter); - } - else - { - // aStatus.SetStatementTooComplex(); - throwFunctionSequenceException(*this); - } -} -//------------------------------------------------------------------ -void OResultSet::SetAssignValue(const String& aColumnName, - const String& aValue, - BOOL bSetNull, - UINT32 nParameter) -{ - Reference<XPropertySet> xCol; - ::cppu::extractInterface(xCol,m_xColNames->getByName(aColumnName)); - sal_Int32 nId = Reference<XColumnLocate>(m_xColNames,UNO_QUERY)->findColumn(aColumnName); - // Kommt diese Column ueberhaupt in der Datei vor? - - if (!xCol.is()) - { - // Diese Column gibt es nicht! -// aStatus.Set(SQL_STAT_ERROR, -// String::CreateFromAscii("S0022"), -// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_COLUMN_NOT_FOUND))), -// 0, String() ); - throwFunctionSequenceException(*this); - } - - // Value an die Row mit den zuzuweisenden Werten binden: - // const ODbVariantRef& xValue = (*aAssignValues)[pFileColumn->GetId()]; - - // Alles geprueft und wir haben den Namen der Column. - // Jetzt eine Value allozieren, den Wert setzen und die Value an die Row binden. - if (bSetNull) - (*m_aAssignValues)[nId].setNull(); - else - { - switch (getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))) - { - // Kriterium je nach Typ als String oder double in die Variable packen ... - case DataType::CHAR: - case DataType::VARCHAR: - (*m_aAssignValues)[nId] = aValue; - // Zeichensatz ist bereits konvertiert, da ja das gesamte Statement konvertiert wurde - break; - - case DataType::BIT: - { - // nyi: gemischte Gross-/Kleinschreibung??? - if (aValue.EqualsIgnoreCaseAscii("TRUE") || aValue.GetChar(0) == '1') - (*m_aAssignValues)[nId] = sal_True; - else if (aValue.EqualsIgnoreCaseAscii("FALSE") || aValue.GetChar(0) == '0') - (*m_aAssignValues)[nId] = sal_False; - else - { - // aStatus.Set(SQL_STAT_ERROR); // nyi: genauer! - throwFunctionSequenceException(*this); - } - } - break; - case DataType::TINYINT: - case DataType::SMALLINT: - case DataType::INTEGER: - case DataType::DECIMAL: - case DataType::NUMERIC: - case DataType::REAL: - case DataType::DOUBLE: - case DataType::DATE: - case DataType::TIME: - case DataType::TIMESTAMP: - { - (*m_aAssignValues)[nId] = aValue; // .ToDouble -// try -// { -// double n = xValue->toDouble(); -// xValue->setDouble(n); -// } -// catch ( ... ) -// { -// aStatus.SetDriverNotCapableError(); -// } - } break; - default: - throwFunctionSequenceException(*this); - } - } - - // Parameter-Nr. merken (als User Data) - // SQL_NO_PARAMETER = kein Parameter. - m_aAssignValues->setParameterIndex(nId,nParameter); - // ((ODbAssignRow*)aAssignValues.getBodyPtr())->setAssignedIndex(pFileColumn->GetId(), nParameter); -} - -//------------------------------------------------------------------ -UINT32 OResultSet::AddParameter(OSQLParseNode * pParameter, const Reference<XPropertySet>& _xCol) -{ - - // Nr. des neu hinzuzufuegenden Parameters: - UINT32 nParameter = m_xParamColumns->size()+1; - - OSL_ENSURE(SQL_ISRULE(pParameter,parameter),"OResultSet::AddParameter: Argument ist kein Parameter"); - OSL_ENSURE(pParameter->count() > 0,"OResultSet: Fehler im Parse Tree"); - OSQLParseNode * pMark = pParameter->getChild(0); - - String aParameterName; - if (SQL_ISPUNCTUATION(pMark,"?")) - aParameterName = '?'; - else if (SQL_ISPUNCTUATION(pMark,":")) - aParameterName = pParameter->getChild(1)->getTokenValue(); - else if (SQL_ISPUNCTUATION(pMark,"[")) - aParameterName = pParameter->getChild(1)->getTokenValue(); - else - { - OSL_ASSERT("OResultSet: Fehler im Parse Tree"); - } - - // Parameter-Column aufsetzen: - sal_Int32 eType = DataType::VARCHAR; - UINT32 nPrecision = 255; - sal_Int32 nScale = 0; - sal_Int32 nNullable = ColumnValue::NULLABLE; - - if (_xCol.is()) - { - // Typ, Precision, Scale ... der angegebenen Column verwenden, - // denn dieser Column wird der Wert zugewiesen bzw. mit dieser - // Column wird der Wert verglichen. - eType = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))); - nPrecision = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))); - nScale = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))); - nNullable = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));; - } - - Reference<XPropertySet> xParaColumn = new connectivity::sdbcx::OColumn(aParameterName - ,::rtl::OUString() - ,::rtl::OUString() - ,nNullable - ,nPrecision - ,nScale - ,eType - ,sal_False - ,sal_False - ,sal_False - ,m_aSQLIterator.isCaseSensitive()); - m_xParamColumns->push_back(xParaColumn); - return nParameter; -} -// ----------------------------------------------------------------------------- -void OResultSet::describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable) -{ - Reference<XPropertySet> xProp; - if(SQL_ISRULE(_pNode,column_ref)) - { - ::rtl::OUString sColumnName,sTableRange; - m_aSQLIterator.getColumnRange(_pNode,sColumnName,sTableRange); - if(sColumnName.getLength()) - { - Reference<XNameAccess> xNameAccess = _xTable->getColumns(); - if(xNameAccess->hasByName(sColumnName)) - xNameAccess->getByName(sColumnName) >>= xProp;; - AddParameter(_pParameter,xProp); - } - } - else - AddParameter(_pParameter,xProp); -// else if(SQL_ISRULE(_pNode,num_value_exp)) -// { -// describeColumn(*aIter,_pNode->getChild(),_xTable); -// } -// else if(SQL_ISRULE(_pNode,term)) -// { -// describeColumn(*aIter,,_xTable); -// } -// else -// { -// describeColumn(*aIter,,_xTable); -// } -} -// ------------------------------------------------------------------------- -void OResultSet::describeParameter() -{ - ::std::vector< OSQLParseNode*> aParseNodes; - scanParameter(m_pParseTree,aParseNodes); - if(aParseNodes.size()) - { - m_xParamColumns = new OSQLColumns(); - const OSQLTables& xTabs = m_aSQLIterator.getTables(); - if(xTabs.size()) - { - OSQLTable xTable = xTabs.begin()->second; - ::std::vector< OSQLParseNode*>::const_iterator aIter = aParseNodes.begin(); - for (;aIter != aParseNodes.end();++aIter ) - { - describeColumn(*aIter,(*aIter)->getParent()->getChild(0),xTable); - } - } - -// ::vos::ORef<OSQLColumns> xColumns = m_aSQLIterator.getParameters(); -// if(xColumns.isValid()) -// { -// OSL_ENSURE(aParseNodes.size() == xColumns->size(),"Not all parameters found!"); -// ::rtl::OUString aTabName,aColName,aParameterName; -// OSQLColumns::iterator aIter = xColumns->begin(); -// for(;aIter != xColumns->end();++aIter) -// { -// m_xParamColumns->push_back(*aIter); -// } -// } - } + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + 0; } // ----------------------------------------------------------------------------- void OResultSet::setBoundedColumns(const OValueRow& _rRow, const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns, const Reference<XIndexAccess>& _xNames, - sal_Bool _bSetColumnMapping) + sal_Bool _bSetColumnMapping, + const Reference<XDatabaseMetaData>& _xMetaData, + ::std::vector<sal_Int32>& _rColMapping) { - ::comphelper::UStringMixEqual aCase(m_xDBMetaData->storesMixedCaseQuotedIdentifiers()); + ::comphelper::UStringMixEqual aCase(_xMetaData->storesMixedCaseQuotedIdentifiers()); Reference<XPropertySet> xTableColumn; ::rtl::OUString sTableColumnName, sSelectColumnRealName; + + const ::rtl::OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME); + const ::rtl::OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME); + const ::rtl::OUString sType = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE); + OValueVector::iterator aRowIter = _rRow->begin()+1; for (sal_Int32 i=0; // the first column is the bookmark column aRowIter != _rRow->end(); @@ -2398,7 +1886,7 @@ void OResultSet::setBoundedColumns(const OValueRow& _rRow, _xNames->getByIndex(i) >>= xTableColumn; OSL_ENSURE(xTableColumn.is(), "OResultSet::OpenImpl: invalid table column!"); if (xTableColumn.is()) - xTableColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sTableColumnName; + xTableColumn->getPropertyValue(sName) >>= sTableColumnName; else sTableColumnName = ::rtl::OUString(); @@ -2409,30 +1897,28 @@ void OResultSet::setBoundedColumns(const OValueRow& _rRow, ++aIter ) { - if((*aIter)->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME))) - (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME)) >>= sSelectColumnRealName; + if((*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName)) + (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName; else - (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sSelectColumnRealName; + (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName; if (aCase(sTableColumnName, sSelectColumnRealName)) { if(_bSetColumnMapping) { - sal_Int32 nSelectColumnPos = aIter - m_xColumns->begin() + 1; + sal_Int32 nSelectColumnPos = aIter - _rxColumns->begin() + 1; // the getXXX methods are 1-based ... sal_Int32 nTableColumnPos = i + 1; // get first table column is the bookmark column ... - m_aColMapping[nSelectColumnPos] = nTableColumnPos; + _rColMapping[nSelectColumnPos] = nTableColumnPos; } aRowIter->setBound(sal_True); sal_Int32 nType = DataType::OTHER; if (xTableColumn.is()) - xTableColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType; + xTableColumn->getPropertyValue(sType) >>= nType; aRowIter->setTypeKind(nType); } - else - aRowIter->setBound(sal_False); } } catch (Exception&) @@ -2458,11 +1944,6 @@ Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getP return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); } // ----------------------------------------------------------------------------- -OSQLAnalyzer* OResultSet::createAnalyzer() -{ - return new OSQLAnalyzer(); -} -// ----------------------------------------------------------------------------- void OResultSet::doTableSpecials(const OSQLTable& _xTable) { Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(_xTable,UNO_QUERY); @@ -2490,4 +1971,18 @@ void OResultSet::clearInsertRow() } } // ----------------------------------------------------------------------------- - +void OResultSet::initializeRow(OValueRow& _rRow,sal_Int32 _nColumnCount) +{ + if(!_rRow.isValid()) + { + _rRow = new OValueVector(_nColumnCount); + (*_rRow)[0].setBound(sal_True); + ::std::for_each(_rRow->begin()+1,_rRow->end(),TSetBound(sal_False)); + } +} +// ----------------------------------------------------------------------------- +sal_Bool OResultSet::fillIndexValues(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> &_xIndex) +{ + return sal_False; +} +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx index 2e68f8f1a596..4b9e536c53b9 100644 --- a/connectivity/source/drivers/file/FStatement.cxx +++ b/connectivity/source/drivers/file/FStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: FStatement.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: oj $ $Date: 2001-07-30 08:52:11 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -133,6 +133,11 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE( ,m_nResultSetType(ResultSetType::FORWARD_ONLY) ,m_nFetchDirection(FetchDirection::FORWARD) ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE) + ,m_pSQLAnalyzer(NULL) + ,m_aOrderbyColumnNumber(SQL_ORDERBYKEYS,SQL_COLUMN_NOTFOUND) + ,m_aOrderbyAscending(SQL_ORDERBYKEYS,1) + ,m_xDBMetaData(_pConnection->getMetaData()) + ,m_pTable(NULL) { m_pConnection->acquire(); @@ -152,6 +157,9 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE( // ----------------------------------------------------------------------------- OStatement_Base::~OStatement_Base() { + osl_incrementInterlockedCount( &m_refCount ); + disposing(); + delete m_pSQLAnalyzer; } //------------------------------------------------------------------------------ void OStatement_Base::disposeResultSet() @@ -169,7 +177,23 @@ void OStatement_BASE2::disposing() disposeResultSet(); + if(m_pSQLAnalyzer) + m_pSQLAnalyzer->dispose(); + + if(m_aRow.isValid()) + { + m_aRow->clear(); + m_aRow = NULL; + } + m_aSQLIterator.dispose(); + + if(m_pTable) + { + m_pTable->release(); + m_pTable = NULL; + } + if (m_pConnection) m_pConnection->release(); @@ -189,10 +213,8 @@ void SAL_CALL OStatement_BASE2::release() throw(RuntimeException) //----------------------------------------------------------------------------- Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException) { - Any aRet = OStatement_BASE::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OPropertySetHelper::queryInterface(rType); - return aRet; + Any aRet = OStatement_BASE::queryInterface(rType); + return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException) @@ -279,52 +301,12 @@ Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUS ::osl::MutexGuard aGuard( m_aMutex ); checkDisposed(OStatement_BASE::rBHelper.bDisposed); + construct(sql); + OResultSet* pResult = createResultSet(); + Reference< XResultSet > xRS = pResult; + initializeResultSet(pResult); - Reference< XResultSet > xRS = NULL; - - ::rtl::OUString aErr; - m_pParseTree = m_aParser.parseTree(aErr,sql); - if(m_pParseTree) - { - m_aSQLIterator.setParseTree(m_pParseTree); - m_aSQLIterator.traverseAll(); - if(m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT || m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT_COUNT) - { - const OSQLTables& xTabs = m_aSQLIterator.getTables(); - if(xTabs.begin() == xTabs.end()) - { - if(!aErr.getLength()) - { - aErr = ::rtl::OUString::createFromAscii("Unknown table name in SELECT statement:\n"); - aErr += sql; - } - throw SQLException(aErr,*this,OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_HY0000),1000,Any()); - } - - OResultSet* pResult = createResultSet(); - pResult->OpenImpl(); - xRS = pResult; - } - else - { - const OSQLTables& xTabs = m_aSQLIterator.getTables(); - if(xTabs.begin() == xTabs.end()) - { - if(!aErr.getLength()) - { - aErr = ::rtl::OUString::createFromAscii("Unknown table name in SELECT statement:\n"); - aErr += sql; - } - throw SQLException(aErr,*this,OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_HY0000),1000,Any()); - } - throw SQLException(::rtl::OUString::createFromAscii("Driver does not support this function!"),*this,::rtl::OUString::createFromAscii("IM001"),0,Any()); - } - } - else - throw SQLException(aErr,*this,OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_HY0000),1000,Any()); - - // Execute the statement. If execute returns true, a result - // set exists. + pResult->OpenImpl(); return xRS; } // ------------------------------------------------------------------------- @@ -339,27 +321,13 @@ sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) checkDisposed(OStatement_BASE::rBHelper.bDisposed); - Reference< XResultSet > xRS = NULL; + construct(sql); + OResultSet* pResult = createResultSet(); + Reference< XResultSet > xRS = pResult; + initializeResultSet(pResult); + pResult->OpenImpl(); - ::rtl::OUString aErr; - m_pParseTree = m_aParser.parseTree(aErr,sql); - if(m_pParseTree) - { - m_aSQLIterator.setParseTree(m_pParseTree); - m_aSQLIterator.traverseAll(); - const OSQLTables& xTabs = m_aSQLIterator.getTables(); - if(xTabs.begin() == xTabs.end()) - throw SQLException(aErr,*this,::rtl::OUString(),0,Any()); - - OResultSet* pResult = createResultSet(); - pResult->OpenImpl(); - xRS = pResult; - return pResult->getRowCountResult(); - } - else - throw SQLException(aErr,*this,::rtl::OUString(),0,Any()); - - return 0; + return pResult->getRowCountResult(); } // ------------------------------------------------------------------------- Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException) @@ -371,8 +339,6 @@ Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeExcepti return makeAny(m_aLastWarning); } // ------------------------------------------------------------------------- - -// ------------------------------------------------------------------------- void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException) { ::osl::MutexGuard aGuard( m_aMutex ); @@ -427,8 +393,153 @@ void SAL_CALL OStatement_Base::disposing(void) return OStatement_BASE2::queryInterface( rType); } // ----------------------------------------------------------------------------- +OSQLAnalyzer* OStatement_Base::createAnalyzer() +{ + return new OSQLAnalyzer(); +} +// ----------------------------------------------------------------------------- +void OStatement_Base::anylizeSQL() +{ + OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::anylizeSQL: Analyzer isn't set!"); + // start analysing the statement + m_pSQLAnalyzer->setOrigColumns(m_xColNames); + m_pSQLAnalyzer->start(m_pParseTree); + const OSQLParseNode* pOrderbyClause = m_aSQLIterator.getOrderTree(); + if(pOrderbyClause) + { + OSQLParseNode * pOrderingSpecCommalist = pOrderbyClause->getChild(2); + OSL_ENSURE(SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OResultSet: Fehler im Parse Tree"); + + for (sal_uInt32 m = 0; m < pOrderingSpecCommalist->count(); m++) + { + OSQLParseNode * pOrderingSpec = pOrderingSpecCommalist->getChild(m); + OSL_ENSURE(SQL_ISRULE(pOrderingSpec,ordering_spec),"OResultSet: Fehler im Parse Tree"); + OSL_ENSURE(pOrderingSpec->count() == 2,"OResultSet: Fehler im Parse Tree"); + + OSQLParseNode * pColumnRef = pOrderingSpec->getChild(0); + if(!SQL_ISRULE(pColumnRef,column_ref)) + { + throw SQLException(); + } + OSQLParseNode * pAscendingDescending = pOrderingSpec->getChild(1); + setOrderbyColumn((UINT16)m,pColumnRef,pAscendingDescending); + } + } +} +//------------------------------------------------------------------ +void OStatement_Base::setOrderbyColumn(UINT16 nOrderbyColumnNo, + OSQLParseNode* pColumnRef, + OSQLParseNode* pAscendingDescending) +{ + if (nOrderbyColumnNo >= m_aOrderbyColumnNumber.size()) + { + throw SQLException(); + } + ::rtl::OUString aColumnName; + if (pColumnRef->count() == 1) + aColumnName = pColumnRef->getChild(0)->getTokenValue(); + else if (pColumnRef->count() == 3) + { + // Nur die Table Range-Variable darf hier vorkommen: +// if (!(pColumnRef->getChild(0)->getTokenValue() == aTableRange)) +// { +// aStatus.Set(SQL_STAT_ERROR, +// String::CreateFromAscii("S1000"), +// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_INVALID_RANGE_VAR))), +// 0, String() ); + // return; + // } + pColumnRef->getChild(2)->parseNodeToStr(aColumnName,m_xDBMetaData,NULL,sal_False,sal_False); + } + else + { + // aStatus.SetStatementTooComplex(); + throw SQLException(); + } + + Reference<XColumnLocate> xColLocate(m_xColNames,UNO_QUERY); + if(!xColLocate.is()) + return; + // Alles geprueft und wir haben den Namen der Column. + // Die wievielte Column ist das? + m_aOrderbyColumnNumber[nOrderbyColumnNo] = xColLocate->findColumn(aColumnName); + + // Ascending or Descending? + m_aOrderbyAscending[nOrderbyColumnNo] = (SQL_ISTOKEN(pAscendingDescending,DESC)) ? + FALSE : TRUE; +} + +// ----------------------------------------------------------------------------- +void OStatement_Base::construct(const ::rtl::OUString& sql) throw(SQLException, RuntimeException) +{ + ::rtl::OUString aErr; + m_pParseTree = m_aParser.parseTree(aErr,sql); + if(m_pParseTree) + { + m_aSQLIterator.setParseTree(m_pParseTree); + m_aSQLIterator.traverseAll(); + const OSQLTables& xTabs = m_aSQLIterator.getTables(); + if(xTabs.empty()) + throw SQLException(::rtl::OUString::createFromAscii("Driver does not support this function!"),*this,::rtl::OUString::createFromAscii("IM001"),0,Any()); + + // at this moment we support only one table per select statement + Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xTabs.begin()->second,UNO_QUERY); + if(xTunnel.is()) + { + if(m_pTable) + m_pTable->release(); + m_pTable = (OFileTable*)xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()); + if(m_pTable) + m_pTable->acquire(); + } + OSL_ENSURE(m_pTable,"No table!"); + m_xColNames = m_pTable->getColumns(); + Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); + // set the binding of the resultrow + m_aRow = new OValueVector(xNames->getCount()); + (*m_aRow)[0].setBound(sal_True); + ::std::for_each(m_aRow->begin()+1,m_aRow->end(),TSetBound(sal_False)); + // create teh column mapping + createColumnMapping(); + + m_pSQLAnalyzer = createAnalyzer(); + + OSL_ENSURE(m_pTable,"We need a table object!"); + Reference<XIndexesSupplier> xIndexSup(xTunnel,UNO_QUERY); + if(xIndexSup.is()) + m_pSQLAnalyzer->setIndexes(xIndexSup->getIndexes()); + + anylizeSQL(); + } + else + throw SQLException(aErr,*this,::rtl::OUString(),0,Any()); +} +// ----------------------------------------------------------------------------- +void OStatement_Base::createColumnMapping() +{ + // initialize the column index map (mapping select columns to table columns) + ::vos::ORef<connectivity::OSQLColumns> xColumns = m_aSQLIterator.getSelectColumns(); + m_aColMapping.resize(xColumns->size() + 1); + for (sal_Int32 i=0; i<(sal_Int32)m_aColMapping.size(); ++i) + m_aColMapping[i] = i; + + Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); + // now check which columns are bound + OResultSet::setBoundedColumns(m_aRow,xColumns,xNames,sal_True,m_xDBMetaData,m_aColMapping); +} +// ----------------------------------------------------------------------------- +void OStatement_Base::initializeResultSet(OResultSet* _pResult) +{ + _pResult->setSqlAnalyzer(m_pSQLAnalyzer); + _pResult->setOrderByColumns(m_aOrderbyColumnNumber); + _pResult->setOrderByAscending(m_aOrderbyAscending); + _pResult->setBindingRow(m_aRow); + _pResult->setColumnMapping(m_aColMapping); + // _pResult->setTable(m_pTable); + +} } } // ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/file/FTable.cxx b/connectivity/source/drivers/file/FTable.cxx index 8fd8994aca91..26fd5691bf7f 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.11 $ + * $Revision: 1.12 $ * - * last change: $Author: fs $ $Date: 2001-07-17 12:34:42 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -200,10 +200,11 @@ Sequence< sal_Int8 > OFileTable::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OFileTable::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 OTable_TYPEDEF::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OTable_TYPEDEF::getSomething(rId); } // ----------------------------------------------------------------------------- void OFileTable::FileClose() diff --git a/connectivity/source/drivers/file/fanalyzer.cxx b/connectivity/source/drivers/file/fanalyzer.cxx index 9d97a0d9036a..6abc44b3d1a1 100644 --- a/connectivity/source/drivers/file/fanalyzer.cxx +++ b/connectivity/source/drivers/file/fanalyzer.cxx @@ -2,9 +2,9 @@ * * $RCSfile: fanalyzer.cxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.15 $ * - * last change: $Author: oj $ $Date: 2001-07-30 08:52:10 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -134,21 +134,11 @@ void OSQLAnalyzer::start(OSQLParseNode* pSQLParseNode) OSL_ENSURE(pSQLParseNode->count() == 5,"OFILECursor: Fehler im Parse Tree"); pWhereClause = pSQLParseNode->getChild(4); } - else if (SQL_ISRULE(pSQLParseNode,update_statement_positioned)) - { - // nyi - DBG_ERROR("OPredicateCompiler: update positioned nyi"); - } else if (SQL_ISRULE(pSQLParseNode,delete_statement_searched)) { OSL_ENSURE(pSQLParseNode->count() == 4,"Fehler im Parse Tree"); pWhereClause = pSQLParseNode->getChild(3); } - else if (SQL_ISRULE(pSQLParseNode,delete_statement_positioned)) - { - // nyi - DBG_ERROR("OPredicateCompiler: positioned nyi"); - } else // Anderes Statement. Keine Selektionskriterien. return; @@ -296,7 +286,7 @@ void OSQLAnalyzer::describeParam(::vos::ORef<OSQLColumns> rParameterColumns) delete pOperand; rParameterColumns = aNewParamColumns; - m_aCompiler.setParameterColumns(rParameterColumns); + // m_aCompiler.setParameterColumns(rParameterColumns); } // ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx index e759aaa39468..6307b8914a7f 100644 --- a/connectivity/source/drivers/file/fcomp.cxx +++ b/connectivity/source/drivers/file/fcomp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: fcomp.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.16 $ * - * last change: $Author: oj $ $Date: 2001-08-09 12:54:45 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:08:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -123,7 +123,6 @@ void OPredicateCompiler::dispose() { Clean(); m_orgColumns = NULL; - m_aParameterColumns = NULL; m_xIndexes = NULL; } //------------------------------------------------------------------ @@ -157,21 +156,11 @@ void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode) DBG_ASSERT(pSQLParseNode->count() == 5,"OFILECursor: Fehler im Parse Tree"); pWhereClause = pSQLParseNode->getChild(4); } - else if (SQL_ISRULE(pSQLParseNode,update_statement_positioned)) - { - // nyi - DBG_ERROR("OPredicateCompiler: update positioned nyi"); - } else if (SQL_ISRULE(pSQLParseNode,delete_statement_searched)) { DBG_ASSERT(pSQLParseNode->count() == 4,"Fehler im Parse Tree"); pWhereClause = pSQLParseNode->getChild(3); } - else if (SQL_ISRULE(pSQLParseNode,delete_statement_positioned)) - { - // nyi - DBG_ERROR("OPredicateCompiler: positioned nyi"); - } else // Anderes Statement. Keine Selektionskriterien. return; diff --git a/connectivity/source/drivers/flat/EConnection.cxx b/connectivity/source/drivers/flat/EConnection.cxx index f029257492aa..f0a8e0711358 100644 --- a/connectivity/source/drivers/flat/EConnection.cxx +++ b/connectivity/source/drivers/flat/EConnection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: EConnection.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-05-17 06:46:52 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:01:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -184,7 +184,7 @@ Reference< XDatabaseMetaData > SAL_CALL OFlatConnection::getMetaData( ) throw(S { ::osl::MutexGuard aGuard( m_aMutex ); Reference< XTablesSupplier > xTab = m_xCatalog; - if(!m_xCatalog.get().is()) + if(!m_xCatalog.is()) { OFlatCatalog *pCat = new OFlatCatalog(this); xTab = pCat; diff --git a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx index 0d0d9cd65a09..b46d3b8c6cba 100644 --- a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx +++ b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: EDatabaseMetaData.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:31:19 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:01:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -128,94 +128,92 @@ Reference< XResultSet > SAL_CALL OFlatDatabaseMetaData::getTypeInfo( ) throw(SQ ::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()); - aRow.push_back(ORowSetValue((sal_Int32)ColumnValue::NULLABLE)); - aRow.push_back(ORowSetValue((sal_Int32)1)); - aRow.push_back(ORowSetValue((sal_Int32)ColumnSearch::CHAR)); - 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("'")); - aRows.push_back(aRow); - - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("LONGVARCHAR")); - aRow[2] = ORowSetValue(DataType::LONGVARCHAR); - aRow[3] = ORowSetValue((sal_Int32)65535); - aRow[4] = ORowSetValue(::rtl::OUString::createFromAscii("'")); - aRow[5] = ORowSetValue(::rtl::OUString::createFromAscii("'")); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("DATE")); - aRow[2] = ORowSetValue(DataType::DATE); - aRow[3] = ORowSetValue((sal_Int32)10); - aRow[4] = ORowSetValue(::rtl::OUString::createFromAscii("'")); - aRow[5] = ORowSetValue(::rtl::OUString::createFromAscii("'")); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("TIME")); - aRow[2] = ORowSetValue(DataType::TIME); - aRow[3] = ORowSetValue((sal_Int32)8); - aRow[4] = ORowSetValue(::rtl::OUString::createFromAscii("'")); - aRow[5] = ORowSetValue(::rtl::OUString::createFromAscii("'")); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("TIMESTAMP")); - aRow[2] = ORowSetValue(DataType::TIMESTAMP); - aRow[3] = ORowSetValue((sal_Int32)19); - aRow[4] = ORowSetValue(::rtl::OUString::createFromAscii("'")); - aRow[5] = ORowSetValue(::rtl::OUString::createFromAscii("'")); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("BOOL")); - aRow[2] = ORowSetValue(DataType::BIT); - aRow[3] = ORowSetValue((sal_Int32)1); - 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[15] = ORowSetValue((sal_Int32)15); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("DOUBLE")); - aRow[2] = ORowSetValue(DataType::DOUBLE); - aRow[3] = ORowSetValue((sal_Int32)20); - aRow[15] = ORowSetValue((sal_Int32)0); - aRows.push_back(aRow); - - aRow[1] = ORowSetValue(::rtl::OUString::createFromAscii("NUMERIC")); - aRow[2] = ORowSetValue(DataType::NUMERIC); - aRow[3] = ORowSetValue((sal_Int32)20); - aRow[15] = ORowSetValue((sal_Int32)20); - aRows.push_back(aRow); + static ODatabaseMetaDataResultSet::ORows aRows; + if(aRows.empty()) + { + ODatabaseMetaDataResultSet::ORow aRow; + + 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(ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE)); + aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); + aRow.push_back(new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR)); + 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(); + 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); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + 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); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIME")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::TIME); + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)8); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::TIMESTAMP); + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)19); + aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue(); + aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue(); + 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[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[15] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)15); + aRows.push_back(aRow); + + aRow[1] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(::rtl::OUString::createFromAscii("DOUBLE")); + aRow[2] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(DataType::DOUBLE); + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)20); + aRow[15] = ODatabaseMetaDataResultSet::get0Value(); + 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[15] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator((sal_Int32)20); + aRows.push_back(aRow); + } pResult->setRows(aRows); return xRef; @@ -249,13 +247,9 @@ Reference< XResultSet > SAL_CALL OFlatDatabaseMetaData::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); - aRow[10] = (sal_Int32)10; + ODatabaseMetaDataResultSet::ORows aRows; + ODatabaseMetaDataResultSet::ORow aRow(19); + 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(); @@ -265,7 +259,7 @@ Reference< XResultSet > SAL_CALL OFlatDatabaseMetaData::getColumns( { Reference< XColumnsSupplier> xTable; ::cppu::extractInterface(xTable,xNames->getByName(*pTabBegin)); - aRow[3] = *pTabBegin; + aRow[3] = new ODatabaseMetaDataResultSet::ORowSetValueDecorator(*pTabBegin); Reference< XNameAccess> xColumns = xTable->getColumns(); if(!xColumns.is()) @@ -280,43 +274,40 @@ Reference< XResultSet > SAL_CALL OFlatDatabaseMetaData::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); } @@ -325,7 +316,7 @@ Reference< XResultSet > SAL_CALL OFlatDatabaseMetaData::getColumns( } ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(); - Reference< XResultSet > xRef = pResult; + Reference< XResultSet > xRef = pResult; pResult->setColumnsMap(); pResult->setRows(aRows); diff --git a/connectivity/source/drivers/flat/ENoException.cxx b/connectivity/source/drivers/flat/ENoException.cxx index 899fdb5e32b8..4b21641648ee 100644 --- a/connectivity/source/drivers/flat/ENoException.cxx +++ b/connectivity/source/drivers/flat/ENoException.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ENoException.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2001-05-23 09:17:42 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:01:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -120,73 +120,61 @@ xub_StrLen OFlatString::GetTokenCount( sal_uInt8 cTok, sal_uInt8 cStrDel ) const } //------------------------------------------------------------------ -ByteString OFlatString::GetToken( xub_StrLen nToken, sal_uInt8 cTok, sal_uInt8 cStrDel ) const +void OFlatString::GetTokenSpecial( ByteString& _rStr,xub_StrLen& nStartPos, sal_uInt8 cTok, sal_uInt8 cStrDel ) const { - if ( !Len() ) - return ByteString(); - - xub_StrLen nTok = 0; - BOOL bStart = TRUE; // Stehen wir auf dem ersten Zeichen im Token? - BOOL bInString = FALSE; // Befinden wir uns INNERHALB eines (cStrDel delimited) String? - ByteString aResult; // Ergebnisstring - - // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen - for( xub_StrLen i = 0; i < Len(); i++ ) + _rStr.Erase(); + xub_StrLen nLen = Len(); + if ( nLen ) { - if (bStart) { - bStart = FALSE; - // Erstes Zeichen ein String-Delimiter? - if ((*this).GetChar(i) == cStrDel) { - bInString = TRUE; // dann sind wir jetzt INNERHALB des Strings! - continue; // dieses Zeichen ueberlesen! - } - } + BOOL bInString = (nStartPos < nLen) && ((*this).GetChar(nStartPos) == cStrDel); // Befinden wir uns INNERHALB eines (cStrDel delimited) String? - if (bInString) { - // Wenn jetzt das String-Delimiter-Zeichen auftritt ... - if ( (*this).GetChar(i) == cStrDel ) { - if ((i+1 < Len()) && ((*this).GetChar(i+1) == cStrDel)) + // Erstes Zeichen ein String-Delimiter? + if (bInString ) + ++nStartPos; // dieses Zeichen ueberlesen! + // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen + for( xub_StrLen i = nStartPos; i < nLen; ++i ) + { + if (bInString) + { + // Wenn jetzt das String-Delimiter-Zeichen auftritt ... + if ( (*this).GetChar(i) == cStrDel ) { - // Verdoppeltes String-Delimiter-Zeichen: - i++; // kein String-Ende, naechstes Zeichen ueberlesen. + if ((i+1 < nLen) && ((*this).GetChar(i+1) == cStrDel)) + { + // Verdoppeltes String-Delimiter-Zeichen: + ++i; // kein String-Ende, naechstes Zeichen ueberlesen. - if (nTok == nToken) + _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String + } + else { - aResult += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String + // String-Ende + bInString = FALSE; } } else { - // String-Ende - bInString = FALSE; - } - } else { - if (nTok == nToken) { - aResult += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String + _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String } - } - - } else { - // Stimmt das Tokenzeichen ueberein, dann erhoehe nTok - if ( (*this).GetChar(i) == cTok ) { - nTok++; - bStart = TRUE; - if ( nTok > nToken ) + } + else + { + // Stimmt das Tokenzeichen ueberein, dann erhoehe nTok + if ( (*this).GetChar(i) == cTok ) { // Vorzeitiger Abbruch der Schleife moeglich, denn // wir haben, was wir wollten. - return aResult; + nStartPos = i+1; + break; } - } else { - if (nTok == nToken) { - aResult += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String + else + { + _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String } } } } - - return aResult; } // ----------------------------------------------------------------------------- void OFlatTable::refreshIndexes() @@ -195,8 +183,7 @@ void OFlatTable::refreshIndexes() // ----------------------------------------------------------------------------- sal_Bool OFlatTable::checkHeaderLine() { - OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; - if (m_nFilePos == 0 && pConnection->isHeaderLine()) + if (m_nFilePos == 0 && ((OFlatConnection*)m_pConnection)->isHeaderLine()) { BOOL bRead2; do @@ -237,7 +224,7 @@ sal_Bool OFlatTable::seekRow(FilePosition eCursorPosition, sal_Int32 nOffset, sa return sal_False; } - m_aRowToFilePos[m_nRowPos] = m_nFilePos; + m_aRowToFilePos.insert(::std::map<sal_Int32,sal_Int32>::value_type(m_nRowPos,m_nFilePos)); m_pFileStream->ReadLine(m_aCurrentLine); if (m_pFileStream->IsEof()) diff --git a/connectivity/source/drivers/flat/EResultSet.cxx b/connectivity/source/drivers/flat/EResultSet.cxx index 5ca899023e8a..99f2366f9533 100644 --- a/connectivity/source/drivers/flat/EResultSet.cxx +++ b/connectivity/source/drivers/flat/EResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: EResultSet.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-07-24 13:17:53 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:01:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -129,9 +129,7 @@ Any SAL_CALL OFlatResultSet::queryInterface( const Type & rType ) throw(RuntimeE return Any(); Any aRet = OResultSet::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OFlatResultSet_BASE::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : OFlatResultSet_BASE::queryInterface(rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL OFlatResultSet::getTypes( ) throw( RuntimeException) @@ -192,10 +190,6 @@ sal_Bool SAL_CALL OFlatResultSet::moveRelativeToBookmark( const Any& bookmark, // ------------------------------------------------------------------------- sal_Int32 SAL_CALL OFlatResultSet::compareBookmarks( const Any& first, const Any& second ) throw( SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - return (first == second) ? 0 : 2; } // ------------------------------------------------------------------------- @@ -206,10 +200,6 @@ sal_Bool SAL_CALL OFlatResultSet::hasOrderedBookmarks( ) throw( SQLException, // ------------------------------------------------------------------------- sal_Int32 SAL_CALL OFlatResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException) { - ::osl::MutexGuard aGuard( m_aMutex ); - checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - - return comphelper::getINT32(bookmark); } // ------------------------------------------------------------------------- @@ -239,4 +229,5 @@ void SAL_CALL OFlatResultSet::release() throw(::com::sun::star::uno::RuntimeExce { return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper()); } +// ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx index 15ef1f2b3ae1..4641003ddebe 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.33 $ + * $Revision: 1.34 $ * - * last change: $Author: oj $ $Date: 2001-07-30 08:52:09 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:01:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -164,10 +164,6 @@ void OFlatTable::fillColumns() } } - m_aTypes.clear(); - m_aPrecisions.clear(); - m_aScales.clear(); - // read first row OFlatString aFirstLine; @@ -184,17 +180,36 @@ void OFlatTable::fillColumns() } // column count xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); + + if(!m_aColumns.isValid()) + m_aColumns = new OSQLColumns(); + else + m_aColumns->clear(); + + m_aTypes.clear(); + m_aPrecisions.clear(); + m_aScales.clear(); + // reserve some space + m_aColumns->reserve(nFieldCount); + m_aTypes.reserve(nFieldCount); + m_aPrecisions.reserve(nFieldCount); + m_aScales.reserve(nFieldCount); + + sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers(); // read description char cDecimalDelimiter = pConnection->getDecimalDelimiter(); char cThousandDelimiter = pConnection->getThousandDelimiter(); ByteString aColumnName; ::rtl::OUString aTypeName; - ::comphelper::UStringMixEqual aCase(pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers()); + ::comphelper::UStringMixEqual aCase(bCase); + xub_StrLen nStartPosHeaderLine = 0; // use for eficient way to get the tokens + xub_StrLen nStartPosFirstLine = 0; // use for eficient way to get the tokens + xub_StrLen nStartPosFirstLine2 = 0; for (xub_StrLen i = 0; i < nFieldCount; i++) { if (pConnection->isHeaderLine()) { - aColumnName = aHeaderLine.GetToken(i,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); + aHeaderLine.GetTokenSpecial(aColumnName,nStartPosHeaderLine,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); aColumnName.Convert(pConnection->getTextEncoding(),pConnection->getTextEncoding()); } else @@ -212,7 +227,8 @@ void OFlatTable::fillColumns() ULONG nIndex = 0; // first without fielddelimiter - ByteString aField(aFirstLine.GetToken(i,pConnection->getFieldDelimiter(),'\0')); + ByteString aField; + aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine,pConnection->getFieldDelimiter(),'\0'); if (aField.Len() == 0 || (pConnection->getStringDelimiter() && pConnection->getStringDelimiter() == aField.GetChar(0))) { @@ -220,7 +236,11 @@ void OFlatTable::fillColumns() } else { - ByteString aField2(aFirstLine.GetToken(i,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter())); + ByteString aField2; + if(pConnection->getStringDelimiter() != '\0') + aFirstLine.GetTokenSpecial(aField2,nStartPosFirstLine2,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); + else + aField2 = aField; if (aField2.Len() == 0) { @@ -340,8 +360,14 @@ void OFlatTable::fillColumns() } sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,aTypeName,::rtl::OUString(), - ColumnValue::NULLABLE,nPrecision,nScale,eType,sal_False,sal_False,sal_False, - getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()); + ColumnValue::NULLABLE, + nPrecision, + nScale, + eType, + sal_False, + sal_False, + sal_False, + bCase); Reference< XPropertySet> xCol = pColumn; m_aColumns->push_back(xCol); m_aTypes.push_back(eType); @@ -453,6 +479,7 @@ void OFlatTable::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()); @@ -502,11 +529,8 @@ Any SAL_CALL OFlatTable::queryInterface( const Type & rType ) throw(RuntimeExcep rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)) return Any(); - Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); - if(aRet.hasValue()) - return aRet; - - return OTable_TYPEDEF::queryInterface(rType); + Any aRet = OTable_TYPEDEF::queryInterface(rType); + return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this)); } //-------------------------------------------------------------------------- @@ -529,10 +553,11 @@ Sequence< sal_Int8 > OFlatTable::getUnoTunnelImplementationId() //------------------------------------------------------------------ sal_Int64 OFlatTable::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 OFlatTable_BASE::getSomething(rId); + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + OFlatTable_BASE::getSomething(rId); } //------------------------------------------------------------------ sal_Bool OFlatTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols,sal_Bool bIsTable,sal_Bool bRetrieveData) @@ -545,13 +570,15 @@ sal_Bool OFlatTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols,sal_Boo OFlatConnection* pConnection = (OFlatConnection*)m_pConnection; sal_Int32 nByteOffset = 1; // Felder: + xub_StrLen nStartPos = 0; + ByteString aStr; OSQLColumns::const_iterator aIter = _rCols.begin(); - for (sal_Int32 i = 1; aIter != _rCols.end();++aIter, i++) + for (sal_Int32 i = 0; aIter != _rCols.end();++aIter, ++i) { - ByteString aStr(m_aCurrentLine.GetToken(i-1,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter())); + m_aCurrentLine.GetTokenSpecial(aStr,nStartPos,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter()); if (aStr.Len() == 0) - (*_rRow)[i].setNull(); + (*_rRow)[i+1].setNull(); else { // Laengen je nach Datentyp: @@ -559,8 +586,8 @@ sal_Bool OFlatTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols,sal_Boo nType; if(bIsTable) { - nLen = m_aPrecisions[i-1]; - nType = m_aTypes[i-1]; + nLen = m_aPrecisions[i]; + nType = m_aTypes[i]; } else { @@ -585,18 +612,18 @@ sal_Bool OFlatTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols,sal_Boo switch(nType) { case DataType::DATE: - (*_rRow)[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,aDate)); + (*_rRow)[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,aDate)); break; case DataType::TIMESTAMP: - (*_rRow)[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,aDate)); + (*_rRow)[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,aDate)); break; default: - (*_rRow)[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes)); + (*_rRow)[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes)); } } catch(Exception&) { - (*_rRow)[i].setNull(); + (*_rRow)[i+1].setNull(); } } break; case DataType::DOUBLE: @@ -623,14 +650,14 @@ sal_Bool OFlatTable::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols,sal_Boo aStrConverted += aStr.GetChar(j) ; } double nVal = toDouble(aStrConverted,pConnection->getTextEncoding()); - (*_rRow)[i] = nVal; + (*_rRow)[i+1] = nVal; } break; case DataType::DECIMAL: case DataType::NUMERIC: default: { // Wert als String in Variable der Row uebernehmen - (*_rRow)[i] = String(aStr, pConnection->getTextEncoding()); + (*_rRow)[i+1] = String(aStr, pConnection->getTextEncoding()); } break; } @@ -652,19 +679,19 @@ BOOL OFlatTable::DropImpl() //------------------------------------------------------------------ BOOL OFlatTable::InsertRow(OValueVector& rRow, BOOL bFlush,const Reference<XIndexAccess>& _xCols) { - return sal_True;; + return sal_False; } //------------------------------------------------------------------ BOOL OFlatTable::UpdateRow(OValueVector& rRow, OValueRow pOrgRow,const Reference<XIndexAccess>& _xCols) { - return sal_True; + return sal_False; } //------------------------------------------------------------------ BOOL OFlatTable::DeleteRow(const OSQLColumns& _rCols) { - return sal_True;; + return sal_False; } //------------------------------------------------------------------ @@ -681,7 +708,7 @@ double toDouble(const ByteString& rString,rtl_TextEncoding _nTextEncoding) //------------------------------------------------------------------ BOOL OFlatTable::UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const Reference<XIndexAccess>& _xCols) { - return sal_True; + return sal_False; } // ----------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/flat/ETables.cxx b/connectivity/source/drivers/flat/ETables.cxx index 1a0424080ecb..79e63296bbb4 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.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:31:18 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:01:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -168,7 +168,7 @@ void SAL_CALL OFlatTables::dropByIndex( sal_Int32 index ) throw(SQLException, In if (index < 0 || index >= getCount()) throw IndexOutOfBoundsException(::rtl::OUString::valueOf(index),*this); - dropByName((*m_aElements[index]).first); + dropByName(getElementName(index)); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx index dbb0bb8e8edd..9659dd0a3032 100644 --- a/connectivity/source/drivers/jdbc/CallableStatement.cxx +++ b/connectivity/source/drivers/jdbc/CallableStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CallableStatement.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-07-04 10:54:30 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:15:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -103,9 +103,7 @@ IMPLEMENT_SERVICE_INFO(java_sql_CallableStatement,"com.sun.star.sdbcx.ACallableS Any SAL_CALL java_sql_CallableStatement::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = java_sql_PreparedStatement::queryInterface(rType); - if(!aRet.hasValue()) - aRet = ::cppu::queryInterface(rType,static_cast< starsdbc::XRow*>(this),static_cast< starsdbc::XOutParameters*>(this)); - return aRet; + return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< starsdbc::XRow*>(this),static_cast< starsdbc::XOutParameters*>(this)); } // ------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_CallableStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx index c83be5edeafa..568962641bab 100644 --- a/connectivity/source/drivers/jdbc/PreparedStatement.cxx +++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: PreparedStatement.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: oj $ $Date: 2001-07-04 10:54:30 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:15:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -136,13 +136,11 @@ void java_sql_PreparedStatement::saveClassRef( jclass pClass ) ::com::sun::star::uno::Any SAL_CALL java_sql_PreparedStatement::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { ::com::sun::star::uno::Any aRet = OStatement_BASE2::queryInterface(rType); - if(!aRet.hasValue()) - aRet = ::cppu::queryInterface( rType, + return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType, static_cast< XPreparedStatement*>(this), static_cast< XParameters*>(this), static_cast< XResultSetMetaDataSupplier*>(this), static_cast< XPreparedBatchExecution*>(this)); - return aRet; } // ------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_PreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx index 3f27294537a3..4b59e2560b40 100644 --- a/connectivity/source/drivers/jdbc/ResultSet.cxx +++ b/connectivity/source/drivers/jdbc/ResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ResultSet.cxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: oj $ $Date: 2001-08-14 07:21:03 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:15:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -183,9 +183,7 @@ void java_sql_ResultSet::disposing(void) ::com::sun::star::uno::Any SAL_CALL java_sql_ResultSet::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException) { ::com::sun::star::uno::Any aRet = OPropertySetHelper::queryInterface(rType); - if(!aRet.hasValue()) - aRet = java_sql_ResultSet_BASE::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : java_sql_ResultSet_BASE::queryInterface(rType); } // ------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_ResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx index 479cbc54e5f8..9422593da2e0 100644 --- a/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx +++ b/connectivity/source/drivers/odbc/ODatabaseMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ODatabaseMetaData.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-07-17 11:26:05 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:11:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -716,18 +716,14 @@ Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLE OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CREATE_VIEW,nValue,*this); sal_Bool bViewsSupported = (nValue & SQL_CV_CREATE_VIEW) == SQL_CV_CREATE_VIEW; - ORows aRows; + ::connectivity::ODatabaseMetaDataResultSet::ORows aRows; for(sal_Int32 i=0;i < nSize;++i) { if( !bViewsSupported && i == 1) continue; // no views supported - ORow aRow; - aRow.push_back(ORowSetValue()); - aRow.push_back(ORowSetValue(sTableTypes[i])); - // bound row - ORow::iterator aIter = aRow.begin(); - for(;aIter != aRow.end();++aIter) - aIter->setBound(sal_True); + ::connectivity::ODatabaseMetaDataResultSet::ORow aRow; + aRow.push_back(::connectivity::ODatabaseMetaDataResultSet::getEmptyValue()); + aRow.push_back(new ::connectivity::ODatabaseMetaDataResultSet::ORowSetValueDecorator(sTableTypes[i])); aRows.push_back(aRow); } pResult->setRows(aRows); diff --git a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx index 34d3e01f2a5d..e77fb96cd0b7 100644 --- a/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx +++ b/connectivity/source/drivers/odbc/ODatabaseMetaDataResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: ODatabaseMetaDataResultSet.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: oj $ $Date: 2001-08-06 07:41:49 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:11:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -438,12 +438,6 @@ Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData // ------------------------------------------------------------------------- Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( m_aMutex ); - - - columnIndex = mapColumn(columnIndex); return NULL; } @@ -451,47 +445,23 @@ Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 col Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( m_aMutex ); - - - columnIndex = mapColumn(columnIndex); return NULL; } // ------------------------------------------------------------------------- Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( m_aMutex ); - - - columnIndex = mapColumn(columnIndex); return NULL; } // ------------------------------------------------------------------------- Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException) { - - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( m_aMutex ); - - - columnIndex = mapColumn(columnIndex); return NULL; } // ------------------------------------------------------------------------- Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException) { - - checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed); - ::osl::MutexGuard aGuard( m_aMutex ); - - - columnIndex = mapColumn(columnIndex); return Any(); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/drivers/odbc/OPreparedStatement.cxx b/connectivity/source/drivers/odbc/OPreparedStatement.cxx index 47200be41933..7c20fbffba43 100644 --- a/connectivity/source/drivers/odbc/OPreparedStatement.cxx +++ b/connectivity/source/drivers/odbc/OPreparedStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: OPreparedStatement.cxx,v $ * - * $Revision: 1.24 $ + * $Revision: 1.25 $ * - * last change: $Author: oj $ $Date: 2001-08-06 07:41:49 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:11:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -139,9 +139,7 @@ void SAL_CALL OPreparedStatement::release() throw(::com::sun::star::uno::Runtime Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OStatement_BASE2::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OPreparedStatement_BASE::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : OPreparedStatement_BASE::queryInterface(rType); } // ------------------------------------------------------------------------- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException) diff --git a/connectivity/source/drivers/odbc/OResultSet.cxx b/connectivity/source/drivers/odbc/OResultSet.cxx index 51414a4dedd1..ee11dc8f8e15 100644 --- a/connectivity/source/drivers/odbc/OResultSet.cxx +++ b/connectivity/source/drivers/odbc/OResultSet.cxx @@ -2,9 +2,9 @@ * * $RCSfile: OResultSet.cxx,v $ * - * $Revision: 1.38 $ + * $Revision: 1.39 $ * - * last change: $Author: oj $ $Date: 2001-08-06 10:58:36 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:11:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -307,10 +307,10 @@ void OResultSet::releaseBuffer() delete static_cast< double* >((void*)*pValue); break; case DataType::LONGVARCHAR: - delete static_cast< char* >((void*)*pValue); + delete [] static_cast< char* >((void*)*pValue); break; case DataType::LONGVARBINARY: - delete static_cast< char* >((void*)*pValue); + delete [] static_cast< char* >((void*)*pValue); break; case DataType::DATE: delete static_cast< DATE_STRUCT* >((void*)*pValue); @@ -346,9 +346,7 @@ void OResultSet::releaseBuffer() Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OPropertySetHelper::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OResultSet_BASE::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw( RuntimeException) diff --git a/connectivity/source/drivers/odbc/OResultSetMetaData.cxx b/connectivity/source/drivers/odbc/OResultSetMetaData.cxx index b96f4941a9e9..4cbbdfd0bc34 100644 --- a/connectivity/source/drivers/odbc/OResultSetMetaData.cxx +++ b/connectivity/source/drivers/odbc/OResultSetMetaData.cxx @@ -2,9 +2,9 @@ * * $RCSfile: OResultSetMetaData.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-08-06 07:41:49 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:11:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -95,7 +95,7 @@ OResultSetMetaData::~OResultSetMetaData() ),m_aStatementHandle,SQL_HANDLE_STMT,*this); if(nRealLen > BUFFER_LEN) { - delete pName; + delete [] pName; pName = new char[nRealLen]; OTools::ThrowException(m_pConnection,N3SQLColAttribute(m_aStatementHandle, (SQLUSMALLINT)column, @@ -107,7 +107,9 @@ OResultSetMetaData::~OResultSetMetaData() ),m_aStatementHandle,SQL_HANDLE_STMT,*this); } - return ::rtl::OUString::createFromAscii(pName); + ::rtl::OUString sValue = ::rtl::OUString::createFromAscii(pName); + delete [] pName; + return sValue; } // ------------------------------------------------------------------------- sal_Int32 OResultSetMetaData::getNumColAttrib(sal_Int32 _column,sal_Int32 ident) throw(SQLException, RuntimeException) diff --git a/connectivity/source/drivers/odbc/OStatement.cxx b/connectivity/source/drivers/odbc/OStatement.cxx index db2b362e03bc..d36c30c4f7ab 100644 --- a/connectivity/source/drivers/odbc/OStatement.cxx +++ b/connectivity/source/drivers/odbc/OStatement.cxx @@ -2,9 +2,9 @@ * * $RCSfile: OStatement.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: fs $ $Date: 2001-08-06 10:55:02 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:11:32 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -193,9 +193,7 @@ void SAL_CALL OStatement_BASE2::release() throw(RuntimeException) Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = OStatement_BASE::queryInterface(rType); - if(!aRet.hasValue()) - aRet = OPropertySetHelper::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException) @@ -519,9 +517,7 @@ Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLEx Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this)); - if(!aRet.hasValue()) - aRet = OStatement_Base::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx b/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx index c2f6abc85b76..c46e340b2187 100644 --- a/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx +++ b/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FDatabaseMetaDataResultSet.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-07-24 13:17:56 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:36 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -107,6 +107,9 @@ #ifndef _COMPHELPER_BROADCASTHELPER_HXX_ #include <comphelper/broadcasthelper.hxx> #endif +#ifndef _VOS_REFERNCE_HXX_ +#include <vos/refernce.hxx> +#endif namespace connectivity { @@ -119,8 +122,7 @@ namespace connectivity ::com::sun::star::sdbc::XCloseable, ::com::sun::star::sdbc::XColumnLocate> ODatabaseMetaDataResultSet_BASE; - DECLARE_STL_VECTOR(ORowSetValue,ORow); - DECLARE_STL_VECTOR(ORow, ORows); + // typedef ORefVector<ORowSetValue> ORow; // typedef ORefVector<ORow> ORows; @@ -130,9 +132,32 @@ namespace connectivity public ::comphelper::OPropertyArrayUsageHelper<ODatabaseMetaDataResultSet> { + public: + /// ORowSetValueDecorator decorates a ORowSetValue so the value is "refcounted" + class ORowSetValueDecorator : public ::vos::OReference + { + ORowSetValue m_aValue; // my own value + public: + ORowSetValueDecorator(){m_aValue.setBound(sal_True);} + ORowSetValueDecorator(const ORowSetValue& _aValue) : m_aValue(_aValue){m_aValue.setBound(sal_True);} + ORowSetValueDecorator& operator=(const ORowSetValue& _aValue); + + operator const ORowSetValue&() const { return m_aValue; } + const ORowSetValue& getValue() const { return m_aValue; } + void setValue(const ORowSetValue& _aValue) { m_aValue = _aValue; } + void setNull() { m_aValue.setNull(); } + + }; + typedef ::vos::ORef<ORowSetValueDecorator> ORowSetValueDecoratorRef; + + DECLARE_STL_VECTOR(ORowSetValueDecoratorRef,ORow); + DECLARE_STL_VECTOR(ORow, ORows); + + private: ORows m_aRows; ORows::iterator m_aRowsIter; + ORowSetValue m_aEmptyValue; ::com::sun::star::uno::WeakReferenceHelper m_aStatement; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; sal_Int32 m_nRowPos; @@ -150,12 +175,14 @@ namespace connectivity void checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException); protected: + const ORowSetValue& getValue(sal_Int32 columnIndex); // OPropertyArrayUsageHelper virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; // OPropertySetHelper virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); - ~ODatabaseMetaDataResultSet(); + + virtual ~ODatabaseMetaDataResultSet(); public: virtual void SAL_CALL acquire() throw(::com::sun::star::uno::RuntimeException); virtual void SAL_CALL release() throw(::com::sun::star::uno::RuntimeException); @@ -241,6 +268,36 @@ namespace connectivity void setTypeInfoMap(); void setBestRowIdentifierMap(); void setVersionColumnsMap(); + + // some methods to get already defined ORowSetValues + // this increase the reuse of ORowSetValues + /// return an empty ORowSetValueDecorator + static ORowSetValueDecoratorRef getEmptyValue(); + /// return an ORowSetValueDecorator with 0 as value + static ORowSetValueDecoratorRef get0Value(); + /// return an ORowSetValueDecorator with 1 as value + static ORowSetValueDecoratorRef get1Value(); + /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value + static ORowSetValueDecoratorRef getBasicValue(); + /// return an ORowSetValueDecorator with string SELECT as value + static ORowSetValueDecoratorRef getSelectValue(); + /// return an ORowSetValueDecorator with string INSERT as value + static ORowSetValueDecoratorRef getInsertValue(); + /// return an ORowSetValueDecorator with string DELETE as value + static ORowSetValueDecoratorRef getDeleteValue(); + /// return an ORowSetValueDecorator with string UPDATE as value + static ORowSetValueDecoratorRef getUpdateValue(); + /// return an ORowSetValueDecorator with string CREATE as value + static ORowSetValueDecoratorRef getCreateValue(); + /// return an ORowSetValueDecorator with string READ as value + static ORowSetValueDecoratorRef getReadValue(); + /// return an ORowSetValueDecorator with string ALTER as value + static ORowSetValueDecoratorRef getAlterValue(); + /// return an ORowSetValueDecorator with string DROP as value + static ORowSetValueDecoratorRef getDropValue(); + /// return an ORowSetValueDecorator with string ' as value + static ORowSetValueDecoratorRef getQuoteValue(); + }; } #endif // _CONNECTIVITY_FDATABASEMETADATARESULTSET_HXX_ diff --git a/connectivity/source/inc/TConnection.hxx b/connectivity/source/inc/TConnection.hxx index 03ad3ad99a96..cade74163039 100644 --- a/connectivity/source/inc/TConnection.hxx +++ b/connectivity/source/inc/TConnection.hxx @@ -2,9 +2,9 @@ * * $RCSfile: TConnection.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-05-18 08:31:18 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -107,7 +107,7 @@ namespace connectivity OMetaConnection() : OMetaConnection_BASE(m_aMutex) ,m_nTextEncoding(RTL_TEXTENCODING_MS_1252){} - rtl_TextEncoding getTextEncoding() const { return m_nTextEncoding; } + inline rtl_TextEncoding getTextEncoding() const { return m_nTextEncoding; } //XUnoTunnel virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw (::com::sun::star::uno::RuntimeException); diff --git a/connectivity/source/inc/adabas/BConnection.hxx b/connectivity/source/inc/adabas/BConnection.hxx index 6c9c724fd6b7..37a93e594bc8 100644 --- a/connectivity/source/inc/adabas/BConnection.hxx +++ b/connectivity/source/inc/adabas/BConnection.hxx @@ -2,9 +2,9 @@ * * $RCSfile: BConnection.hxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2001-04-27 10:08:11 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,7 +88,7 @@ namespace connectivity class OAdabasConnection : public OConnection_BASE2 { - ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; sal_Bool isStarted(); diff --git a/connectivity/source/inc/adabas/BDriver.hxx b/connectivity/source/inc/adabas/BDriver.hxx index 3599ee3b35d6..f921658bf352 100644 --- a/connectivity/source/inc/adabas/BDriver.hxx +++ b/connectivity/source/inc/adabas/BDriver.hxx @@ -2,9 +2,9 @@ * * $RCSfile: BDriver.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-05-30 14:16:08 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -92,7 +92,6 @@ namespace connectivity class ODriver : public ODriver_BASE, public ::com::sun::star::sdbcx::XDataDefinitionSupplier { - ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; protected: virtual SQLHANDLE EnvironmentHandle(::rtl::OUString &_rPath); public: diff --git a/connectivity/source/inc/adabas/BUser.hxx b/connectivity/source/inc/adabas/BUser.hxx index b4691766675c..d373c1453988 100644 --- a/connectivity/source/inc/adabas/BUser.hxx +++ b/connectivity/source/inc/adabas/BUser.hxx @@ -2,9 +2,9 @@ * * $RCSfile: BUser.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-06-20 09:29:42 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:37 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -86,8 +86,6 @@ namespace connectivity OAdabasUser( OAdabasConnection* _pConnection); OAdabasUser( OAdabasConnection* _pConnection,const ::rtl::OUString& _Name); - // XInterface - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); // XUser virtual void SAL_CALL changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); // XAuthorizable diff --git a/connectivity/source/inc/ado/AConnection.hxx b/connectivity/source/inc/ado/AConnection.hxx index aee6447712f4..205977e4a54c 100644 --- a/connectivity/source/inc/ado/AConnection.hxx +++ b/connectivity/source/inc/ado/AConnection.hxx @@ -2,9 +2,9 @@ * * $RCSfile: AConnection.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-04-27 10:08:12 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -113,7 +113,7 @@ namespace connectivity connectivity::OWeakRefArray m_aStatements; // vector containing a list // of all the Statement objects // for this Connection - ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; ODriver* m_pDriver; private: WpADOConnection* m_pAdoConnection; diff --git a/connectivity/source/inc/dbase/DTable.hxx b/connectivity/source/inc/dbase/DTable.hxx index 6e802371da26..947cd875b0be 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.26 $ + * $Revision: 1.27 $ * - * last change: $Author: oj $ $Date: 2001-08-10 11:05:34 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -154,7 +154,7 @@ namespace connectivity BOOL WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr); BOOL WriteBuffer(); BOOL UpdateBuffer(OValueVector& rRow, OValueRow pOrgRow,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xCols); - ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> isUniqueByColumnName(const ::rtl::OUString& _rColName); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> isUniqueByColumnName(sal_Int32 _nColumnPos); void AllocBuffer(); void throwInvalidDbaseFormat(); diff --git a/connectivity/source/inc/file/FConnection.hxx b/connectivity/source/inc/file/FConnection.hxx index ef6d8605c381..1ad2cf50ca75 100644 --- a/connectivity/source/inc/file/FConnection.hxx +++ b/connectivity/source/inc/file/FConnection.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FConnection.hxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: oj $ $Date: 2001-07-04 10:54:31 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -121,7 +121,7 @@ namespace connectivity // Data attributes //==================================================================== ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; - ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; + ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog; ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by diff --git a/connectivity/source/inc/file/FPreparedStatement.hxx b/connectivity/source/inc/file/FPreparedStatement.hxx index 0247e17a504c..448a5db96c59 100644 --- a/connectivity/source/inc/file/FPreparedStatement.hxx +++ b/connectivity/source/inc/file/FPreparedStatement.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FPreparedStatement.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-07-23 07:55:59 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,13 +102,18 @@ namespace connectivity //==================================================================== // Data attributes //==================================================================== - + ::std::vector<sal_Int32> m_aParameterIndexes; // maps the parameter index to column index ::rtl::OUString m_aSql; - OValueRow m_aRow; + OValueRow m_aEvaluateRow; // contains all values of a row + OValueRow m_aParameterRow; + ORefAssignValues m_aAssignValues; // needed for insert,update and parameters + // to compare with the restrictions + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; - // ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet > m_xRS; // only to enshure that the result isn't deleted + OResultSet* m_pResultSet; - OFileTable* m_pTable; + TIntVector* m_pEvaluationKeySet; + ::vos::ORef<connectivity::OSQLColumns> m_xParamColumns; // the parameter columns // factory method for resultset's virtual OResultSet* createResultSet(); @@ -117,12 +122,28 @@ namespace connectivity void checkAndResizeParameters(sal_Int32 parameterIndex); void setParameter(sal_Int32 parameterIndex, const ORowSetValue& x); + + void GetAssignValues(); + void SetAssignValue(const String& aColumnName, + const String& aValue, + BOOL bSetNull = FALSE, + UINT32 nParameter=SQL_NO_PARAMETER); + UINT32 AddParameter(connectivity::OSQLParseNode * pParameter, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol); + void scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes); + void describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable); + void describeParameter(); + + void ParseAssignValues( const ::std::vector< String>& aColumnNameList, + connectivity::OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex); + + virtual void initializeResultSet(OResultSet* _pResult); public: DECLARE_SERVICE_INFO(); // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: OPreparedStatement( OConnection* _pConnection); - void construct(const ::rtl::OUString& sql) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + virtual void construct(const ::rtl::OUString& sql) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); // OComponentHelper virtual void SAL_CALL disposing(void); diff --git a/connectivity/source/inc/file/FResultSet.hxx b/connectivity/source/inc/file/FResultSet.hxx index a03070c265e3..54193927a223 100644 --- a/connectivity/source/inc/file/FResultSet.hxx +++ b/connectivity/source/inc/file/FResultSet.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FResultSet.hxx,v $ * - * $Revision: 1.23 $ + * $Revision: 1.24 $ * - * last change: $Author: oj $ $Date: 2001-08-10 11:04:03 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -138,9 +138,6 @@ namespace connectivity rtl::OUString* pString; } OFILEKey; -#define SQL_ORDERBYKEYS 10 -#define SQL_COLUMN_NOTFOUND STRING_NOTFOUND - class OFILEKeyValue { private: @@ -189,13 +186,13 @@ namespace connectivity // auf den gerade zur Sortierung verwendeten Index hinterlegt // (wird von der Vergleichsfunktion OFILEKeyCompare verwendet). OKeyType eKeyType[SQL_ORDERBYKEYS]; - BOOL bAscending[SQL_ORDERBYKEYS]; + ::std::vector<sal_Int16> m_aAscending; public: OFILESortIndex(const OKeyType eKeyType[], // Art des Schluessels: numerisch/String/nicht sortieren (Genau 3 Eintraege!) - const BOOL bAscending[], // TRUE = Aufsteigend sortieren (Genau 3 Eintraege!) + const ::std::vector<sal_Int16>& _aAscending, // TRUE = Aufsteigend sortieren (Genau 3 Eintraege!) INT32 nMaxNumberOfRows, rtl_TextEncoding eSet); @@ -255,6 +252,9 @@ OFILEKeyCompare(const void * elem1, const void * elem2); ::std::vector<void*> m_aBindVector; ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime + ::std::vector<sal_Int32> m_aOrderbyColumnNumber; + ::std::vector<sal_Int16> m_aOrderbyAscending; + OValueRow m_aRow; OValueRow m_aEvaluateRow; // contains all values of a row OValueRow m_aParameterRow; @@ -271,8 +271,7 @@ OFILEKeyCompare(const void * elem1, const void * elem2); OKeySet* m_pFileSet; OKeySet::iterator m_aFileSetIter; - sal_Int32 m_nOrderbyColumnNumber[SQL_ORDERBYKEYS]; - BOOL bOrderbyAscending[SQL_ORDERBYKEYS]; + OFILESortIndex* m_pSortIndex; ::vos::ORef<connectivity::OSQLColumns> m_xColumns; // this are the select columns @@ -292,6 +291,8 @@ OFILEKeyCompare(const void * elem1, const void * elem2); ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData; ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns + ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess> m_xColsIdx; // table columns + ::rtl::OUString m_aTableRange; rtl_TextEncoding m_nTextEncoding; @@ -311,36 +312,19 @@ OFILEKeyCompare(const void * elem1, const void * elem2); sal_Bool m_bRowDeleted; sal_Bool m_bShowDeleted; + void initializeRow(OValueRow& _rRow,sal_Int32 _nColumnCount); void construct(); sal_Bool evaluate(); - void describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable); + BOOL ExecuteRow(OFileTable::FilePosition eFirstCursorPosition, INT32 nOffset = 1, BOOL bRebind = TRUE, BOOL bEvaluate = TRUE, BOOL bRetrieveData = TRUE); - void setBoundedColumns(const OValueRow& _rRow, - const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns, - const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xNames, - sal_Bool _bSetColumnMapping); - OFILEKeyValue* GetOrderbyKeyValue(OValueRow _rRow); - BOOL IsSorted() const {return m_nOrderbyColumnNumber[0] != SQL_COLUMN_NOTFOUND;} - void anylizeSQL(); - void setOrderbyColumn(UINT16 nOrderbyColumnNo, - connectivity::OSQLParseNode* pColumnRef, - connectivity::OSQLParseNode* pAscendingDescending); - void SetAssignValue(const String& aColumnName, - const String& aValue, - BOOL bSetNull = FALSE, - UINT32 nParameter=SQL_NO_PARAMETER); - void ParseAssignValues( const ::std::vector< String>& aColumnNameList, - connectivity::OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex); - UINT32 AddParameter(connectivity::OSQLParseNode * pParameter, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol); - void GetAssignValues(); - - void scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes); + BOOL IsSorted() const { return m_aOrderbyColumnNumber[0] != SQL_COLUMN_NOTFOUND;} + sal_Bool moveAbsolute(sal_Int32 _nOffset,sal_Bool _bRetrieveData); // return true when the select statement is "select count(*) from table" sal_Bool isCount() const; @@ -356,23 +340,18 @@ OFILEKeyCompare(const void * elem1, const void * elem2); BOOL Move(OFileTable::FilePosition eCursorPosition, INT32 nOffset, BOOL bRetrieveData); BOOL SkipDeleted(OFileTable::FilePosition eCursorPosition, INT32 nOffset, BOOL bRetrieveData); - // create the analyzer - virtual OSQLAnalyzer* createAnalyzer(); - - virtual sal_Bool fillIndexValues(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> &_xIndex) - { return sal_False; } + virtual sal_Bool fillIndexValues(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> &_xIndex); // OPropertyArrayUsageHelper virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; // OPropertySetHelper virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); + virtual ~OResultSet(); public: DECLARE_SERVICE_INFO(); // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird: OResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator); - ~OResultSet(); - ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *() { @@ -475,8 +454,26 @@ OFILEKeyCompare(const void * elem1, const void * elem2); virtual void doTableSpecials(const OSQLTable& _xTable); sal_Int32 getRowCountResult() const { return m_nRowCountResult; } - void setParameterRow(const OValueRow& _rParaRow) { m_aParameterRow = _rParaRow; } - void describeParameter(); + void setParameterRow(const OValueRow& _rParaRow) { m_aParameterRow = _rParaRow; } + void setEvaluationRow(const OValueRow& _aRow) { m_aEvaluateRow = _aRow; } + void setParameterColumns(const ::vos::ORef<connectivity::OSQLColumns>& _xParamColumns) { m_xParamColumns = _xParamColumns; } + void setAssignValues(const ORefAssignValues& _aAssignValues) { m_aAssignValues = _aAssignValues; } + void setBindingRow(const OValueRow& _aRow) { m_aRow = _aRow; } + void setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMapping) { m_aColMapping = _aColumnMapping; } + void setSqlAnalyzer(OSQLAnalyzer* _pSQLAnalyzer) { m_pSQLAnalyzer = _pSQLAnalyzer; } + + void setOrderByColumns(const ::std::vector<sal_Int32>& _aColumnOrderBy) { m_aOrderbyColumnNumber = _aColumnOrderBy; } + void setOrderByAscending(const ::std::vector<sal_Int16>& _aOrderbyAsc) { m_aOrderbyAscending = _aOrderbyAsc; } + void setEvaluationKeySet(TIntVector* _pEvaluationKeySet) { m_pEvaluationKeySet = _pEvaluationKeySet; } + + // clears the resultset so it can be reused by a preparedstatement + void clear(); + static void setBoundedColumns(const OValueRow& _rRow, + const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns, + const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xNames, + sal_Bool _bSetColumnMapping, + const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData, + ::std::vector<sal_Int32>& _rColMapping); }; // ------------------------------------------------------------------------- inline sal_Int32 OResultSet::mapColumn(sal_Int32 column) diff --git a/connectivity/source/inc/file/FStatement.hxx b/connectivity/source/inc/file/FStatement.hxx index 062df51d98d0..0297181f025a 100644 --- a/connectivity/source/inc/file/FStatement.hxx +++ b/connectivity/source/inc/file/FStatement.hxx @@ -2,9 +2,9 @@ * * $RCSfile: FStatement.hxx,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: oj $ $Date: 2001-05-23 14:05:55 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -114,11 +114,15 @@ #include <comphelper/broadcasthelper.hxx> #endif +#define SQL_ORDERBYKEYS 10 +#define SQL_COLUMN_NOTFOUND STRING_NOTFOUND + namespace connectivity { namespace file { class OResultSet; + class OFileTable; typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbc::XStatement, ::com::sun::star::sdbc::XWarningsSupplier, ::com::sun::star::util::XCancellable, @@ -134,17 +138,26 @@ namespace connectivity { protected: + ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime + ::std::vector<sal_Int32> m_aOrderbyColumnNumber; + ::std::vector<sal_Int16> m_aOrderbyAscending; + ::com::sun::star::sdbc::SQLWarning m_aLastWarning; ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created - // for this Statement + ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData; + ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns // for this Statement connectivity::OSQLParser m_aParser; connectivity::OSQLParseTreeIterator m_aSQLIterator; - OConnection* m_pConnection;// The owning Connection object connectivity::OSQLParseNode* m_pParseTree; + OSQLAnalyzer* m_pSQLAnalyzer; //the sql analyzer used by the resultset + + OFileTable* m_pTable; // the current table + OValueRow m_aRow; + ::rtl::OUString m_aCursorName; sal_Int32 m_nMaxFieldSize; @@ -155,7 +168,19 @@ namespace connectivity sal_Int32 m_nFetchDirection; sal_Int32 m_nResultSetConcurrency; sal_Bool m_bEscapeProcessing; + protected: + // initialize the column index map (mapping select columns to table columns) + void createColumnMapping(); + // searches the statement for sort criteria + void anylizeSQL(); + void setOrderbyColumn(UINT16 nOrderbyColumnNo, + connectivity::OSQLParseNode* pColumnRef, + connectivity::OSQLParseNode* pAscendingDescending); + + virtual void initializeResultSet(OResultSet* _pResult); + // create the analyzer + virtual OSQLAnalyzer* createAnalyzer(); void reset () throw( ::com::sun::star::sdbc::SQLException); void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException); @@ -180,6 +205,9 @@ namespace connectivity OConnection* getOwnConnection() const { return m_pConnection;} using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >; + + virtual void construct(const ::rtl::OUString& sql) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); + // OComponentHelper virtual void SAL_CALL disposing(void); // XInterface diff --git a/connectivity/source/inc/file/fanalyzer.hxx b/connectivity/source/inc/file/fanalyzer.hxx index 0c86610a8004..b54db66c55ef 100644 --- a/connectivity/source/inc/file/fanalyzer.hxx +++ b/connectivity/source/inc/file/fanalyzer.hxx @@ -2,9 +2,9 @@ * * $RCSfile: fanalyzer.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-06-27 10:02:09 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -94,7 +94,6 @@ namespace connectivity virtual BOOL hasRestriction() const; BOOL evaluateRestriction() {return m_aInterpreter.start();} void setOrigColumns(const OFileColumns& rCols) { m_aCompiler.setOrigColumns(rCols); } - void setParameterColumns(::vos::ORef< connectivity::OSQLColumns > _rParaCols) { m_aCompiler.setParameterColumns(_rParaCols); } virtual OOperandAttr* createOperandAttr(sal_Int32 _nPos, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _xIndexes=NULL); diff --git a/connectivity/source/inc/file/fcomp.hxx b/connectivity/source/inc/file/fcomp.hxx index d45670d32c7c..de7c29053351 100644 --- a/connectivity/source/inc/file/fcomp.hxx +++ b/connectivity/source/inc/file/fcomp.hxx @@ -2,9 +2,9 @@ * * $RCSfile: fcomp.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-05-23 09:10:29 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:38 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,7 +84,6 @@ namespace connectivity OCodeList m_aCodeList; OFileColumns m_orgColumns; // in filecurs this are the filecolumns - ::vos::ORef< connectivity::OSQLColumns> m_aParameterColumns; OSQLAnalyzer* m_pAnalyzer; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xIndexes; sal_Int32 m_nParamCounter; @@ -104,12 +103,6 @@ namespace connectivity sal_Bool hasORCondition() const {return m_bORCondition;} void setOrigColumns(const OFileColumns& rCols) { m_orgColumns = rCols; } const OFileColumns getOrigColumns() const { return m_orgColumns; } - - void setParameterColumns(::vos::ORef< connectivity::OSQLColumns > _rParaCols) - { - m_aParameterColumns = _rParaCols; - } - protected: OOperand* execute_COMPARE(connectivity::OSQLParseNode* pPredicateNode) throw( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); OOperand* execute_LIKE(connectivity::OSQLParseNode* pPredicateNode) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); diff --git a/connectivity/source/inc/flat/EConnection.hxx b/connectivity/source/inc/flat/EConnection.hxx index 195d6d4456e4..35ad9f24efee 100644 --- a/connectivity/source/inc/flat/EConnection.hxx +++ b/connectivity/source/inc/flat/EConnection.hxx @@ -2,9 +2,9 @@ * * $RCSfile: EConnection.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2000-10-05 14:46:14 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -87,12 +87,12 @@ namespace connectivity virtual void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException); // own methods - sal_Bool isFixedLength() const { return m_bFixedLength; } - sal_Bool isHeaderLine() const { return m_bHeaderLine; } - sal_uInt8 getFieldDelimiter() const { return m_cFieldDelimiter; } - sal_uInt8 getStringDelimiter() const { return m_cStringDelimiter; } - sal_uInt8 getDecimalDelimiter() const { return m_cDecimalDelimiter; } - sal_uInt8 getThousandDelimiter() const { return m_cThousandDelimiter;} + inline sal_Bool isFixedLength() const { return m_bFixedLength; } + inline sal_Bool isHeaderLine() const { return m_bHeaderLine; } + inline sal_uInt8 getFieldDelimiter() const { return m_cFieldDelimiter; } + inline sal_uInt8 getStringDelimiter() const { return m_cStringDelimiter; } + inline sal_uInt8 getDecimalDelimiter() const { return m_cDecimalDelimiter; } + inline sal_uInt8 getThousandDelimiter() const { return m_cThousandDelimiter;} // XServiceInfo DECLARE_SERVICE_INFO(); diff --git a/connectivity/source/inc/flat/ETable.hxx b/connectivity/source/inc/flat/ETable.hxx index ed0a2958d945..3ac570ef8f23 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.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-07-30 08:52:08 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:00:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -90,7 +90,7 @@ namespace connectivity OFlatString(){} xub_StrLen GetTokenCount( sal_uInt8 cTok = ';', sal_uInt8 cStrDel = '\0' ) const; - ByteString GetToken( xub_StrLen nToken, sal_uInt8 cTok = ';', sal_uInt8 cStrDel = '\0' ) const; + void GetTokenSpecial( ByteString& _rStr,xub_StrLen& nStartPos, sal_uInt8 cTok = ';', sal_uInt8 cStrDel = '\0' ) const; }; diff --git a/connectivity/source/inc/mozaddressbook/MABConnection.hxx b/connectivity/source/inc/mozaddressbook/MABConnection.hxx index 08b52fc58c69..a8880a0d57d9 100644 --- a/connectivity/source/inc/mozaddressbook/MABConnection.hxx +++ b/connectivity/source/inc/mozaddressbook/MABConnection.hxx @@ -2,9 +2,9 @@ * * $RCSfile: MABConnection.hxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: wvd $ $Date: 2001-07-19 13:57:25 $ + * last change: $Author: oj $ $Date: 2001-08-24 05:58:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -82,7 +82,8 @@ namespace connectivity class OMozabDriver; class OMozabConnection : public file::OConnection { - OMozabColumnAlias m_aColumnAlias; + OMozabColumnAlias m_aColumnAlias; + ::rtl::OUString m_sURL; // contains the real url set by construct rtl::OUString m_sMozillaURI; sal_Int32 m_nAnonABCount; sal_Int32 m_nMaxResultRecords; @@ -115,6 +116,8 @@ namespace connectivity rtl::OUString getMozURI() const { return m_sMozillaURI; } + ::rtl::OUString getConnectionURL() const { return m_sURL; } + sal_Bool usesFactory(void) const { return m_UsesFactory ; } sal_Bool isLDAP(void) const { return m_IsLDAP ; } diff --git a/connectivity/source/inc/mozaddressbook/MABDatabaseMetaData.hxx b/connectivity/source/inc/mozaddressbook/MABDatabaseMetaData.hxx index d2ffab7bd2f9..3b69f9568d98 100644 --- a/connectivity/source/inc/mozaddressbook/MABDatabaseMetaData.hxx +++ b/connectivity/source/inc/mozaddressbook/MABDatabaseMetaData.hxx @@ -2,9 +2,9 @@ * * $RCSfile: MABDatabaseMetaData.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-06-01 08:29:26 $ + * last change: $Author: oj $ $Date: 2001-08-24 05:58:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -321,8 +321,6 @@ namespace connectivity throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes() - throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo() diff --git a/connectivity/source/inc/mozaddressbook/MABDatabaseMetaDataHelper.hxx b/connectivity/source/inc/mozaddressbook/MABDatabaseMetaDataHelper.hxx index 6d16b4592456..70e2f7db21f7 100644 --- a/connectivity/source/inc/mozaddressbook/MABDatabaseMetaDataHelper.hxx +++ b/connectivity/source/inc/mozaddressbook/MABDatabaseMetaDataHelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: MABDatabaseMetaDataHelper.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-07-03 10:21:57 $ + * last change: $Author: oj $ $Date: 2001-08-24 05:58:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -127,7 +127,7 @@ namespace connectivity public: OMozabDatabaseMetaDataHelper( ); ~OMozabDatabaseMetaDataHelper(); - connectivity::ORows &getTables( OMozabConnection* _pCon ); + ODatabaseMetaDataResultSet::ORows& getTables( OMozabConnection* _pCon ); private: sal_Bool m_bProfileExists ; }; diff --git a/connectivity/source/inc/mozaddressbook/MABPreparedStatement.hxx b/connectivity/source/inc/mozaddressbook/MABPreparedStatement.hxx index 710030701f79..1f486f64013a 100644 --- a/connectivity/source/inc/mozaddressbook/MABPreparedStatement.hxx +++ b/connectivity/source/inc/mozaddressbook/MABPreparedStatement.hxx @@ -2,9 +2,9 @@ * * $RCSfile: MABPreparedStatement.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2001-05-29 13:06:43 $ + * last change: $Author: oj $ $Date: 2001-08-24 05:58:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -75,6 +75,9 @@ namespace connectivity { protected: virtual file::OResultSet* createResultSet(); + // here we create a SQL analyzer which doesn't support any restrictions + // these are already done by the server side + virtual file::OSQLAnalyzer* createAnalyzer(); public: // DECLARE_CTY_DEFAULTS(file::OStatement); OMozabPreparedStatement( file::OConnection* _pConnection ) : file::OPreparedStatement( _pConnection ){} diff --git a/connectivity/source/inc/mozaddressbook/MABQueryHelper.hxx b/connectivity/source/inc/mozaddressbook/MABQueryHelper.hxx index f61fd90bc952..9c4c87c97aab 100644 --- a/connectivity/source/inc/mozaddressbook/MABQueryHelper.hxx +++ b/connectivity/source/inc/mozaddressbook/MABQueryHelper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: MABQueryHelper.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: mmaher $ $Date: 2001-07-20 15:34:17 $ + * last change: $Author: oj $ $Date: 2001-08-24 05:58:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -64,12 +64,21 @@ #include <MABNSInclude.hxx> +#ifndef _SAL_TYPES_H_ #include <sal/types.h> -#include <map> -#include <vector> +#endif +#ifndef _RTL_USTRING_HXX_ #include <rtl/ustring.hxx> +#endif +#ifndef _OSL_MUTEX_HXX_ #include <osl/mutex.hxx> +#endif +#ifndef _OSL_CONDITN_HXX_ #include <osl/conditn.hxx> +#endif +#ifndef _COMPHELPER_STLTYPES_HXX_ +#include <comphelper/stl_types.hxx> +#endif namespace connectivity @@ -81,12 +90,7 @@ namespace connectivity private: mutable ::osl::Mutex m_aMutex; - struct ltstr - { - sal_Bool operator()( const ::rtl::OUString &s1, const ::rtl::OUString &s2) const; - }; - - typedef std::map< rtl::OUString, rtl::OUString, ltstr > fieldMap; + DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUString,fieldMap); fieldMap m_Fields; diff --git a/connectivity/source/inc/mozaddressbook/MABResultSet.hxx b/connectivity/source/inc/mozaddressbook/MABResultSet.hxx index 24d2c89bda7f..3ba620d2722d 100644 --- a/connectivity/source/inc/mozaddressbook/MABResultSet.hxx +++ b/connectivity/source/inc/mozaddressbook/MABResultSet.hxx @@ -2,9 +2,9 @@ * * $RCSfile: MABResultSet.hxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: oj $ $Date: 2001-06-27 10:02:08 $ + * last change: $Author: oj $ $Date: 2001-08-24 05:58:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -103,9 +103,6 @@ namespace connectivity virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper(); virtual sal_Bool fillIndexValues(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XColumnsSupplier> &_xIndex); - // here we create a SQL analyzer which doesn't support any restrictions - // these are already done by the server side - virtual file::OSQLAnalyzer* createAnalyzer(); public: DECLARE_SERVICE_INFO(); diff --git a/connectivity/source/inc/mozaddressbook/MABStatement.hxx b/connectivity/source/inc/mozaddressbook/MABStatement.hxx index 3ba786cb6332..1bd313df582d 100644 --- a/connectivity/source/inc/mozaddressbook/MABStatement.hxx +++ b/connectivity/source/inc/mozaddressbook/MABStatement.hxx @@ -2,9 +2,9 @@ * * $RCSfile: MABStatement.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: dkenny $ $Date: 2001-05-28 22:02:59 $ + * last change: $Author: oj $ $Date: 2001-08-24 05:58:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -65,16 +65,35 @@ #ifndef _CONNECTIVITY_FILE_OSTATEMENT_HXX_ #include "file/FStatement.hxx" #endif +#ifndef _CONNECTIVITY_FILE_FANALYZER_HXX_ +#include "file/fanalyzer.hxx" +#endif namespace connectivity { namespace mozaddressbook { + // ----------------------------------------------------------------------------- + typedef ::connectivity::file::OSQLAnalyzer OMozabAnalyzer_BASE; + /** little helper class to avoid filtering by the file resultset + this analyzer doesn't soppurt restrictions + */ + + class OMozabAnalyzer : public OMozabAnalyzer_BASE + { + public: + OMozabAnalyzer(){} + virtual BOOL hasRestriction() const; + }; + class OConnection; class OMozabStatement : public file::OStatement { protected: virtual file::OResultSet* createResultSet(); + // here we create a SQL analyzer which doesn't support any restrictions + // these are already done by the server side + virtual file::OSQLAnalyzer* createAnalyzer(); public: // DECLARE_CTY_DEFAULTS(file::OStatement); OMozabStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){} diff --git a/connectivity/source/inc/mozaddressbook/MABTypeConverter.hxx b/connectivity/source/inc/mozaddressbook/MABTypeConverter.hxx index 52355617b219..f4a73067126b 100644 --- a/connectivity/source/inc/mozaddressbook/MABTypeConverter.hxx +++ b/connectivity/source/inc/mozaddressbook/MABTypeConverter.hxx @@ -2,9 +2,9 @@ * * $RCSfile: MABTypeConverter.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: wvd $ $Date: 2001-08-09 09:28:11 $ + * last change: $Author: oj $ $Date: 2001-08-24 05:58:07 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -67,7 +67,7 @@ #include "file/FTable.hxx" #endif -#include<string> +#include <string> namespace connectivity { @@ -75,23 +75,17 @@ namespace connectivity { class OMozabTypeConverter { - private: - protected: - ::osl::Mutex m_aMutex; public: - void ouStringToNsString(const ::rtl::OUString&, nsString&) const; - void nsStringToOUString(const nsString&, ::rtl::OUString&) const; - void prUnicharToOUString(const PRUnichar*, ::rtl::OUString&) const; + static void ouStringToNsString(const ::rtl::OUString&, nsString&); + static void nsStringToOUString(const nsString&, ::rtl::OUString&); + static void prUnicharToOUString(const PRUnichar*, ::rtl::OUString&); // Use free() for the following 3 calls. - char *ouStringToCCharStringAscii(const ::rtl::OUString&) const; - char *nsStringToCCharStringAscii(const nsString&) const; - char *ouStringToCCharStringUtf8(const ::rtl::OUString&) const; + static char *ouStringToCCharStringAscii(const ::rtl::OUString&); + static char *nsStringToCCharStringAscii(const nsString&); + static char *ouStringToCCharStringUtf8(const ::rtl::OUString&); // Convert to stl-string. - ::std::string ouStringToStlString(const ::rtl::OUString&) const; - ::std::string nsStringToStlString(const nsString&) const; - public: - OMozabTypeConverter(); - virtual ~OMozabTypeConverter(); + static ::std::string ouStringToStlString(const ::rtl::OUString&); + static ::std::string nsStringToStlString(const nsString&); }; } } diff --git a/connectivity/source/manager/mdrivermanager.cxx b/connectivity/source/manager/mdrivermanager.cxx index cfe5e63b7ef1..2f763b3a1f7c 100644 --- a/connectivity/source/manager/mdrivermanager.cxx +++ b/connectivity/source/manager/mdrivermanager.cxx @@ -2,9 +2,9 @@ * * $RCSfile: mdrivermanager.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-08-15 13:35:05 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:09:35 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -251,10 +251,11 @@ void OSDBCDriverManager::initializeDriverPrecedence() Reference< XServiceInfo > xDriverSI(*aDriverLoop, UNO_QUERY); OSL_ENSURE(xDriverSI.is(), "OSDBCDriverManager::initializeDriverPrecedence: encountered a driver without service info!"); if (xDriverSI.is()) - aDriverImplNames[xDriverSI->getImplementationName()] = sal_Int32(aDriverLoop - m_aDriversBS.begin()); + aDriverImplNames.insert(MapString2Int::value_type(xDriverSI->getImplementationName(),sal_Int32(aDriverLoop - m_aDriversBS.begin()))); } BootstrappedDrivers aSortedDrivers; + aSortedDrivers.reserve(3); // this will be the sorted drivers ::std::set< sal_Int32 > aPreferedDriversOriginalPos; // the drivers in m_aDriversBS which have been inserted in aSortedDrivers diff --git a/connectivity/source/parse/sqlbison.y b/connectivity/source/parse/sqlbison.y index 58f9b051e4b3..425fd33a2b3f 100644 --- a/connectivity/source/parse/sqlbison.y +++ b/connectivity/source/parse/sqlbison.y @@ -1,7 +1,7 @@ %{ //-------------------------------------------------------------------------- // -// $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/connectivity/source/parse/sqlbison.y,v 1.30 2001-08-14 13:23:51 oj Exp $ +// $Header: /zpool/svn/migration/cvs_rep_09_09_08/code/connectivity/source/parse/sqlbison.y,v 1.31 2001-08-24 06:07:23 oj Exp $ // // Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. // @@ -9,7 +9,7 @@ // OJ // // Last change: -// $Author: oj $ $Date: 2001-08-14 13:23:51 $ $Revision: 1.30 $ +// $Author: oj $ $Date: 2001-08-24 06:07:23 $ $Revision: 1.31 $ // // Description: // @@ -3371,12 +3371,12 @@ sal_uInt32 OSQLParser::RuleID(OSQLParseNode::Rule eRule) s_nRuleIDs[eRule] = StrToRuleID("range_variable"); break; case OSQLParseNode::column: s_nRuleIDs[eRule] = StrToRuleID("column"); break; - case OSQLParseNode::delete_statement_positioned: - s_nRuleIDs[eRule] = StrToRuleID("delete_statement_positioned"); break; +// case OSQLParseNode::delete_statement_positioned: +// s_nRuleIDs[eRule] = StrToRuleID("delete_statement_positioned"); break; case OSQLParseNode::delete_statement_searched: s_nRuleIDs[eRule] = StrToRuleID("delete_statement_searched"); break; - case OSQLParseNode::update_statement_positioned: - s_nRuleIDs[eRule] = StrToRuleID("update_statement_positioned"); break; +// case OSQLParseNode::update_statement_positioned: +// s_nRuleIDs[eRule] = StrToRuleID("update_statement_positioned"); break; case OSQLParseNode::update_statement_searched: s_nRuleIDs[eRule] = StrToRuleID("update_statement_searched"); break; case OSQLParseNode::assignment_commalist: diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx index cb2b19dd3e0f..67a4711af6e2 100644 --- a/connectivity/source/parse/sqliterator.cxx +++ b/connectivity/source/parse/sqliterator.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sqliterator.cxx,v $ * - * $Revision: 1.25 $ + * $Revision: 1.26 $ * - * last change: $Author: oj $ $Date: 2001-07-19 09:28:23 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:07:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -192,18 +192,10 @@ void OSQLParseTreeIterator::setParseTree(const OSQLParseNode * pNewParseTree) { m_eStatementType = SQL_STATEMENT_INSERT; } - else if (SQL_ISRULE(m_pParseTree,update_statement_positioned)) - { - m_eStatementType = SQL_STATEMENT_UPDATE; - } else if (SQL_ISRULE(m_pParseTree,update_statement_searched)) { m_eStatementType = SQL_STATEMENT_UPDATE; } - else if (SQL_ISRULE(m_pParseTree,delete_statement_positioned)) - { - m_eStatementType = SQL_STATEMENT_DELETE; - } else if (SQL_ISRULE(m_pParseTree,delete_statement_searched)) { m_eStatementType = SQL_STATEMENT_DELETE; @@ -770,9 +762,6 @@ void OSQLParseTreeIterator::traverseSelectionCriteria(const OSQLParseNode* pSele } else if (SQL_ISRULE(pSelectNode,update_statement_searched)) { OSL_ENSURE(pSelectNode->count() == 5,"OSQLParseTreeIterator: Fehler im Parse Tree"); pWhereClause = pSelectNode->getChild(4); - } else if (SQL_ISRULE(pSelectNode,update_statement_positioned)) { - // nyi - OSL_ASSERT("OSQLParseTreeIterator::getSelectionCriteria: positioned nyi"); } else if (SQL_ISRULE(pSelectNode,delete_statement_searched)) { OSL_ENSURE(pSelectNode->count() == 4,"OSQLParseTreeIterator: Fehler im Parse Tree"); pWhereClause = pSelectNode->getChild(3); @@ -1194,6 +1183,7 @@ void OSQLParseTreeIterator::appendColumns(const ::rtl::OUString& _rTableAlias,co const ::rtl::OUString* pBegin = aColNames.getConstArray(); const ::rtl::OUString* pEnd = pBegin + aColNames.getLength(); + sal_Bool bCase = m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers(); for(;pBegin != pEnd;++pBegin) { @@ -1210,7 +1200,7 @@ void OSQLParseTreeIterator::appendColumns(const ::rtl::OUString& _rTableAlias,co , getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))) , getBOOL(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT))) , getBOOL(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY))) - , m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + , bCase); pColumn->setTableName(_rTableAlias); pColumn->setRealName(*pBegin); @@ -1267,7 +1257,7 @@ void OSQLParseTreeIterator::setSelectColumnName(const ::rtl::OUString & rColumnN OSL_ENSURE(xColumn.is(),"Column isn't a propertyset!"); ::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias)); - OParseColumn* pColumn = new OParseColumn(xColumn,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + OParseColumn* pColumn = new OParseColumn(xColumn,m_aCaseEqual.isCaseSensitive()); pColumn->setTableName(aIter->first); pColumn->setName(aNewColName); pColumn->setRealName(rColumnName); @@ -1291,7 +1281,7 @@ void OSQLParseTreeIterator::setSelectColumnName(const ::rtl::OUString & rColumnN ::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias)); OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(), - ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,m_aCaseEqual.isCaseSensitive()); pColumn->setFunction(bFkt); pColumn->setRealName(rColumnName); @@ -1312,7 +1302,7 @@ void OSQLParseTreeIterator::setSelectColumnName(const ::rtl::OUString & rColumnN ::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias)); OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(), - ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,m_aCaseEqual.isCaseSensitive()); pColumn->setFunction(sal_True); pColumn->setRealName(rColumnName); pColumn->setTableName(aFind->first); @@ -1327,7 +1317,7 @@ void OSQLParseTreeIterator::setSelectColumnName(const ::rtl::OUString & rColumnN { ::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias)); - OParseColumn* pColumn = new OParseColumn(xColumn,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + OParseColumn* pColumn = new OParseColumn(xColumn,m_aCaseEqual.isCaseSensitive()); pColumn->setName(aNewColName); pColumn->setRealName(rColumnName); pColumn->setTableName(aFind->first); @@ -1353,7 +1343,7 @@ void OSQLParseTreeIterator::setSelectColumnName(const ::rtl::OUString & rColumnN ::rtl::OUString aNewColName(getUniqueColumnName(rColumnAlias)); OParseColumn* pColumn = new OParseColumn(aNewColName,::rtl::OUString(),::rtl::OUString(), - ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,m_xDatabaseMetaData->storesMixedCaseQuotedIdentifiers()); + ColumnValue::NULLABLE_UNKNOWN,0,0,DataType::VARCHAR,sal_False,sal_False,m_aCaseEqual.isCaseSensitive()); pColumn->setFunction(sal_True); diff --git a/connectivity/source/parse/sqlnode.cxx b/connectivity/source/parse/sqlnode.cxx index 2e94794296e7..bb11096eb5dc 100644 --- a/connectivity/source/parse/sqlnode.cxx +++ b/connectivity/source/parse/sqlnode.cxx @@ -2,9 +2,9 @@ * * $RCSfile: sqlnode.cxx,v $ * - * $Revision: 1.19 $ + * $Revision: 1.20 $ * - * last change: $Author: oj $ $Date: 2001-07-25 06:13:55 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:07:23 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1104,7 +1104,7 @@ OSQLParser::OSQLParser(const ::com::sun::star::uno::Reference< ::com::sun::star: s_xLocaleData = Reference<XLocaleData>(m_xServiceFactory->createInstance(::rtl::OUString::createFromAscii("com.sun.star.i18n.LocaleData")),UNO_QUERY); // auf 0 zuruecksetzen - memset(OSQLParser::s_nRuleIDs,0,sizeof(sal_uInt16) * OSQLParseNode::rule_count+1); + memset(OSQLParser::s_nRuleIDs,0,sizeof(OSQLParser::s_nRuleIDs[0]) * (OSQLParseNode::rule_count+1)); } ++s_nRefCount; diff --git a/connectivity/source/sdbcx/VCatalog.cxx b/connectivity/source/sdbcx/VCatalog.cxx index dca34fae78c2..f10ae522a205 100644 --- a/connectivity/source/sdbcx/VCatalog.cxx +++ b/connectivity/source/sdbcx/VCatalog.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VCatalog.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:34:03 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:06:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -140,6 +140,8 @@ Reference< XNameAccess > SAL_CALL OCatalog::getTables( ) throw(RuntimeException ::osl::MutexGuard aGuard(m_aMutex); checkDisposed(OCatalog_BASE::rBHelper.bDisposed); + if(!m_pTables) + refreshTables(); return const_cast<OCatalog*>(this)->m_pTables; } @@ -150,6 +152,8 @@ Reference< XNameAccess > SAL_CALL OCatalog::getViews( ) throw(RuntimeException) ::osl::MutexGuard aGuard(m_aMutex); checkDisposed(OCatalog_BASE::rBHelper.bDisposed); + if(!m_pViews) + refreshViews(); return const_cast<OCatalog*>(this)->m_pViews; } @@ -160,6 +164,8 @@ Reference< XNameAccess > SAL_CALL OCatalog::getUsers( ) throw(RuntimeException) ::osl::MutexGuard aGuard(m_aMutex); checkDisposed(OCatalog_BASE::rBHelper.bDisposed); + if(!m_pUsers) + refreshUsers(); return const_cast<OCatalog*>(this)->m_pUsers; } @@ -171,6 +177,9 @@ Reference< XNameAccess > SAL_CALL OCatalog::getGroups( ) throw(RuntimeException checkDisposed(OCatalog_BASE::rBHelper.bDisposed); + if(!m_pGroups) + refreshGroups(); + return const_cast<OCatalog*>(this)->m_pGroups; } // ------------------------------------------------------------------------- diff --git a/connectivity/source/sdbcx/VCollection.cxx b/connectivity/source/sdbcx/VCollection.cxx index f6229ed4c965..422cefa77985 100644 --- a/connectivity/source/sdbcx/VCollection.cxx +++ b/connectivity/source/sdbcx/VCollection.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VCollection.cxx,v $ * - * $Revision: 1.21 $ + * $Revision: 1.22 $ * - * last change: $Author: oj $ $Date: 2001-08-13 13:58:56 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:06:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -99,6 +99,7 @@ OCollection::OCollection(::cppu::OWeakObject& _rParent,sal_Bool _bCase, ::osl::M ,m_aRefreshListeners(_rMutex) ,m_aNameMap(_bCase ? true : false) { + m_aElements.reserve(_rVector.size()); for(TStringVector::const_iterator i=_rVector.begin(); i != _rVector.end();++i) m_aElements.push_back(m_aNameMap.insert(m_aNameMap.begin(), ObjectMap::value_type(*i,WeakReference< ::com::sun::star::container::XNamed >()))); } @@ -144,7 +145,7 @@ void OCollection::disposing(void) Any SAL_CALL OCollection::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsException, WrappedTargetException, RuntimeException) { ::osl::MutexGuard aGuard(m_rMutex); - if (Index < 0 || Index >= getCount()) + if (Index < 0 || Index >= m_aNameMap.size()) throw IndexOutOfBoundsException(::rtl::OUString::valueOf(Index),*this); ObjectIter aIter = m_aElements[Index]; @@ -162,7 +163,7 @@ Any SAL_CALL OCollection::getByIndex( sal_Int32 Index ) throw(IndexOutOfBoundsEx (*aIter).second = xName; } - return makeAny( Reference< XPropertySet >(xName,UNO_QUERY)); + return makeAny(xName); } // ------------------------------------------------------------------------- Any SAL_CALL OCollection::getByName( const ::rtl::OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) @@ -186,7 +187,7 @@ Any SAL_CALL OCollection::getByName( const ::rtl::OUString& aName ) throw(NoSuch (*aIter).second = xName; } - return makeAny( Reference< XPropertySet >(xName,UNO_QUERY)); + return makeAny(xName); } // ------------------------------------------------------------------------- Sequence< ::rtl::OUString > SAL_CALL OCollection::getElementNames( ) throw(RuntimeException) @@ -226,6 +227,8 @@ void SAL_CALL OCollection::refresh( ) throw(RuntimeException) void OCollection::reFill(const TStringVector &_rVector) { OSL_ENSURE(!m_aNameMap.size(),"OCollection::reFill: collection isn't empty"); + m_aElements.reserve(_rVector.size()); + for(TStringVector::const_iterator i=_rVector.begin(); i != _rVector.end();++i) m_aElements.push_back(m_aNameMap.insert(m_aNameMap.begin(), ObjectMap::value_type(*i,WeakReference< ::com::sun::star::container::XNamed >()))); } diff --git a/connectivity/source/sdbcx/VDescriptor.cxx b/connectivity/source/sdbcx/VDescriptor.cxx index 8cabd3a325ae..9f605ad4adf9 100644 --- a/connectivity/source/sdbcx/VDescriptor.cxx +++ b/connectivity/source/sdbcx/VDescriptor.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VDescriptor.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: fs $ $Date: 2001-03-19 07:33:30 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:06:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -89,10 +89,11 @@ namespace connectivity // com::sun::star::lang::XUnoTunnel sal_Int64 SAL_CALL ODescriptor::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 0; + return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) ) + ? + (sal_Int64)this + : + 0; } // ----------------------------------------------------------------------------- @@ -115,9 +116,7 @@ namespace connectivity Any SAL_CALL ODescriptor::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = ::cppu::queryInterface(rType,static_cast< XUnoTunnel*> (this)); - if(!aRet.hasValue()) - aRet = ODescriptor_PBASE::queryInterface(rType); - return aRet; + return aRet.hasValue() ? aRet : ODescriptor_PBASE::queryInterface(rType); } // ----------------------------------------------------------------------------- @@ -142,6 +141,9 @@ namespace connectivity /************************************************************************* * history: * $Log: not supported by cvs2svn $ + * Revision 1.1 2001/03/19 07:33:30 fs + * initial checkin - implementation of ODescriptor + * * * Revision 1.0 19.03.01 08:21:59 fs ************************************************************************/ diff --git a/connectivity/source/sdbcx/VGroup.cxx b/connectivity/source/sdbcx/VGroup.cxx index 46143cf57e78..54a3a5ffa79f 100644 --- a/connectivity/source/sdbcx/VGroup.cxx +++ b/connectivity/source/sdbcx/VGroup.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VGroup.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:34:03 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:06:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -110,10 +110,8 @@ OGroup::~OGroup() // ------------------------------------------------------------------------- Any SAL_CALL OGroup::queryInterface( const Type & rType ) throw(RuntimeException) { - Any aRet = ODescriptor::queryInterface( rType); - if(aRet.hasValue()) - return aRet; - return OGroup_BASE::queryInterface( rType); + Any aRet = ODescriptor::queryInterface( rType); + return aRet.hasValue() ? aRet : OGroup_BASE::queryInterface( rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL OGroup::getTypes( ) throw(RuntimeException) diff --git a/connectivity/source/sdbcx/VUser.cxx b/connectivity/source/sdbcx/VUser.cxx index 8e83142b8784..1c51f49055fb 100644 --- a/connectivity/source/sdbcx/VUser.cxx +++ b/connectivity/source/sdbcx/VUser.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VUser.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:34:03 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:06:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -122,10 +122,8 @@ void OUser::disposing(void) // ------------------------------------------------------------------------- Any SAL_CALL OUser::queryInterface( const Type & rType ) throw(RuntimeException) { - Any aRet = ODescriptor::queryInterface( rType); - if(aRet.hasValue()) - return aRet; - return OUser_BASE::queryInterface( rType); + Any aRet = ODescriptor::queryInterface( rType); + return aRet.hasValue() ? aRet : OUser_BASE::queryInterface( rType); } // ------------------------------------------------------------------------- Sequence< Type > SAL_CALL OUser::getTypes( ) throw(RuntimeException) diff --git a/connectivity/source/sdbcx/VView.cxx b/connectivity/source/sdbcx/VView.cxx index d63103f02804..22425d08edfb 100644 --- a/connectivity/source/sdbcx/VView.cxx +++ b/connectivity/source/sdbcx/VView.cxx @@ -2,9 +2,9 @@ * * $RCSfile: VView.cxx,v $ * - * $Revision: 1.9 $ + * $Revision: 1.10 $ * - * last change: $Author: oj $ $Date: 2001-05-14 11:34:03 $ + * last change: $Author: oj $ $Date: 2001-08-24 06:06:12 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -148,9 +148,7 @@ Any SAL_CALL OView::queryInterface( const Type & rType ) throw(RuntimeException) { Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::container::XNamed*> (this), static_cast< XServiceInfo*> (this)); - if(aRet.hasValue()) - return aRet; - return ODescriptor::queryInterface( rType); + return aRet.hasValue() ? aRet : ODescriptor::queryInterface( rType); } // ------------------------------------------------------------------------- ::cppu::IPropertyArrayHelper* OView::createArrayHelper(sal_Int32 _nId) const |