diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-03-19 15:38:50 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2003-03-19 15:38:50 +0000 |
commit | 53128e64b7552217c8cf290e73ef7a69c375a37c (patch) | |
tree | aff2389b82d86c4bc405f32d413f7d93b3785246 /connectivity/source/commontools | |
parent | a0b65deaa6e999132779e26f2b448dfa8662963c (diff) |
MWS_SRX644: migrate branch mws_srx644 -> HEAD
Diffstat (limited to 'connectivity/source/commontools')
-rw-r--r-- | connectivity/source/commontools/CommonTools.cxx | 34 | ||||
-rw-r--r-- | connectivity/source/commontools/TDatabaseMetaDataBase.cxx | 14 | ||||
-rw-r--r-- | connectivity/source/commontools/conncleanup.cxx | 17 | ||||
-rw-r--r-- | connectivity/source/commontools/dbcharset.cxx | 246 | ||||
-rw-r--r-- | connectivity/source/commontools/dbconversion.cxx | 76 | ||||
-rw-r--r-- | connectivity/source/commontools/dbexception.cxx | 38 | ||||
-rw-r--r-- | connectivity/source/commontools/dbtools.cxx | 363 | ||||
-rw-r--r-- | connectivity/source/commontools/dbtools2.cxx | 27 | ||||
-rw-r--r-- | connectivity/source/commontools/predicateinput.cxx | 19 |
9 files changed, 446 insertions, 388 deletions
diff --git a/connectivity/source/commontools/CommonTools.cxx b/connectivity/source/commontools/CommonTools.cxx index e232cf2275a1..a7d24040bc5f 100644 --- a/connectivity/source/commontools/CommonTools.cxx +++ b/connectivity/source/commontools/CommonTools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: CommonTools.cxx,v $ * - * $Revision: 1.13 $ + * $Revision: 1.14 $ * - * last change: $Author: oj $ $Date: 2002-07-30 09:44:56 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:38:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -172,10 +172,12 @@ namespace connectivity rtl::OUString toDateString(const ::com::sun::star::util::Date& rDate) { sal_Char s[11]; - sprintf(s,"%04d-%02d-%02d", - (int)rDate.Year, - (int)rDate.Month, - (int)rDate.Day); + snprintf(s, + sizeof(s), + "%04d-%02d-%02d", + (int)rDate.Year, + (int)rDate.Month, + (int)rDate.Day); s[10] = 0; return rtl::OUString::createFromAscii(s); } @@ -184,7 +186,9 @@ namespace connectivity rtl::OUString toTimeString(const ::com::sun::star::util::Time& rTime) { sal_Char s[9]; - sprintf(s,"%02d:%02d:%02d", + snprintf(s, + sizeof(s), + "%02d:%02d:%02d", (int)rTime.Hours, (int)rTime.Minutes, (int)rTime.Seconds); @@ -196,13 +200,15 @@ namespace connectivity rtl::OUString toDateTimeString(const ::com::sun::star::util::DateTime& rDateTime) { sal_Char s[21]; - sprintf(s,"%04d-%02d-%02d %02d:%02d:%02d", - (int)rDateTime.Year, - (int)rDateTime.Month, - (int)rDateTime.Day, - (int)rDateTime.Hours, - (int)rDateTime.Minutes, - (int)rDateTime.Seconds); + snprintf(s, + sizeof(s), + "%04d-%02d-%02d %02d:%02d:%02d", + (int)rDateTime.Year, + (int)rDateTime.Month, + (int)rDateTime.Day, + (int)rDateTime.Hours, + (int)rDateTime.Minutes, + (int)rDateTime.Seconds); s[20] = 0; return rtl::OUString::createFromAscii(s); } diff --git a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx index c1c41c8a1f37..f5e40c8c9b54 100644 --- a/connectivity/source/commontools/TDatabaseMetaDataBase.cxx +++ b/connectivity/source/commontools/TDatabaseMetaDataBase.cxx @@ -2,9 +2,9 @@ * * $RCSfile: TDatabaseMetaDataBase.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: oj $ $Date: 2000-11-03 13:26:24 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:38:13 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -80,10 +80,12 @@ ODatabaseMetaDataBase::ODatabaseMetaDataBase(const Reference< XConnection >& _rx : m_xConnection(_rxConnection) { osl_incrementInterlockedCount( &m_refCount ); - m_xListenerHelper = new OEventListenerHelper(this); - Reference<XComponent> xCom(m_xConnection,UNO_QUERY); - if(xCom.is()) - xCom->addEventListener(m_xListenerHelper); + { + m_xListenerHelper = new OEventListenerHelper(this); + Reference<XComponent> xCom(m_xConnection,UNO_QUERY); + if(xCom.is()) + xCom->addEventListener(m_xListenerHelper); + } osl_decrementInterlockedCount( &m_refCount ); } // ------------------------------------------------------------------------- diff --git a/connectivity/source/commontools/conncleanup.cxx b/connectivity/source/commontools/conncleanup.cxx index a3295918c318..659d97bd0952 100644 --- a/connectivity/source/commontools/conncleanup.cxx +++ b/connectivity/source/commontools/conncleanup.cxx @@ -2,9 +2,9 @@ * * $RCSfile: conncleanup.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: fs $ $Date: 2001-11-08 10:46:42 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:38:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -285,16 +285,3 @@ namespace dbtools } // namespace dbtools //......................................................................... -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * Revision 1.2 2001/06/21 14:13:24 oj - * #88525# connect as rowlistener to get notified when the rowset changed - * - * Revision 1.1 2001/04/12 09:48:11 fs - * initial checkin - helper for automatically disposing a rowset's connection - * - * - * Revision 1.0 12.04.01 09:36:29 fs - ************************************************************************/ - diff --git a/connectivity/source/commontools/dbcharset.cxx b/connectivity/source/commontools/dbcharset.cxx index b01d3bc78066..a625176ec890 100644 --- a/connectivity/source/commontools/dbcharset.cxx +++ b/connectivity/source/commontools/dbcharset.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbcharset.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: oj $ $Date: 2002-03-04 11:05:39 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:38:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -66,141 +66,129 @@ #include <osl/diagnose.h> #endif +#ifndef _RTL_TENCINFO_H +#include <rtl/tencinfo.h> +#endif + //......................................................................... namespace dbtools { //......................................................................... - //------------------------------------------------------------------------- - template <class T> - sal_Int32 getSequenceIndex( const ::std::vector< T >& _rUnsortedContainer, const T& _rLookupElement ) - { - for ( ::std::vector< T >::const_iterator aSearch = _rUnsortedContainer.begin(); - aSearch != _rUnsortedContainer.end(); - ++aSearch - ) - if (*aSearch == _rLookupElement) - return aSearch - _rUnsortedContainer.begin(); - - return _rUnsortedContainer.size(); - } - //========================================================================= //= OCharsetMap //========================================================================= //------------------------------------------------------------------------- OCharsetMap::OCharsetMap() - #ifdef _DEBUG - :m_nLivingIterators(0) - #endif { - m_aEncodings.resize(12); - m_aEncodings[ 0] = RTL_TEXTENCODING_MS_1252; // ANSI - m_aEncodings[ 1] = RTL_TEXTENCODING_APPLE_ROMAN; // MAC - m_aEncodings[ 2] = RTL_TEXTENCODING_IBM_437; // IBMPC_437 - m_aEncodings[ 3] = RTL_TEXTENCODING_IBM_850; // IBMPC_850 - m_aEncodings[ 4] = RTL_TEXTENCODING_IBM_860; // IBMPC_860 - m_aEncodings[ 5] = RTL_TEXTENCODING_IBM_861; // IBMPC_861 - m_aEncodings[ 6] = RTL_TEXTENCODING_IBM_863; // IBMPC_863 - m_aEncodings[ 7] = RTL_TEXTENCODING_IBM_865; // IBMPC_865 - m_aEncodings[ 8] = RTL_TEXTENCODING_IBM_866; // IBMPC_866 (cyrillic) - m_aEncodings[ 9] = RTL_TEXTENCODING_DONTKNOW; // SYSTEM - m_aEncodings[10] = RTL_TEXTENCODING_UTF8; // UTF-8 - m_aEncodings[11] = RTL_TEXTENCODING_BIG5_HKSCS; // Big5-HKSCS + } - m_aNames.resize(12); - m_aNames[ 0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ANSI")); - m_aNames[ 1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAC")); - m_aNames[ 2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_437")); - m_aNames[ 3] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_850")); - m_aNames[ 4] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_860")); - m_aNames[ 5] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_861")); - m_aNames[ 6] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_863")); - m_aNames[ 7] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_865")); - m_aNames[ 8] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBMPC_866")); - m_aNames[ 9] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYSTEM")); - m_aNames[10] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UTF-8")); - m_aNames[10] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Big5-HKSCS")); + //------------------------------------------------------------------------- + void OCharsetMap::lateConstruct() + { + const rtl_TextEncoding eFirstEncoding = RTL_TEXTENCODING_DONTKNOW; + const rtl_TextEncoding eLastEncoding = 100; // TODO: a define in rtl/textenc.h would be fine here ... + OSL_ENSURE( 0 == eFirstEncoding, "OCharsetMap::OCharsetMap: somebody changed the numbers!" ); - OSL_ENSURE(m_aEncodings.size() == m_aNames.size(), - "OCharsetMap::OCharsetMap: inconsistentce(1)!"); + rtl_TextEncodingInfo aInfo; aInfo.StructSize = sizeof( rtl_TextEncodingInfo ); + for ( rtl_TextEncoding eEncoding = eFirstEncoding; eEncoding < eLastEncoding; ++eEncoding ) + { + if ( ( RTL_TEXTENCODING_DONTKNOW == eEncoding ) // this is always allowed - it has the special meaning "system encoding" + || ( rtl_getTextEncodingInfo( eEncoding, &aInfo ) + && approveEncoding( eEncoding, aInfo ) + ) + ) + { + m_aEncodings.insert( eEncoding ); + } + } - // the IANA representations of the character sets which we know - m_aIanaNames.resize(12); - m_aIanaNames[ 0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("windows-1252")); - m_aIanaNames[ 1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("macintosh")); - m_aIanaNames[ 2] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM437")); - m_aIanaNames[ 3] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM850")); - m_aIanaNames[ 4] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM860")); - m_aIanaNames[ 5] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM861")); - m_aIanaNames[ 6] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM863")); - m_aIanaNames[ 7] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM865")); - m_aIanaNames[ 8] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IBM866")); - m_aIanaNames[ 9] = ::rtl::OUString(); - m_aIanaNames[10] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UTF-8")); - m_aIanaNames[11] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Big5-HKSCS")); + OSL_ENSURE( find( RTL_TEXTENCODING_MS_1252 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding ANSI!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_APPLE_ROMAN ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding macintosh!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_IBM_437 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM437!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_IBM_850) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM850!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_IBM_860 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM860!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_IBM_861 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM861!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_IBM_863 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM863!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_IBM_865 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM865!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_IBM_866 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding IBM866!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_DONTKNOW ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding SYSTEM!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_UTF8 ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding UTF-8!" ); + OSL_ENSURE( find( RTL_TEXTENCODING_BIG5_HKSCS ) != end(), "OCharsetMap::lateConstruct: missing compatibility encoding Big5-HKSCS!" ); + } - OSL_ENSURE(m_aNames.size() == m_aIanaNames.size(), - "OCharsetMap::OCharsetMap: inconsistentce(2)!"); + //------------------------------------------------------------------------- + sal_Bool OCharsetMap::approveEncoding( const rtl_TextEncoding _eEncoding, const rtl_TextEncodingInfo& _rInfo ) const + { + sal_Bool bIsMimeEncoding = 0 != ( _rInfo.Flags & RTL_TEXTENCODING_INFO_MIME ); + OSL_ENSURE( !bIsMimeEncoding || rtl_getMimeCharsetFromTextEncoding( _eEncoding ), + "OCharsetMap::OCharsetMap: inconsistence in rtl!" ); + return bIsMimeEncoding; } //------------------------------------------------------------------------- OCharsetMap::~OCharsetMap() { - OSL_ENSURE(0 == m_nLivingIterators, "OCharsetMap::~OCharsetMap : there are still living iterator objects!"); } //------------------------------------------------------------------------- OCharsetMap::CharsetIterator OCharsetMap::begin() const { - return CharsetIterator(this, 0); + ensureConstructed( ); + return CharsetIterator(this, m_aEncodings.begin() ); } //------------------------------------------------------------------------- OCharsetMap::CharsetIterator OCharsetMap::find(const rtl_TextEncoding _eEncoding) const { - sal_Int32 nSize = m_aEncodings.size(); - TextEncVector::const_iterator aFind = ::std::find(m_aEncodings.begin(),m_aEncodings.end(),(sal_Int32)_eEncoding); - if(aFind != m_aEncodings.end()) - nSize = aFind - m_aEncodings.begin(); - - return CharsetIterator(this, nSize); + ensureConstructed( ); + return CharsetIterator( this, m_aEncodings.find( _eEncoding ) ); } //------------------------------------------------------------------------- OCharsetMap::CharsetIterator OCharsetMap::find(const ::rtl::OUString& _rIanaName, const IANA&) const { - return CharsetIterator(this, getSequenceIndex(m_aIanaNames, _rIanaName)); - } + ensureConstructed( ); - //------------------------------------------------------------------------- - OCharsetMap::CharsetIterator OCharsetMap::find(const ::rtl::OUString& _rLogicalName, const Logical&) const - { - return CharsetIterator(this, getSequenceIndex(m_aNames, _rLogicalName)); + rtl_TextEncoding eEncoding = RTL_TEXTENCODING_DONTKNOW; + if ( _rIanaName.getLength() ) + { + // byte string conversion + ::rtl::OString sMimeByteString( _rIanaName.getStr(), _rIanaName.getLength(), RTL_TEXTENCODING_ASCII_US ); + // look up + eEncoding = rtl_getTextEncodingFromMimeCharset( sMimeByteString.getStr() ); + + if ( RTL_TEXTENCODING_DONTKNOW == eEncoding ) + { // if we're here, the name is not empty, but unknown -> this is an invalid name + return end(); + } + } + + return find( eEncoding ); } //------------------------------------------------------------------------- OCharsetMap::CharsetIterator OCharsetMap::end() const { - return CharsetIterator(this, m_aNames.size()); + ensureConstructed( ); + + return CharsetIterator( this, m_aEncodings.end() ); } //========================================================================= //= CharsetIteratorDerefHelper //========================================================================= //------------------------------------------------------------------------- - CharsetIteratorDerefHelper::CharsetIteratorDerefHelper(const CharsetIteratorDerefHelper& _rSource) - :m_eEncoding(_rSource.m_eEncoding) - ,m_aIanaName(_rSource.m_aIanaName) - ,m_aName(_rSource.m_aName) + CharsetIteratorDerefHelper::CharsetIteratorDerefHelper( const CharsetIteratorDerefHelper& _rSource ) + :m_eEncoding( _rSource.m_eEncoding ) + ,m_aIanaName( _rSource.m_aIanaName ) { } //------------------------------------------------------------------------- - CharsetIteratorDerefHelper::CharsetIteratorDerefHelper(const rtl_TextEncoding _eEncoding, const ::rtl::OUString& _rIanaName, const ::rtl::OUString& _rName) - :m_eEncoding(_eEncoding) - ,m_aIanaName(_rIanaName) - ,m_aName(_rName) + CharsetIteratorDerefHelper:: CharsetIteratorDerefHelper(const rtl_TextEncoding _eEncoding, const ::rtl::OUString& _rIanaName ) + :m_eEncoding( _eEncoding ) + ,m_aIanaName( _rIanaName ) { } @@ -214,102 +202,68 @@ namespace dbtools //= OCharsetMap::CharsetIterator //========================================================================= //------------------------------------------------------------------------- - OCharsetMap::CharsetIterator::CharsetIterator(const OCharsetMap* _pContainer, sal_Int32 _nInitialPos) - :m_pContainer(_pContainer) - ,m_nPosition(_nInitialPos) + OCharsetMap::CharsetIterator::CharsetIterator(const OCharsetMap* _pContainer, OCharsetMap::TextEncBag::const_iterator _aPos ) + :m_pContainer( _pContainer ) + ,m_aPos( _aPos ) { - OSL_ENSURE(m_pContainer, "OCharsetMap::CharsetIterator::CharsetIterator : invalid container!"); - #ifdef _DEBUG - ++const_cast<OCharsetMap*>(m_pContainer)->m_nLivingIterators; - #endif + OSL_ENSURE( m_pContainer, "OCharsetMap::CharsetIterator::CharsetIterator : invalid container!" ); } //------------------------------------------------------------------------- OCharsetMap::CharsetIterator::CharsetIterator(const CharsetIterator& _rSource) - :m_pContainer(_rSource.m_pContainer) - ,m_nPosition(_rSource.m_nPosition) + :m_pContainer( _rSource.m_pContainer ) + ,m_aPos( _rSource.m_aPos ) { - #ifdef _DEBUG - ++const_cast<OCharsetMap*>(m_pContainer)->m_nLivingIterators; - #endif } //------------------------------------------------------------------------- OCharsetMap::CharsetIterator::~CharsetIterator() { - #ifdef _DEBUG - --const_cast<OCharsetMap*>(m_pContainer)->m_nLivingIterators; - #endif } //------------------------------------------------------------------------- CharsetIteratorDerefHelper OCharsetMap::CharsetIterator::operator*() const { - OSL_ENSURE((sal_uInt32)m_nPosition < m_pContainer->m_aEncodings.size(), "OCharsetMap::CharsetIterator::operator*: invalid position!"); - OSL_ENSURE((sal_uInt32)m_nPosition < m_pContainer->m_aIanaNames.size(), "OCharsetMap::CharsetIterator::operator*: invalid position!"); - OSL_ENSURE((sal_uInt32)m_nPosition < m_pContainer->m_aNames.size(), "OCharsetMap::CharsetIterator::operator*: invalid position!"); - return CharsetIteratorDerefHelper( - m_pContainer->m_aEncodings[m_nPosition], - m_pContainer->m_aIanaNames[m_nPosition], - m_pContainer->m_aNames[m_nPosition]); + OSL_ENSURE( m_aPos != m_pContainer->m_aEncodings.end(), "OCharsetMap::CharsetIterator::operator*: invalid position!"); + + rtl_TextEncoding eEncoding = *m_aPos; + ::rtl::OUString sIanaName; + + if ( RTL_TEXTENCODING_DONTKNOW != eEncoding ) + { // it's not the virtual "system charset" + const char* pIanaName = rtl_getMimeCharsetFromTextEncoding( eEncoding ); + OSL_ENSURE( pIanaName, "OCharsetMap::CharsetIterator: invalid mime name!" ); + if ( pIanaName ) + sIanaName = ::rtl::OUString::createFromAscii( pIanaName ); + } + return CharsetIteratorDerefHelper( eEncoding, sIanaName ); } //------------------------------------------------------------------------- const OCharsetMap::CharsetIterator& OCharsetMap::CharsetIterator::operator++() { - OSL_ENSURE((sal_uInt32)m_nPosition < m_pContainer->m_aNames.size(), "OCharsetMap::CharsetIterator::operator++ : invalid position!"); - if ((sal_uInt32)m_nPosition < m_pContainer->m_aNames.size()) - ++m_nPosition; + OSL_ENSURE( m_aPos != m_pContainer->m_aEncodings.end(), "OCharsetMap::CharsetIterator::operator++ : invalid position!" ); + if ( m_aPos != m_pContainer->m_aEncodings.end()) + ++m_aPos; return *this; } //------------------------------------------------------------------------- const OCharsetMap::CharsetIterator& OCharsetMap::CharsetIterator::operator--() { - OSL_ENSURE(m_nPosition >= 0, "OCharsetMap::CharsetIterator::operator-- : invalid position!"); - if (m_nPosition >= 0) - --m_nPosition; + OSL_ENSURE( m_aPos != m_pContainer->m_aEncodings.begin(), "OCharsetMap::CharsetIterator::operator-- : invalid position!" ); + if ( m_aPos != m_pContainer->m_aEncodings.begin() ) + --m_aPos; return *this; } //------------------------------------------------------------------------- - sal_Int32 operator-(const OCharsetMap::CharsetIterator& lhs, const OCharsetMap::CharsetIterator& rhs) - { - return lhs.m_nPosition - rhs.m_nPosition; - } - - //------------------------------------------------------------------------- bool operator==(const OCharsetMap::CharsetIterator& lhs, const OCharsetMap::CharsetIterator& rhs) { - return (lhs.m_pContainer == rhs.m_pContainer) && (lhs.m_nPosition == rhs.m_nPosition); + return ( lhs.m_pContainer == rhs.m_pContainer ) && ( lhs.m_aPos == rhs.m_aPos ); } //......................................................................... } // namespace dbtools //......................................................................... -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * Revision 1.6 2001/10/15 13:30:12 fs - * #93204# new supported charset IBM866 (cyrillic) - * - * Revision 1.5 2001/05/18 08:51:34 oj - * #86528# size changes - * - * Revision 1.4 2001/04/27 08:04:07 fs - * #86370# add UTF-8 to the list of supported charsets - * - * Revision 1.3 2001/04/09 06:09:58 fs - * m_nLivingIterators for _DEBUG, not DBG_UTIL - * - * Revision 1.2 2001/02/13 09:47:39 fs - * #83632# merge IBMPC, IBMPC(850), DOS - * - * Revision 1.1 2000/11/29 22:21:42 fs - * initial checkin - helper class for translating charset representations - * - * - * Revision 1.0 29.11.00 18:42:55 fs - ************************************************************************/ - diff --git a/connectivity/source/commontools/dbconversion.cxx b/connectivity/source/commontools/dbconversion.cxx index 276bc988406e..564ea4be7669 100644 --- a/connectivity/source/commontools/dbconversion.cxx +++ b/connectivity/source/commontools/dbconversion.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbconversion.cxx,v $ * - * $Revision: 1.18 $ + * $Revision: 1.19 $ * - * last change: $Author: oj $ $Date: 2002-03-21 14:56:29 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:38:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,10 +102,12 @@ using namespace ::com::sun::star::beans; ::rtl::OUString DBTypeConversion::toDateString(const Date& rDate) { sal_Char s[11]; - sprintf(s,"%04d-%02d-%02d", - (int)rDate.Year, - (int)rDate.Month, - (int)rDate.Day); + snprintf(s, + sizeof(s), + "%04d-%02d-%02d", + (int)rDate.Year, + (int)rDate.Month, + (int)rDate.Day); s[10] = 0; return ::rtl::OUString::createFromAscii(s); } @@ -113,7 +115,9 @@ using namespace ::com::sun::star::beans; ::rtl::OUString DBTypeConversion::toTimeString(const Time& rTime) { sal_Char s[9]; - sprintf(s,"%02d:%02d:%02d", + snprintf(s, + sizeof(s), + "%02d:%02d:%02d", (int)rTime.Hours, (int)rTime.Minutes, (int)rTime.Seconds); @@ -501,61 +505,3 @@ Time DBTypeConversion::toTime(const ::rtl::OUString& _sSQLString) //......................................................................... -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * Revision 1.17 2001/10/01 11:24:27 oj - * #92613# unbound evaluationrow fixed - * - * Revision 1.16 2001/08/06 06:21:03 oj - * #89430# overflow corrected - * - * Revision 1.15 2001/05/25 13:09:29 oj - * #86839# flush scanner buffer - * - * Revision 1.14 2001/05/11 17:25:49 pl - * rtl string api changes - * - * Revision 1.13 2001/03/27 12:19:34 jl - * calls to sal_setInt64 hhave been removed - * - * Revision 1.12 2001/03/21 13:37:07 jl - * OSL_ENSHURE replaced by OSL_ENSURE - * - * Revision 1.11 2001/03/15 08:45:56 fs - * cppuhelper/extract -> comphelper/extract - * - * Revision 1.10 2001/01/03 09:02:13 oj - * check month >0 and < 13 - * - * Revision 1.9 2000/12/06 12:14:59 oj - * #80219# toDays corrected - * - * Revision 1.8 2000/11/30 15:29:40 oj - * #80934# standarddate is no longer public - * - * Revision 1.7 2000/11/09 08:46:09 oj - * some new methods for db's - * - * Revision 1.6 2000/11/08 09:28:45 oj - * forget assignment of return value - * - * Revision 1.5 2000/10/27 07:04:22 fs - * corrected the starutil namespace - * - * Revision 1.4 2000/10/27 07:01:07 fs - * new: toDate(sal_Int32) / toTime(sal_Int32) - * - * Revision 1.3 2000/10/24 15:00:32 oj - * make strings unique for lib's - * - * Revision 1.2 2000/10/19 11:46:15 oj - * remove tools from dbtools - * - * Revision 1.1 2000/10/05 08:50:32 fs - * moved the files from unotools to here - * - * - * Revision 1.0 29.09.00 08:17:18 fs - ************************************************************************/ - diff --git a/connectivity/source/commontools/dbexception.cxx b/connectivity/source/commontools/dbexception.cxx index c4f285849886..349d4622ce87 100644 --- a/connectivity/source/commontools/dbexception.cxx +++ b/connectivity/source/commontools/dbexception.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbexception.cxx,v $ * - * $Revision: 1.10 $ + * $Revision: 1.11 $ * - * last change: $Author: oj $ $Date: 2002-09-27 13:55:58 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:38:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -413,37 +413,3 @@ void throwGenericSQLException(const ::rtl::OUString& _rMsg, const Reference< XIn //......................................................................... -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * Revision 1.9 2001/11/08 07:11:36 dkenny - * #93274# - select count(*)... - * - * Revision 1.8 2001/06/26 07:54:03 fs - * throwGenericSQLException version with additional NextException parameter - * - * Revision 1.7 2001/05/14 11:42:00 oj - * #86528# lower size need - * - * Revision 1.6 2001/04/19 07:05:17 fs - * +throwFunctionSequenceException - * - * Revision 1.5 2001/03/21 13:37:07 jl - * OSL_ENSHURE replaced by OSL_ENSURE - * - * Revision 1.4 2001/03/01 17:02:19 fs - * operator= for SQLExceptionInfo, new ctor for SQLExceptionIteratorHelper, new next method - * - * Revision 1.3 2000/11/08 18:54:44 fs - * corrected the initial setting of the SQLExceptionInfo - * - * Revision 1.2 2000/10/24 15:00:32 oj - * make strings unique for lib's - * - * Revision 1.1 2000/10/05 08:50:41 fs - * moved the files from unotools to here - * - * - * Revision 1.0 29.09.00 08:17:11 fs - ************************************************************************/ - diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 944c98852847..d7878b635b2a 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbtools.cxx,v $ * - * $Revision: 1.48 $ + * $Revision: 1.49 $ * - * last change: $Author: oj $ $Date: 2002-11-21 14:04:38 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:38:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -211,7 +211,7 @@ #ifndef _COM_SUN_STAR_SDBC_XPARAMETERS_HPP_ #include <com/sun/star/sdbc/XParameters.hpp> #endif - +#include <algorithm> using namespace ::comphelper; using namespace ::com::sun::star::uno; @@ -589,23 +589,261 @@ Reference< XConnection> connectRowset(const Reference< XRowSet>& _rxRowSet, cons //------------------------------------------------------------------------------ Reference< XNameAccess> getTableFields(const Reference< XConnection>& _rxConn,const ::rtl::OUString& _rName) { - Reference< XTablesSupplier> xSupplyTables(_rxConn, UNO_QUERY); - OSL_ENSURE(xSupplyTables.is(), "::getTableFields : invalid connection !"); - // the conn already said it would support the service sdb::Connection - Reference< XNameAccess> xTables( xSupplyTables->getTables()); - if (xTables.is() && xTables->hasByName(_rName)) + Reference< XComponent > xDummy; + return getFieldsByCommandDescriptor( _rxConn, CommandType::TABLE, _rName, xDummy ); +} + +//------------------------------------------------------------------------------ +namespace +{ + enum FieldLookupState + { + HANDLE_TABLE, HANDLE_QUERY, HANDLE_SQL, RETRIEVE_OBJECT, RETRIEVE_COLUMNS, DONE, FAILED + }; +} + +//------------------------------------------------------------------------------ +Reference< XNameAccess > getFieldsByCommandDescriptor( const Reference< XConnection >& _rxConnection, + const sal_Int32 _nCommandType, const ::rtl::OUString& _rCommand, + Reference< XComponent >& _rxKeepFieldsAlive, SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) ) +{ + OSL_PRECOND( _rxConnection.is(), "::dbtools::getFieldsByCommandDescriptor: invalid connection!" ); + OSL_PRECOND( ( CommandType::TABLE == _nCommandType ) || ( CommandType::QUERY == _nCommandType ) || ( CommandType::COMMAND == _nCommandType ), + "::dbtools::getFieldsByCommandDescriptor: invalid command type!" ); + OSL_PRECOND( _rCommand.getLength(), "::dbtools::getFieldsByCommandDescriptor: invalid command (empty)!" ); + + Reference< XNameAccess > xFields; + + // reset the error + if ( _pErrorInfo ) + *_pErrorInfo = SQLExceptionInfo(); + // reset the ownership holder + _rxKeepFieldsAlive.clear(); + + // go for the fields + try + { + // some kind of state machine to ease the sharing of code + FieldLookupState eState = FAILED; + switch ( _nCommandType ) + { + case CommandType::TABLE: + eState = HANDLE_TABLE; + break; + case CommandType::QUERY: + eState = HANDLE_QUERY; + break; + case CommandType::COMMAND: + eState = HANDLE_SQL; + break; + } + + // needed in various states: + Reference< XNameAccess > xObjectCollection; + Reference< XColumnsSupplier > xSupplyColumns; + + // go! + while ( ( DONE != eState ) && ( FAILED != eState ) ) + { + switch ( eState ) + { + case HANDLE_TABLE: + { + // initial state for handling the tables + + // get the table objects + Reference< XTablesSupplier > xSupplyTables( _rxConnection, UNO_QUERY ); + if ( xSupplyTables.is() ) + xObjectCollection = xSupplyTables->getTables(); + // if something went wrong 'til here, then this will be handled in the next state + + // next state: get the object + eState = RETRIEVE_OBJECT; + } + break; + + case HANDLE_QUERY: + { + // initial state for handling the tables + + // get the table objects + Reference< XQueriesSupplier > xSupplyQueries( _rxConnection, UNO_QUERY ); + if ( xSupplyQueries.is() ) + xObjectCollection = xSupplyQueries->getQueries(); + // if something went wrong 'til here, then this will be handled in the next state + + // next state: get the object + eState = RETRIEVE_OBJECT; + } + break; + + case RETRIEVE_OBJECT: + // here we should have an object (aka query or table) collection, and are going + // to retrieve the desired object + + // next state: default to FAILED + eState = FAILED; + + OSL_ENSURE( xObjectCollection.is(), "::dbtools::getFieldsByCommandDescriptor: invalid connection (no sdb.Connection, or no Tables-/QueriesSupplier)!"); + if ( xObjectCollection.is() ) + { + if ( xObjectCollection.is() && xObjectCollection->hasByName( _rCommand ) ) + { + xObjectCollection->getByName( _rCommand ) >>= xSupplyColumns; + // (xSupplyColumns being NULL will be handled in the next state) + + // next: go for the columns + eState = RETRIEVE_COLUMNS; + } + } + break; + + case RETRIEVE_COLUMNS: + OSL_ENSURE( xSupplyColumns.is(), "::dbtools::getFieldsByCommandDescriptor: could not retrieve the columns supplier!" ); + + // next state: default to FAILED + eState = FAILED; + + if ( xSupplyColumns.is() ) + { + xFields = xSupplyColumns->getColumns(); + // that's it + eState = DONE; + } + break; + + case HANDLE_SQL: + { + ::rtl::OUString sStatementToExecute( _rCommand ); + + // well, the main problem here is to handle statements which contain a parameter + // If we would simply execute a parametrized statement, then this will fail because + // we cannot supply any parameter values. + // Thus, we try to analyze the statement, and to append a WHERE 0=1 filter criterion + // This should cause every driver to not really execute the statement, but to return + // an empty result set with the proper structure. We then can use this result set + // to retrieve the columns. + + try + { + Reference< XSQLQueryComposerFactory > xComposerFac( _rxConnection, UNO_QUERY ); + Reference< XSQLQueryComposer > xComposer; + if ( xComposerFac.is() ) + xComposer = xComposerFac->createQueryComposer( ); + if ( xComposer.is() ) + { + xComposer->setQuery( sStatementToExecute ); + + // Now set the filter to a dummy restriction which will result in an empty + // result set. + + // Unfortunately, if the statement already has a non-empty filter it is not + // removed when setting a new one. Instead, the statement set with "setQuery", + // acts as basis, everything added later (setFilter/setOrder and such) is + // _added_. So we need to strip the original WHERE clause (if there is one) + // manually + { + ::rtl::OUString sComplete = xComposer->getComposedQuery( ); + // we norm it: now there's really a "WHERE", not only a "where" or such ... + + sal_Int32 nWherePos = sComplete.lastIndexOf( ::rtl::OUString::createFromAscii( "WHERE" ) ); + if ( -1 < nWherePos ) + { // there indeed already is a where clause + sComplete = sComplete.copy( 0, nWherePos ); + // this is not correct. The "WHERE" may have been a part of e.g. a filter itself + // (something like "WHERE <field> = 'WHERE'"), but without an API + // for _analyzing_ (and not only _composing_) queries, we don't have + // much of a chance ... + try + { + xComposer->setQuery( sComplete ); + } + catch( const Exception& ) + { + // just in case we found the wrong WHERE substring .... + } + } + } + + xComposer->setFilter( ::rtl::OUString::createFromAscii( "0=1" ) ); + sStatementToExecute = xComposer->getComposedQuery( ); + } + } + catch( const Exception& ) + { + // silent this error, this was just a try. If we're here, we did not change sStatementToExecute, + // so it will still be _rCommand, which then will be executed without being touched + } + + // now execute + Reference< XPreparedStatement > xStatement = _rxConnection->prepareStatement( sStatementToExecute ); + // transfer ownership of this temporary object to the caller + _rxKeepFieldsAlive = _rxKeepFieldsAlive.query( xStatement ); + + // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter + // failed - in this case, the MaxRows restriction should at least ensure that there + // is no data returned (which would be potentially expensive) + Reference< XPropertySet > xStatementProps( xStatement,UNO_QUERY ); + try + { + if ( xStatementProps.is() ) + xStatementProps->setPropertyValue( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MaxRows" ) ), + makeAny( sal_Int32( 0 ) ) + ); + } + catch( const Exception& ) + { + OSL_ENSURE( sal_False, "::dbtools::getFieldsByCommandDescriptor: could not set the MaxRows!" ); + // oh damn. Not much of a chance to recover, we will no retrieve the complete + // full blown result set + } + + xSupplyColumns = xSupplyColumns.query( xStatement->executeQuery() ); + // this should have given us a result set which does not contain any data, but + // the structural information we need + + // so the next state is to get the columns + eState = RETRIEVE_COLUMNS; + } + break; + + default: + OSL_ENSURE( sal_False, "::dbtools::getFieldsByCommandDescriptor: oops! unhandled state here!" ); + eState = FAILED; + } + } + } + catch( const SQLContext& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); } + catch( const SQLWarning& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); } + catch( const SQLException& e ) { if ( _pErrorInfo ) *_pErrorInfo = SQLExceptionInfo( e ); } + catch( const Exception& ) { - Reference< XColumnsSupplier> xTableCols; - xTables->getByName(_rName) >>= xTableCols; - OSL_ENSURE(xTableCols.is(), "::getTableFields : invalid table !"); - // the table is expected to support the service sddb::Table, which requires an XColumnsSupplier interface - - Reference< XNameAccess> xFieldNames(xTableCols->getColumns(), UNO_QUERY); - OSL_ENSURE(xFieldNames.is(), "::getTableFields : TableCols->getColumns doesn't export a NameAccess !"); - return xFieldNames; + OSL_ENSURE( sal_False, "::dbtools::getFieldsByCommandDescriptor: caught an exception while retrieving the fields!" ); } - return Reference< XNameAccess>(); + return xFields; +} + +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > getFieldNamesByCommandDescriptor( const Reference< XConnection >& _rxConnection, + const sal_Int32 _nCommandType, const ::rtl::OUString& _rCommand, + SQLExceptionInfo* _pErrorInfo ) SAL_THROW( ( ) ) +{ + // get the container for the fields + Reference< XComponent > xKeepFieldsAlive; + Reference< XNameAccess > xFieldContainer = getFieldsByCommandDescriptor( _rxConnection, _nCommandType, _rCommand, xKeepFieldsAlive ); + + // get the names of the fields + Sequence< ::rtl::OUString > aNames; + if ( xFieldContainer.is() ) + aNames = xFieldContainer->getElementNames(); + + // clean up any temporary objects which have been created + disposeComponent( xKeepFieldsAlive ); + + // outta here + return aNames; } //------------------------------------------------------------------------------ @@ -739,11 +977,15 @@ try ) { // binaere Suche - Property* pResult = (Property*) bsearch(pOldProps + i, (void*)pNewProps, nNewLen, sizeof(Property), - &PropertyCompare); - if (pResult && (pResult->Attributes == pOldProps[i].Attributes) - && ((pResult->Attributes & PropertyAttribute::READONLY) == 0) - && (pResult->Type.equals(pOldProps[i].Type))) + Property* pResult = ::std::lower_bound(pNewProps, pNewProps + nNewLen,pOldProps[i].Name, ::comphelper::PropertyStringLessFunctor()); + +// Property* pResult = (Property*) bsearch(pOldProps + i, (void*)pNewProps, nNewLen, sizeof(Property), +// &PropertyCompare); + if (pResult + && ( pResult != pNewProps + nNewLen && pResult->Name == pOldProps[i].Name ) + && ( pResult->Attributes == pOldProps[i].Attributes ) + && ( (pResult->Attributes & PropertyAttribute::READONLY) == 0 ) + && ( pResult->Type.equals(pOldProps[i].Type)) ) { // Attribute stimmen ueberein und Property ist nicht read-only try { @@ -1108,10 +1350,11 @@ Reference< XSQLQueryComposer> getCurrentSettingsComposer( catch(SQLException&) { xReturn = NULL; + throw; } catch(Exception&) { - OSL_ENSURE(sal_False, "::getCurrentSettingsComposer : catched an exception !"); + OSL_ENSURE(sal_False, "::getCurrentSettingsComposer : caught an exception !"); xReturn = NULL; } @@ -1128,43 +1371,43 @@ namespace bool supportsSchemasInDataManipulation( ) { - return m_xMetaData->supportsSchemasInDataManipulation(); + return m_xMetaData->supportsSchemasInDataManipulation() ? true : false; } bool supportsSchemasInProcedureCalls( ) { - return m_xMetaData->supportsSchemasInProcedureCalls(); + return m_xMetaData->supportsSchemasInProcedureCalls() ? true : false; } bool supportsSchemasInTableDefinitions( ) { - return m_xMetaData->supportsSchemasInTableDefinitions(); + return m_xMetaData->supportsSchemasInTableDefinitions() ? true : false; } bool supportsSchemasInIndexDefinitions( ) { - return m_xMetaData->supportsSchemasInIndexDefinitions(); + return m_xMetaData->supportsSchemasInIndexDefinitions() ? true : false; } bool supportsSchemasInPrivilegeDefinitions( ) { - return m_xMetaData->supportsSchemasInPrivilegeDefinitions(); + return m_xMetaData->supportsSchemasInPrivilegeDefinitions() ? true : false; } bool supportsCatalogsInDataManipulation( ) { - return m_xMetaData->supportsCatalogsInDataManipulation(); + return m_xMetaData->supportsCatalogsInDataManipulation() ? true : false; } bool supportsCatalogsInProcedureCalls( ) { - return m_xMetaData->supportsCatalogsInProcedureCalls(); + return m_xMetaData->supportsCatalogsInProcedureCalls() ? true : false; } bool supportsCatalogsInTableDefinitions( ) { - return m_xMetaData->supportsCatalogsInTableDefinitions(); + return m_xMetaData->supportsCatalogsInTableDefinitions() ? true : false; } bool supportsCatalogsInIndexDefinitions( ) { - return m_xMetaData->supportsCatalogsInIndexDefinitions(); + return m_xMetaData->supportsCatalogsInIndexDefinitions() ? true : false; } bool supportsCatalogsInPrivilegeDefinitions( ) { - return m_xMetaData->supportsCatalogsInPrivilegeDefinitions(); + return m_xMetaData->supportsCatalogsInPrivilegeDefinitions() ? true : false; } }; } @@ -1786,57 +2029,3 @@ void checkDisposed(sal_Bool _bThrow) throw ( DisposedException ) } //namespace connectivity // ----------------------------------------------------------------------------- -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * Revision 1.47 2002/11/14 07:48:51 oj - * #105110# extend createUniqueName with bool param - * - * Revision 1.46 2002/10/07 12:48:11 oj - * #i3289# correct table name quoting so that in every situation the correct schema, catalog is used - * - * Revision 1.45 2002/09/13 08:28:02 fs - * #103242# implSetObject: handle TypeClass_HYPER - * - * Revision 1.44 2002/08/26 12:35:02 oj - * #98671# change type for sequence to VARBINARY - * - * Revision 1.43 2001/12/04 14:34:19 oj - * #95553# check if scale is greater than 0 - * - * Revision 1.42 2001/10/30 15:26:27 oj - * #93939# composeTableName remember values from metadata now - * - * Revision 1.41 2001/09/20 12:51:56 oj - * #92232# fixes for BIGINT type - * - * Revision 1.40 2001/08/28 14:36:17 fs - * encountered during #74241#: prependContextInfo uses a const SQLException& now - * - * Revision 1.39 2001/08/24 06:02:18 oj - * #90015# code corrcetions for some speedup's - * - * 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 - * - * Revision 1.36 2001/06/26 10:09:13 oj - * #87808# new method to wrap setObject method - * - * Revision 1.35 2001/06/26 09:27:28 fs - * #88392# +implUpdaetObject - * - * Revision 1.34 2001/06/22 10:53:35 oj - * #88455# new functions for parameters - * - * Revision 1.33 2001/06/21 11:08:16 oj - * #87925# start at 1 - * - * Revision 1.32 2001/06/15 09:55:48 fs - * #86986# moved css/ui/* to css/ui/dialogs/* - * - * Revision 1.0 29.09.00 08:16:59 fs - ************************************************************************/ - diff --git a/connectivity/source/commontools/dbtools2.cxx b/connectivity/source/commontools/dbtools2.cxx index 201e4556d1b7..dc96aadc2120 100644 --- a/connectivity/source/commontools/dbtools2.cxx +++ b/connectivity/source/commontools/dbtools2.cxx @@ -2,9 +2,9 @@ * * $RCSfile: dbtools2.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: oj $ $Date: 2002-12-12 10:45:02 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:38:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -489,6 +489,29 @@ Reference<XPropertySet> createSDBCXColumn(const Reference<XPropertySet>& _xTable { } + if ( nField11 != ColumnValue::NO_NULLS ) + { + try + { + Reference< XResultSet > xResult = xMetaData->getPrimaryKeys(aCatalog, aSchema, aTable); + Reference< XRow > xRow(xResult,UNO_QUERY); + if ( xRow.is() ) + { + while( xResult->next() ) // there can be only one primary key + { + ::rtl::OUString sKeyColumn = xRow->getString(4); + if ( _rName == sKeyColumn ) + { + nField11 = ColumnValue::NO_NULLS; + break; + } + } + } + } + catch(SQLException&) + { + } + } connectivity::sdbcx::OColumn* pRet = new connectivity::sdbcx::OColumn(_rName, aField6, diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index 486593a9c25f..9a2615f40f37 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -2,9 +2,9 @@ * * $RCSfile: predicateinput.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: oj $ $Date: 2002-12-04 11:23:14 $ + * last change: $Author: hr $ $Date: 2003-03-19 16:38:15 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -433,19 +433,4 @@ namespace dbtools } // namespace dbtools //......................................................................... -/************************************************************************* - * history: - * $Log: not supported by cvs2svn $ - * Revision 1.3 2002/09/27 11:15:47 oj - * #97230# new interface for ParseContext - * - * Revision 1.2 2002/09/26 07:59:42 oj - * #103685# correct index of replaceAt call - * - * Revision 1.1 2002/04/09 14:31:04 fs - * initial checkin - helper class for inputting predicate values - * - * - * Revision 1.0 04.04.02 15:57:58 fs - ************************************************************************/ |